1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5  * Copyright (C) 2016-2017 Intel Deutschland GmbH
6  */
7 #ifndef __iwl_fw_api_scan_h__
8 #define __iwl_fw_api_scan_h__
9 
10 /* Scan Commands, Responses, Notifications */
11 
12 /**
13  * enum iwl_scan_subcmd_ids - scan commands
14  */
15 enum iwl_scan_subcmd_ids {
16 	/**
17 	 * @OFFLOAD_MATCH_INFO_NOTIF: &struct iwl_scan_offload_match_info
18 	 */
19 	OFFLOAD_MATCH_INFO_NOTIF = 0xFC,
20 };
21 
22 /* Max number of IEs for direct SSID scans in a command */
23 #define PROBE_OPTION_MAX		20
24 
25 #define SCAN_SHORT_SSID_MAX_SIZE        8
26 #define SCAN_BSSID_MAX_SIZE             16
27 
28 /**
29  * struct iwl_ssid_ie - directed scan network information element
30  *
31  * Up to 20 of these may appear in REPLY_SCAN_CMD,
32  * selected by "type" bit field in struct iwl_scan_channel;
33  * each channel may select different ssids from among the 20 entries.
34  * SSID IEs get transmitted in reverse order of entry.
35  *
36  * @id: element ID
37  * @len: element length
38  * @ssid: element (SSID) data
39  */
40 struct iwl_ssid_ie {
41 	u8 id;
42 	u8 len;
43 	u8 ssid[IEEE80211_MAX_SSID_LEN];
44 } __packed; /* SCAN_DIRECT_SSID_IE_API_S_VER_1 */
45 
46 /* scan offload */
47 #define IWL_SCAN_MAX_BLACKLIST_LEN	64
48 #define IWL_SCAN_SHORT_BLACKLIST_LEN	16
49 #define IWL_SCAN_MAX_PROFILES		11
50 #define IWL_SCAN_MAX_PROFILES_V2	8
51 #define SCAN_OFFLOAD_PROBE_REQ_SIZE	512
52 #define SCAN_NUM_BAND_PROBE_DATA_V_1	2
53 #define SCAN_NUM_BAND_PROBE_DATA_V_2	3
54 
55 /* Default watchdog (in MS) for scheduled scan iteration */
56 #define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
57 
58 #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
59 #define CAN_ABORT_STATUS 1
60 
61 #define IWL_FULL_SCAN_MULTIPLIER 5
62 #define IWL_FAST_SCHED_SCAN_ITERATIONS 3
63 #define IWL_MAX_SCHED_SCAN_PLANS 2
64 
65 enum scan_framework_client {
66 	SCAN_CLIENT_SCHED_SCAN		= BIT(0),
67 	SCAN_CLIENT_NETDETECT		= BIT(1),
68 	SCAN_CLIENT_ASSET_TRACKING	= BIT(2),
69 };
70 
71 /**
72  * struct iwl_scan_offload_blocklist - SCAN_OFFLOAD_BLACKLIST_S
73  * @ssid:		MAC address to filter out
74  * @reported_rssi:	AP rssi reported to the host
75  * @client_bitmap: clients ignore this entry  - enum scan_framework_client
76  */
77 struct iwl_scan_offload_blocklist {
78 	u8 ssid[ETH_ALEN];
79 	u8 reported_rssi;
80 	u8 client_bitmap;
81 } __packed;
82 
83 enum iwl_scan_offload_network_type {
84 	IWL_NETWORK_TYPE_BSS	= 1,
85 	IWL_NETWORK_TYPE_IBSS	= 2,
86 	IWL_NETWORK_TYPE_ANY	= 3,
87 };
88 
89 enum iwl_scan_offload_band_selection {
90 	IWL_SCAN_OFFLOAD_SELECT_2_4	= 0x4,
91 	IWL_SCAN_OFFLOAD_SELECT_5_2	= 0x8,
92 	IWL_SCAN_OFFLOAD_SELECT_ANY	= 0xc,
93 };
94 
95 enum iwl_scan_offload_auth_alg {
96 	IWL_AUTH_ALGO_UNSUPPORTED  = 0x00,
97 	IWL_AUTH_ALGO_NONE         = 0x01,
98 	IWL_AUTH_ALGO_PSK          = 0x02,
99 	IWL_AUTH_ALGO_8021X        = 0x04,
100 	IWL_AUTH_ALGO_SAE          = 0x08,
101 	IWL_AUTH_ALGO_8021X_SHA384 = 0x10,
102 	IWL_AUTH_ALGO_OWE          = 0x20,
103 };
104 
105 /**
106  * struct iwl_scan_offload_profile - SCAN_OFFLOAD_PROFILE_S
107  * @ssid_index:		index to ssid list in fixed part
108  * @unicast_cipher:	encryption algorithm to match - bitmap
109  * @auth_alg:		authentication algorithm to match - bitmap
110  * @network_type:	enum iwl_scan_offload_network_type
111  * @band_selection:	enum iwl_scan_offload_band_selection
112  * @client_bitmap:	clients waiting for match - enum scan_framework_client
113  * @reserved:		reserved
114  */
115 struct iwl_scan_offload_profile {
116 	u8 ssid_index;
117 	u8 unicast_cipher;
118 	u8 auth_alg;
119 	u8 network_type;
120 	u8 band_selection;
121 	u8 client_bitmap;
122 	u8 reserved[2];
123 } __packed;
124 
125 /**
126  * struct iwl_scan_offload_profile_cfg_data
127  * @blocklist_len:	length of blocklist
128  * @num_profiles:	num of profiles in the list
129  * @match_notify:	clients waiting for match found notification
130  * @pass_match:		clients waiting for the results
131  * @active_clients:	active clients bitmap - enum scan_framework_client
132  * @any_beacon_notify:	clients waiting for match notification without match
133  * @reserved:		reserved
134  */
135 struct iwl_scan_offload_profile_cfg_data {
136 	u8 blocklist_len;
137 	u8 num_profiles;
138 	u8 match_notify;
139 	u8 pass_match;
140 	u8 active_clients;
141 	u8 any_beacon_notify;
142 	u8 reserved[2];
143 } __packed;
144 
145 /**
146  * struct iwl_scan_offload_profile_cfg
147  * @profiles:	profiles to search for match
148  * @data:	the rest of the data for profile_cfg
149  */
150 struct iwl_scan_offload_profile_cfg_v1 {
151 	struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES];
152 	struct iwl_scan_offload_profile_cfg_data data;
153 } __packed; /* SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1-2*/
154 
155 /**
156  * struct iwl_scan_offload_profile_cfg
157  * @profiles:	profiles to search for match
158  * @data:	the rest of the data for profile_cfg
159  */
160 struct iwl_scan_offload_profile_cfg {
161 	struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES_V2];
162 	struct iwl_scan_offload_profile_cfg_data data;
163 } __packed; /* SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_3*/
164 
165 /**
166  * struct iwl_scan_schedule_lmac - schedule of scan offload
167  * @delay:		delay between iterations, in seconds.
168  * @iterations:		num of scan iterations
169  * @full_scan_mul:	number of partial scans before each full scan
170  */
171 struct iwl_scan_schedule_lmac {
172 	__le16 delay;
173 	u8 iterations;
174 	u8 full_scan_mul;
175 } __packed; /* SCAN_SCHEDULE_API_S */
176 
177 enum iwl_scan_offload_complete_status {
178 	IWL_SCAN_OFFLOAD_COMPLETED	= 1,
179 	IWL_SCAN_OFFLOAD_ABORTED	= 2,
180 };
181 
182 enum iwl_scan_ebs_status {
183 	IWL_SCAN_EBS_SUCCESS,
184 	IWL_SCAN_EBS_FAILED,
185 	IWL_SCAN_EBS_CHAN_NOT_FOUND,
186 	IWL_SCAN_EBS_INACTIVE,
187 };
188 
189 /**
190  * struct iwl_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
191  * @tx_flags: combination of TX_CMD_FLG_*
192  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
193  *	cleared. Combination of RATE_MCS_*
194  * @sta_id: index of destination station in FW station table
195  * @reserved: for alignment and future use
196  */
197 struct iwl_scan_req_tx_cmd {
198 	__le32 tx_flags;
199 	__le32 rate_n_flags;
200 	u8 sta_id;
201 	u8 reserved[3];
202 } __packed;
203 
204 enum iwl_scan_channel_flags_lmac {
205 	IWL_UNIFIED_SCAN_CHANNEL_FULL		= BIT(27),
206 	IWL_UNIFIED_SCAN_CHANNEL_PARTIAL	= BIT(28),
207 };
208 
209 /**
210  * struct iwl_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
211  * @flags:		bits 1-20: directed scan to i'th ssid
212  *			other bits &enum iwl_scan_channel_flags_lmac
213  * @channel_num:	channel number 1-13 etc
214  * @iter_count:		scan iteration on this channel
215  * @iter_interval:	interval in seconds between iterations on one channel
216  */
217 struct iwl_scan_channel_cfg_lmac {
218 	__le32 flags;
219 	__le16 channel_num;
220 	__le16 iter_count;
221 	__le32 iter_interval;
222 } __packed;
223 
224 /**
225  * struct iwl_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
226  * @offset: offset in the data block
227  * @len: length of the segment
228  */
229 struct iwl_scan_probe_segment {
230 	__le16 offset;
231 	__le16 len;
232 } __packed;
233 
234 /**
235  * struct iwl_scan_probe_req_v1 - PROBE_REQUEST_FRAME_API_S_VER_2
236  * @mac_header: first (and common) part of the probe
237  * @band_data: band specific data
238  * @common_data: last (and common) part of the probe
239  * @buf: raw data block
240  */
241 struct iwl_scan_probe_req_v1 {
242 	struct iwl_scan_probe_segment mac_header;
243 	struct iwl_scan_probe_segment band_data[SCAN_NUM_BAND_PROBE_DATA_V_1];
244 	struct iwl_scan_probe_segment common_data;
245 	u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
246 } __packed;
247 
248 /**
249  * struct iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_v2
250  * @mac_header: first (and common) part of the probe
251  * @band_data: band specific data
252  * @common_data: last (and common) part of the probe
253  * @buf: raw data block
254  */
255 struct iwl_scan_probe_req {
256 	struct iwl_scan_probe_segment mac_header;
257 	struct iwl_scan_probe_segment band_data[SCAN_NUM_BAND_PROBE_DATA_V_2];
258 	struct iwl_scan_probe_segment common_data;
259 	u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
260 } __packed;
261 
262 enum iwl_scan_channel_flags {
263 	IWL_SCAN_CHANNEL_FLAG_EBS		= BIT(0),
264 	IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE	= BIT(1),
265 	IWL_SCAN_CHANNEL_FLAG_CACHE_ADD		= BIT(2),
266 	IWL_SCAN_CHANNEL_FLAG_EBS_FRAG		= BIT(3),
267 	IWL_SCAN_CHANNEL_FLAG_FORCE_EBS         = BIT(4),
268 	IWL_SCAN_CHANNEL_FLAG_ENABLE_CHAN_ORDER = BIT(5),
269 	IWL_SCAN_CHANNEL_FLAG_6G_PSC_NO_FILTER  = BIT(6),
270 };
271 
272 /**
273  * struct iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
274  * @flags: enum iwl_scan_channel_flags
275  * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
276  *	involved.
277  *	1 - EBS is disabled.
278  *	2 - every second scan will be full scan(and so on).
279  */
280 struct iwl_scan_channel_opt {
281 	__le16 flags;
282 	__le16 non_ebs_ratio;
283 } __packed;
284 
285 /**
286  * enum iwl_mvm_lmac_scan_flags - LMAC scan flags
287  * @IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
288  *	without filtering.
289  * @IWL_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
290  * @IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
291  * @IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
292  * @IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS: multiple SSID matching
293  * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
294  * @IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
295  *	and DS parameter set IEs into probe requests.
296  * @IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
297  *	1, 6 and 11.
298  * @IWL_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
299  */
300 enum iwl_mvm_lmac_scan_flags {
301 	IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL		= BIT(0),
302 	IWL_MVM_LMAC_SCAN_FLAG_PASSIVE		= BIT(1),
303 	IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION	= BIT(2),
304 	IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE	= BIT(3),
305 	IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS	= BIT(4),
306 	IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED	= BIT(5),
307 	IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED	= BIT(6),
308 	IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL	= BIT(7),
309 	IWL_MVM_LMAC_SCAN_FLAG_MATCH		= BIT(9),
310 };
311 
312 enum iwl_scan_priority {
313 	IWL_SCAN_PRIORITY_LOW,
314 	IWL_SCAN_PRIORITY_MEDIUM,
315 	IWL_SCAN_PRIORITY_HIGH,
316 };
317 
318 enum iwl_scan_priority_ext {
319 	IWL_SCAN_PRIORITY_EXT_0_LOWEST,
320 	IWL_SCAN_PRIORITY_EXT_1,
321 	IWL_SCAN_PRIORITY_EXT_2,
322 	IWL_SCAN_PRIORITY_EXT_3,
323 	IWL_SCAN_PRIORITY_EXT_4,
324 	IWL_SCAN_PRIORITY_EXT_5,
325 	IWL_SCAN_PRIORITY_EXT_6,
326 	IWL_SCAN_PRIORITY_EXT_7_HIGHEST,
327 };
328 
329 /**
330  * struct iwl_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
331  * @reserved1: for alignment and future use
332  * @n_channels: num of channels to scan
333  * @active_dwell: dwell time for active channels
334  * @passive_dwell: dwell time for passive channels
335  * @fragmented_dwell: dwell time for fragmented passive scan
336  * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
337  * @reserved2: for alignment and future use
338  * @rx_chain_select: PHY_RX_CHAIN_* flags
339  * @scan_flags: &enum iwl_mvm_lmac_scan_flags
340  * @max_out_time: max time (in TU) to be out of associated channel
341  * @suspend_time: pause scan this long (TUs) when returning to service channel
342  * @flags: RXON flags
343  * @filter_flags: RXON filter
344  * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
345  * @direct_scan: list of SSIDs for directed active scan
346  * @scan_prio: enum iwl_scan_priority
347  * @iter_num: number of scan iterations
348  * @delay: delay in seconds before first iteration
349  * @schedule: two scheduling plans. The first one is finite, the second one can
350  *	be infinite.
351  * @channel_opt: channel optimization options, for full and partial scan
352  * @data: channel configuration and probe request packet.
353  */
354 struct iwl_scan_req_lmac {
355 	/* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
356 	__le32 reserved1;
357 	u8 n_channels;
358 	u8 active_dwell;
359 	u8 passive_dwell;
360 	u8 fragmented_dwell;
361 	u8 extended_dwell;
362 	u8 reserved2;
363 	__le16 rx_chain_select;
364 	__le32 scan_flags;
365 	__le32 max_out_time;
366 	__le32 suspend_time;
367 	/* RX_ON_FLAGS_API_S_VER_1 */
368 	__le32 flags;
369 	__le32 filter_flags;
370 	struct iwl_scan_req_tx_cmd tx_cmd[2];
371 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
372 	__le32 scan_prio;
373 	/* SCAN_REQ_PERIODIC_PARAMS_API_S */
374 	__le32 iter_num;
375 	__le32 delay;
376 	struct iwl_scan_schedule_lmac schedule[IWL_MAX_SCHED_SCAN_PLANS];
377 	struct iwl_scan_channel_opt channel_opt[2];
378 	u8 data[];
379 } __packed;
380 
381 /**
382  * struct iwl_scan_results_notif - scan results for one channel -
383  *	SCAN_RESULT_NTF_API_S_VER_3
384  * @channel: which channel the results are from
385  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
386  * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
387  * @num_probe_not_sent: # of request that weren't sent due to not enough time
388  * @duration: duration spent in channel, in usecs
389  */
390 struct iwl_scan_results_notif {
391 	u8 channel;
392 	u8 band;
393 	u8 probe_status;
394 	u8 num_probe_not_sent;
395 	__le32 duration;
396 } __packed;
397 
398 /**
399  * struct iwl_lmac_scan_complete_notif - notifies end of scanning (all channels)
400  *	SCAN_COMPLETE_NTF_API_S_VER_3
401  * @scanned_channels: number of channels scanned (and number of valid results)
402  * @status: one of SCAN_COMP_STATUS_*
403  * @bt_status: BT on/off status
404  * @last_channel: last channel that was scanned
405  * @tsf_low: TSF timer (lower half) in usecs
406  * @tsf_high: TSF timer (higher half) in usecs
407  * @results: an array of scan results, only "scanned_channels" of them are valid
408  */
409 struct iwl_lmac_scan_complete_notif {
410 	u8 scanned_channels;
411 	u8 status;
412 	u8 bt_status;
413 	u8 last_channel;
414 	__le32 tsf_low;
415 	__le32 tsf_high;
416 	struct iwl_scan_results_notif results[];
417 } __packed;
418 
419 /**
420  * struct iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
421  * @last_schedule_line: last schedule line executed (fast or regular)
422  * @last_schedule_iteration: last scan iteration executed before scan abort
423  * @status: &enum iwl_scan_offload_complete_status
424  * @ebs_status: EBS success status &enum iwl_scan_ebs_status
425  * @time_after_last_iter: time in seconds elapsed after last iteration
426  * @reserved: reserved
427  */
428 struct iwl_periodic_scan_complete {
429 	u8 last_schedule_line;
430 	u8 last_schedule_iteration;
431 	u8 status;
432 	u8 ebs_status;
433 	__le32 time_after_last_iter;
434 	__le32 reserved;
435 } __packed;
436 
437 /* UMAC Scan API */
438 
439 /* The maximum of either of these cannot exceed 8, because we use an
440  * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h).
441  */
442 #define IWL_MVM_MAX_UMAC_SCANS 4
443 #define IWL_MVM_MAX_LMAC_SCANS 1
444 
445 enum scan_config_flags {
446 	SCAN_CONFIG_FLAG_ACTIVATE			= BIT(0),
447 	SCAN_CONFIG_FLAG_DEACTIVATE			= BIT(1),
448 	SCAN_CONFIG_FLAG_FORBID_CHUB_REQS		= BIT(2),
449 	SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS		= BIT(3),
450 	SCAN_CONFIG_FLAG_SET_TX_CHAINS			= BIT(8),
451 	SCAN_CONFIG_FLAG_SET_RX_CHAINS			= BIT(9),
452 	SCAN_CONFIG_FLAG_SET_AUX_STA_ID			= BIT(10),
453 	SCAN_CONFIG_FLAG_SET_ALL_TIMES			= BIT(11),
454 	SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES		= BIT(12),
455 	SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS		= BIT(13),
456 	SCAN_CONFIG_FLAG_SET_LEGACY_RATES		= BIT(14),
457 	SCAN_CONFIG_FLAG_SET_MAC_ADDR			= BIT(15),
458 	SCAN_CONFIG_FLAG_SET_FRAGMENTED			= BIT(16),
459 	SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED		= BIT(17),
460 	SCAN_CONFIG_FLAG_SET_CAM_MODE			= BIT(18),
461 	SCAN_CONFIG_FLAG_CLEAR_CAM_MODE			= BIT(19),
462 	SCAN_CONFIG_FLAG_SET_PROMISC_MODE		= BIT(20),
463 	SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE		= BIT(21),
464 	SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED		= BIT(22),
465 	SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED		= BIT(23),
466 
467 	/* Bits 26-31 are for num of channels in channel_array */
468 #define SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
469 };
470 
471 enum scan_config_rates {
472 	/* OFDM basic rates */
473 	SCAN_CONFIG_RATE_6M	= BIT(0),
474 	SCAN_CONFIG_RATE_9M	= BIT(1),
475 	SCAN_CONFIG_RATE_12M	= BIT(2),
476 	SCAN_CONFIG_RATE_18M	= BIT(3),
477 	SCAN_CONFIG_RATE_24M	= BIT(4),
478 	SCAN_CONFIG_RATE_36M	= BIT(5),
479 	SCAN_CONFIG_RATE_48M	= BIT(6),
480 	SCAN_CONFIG_RATE_54M	= BIT(7),
481 	/* CCK basic rates */
482 	SCAN_CONFIG_RATE_1M	= BIT(8),
483 	SCAN_CONFIG_RATE_2M	= BIT(9),
484 	SCAN_CONFIG_RATE_5M	= BIT(10),
485 	SCAN_CONFIG_RATE_11M	= BIT(11),
486 
487 	/* Bits 16-27 are for supported rates */
488 #define SCAN_CONFIG_SUPPORTED_RATE(rate)	((rate) << 16)
489 };
490 
491 enum iwl_channel_flags {
492 	IWL_CHANNEL_FLAG_EBS				= BIT(0),
493 	IWL_CHANNEL_FLAG_ACCURATE_EBS			= BIT(1),
494 	IWL_CHANNEL_FLAG_EBS_ADD			= BIT(2),
495 	IWL_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE	= BIT(3),
496 };
497 
498 enum iwl_uhb_chan_cfg_flags {
499 	IWL_UHB_CHAN_CFG_FLAG_UNSOLICITED_PROBE_RES = BIT(24),
500 	IWL_UHB_CHAN_CFG_FLAG_PSC_CHAN_NO_LISTEN    = BIT(25),
501 	IWL_UHB_CHAN_CFG_FLAG_FORCE_PASSIVE         = BIT(26),
502 };
503 /**
504  * struct iwl_scan_dwell
505  * @active:		default dwell time for active scan
506  * @passive:		default dwell time for passive scan
507  * @fragmented:		default dwell time for fragmented scan
508  * @extended:		default dwell time for channels 1, 6 and 11
509  */
510 struct iwl_scan_dwell {
511 	u8 active;
512 	u8 passive;
513 	u8 fragmented;
514 	u8 extended;
515 } __packed;
516 
517 /**
518  * struct iwl_scan_config_v1 - scan configuration command
519  * @flags:			enum scan_config_flags
520  * @tx_chains:			valid_tx antenna - ANT_* definitions
521  * @rx_chains:			valid_rx antenna - ANT_* definitions
522  * @legacy_rates:		default legacy rates - enum scan_config_rates
523  * @out_of_channel_time:	default max out of serving channel time
524  * @suspend_time:		default max suspend time
525  * @dwell:			dwells for the scan
526  * @mac_addr:			default mac address to be used in probes
527  * @bcast_sta_id:		the index of the station in the fw
528  * @channel_flags:		default channel flags - enum iwl_channel_flags
529  *				scan_config_channel_flag
530  * @channel_array:		default supported channels
531  */
532 struct iwl_scan_config_v1 {
533 	__le32 flags;
534 	__le32 tx_chains;
535 	__le32 rx_chains;
536 	__le32 legacy_rates;
537 	__le32 out_of_channel_time;
538 	__le32 suspend_time;
539 	struct iwl_scan_dwell dwell;
540 	u8 mac_addr[ETH_ALEN];
541 	u8 bcast_sta_id;
542 	u8 channel_flags;
543 	u8 channel_array[];
544 } __packed; /* SCAN_CONFIG_DB_CMD_API_S */
545 
546 #define SCAN_TWO_LMACS 2
547 #define SCAN_LB_LMAC_IDX 0
548 #define SCAN_HB_LMAC_IDX 1
549 
550 /**
551  * struct iwl_scan_config_v2 - scan configuration command
552  * @flags:			enum scan_config_flags
553  * @tx_chains:			valid_tx antenna - ANT_* definitions
554  * @rx_chains:			valid_rx antenna - ANT_* definitions
555  * @legacy_rates:		default legacy rates - enum scan_config_rates
556  * @out_of_channel_time:	default max out of serving channel time
557  * @suspend_time:		default max suspend time
558  * @dwell:			dwells for the scan
559  * @mac_addr:			default mac address to be used in probes
560  * @bcast_sta_id:		the index of the station in the fw
561  * @channel_flags:		default channel flags - enum iwl_channel_flags
562  *				scan_config_channel_flag
563  * @channel_array:		default supported channels
564  */
565 struct iwl_scan_config_v2 {
566 	__le32 flags;
567 	__le32 tx_chains;
568 	__le32 rx_chains;
569 	__le32 legacy_rates;
570 	__le32 out_of_channel_time[SCAN_TWO_LMACS];
571 	__le32 suspend_time[SCAN_TWO_LMACS];
572 	struct iwl_scan_dwell dwell;
573 	u8 mac_addr[ETH_ALEN];
574 	u8 bcast_sta_id;
575 	u8 channel_flags;
576 	u8 channel_array[];
577 } __packed; /* SCAN_CONFIG_DB_CMD_API_S_2 */
578 
579 /**
580  * struct iwl_scan_config - scan configuration command
581  * @enable_cam_mode: whether to enable CAM mode.
582  * @enable_promiscouos_mode: whether to enable promiscouos mode
583  * @bcast_sta_id: the index of the station in the fw. Deprecated starting with
584  *     API version 5.
585  * @reserved: reserved
586  * @tx_chains: valid_tx antenna - ANT_* definitions
587  * @rx_chains: valid_rx antenna - ANT_* definitions
588  */
589 struct iwl_scan_config {
590 	u8 enable_cam_mode;
591 	u8 enable_promiscouos_mode;
592 	u8 bcast_sta_id;
593 	u8 reserved;
594 	__le32 tx_chains;
595 	__le32 rx_chains;
596 } __packed; /* SCAN_CONFIG_DB_CMD_API_S_5 */
597 
598 /**
599  * enum iwl_umac_scan_flags - UMAC scan flags
600  * @IWL_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
601  *	can be preempted by other scan requests with higher priority.
602  *	The low priority scan will be resumed when the higher proirity scan is
603  *	completed.
604  * @IWL_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
605  *	when scan starts.
606  */
607 enum iwl_umac_scan_flags {
608 	IWL_UMAC_SCAN_FLAG_PREEMPTIVE		= BIT(0),
609 	IWL_UMAC_SCAN_FLAG_START_NOTIF		= BIT(1),
610 };
611 
612 enum iwl_umac_scan_uid_offsets {
613 	IWL_UMAC_SCAN_UID_TYPE_OFFSET		= 0,
614 	IWL_UMAC_SCAN_UID_SEQ_OFFSET		= 8,
615 };
616 
617 enum iwl_umac_scan_general_flags {
618 	IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC		= BIT(0),
619 	IWL_UMAC_SCAN_GEN_FLAGS_OVER_BT			= BIT(1),
620 	IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL		= BIT(2),
621 	IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE			= BIT(3),
622 	IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT		= BIT(4),
623 	IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE		= BIT(5),
624 	IWL_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID		= BIT(6),
625 	IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED		= BIT(7),
626 	IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED		= BIT(8),
627 	IWL_UMAC_SCAN_GEN_FLAGS_MATCH			= BIT(9),
628 	IWL_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL		= BIT(10),
629 	/* Extended dwell is obselete when adaptive dwell is used, making this
630 	 * bit reusable. Hence, probe request defer is used only when adaptive
631 	 * dwell is supported. */
632 	IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_DEFER_SUPP	= BIT(10),
633 	IWL_UMAC_SCAN_GEN_FLAGS_LMAC2_FRAGMENTED	= BIT(11),
634 	IWL_UMAC_SCAN_GEN_FLAGS_ADAPTIVE_DWELL		= BIT(13),
635 	IWL_UMAC_SCAN_GEN_FLAGS_MAX_CHNL_TIME		= BIT(14),
636 	IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_HIGH_TX_RATE	= BIT(15),
637 };
638 
639 /**
640  * enum iwl_umac_scan_general_flags2 - UMAC scan general flags #2
641  * @IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL: Whether to send a complete
642  *	notification per channel or not.
643  * @IWL_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER: Whether to allow channel
644  *	reorder optimization or not.
645  */
646 enum iwl_umac_scan_general_flags2 {
647 	IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL		= BIT(0),
648 	IWL_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER	= BIT(1),
649 };
650 
651 /**
652  * enum iwl_umac_scan_general_flags_v2 - UMAC scan general flags version 2
653  *
654  * The FW flags were reordered and hence the driver introduce version 2
655  *
656  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_PERIODIC: periodic or scheduled
657  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_PASS_ALL: pass all probe responses and beacons
658  *                                       during scan iterations
659  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_NTFY_ITER_COMPLETE: send complete notification
660  *      on every iteration instead of only once after the last iteration
661  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_FRAGMENTED_LMAC1: fragmented scan LMAC1
662  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_FRAGMENTED_LMAC2: fragmented scan LMAC2
663  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_MATCH: does this scan check for profile matching
664  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_USE_ALL_RX_CHAINS: use all valid chains for RX
665  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_ADAPTIVE_DWELL: works with adaptive dwell
666  *                                             for active channel
667  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_PREEMPTIVE: can be preempted by other requests
668  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_NTF_START: send notification of scan start
669  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_MULTI_SSID: matching on multiple SSIDs
670  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_FORCE_PASSIVE: all the channels scanned
671  *                                           as passive
672  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_TRIGGER_UHB_SCAN: at the end of 2.4GHz and
673  *		5.2Ghz bands scan, trigger scan on 6GHz band to discover
674  *		the reported collocated APs
675  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN: at the end of 2.4GHz and 5GHz
676  *      bands scan, if not APs were discovered, allow scan to conitnue and scan
677  *      6GHz PSC channels in order to discover country information.
678  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN_FILTER_IN: in case
679  *      &IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN is enabled and scan is
680  *      activated over 6GHz PSC channels, filter in beacons and probe responses.
681  * @IWL_UMAC_SCAN_GEN_FLAGS_V2_OCE: if set, send probe requests in a minimum
682  *      rate of 5.5Mpbs, filter in broadcast probe responses and set the max
683  *      channel time indication field in the FILS request parameters element
684  *      (if included by the driver in the probe request IEs).
685  */
686 enum iwl_umac_scan_general_flags_v2 {
687 	IWL_UMAC_SCAN_GEN_FLAGS_V2_PERIODIC             = BIT(0),
688 	IWL_UMAC_SCAN_GEN_FLAGS_V2_PASS_ALL             = BIT(1),
689 	IWL_UMAC_SCAN_GEN_FLAGS_V2_NTFY_ITER_COMPLETE   = BIT(2),
690 	IWL_UMAC_SCAN_GEN_FLAGS_V2_FRAGMENTED_LMAC1     = BIT(3),
691 	IWL_UMAC_SCAN_GEN_FLAGS_V2_FRAGMENTED_LMAC2     = BIT(4),
692 	IWL_UMAC_SCAN_GEN_FLAGS_V2_MATCH                = BIT(5),
693 	IWL_UMAC_SCAN_GEN_FLAGS_V2_USE_ALL_RX_CHAINS    = BIT(6),
694 	IWL_UMAC_SCAN_GEN_FLAGS_V2_ADAPTIVE_DWELL       = BIT(7),
695 	IWL_UMAC_SCAN_GEN_FLAGS_V2_PREEMPTIVE           = BIT(8),
696 	IWL_UMAC_SCAN_GEN_FLAGS_V2_NTF_START            = BIT(9),
697 	IWL_UMAC_SCAN_GEN_FLAGS_V2_MULTI_SSID           = BIT(10),
698 	IWL_UMAC_SCAN_GEN_FLAGS_V2_FORCE_PASSIVE        = BIT(11),
699 	IWL_UMAC_SCAN_GEN_FLAGS_V2_TRIGGER_UHB_SCAN     = BIT(12),
700 	IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN    = BIT(13),
701 	IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN_FILTER_IN = BIT(14),
702 	IWL_UMAC_SCAN_GEN_FLAGS_V2_OCE                  = BIT(15),
703 };
704 
705 /**
706  * enum iwl_umac_scan_general_params_flags2 - UMAC scan general flags2
707  *
708  * @IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_RESPECT_P2P_GO_LB: scan event scheduling
709  *     should be aware of a P2P GO operation on the 2GHz band.
710  * @IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_RESPECT_P2P_GO_HB: scan event scheduling
711  *     should be aware of a P2P GO operation on the 5GHz or 6GHz band.
712  * @IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_DONT_TOGGLE_ANT: don't toggle between
713  *     valid antennas, and use the same antenna as in previous scan
714  */
715 enum iwl_umac_scan_general_params_flags2 {
716 	IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_RESPECT_P2P_GO_LB = BIT(0),
717 	IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_RESPECT_P2P_GO_HB = BIT(1),
718 	IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_DONT_TOGGLE_ANT   = BIT(2),
719 };
720 
721 /**
722  * struct iwl_scan_channel_cfg_umac
723  * @flags:		bitmap - 0-19:	directed scan to i'th ssid.
724  * @channel_num:	channel number 1-13 etc.
725  * @band:		band of channel: 0 for 2GHz, 1 for 5GHz
726  * @iter_count:		repetition count for the channel.
727  * @iter_interval:	interval between two scan iterations on one channel.
728  */
729 struct  iwl_scan_channel_cfg_umac {
730 	__le32 flags;
731 	/* Both versions are of the same size, so use a union without adjusting
732 	 * the command size later
733 	 */
734 	union {
735 		struct {
736 			u8 channel_num;
737 			u8 iter_count;
738 			__le16 iter_interval;
739 		} v1;  /* SCAN_CHANNEL_CONFIG_API_S_VER_1 */
740 		struct {
741 			u8 channel_num;
742 			u8 band;
743 			u8 iter_count;
744 			u8 iter_interval;
745 		 } v2; /* SCAN_CHANNEL_CONFIG_API_S_VER_2
746 			* SCAN_CHANNEL_CONFIG_API_S_VER_3
747 			* SCAN_CHANNEL_CONFIG_API_S_VER_4
748 			*/
749 	};
750 } __packed;
751 
752 /**
753  * struct iwl_scan_umac_schedule
754  * @interval: interval in seconds between scan iterations
755  * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
756  * @reserved: for alignment and future use
757  */
758 struct iwl_scan_umac_schedule {
759 	__le16 interval;
760 	u8 iter_count;
761 	u8 reserved;
762 } __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
763 
764 struct iwl_scan_req_umac_tail_v1 {
765 	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
766 	struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
767 	__le16 delay;
768 	__le16 reserved;
769 	/* SCAN_PROBE_PARAMS_API_S_VER_1 */
770 	struct iwl_scan_probe_req_v1 preq;
771 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
772 } __packed;
773 
774 /**
775  * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command
776  *      parameters following channels configuration array.
777  * @schedule: two scheduling plans.
778  * @delay: delay in TUs before starting the first scan iteration
779  * @reserved: for future use and alignment
780  * @preq: probe request with IEs blocks
781  * @direct_scan: list of SSIDs for directed active scan
782  */
783 struct iwl_scan_req_umac_tail_v2 {
784 	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
785 	struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
786 	__le16 delay;
787 	__le16 reserved;
788 	/* SCAN_PROBE_PARAMS_API_S_VER_2 */
789 	struct iwl_scan_probe_req preq;
790 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
791 } __packed;
792 
793 /**
794  * struct iwl_scan_umac_chan_param
795  * @flags: channel flags &enum iwl_scan_channel_flags
796  * @count: num of channels in scan request
797  * @reserved: for future use and alignment
798  */
799 struct iwl_scan_umac_chan_param {
800 	u8 flags;
801 	u8 count;
802 	__le16 reserved;
803 } __packed; /*SCAN_CHANNEL_PARAMS_API_S_VER_1 */
804 
805 /**
806  * struct iwl_scan_req_umac
807  * @flags: &enum iwl_umac_scan_flags
808  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
809  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
810  * @general_flags: &enum iwl_umac_scan_general_flags
811  * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
812  * @extended_dwell: dwell time for channels 1, 6 and 11
813  * @active_dwell: dwell time for active scan per LMAC
814  * @passive_dwell: dwell time for passive scan per LMAC
815  * @fragmented_dwell: dwell time for fragmented passive scan
816  * @adwell_default_n_aps: for adaptive dwell the default number of APs
817  *	per channel
818  * @adwell_default_n_aps_social: for adaptive dwell the default
819  *	number of APs per social (1,6,11) channel
820  * @general_flags2: &enum iwl_umac_scan_general_flags2
821  * @adwell_max_budget: for adaptive dwell the maximal budget of TU to be added
822  *	to total scan time
823  * @max_out_time: max out of serving channel time, per LMAC - for CDB there
824  *	are 2 LMACs
825  * @suspend_time: max suspend time, per LMAC - for CDB there are 2 LMACs
826  * @scan_priority: scan internal prioritization &enum iwl_scan_priority
827  * @num_of_fragments: Number of fragments needed for full coverage per band.
828  *	Relevant only for fragmented scan.
829  * @channel: &struct iwl_scan_umac_chan_param
830  * @reserved: for future use and alignment
831  * @reserved3: for future use and alignment
832  * @data: &struct iwl_scan_channel_cfg_umac and
833  *	&struct iwl_scan_req_umac_tail
834  */
835 struct iwl_scan_req_umac {
836 	__le32 flags;
837 	__le32 uid;
838 	__le32 ooc_priority;
839 	__le16 general_flags;
840 	u8 reserved;
841 	u8 scan_start_mac_id;
842 	union {
843 		struct {
844 			u8 extended_dwell;
845 			u8 active_dwell;
846 			u8 passive_dwell;
847 			u8 fragmented_dwell;
848 			__le32 max_out_time;
849 			__le32 suspend_time;
850 			__le32 scan_priority;
851 			struct iwl_scan_umac_chan_param channel;
852 			u8 data[];
853 		} v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
854 		struct {
855 			u8 extended_dwell;
856 			u8 active_dwell;
857 			u8 passive_dwell;
858 			u8 fragmented_dwell;
859 			__le32 max_out_time[SCAN_TWO_LMACS];
860 			__le32 suspend_time[SCAN_TWO_LMACS];
861 			__le32 scan_priority;
862 			struct iwl_scan_umac_chan_param channel;
863 			u8 data[];
864 		} v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
865 		struct {
866 			u8 active_dwell;
867 			u8 passive_dwell;
868 			u8 fragmented_dwell;
869 			u8 adwell_default_n_aps;
870 			u8 adwell_default_n_aps_social;
871 			u8 reserved3;
872 			__le16 adwell_max_budget;
873 			__le32 max_out_time[SCAN_TWO_LMACS];
874 			__le32 suspend_time[SCAN_TWO_LMACS];
875 			__le32 scan_priority;
876 			struct iwl_scan_umac_chan_param channel;
877 			u8 data[];
878 		} v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
879 		struct {
880 			u8 active_dwell[SCAN_TWO_LMACS];
881 			u8 reserved2;
882 			u8 adwell_default_n_aps;
883 			u8 adwell_default_n_aps_social;
884 			u8 general_flags2;
885 			__le16 adwell_max_budget;
886 			__le32 max_out_time[SCAN_TWO_LMACS];
887 			__le32 suspend_time[SCAN_TWO_LMACS];
888 			__le32 scan_priority;
889 			u8 passive_dwell[SCAN_TWO_LMACS];
890 			u8 num_of_fragments[SCAN_TWO_LMACS];
891 			struct iwl_scan_umac_chan_param channel;
892 			u8 data[];
893 		} v8; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_8 */
894 		struct {
895 			u8 active_dwell[SCAN_TWO_LMACS];
896 			u8 adwell_default_hb_n_aps;
897 			u8 adwell_default_lb_n_aps;
898 			u8 adwell_default_n_aps_social;
899 			u8 general_flags2;
900 			__le16 adwell_max_budget;
901 			__le32 max_out_time[SCAN_TWO_LMACS];
902 			__le32 suspend_time[SCAN_TWO_LMACS];
903 			__le32 scan_priority;
904 			u8 passive_dwell[SCAN_TWO_LMACS];
905 			u8 num_of_fragments[SCAN_TWO_LMACS];
906 			struct iwl_scan_umac_chan_param channel;
907 			u8 data[];
908 		} v9; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_9 */
909 	};
910 } __packed;
911 
912 #define IWL_SCAN_REQ_UMAC_SIZE_V8 sizeof(struct iwl_scan_req_umac)
913 #define IWL_SCAN_REQ_UMAC_SIZE_V7 48
914 #define IWL_SCAN_REQ_UMAC_SIZE_V6 44
915 #define IWL_SCAN_REQ_UMAC_SIZE_V1 36
916 
917 /**
918  * struct iwl_scan_probe_params_v3
919  * @preq: scan probe request params
920  * @ssid_num: number of valid SSIDs in direct scan array
921  * @short_ssid_num: number of valid short SSIDs in short ssid array
922  * @bssid_num: number of valid bssid in bssids array
923  * @reserved: reserved
924  * @direct_scan: list of ssids
925  * @short_ssid: array of short ssids
926  * @bssid_array: array of bssids
927  */
928 struct iwl_scan_probe_params_v3 {
929 	struct iwl_scan_probe_req preq;
930 	u8 ssid_num;
931 	u8 short_ssid_num;
932 	u8 bssid_num;
933 	u8 reserved;
934 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
935 	__le32 short_ssid[SCAN_SHORT_SSID_MAX_SIZE];
936 	u8 bssid_array[SCAN_BSSID_MAX_SIZE][ETH_ALEN];
937 } __packed; /* SCAN_PROBE_PARAMS_API_S_VER_3 */
938 
939 /**
940  * struct iwl_scan_probe_params_v4
941  * @preq: scan probe request params
942  * @short_ssid_num: number of valid short SSIDs in short ssid array
943  * @bssid_num: number of valid bssid in bssids array
944  * @reserved: reserved
945  * @direct_scan: list of ssids
946  * @short_ssid: array of short ssids
947  * @bssid_array: array of bssids
948  */
949 struct iwl_scan_probe_params_v4 {
950 	struct iwl_scan_probe_req preq;
951 	u8 short_ssid_num;
952 	u8 bssid_num;
953 	__le16 reserved;
954 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
955 	__le32 short_ssid[SCAN_SHORT_SSID_MAX_SIZE];
956 	u8 bssid_array[SCAN_BSSID_MAX_SIZE][ETH_ALEN];
957 } __packed; /* SCAN_PROBE_PARAMS_API_S_VER_4 */
958 
959 #define SCAN_MAX_NUM_CHANS_V3 67
960 
961 /**
962  * struct iwl_scan_channel_params_v4
963  * @flags: channel flags &enum iwl_scan_channel_flags
964  * @count: num of channels in scan request
965  * @num_of_aps_override: override the number of APs the FW uses to calculate
966  *	dwell time when adaptive dwell is used
967  * @reserved: for future use and alignment
968  * @channel_config: array of explicit channel configurations
969  *                  for 2.4Ghz and 5.2Ghz bands
970  * @adwell_ch_override_bitmap: when using adaptive dwell, override the number
971  *	of APs value with &num_of_aps_override for the channel.
972  *	To cast channel to index, use &iwl_mvm_scan_ch_and_band_to_idx
973  */
974 struct iwl_scan_channel_params_v4 {
975 	u8 flags;
976 	u8 count;
977 	u8 num_of_aps_override;
978 	u8 reserved;
979 	struct iwl_scan_channel_cfg_umac channel_config[SCAN_MAX_NUM_CHANS_V3];
980 	u8 adwell_ch_override_bitmap[16];
981 } __packed; /* SCAN_CHANNEL_PARAMS_API_S_VER_4 also
982 	       SCAN_CHANNEL_PARAMS_API_S_VER_5 */
983 
984 /**
985  * struct iwl_scan_channel_params_v6
986  * @flags: channel flags &enum iwl_scan_channel_flags
987  * @count: num of channels in scan request
988  * @n_aps_override: override the number of APs the FW uses to calculate dwell
989  *	time when adaptive dwell is used.
990  *	Channel k will use n_aps_override[i] when BIT(20 + i) is set in
991  *	channel_config[k].flags
992  * @channel_config: array of explicit channel configurations
993  *                  for 2.4Ghz and 5.2Ghz bands
994  */
995 struct iwl_scan_channel_params_v6 {
996 	u8 flags;
997 	u8 count;
998 	u8 n_aps_override[2];
999 	struct iwl_scan_channel_cfg_umac channel_config[SCAN_MAX_NUM_CHANS_V3];
1000 } __packed; /* SCAN_CHANNEL_PARAMS_API_S_VER_6 */
1001 
1002 /**
1003  * struct iwl_scan_general_params_v11
1004  * @flags: &enum iwl_umac_scan_general_flags_v2
1005  * @reserved: reserved for future
1006  * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
1007  * @active_dwell: dwell time for active scan per LMAC
1008  * @adwell_default_2g: adaptive dwell default number of APs
1009  *                        for 2.4GHz channel
1010  * @adwell_default_5g: adaptive dwell default number of APs
1011  *                        for 5GHz channels
1012  * @adwell_default_social_chn: adaptive dwell default number of
1013  *                             APs per social channel
1014  * @flags2: for version 11 see &enum iwl_umac_scan_general_params_flags2.
1015  *     Otherwise reserved.
1016  * @adwell_max_budget: the maximal number of TUs that adaptive dwell
1017  *                     can add to the total scan time
1018  * @max_out_of_time: max out of serving channel time, per LMAC
1019  * @suspend_time: max suspend time, per LMAC
1020  * @scan_priority: priority of the request
1021  * @passive_dwell: continues dwell time for passive channel
1022  *                 (without adaptive dwell)
1023  * @num_of_fragments: number of fragments needed for full fragmented
1024  *                    scan coverage.
1025  */
1026 struct iwl_scan_general_params_v11 {
1027 	__le16 flags;
1028 	u8 reserved;
1029 	u8 scan_start_mac_id;
1030 	u8 active_dwell[SCAN_TWO_LMACS];
1031 	u8 adwell_default_2g;
1032 	u8 adwell_default_5g;
1033 	u8 adwell_default_social_chn;
1034 	u8 flags2;
1035 	__le16 adwell_max_budget;
1036 	__le32 max_out_of_time[SCAN_TWO_LMACS];
1037 	__le32 suspend_time[SCAN_TWO_LMACS];
1038 	__le32 scan_priority;
1039 	u8 passive_dwell[SCAN_TWO_LMACS];
1040 	u8 num_of_fragments[SCAN_TWO_LMACS];
1041 } __packed; /* SCAN_GENERAL_PARAMS_API_S_VER_11 and *_VER_10 */
1042 
1043 /**
1044  * struct iwl_scan_periodic_parms_v1
1045  * @schedule: can scheduling parameter
1046  * @delay: initial delay of the periodic scan in seconds
1047  * @reserved: reserved for future
1048  */
1049 struct iwl_scan_periodic_parms_v1 {
1050 	struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
1051 	__le16 delay;
1052 	__le16 reserved;
1053 } __packed; /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
1054 
1055 /**
1056  * struct iwl_scan_req_params_v12
1057  * @general_params: &struct iwl_scan_general_params_v11
1058  * @channel_params: &struct iwl_scan_channel_params_v4
1059  * @periodic_params: &struct iwl_scan_periodic_parms_v1
1060  * @probe_params: &struct iwl_scan_probe_params_v3
1061  */
1062 struct iwl_scan_req_params_v12 {
1063 	struct iwl_scan_general_params_v11 general_params;
1064 	struct iwl_scan_channel_params_v4 channel_params;
1065 	struct iwl_scan_periodic_parms_v1 periodic_params;
1066 	struct iwl_scan_probe_params_v3 probe_params;
1067 } __packed; /* SCAN_REQUEST_PARAMS_API_S_VER_12 */
1068 
1069 /**
1070  * struct iwl_scan_req_params_v15
1071  * @general_params: &struct iwl_scan_general_params_v11
1072  * @channel_params: &struct iwl_scan_channel_params_v6
1073  * @periodic_params: &struct iwl_scan_periodic_parms_v1
1074  * @probe_params: &struct iwl_scan_probe_params_v4
1075  */
1076 struct iwl_scan_req_params_v15 {
1077 	struct iwl_scan_general_params_v11 general_params;
1078 	struct iwl_scan_channel_params_v6 channel_params;
1079 	struct iwl_scan_periodic_parms_v1 periodic_params;
1080 	struct iwl_scan_probe_params_v4 probe_params;
1081 } __packed; /* SCAN_REQUEST_PARAMS_API_S_VER_15 and *_VER_14 */
1082 
1083 /**
1084  * struct iwl_scan_req_umac_v12
1085  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
1086  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
1087  * @scan_params: scan parameters
1088  */
1089 struct iwl_scan_req_umac_v12 {
1090 	__le32 uid;
1091 	__le32 ooc_priority;
1092 	struct iwl_scan_req_params_v12 scan_params;
1093 } __packed; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_12 */
1094 
1095 /**
1096  * struct iwl_scan_req_umac_v15
1097  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
1098  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
1099  * @scan_params: scan parameters
1100  */
1101 struct iwl_scan_req_umac_v15 {
1102 	__le32 uid;
1103 	__le32 ooc_priority;
1104 	struct iwl_scan_req_params_v15 scan_params;
1105 } __packed; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_15 and *_VER_14 */
1106 
1107 /**
1108  * struct iwl_umac_scan_abort
1109  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
1110  * @flags: reserved
1111  */
1112 struct iwl_umac_scan_abort {
1113 	__le32 uid;
1114 	__le32 flags;
1115 } __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
1116 
1117 /**
1118  * struct iwl_umac_scan_complete
1119  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
1120  * @last_schedule: last scheduling line
1121  * @last_iter: last scan iteration number
1122  * @status: &enum iwl_scan_offload_complete_status
1123  * @ebs_status: &enum iwl_scan_ebs_status
1124  * @time_from_last_iter: time elapsed from last iteration
1125  * @reserved: for future use
1126  */
1127 struct iwl_umac_scan_complete {
1128 	__le32 uid;
1129 	u8 last_schedule;
1130 	u8 last_iter;
1131 	u8 status;
1132 	u8 ebs_status;
1133 	__le32 time_from_last_iter;
1134 	__le32 reserved;
1135 } __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
1136 
1137 #define SCAN_OFFLOAD_MATCHING_CHANNELS_LEN_V1 5
1138 #define SCAN_OFFLOAD_MATCHING_CHANNELS_LEN    7
1139 
1140 /**
1141  * struct iwl_scan_offload_profile_match_v1 - match information
1142  * @bssid: matched bssid
1143  * @reserved: reserved
1144  * @channel: channel where the match occurred
1145  * @energy: energy
1146  * @matching_feature: feature matches
1147  * @matching_channels: bitmap of channels that matched, referencing
1148  *	the channels passed in the scan offload request.
1149  */
1150 struct iwl_scan_offload_profile_match_v1 {
1151 	u8 bssid[ETH_ALEN];
1152 	__le16 reserved;
1153 	u8 channel;
1154 	u8 energy;
1155 	u8 matching_feature;
1156 	u8 matching_channels[SCAN_OFFLOAD_MATCHING_CHANNELS_LEN_V1];
1157 } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
1158 
1159 /**
1160  * struct iwl_scan_offload_profiles_query_v1 - match results query response
1161  * @matched_profiles: bitmap of matched profiles, referencing the
1162  *	matches passed in the scan offload request
1163  * @last_scan_age: age of the last offloaded scan
1164  * @n_scans_done: number of offloaded scans done
1165  * @gp2_d0u: GP2 when D0U occurred
1166  * @gp2_invoked: GP2 when scan offload was invoked
1167  * @resume_while_scanning: not used
1168  * @self_recovery: obsolete
1169  * @reserved: reserved
1170  * @matches: array of match information, one for each match
1171  */
1172 struct iwl_scan_offload_profiles_query_v1 {
1173 	__le32 matched_profiles;
1174 	__le32 last_scan_age;
1175 	__le32 n_scans_done;
1176 	__le32 gp2_d0u;
1177 	__le32 gp2_invoked;
1178 	u8 resume_while_scanning;
1179 	u8 self_recovery;
1180 	__le16 reserved;
1181 	struct iwl_scan_offload_profile_match_v1 matches[];
1182 } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
1183 
1184 /**
1185  * struct iwl_scan_offload_profile_match - match information
1186  * @bssid: matched bssid
1187  * @reserved: reserved
1188  * @channel: channel where the match occurred
1189  * @energy: energy
1190  * @matching_feature: feature matches
1191  * @matching_channels: bitmap of channels that matched, referencing
1192  *	the channels passed in the scan offload request.
1193  */
1194 struct iwl_scan_offload_profile_match {
1195 	u8 bssid[ETH_ALEN];
1196 	__le16 reserved;
1197 	u8 channel;
1198 	u8 energy;
1199 	u8 matching_feature;
1200 	u8 matching_channels[SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
1201 } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_2 */
1202 
1203 /**
1204  * struct iwl_scan_offload_match_info - match results information
1205  * @matched_profiles: bitmap of matched profiles, referencing the
1206  *	matches passed in the scan offload request
1207  * @last_scan_age: age of the last offloaded scan
1208  * @n_scans_done: number of offloaded scans done
1209  * @gp2_d0u: GP2 when D0U occurred
1210  * @gp2_invoked: GP2 when scan offload was invoked
1211  * @resume_while_scanning: not used
1212  * @self_recovery: obsolete
1213  * @reserved: reserved
1214  * @matches: array of match information, one for each match
1215  */
1216 struct iwl_scan_offload_match_info {
1217 	__le32 matched_profiles;
1218 	__le32 last_scan_age;
1219 	__le32 n_scans_done;
1220 	__le32 gp2_d0u;
1221 	__le32 gp2_invoked;
1222 	u8 resume_while_scanning;
1223 	u8 self_recovery;
1224 	__le16 reserved;
1225 	struct iwl_scan_offload_profile_match matches[];
1226 } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_3 and
1227 	     * SCAN_OFFLOAD_MATCH_INFO_NOTIFICATION_S_VER_1
1228 	     */
1229 
1230 /**
1231  * struct iwl_umac_scan_iter_complete_notif - notifies end of scanning iteration
1232  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
1233  * @scanned_channels: number of channels scanned and number of valid elements in
1234  *	results array
1235  * @status: one of SCAN_COMP_STATUS_*
1236  * @bt_status: BT on/off status
1237  * @last_channel: last channel that was scanned
1238  * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
1239  *	in &struct iwl_scan_req_umac.
1240  * @results: array of scan results, length in @scanned_channels
1241  */
1242 struct iwl_umac_scan_iter_complete_notif {
1243 	__le32 uid;
1244 	u8 scanned_channels;
1245 	u8 status;
1246 	u8 bt_status;
1247 	u8 last_channel;
1248 	__le64 start_tsf;
1249 	struct iwl_scan_results_notif results[];
1250 } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
1251 
1252 #endif /* __iwl_fw_api_scan_h__ */
1253