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