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