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