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