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  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of version 2 of the GNU General Public License as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * The full GNU General Public License is included in this distribution
22  * in the file called COPYING.
23  *
24  * Contact Information:
25  *  Intel Linux Wireless <linuxwifi@intel.com>
26  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27  *
28  * BSD LICENSE
29  *
30  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
33  * All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  *
39  *  * Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  *  * Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in
43  *    the documentation and/or other materials provided with the
44  *    distribution.
45  *  * Neither the name Intel Corporation nor the names of its
46  *    contributors may be used to endorse or promote products derived
47  *    from this software without specific prior written permission.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  *****************************************************************************/
62 
63 #ifndef __iwl_fw_api_scan_h__
64 #define __iwl_fw_api_scan_h__
65 
66 /* Scan Commands, Responses, Notifications */
67 
68 /* Max number of IEs for direct SSID scans in a command */
69 #define PROBE_OPTION_MAX		20
70 
71 /**
72  * struct iwl_ssid_ie - directed scan network information element
73  *
74  * Up to 20 of these may appear in REPLY_SCAN_CMD,
75  * selected by "type" bit field in struct iwl_scan_channel;
76  * each channel may select different ssids from among the 20 entries.
77  * SSID IEs get transmitted in reverse order of entry.
78  *
79  * @id: element ID
80  * @len: element length
81  * @ssid: element (SSID) data
82  */
83 struct iwl_ssid_ie {
84 	u8 id;
85 	u8 len;
86 	u8 ssid[IEEE80211_MAX_SSID_LEN];
87 } __packed; /* SCAN_DIRECT_SSID_IE_API_S_VER_1 */
88 
89 /* scan offload */
90 #define IWL_SCAN_MAX_BLACKLIST_LEN	64
91 #define IWL_SCAN_SHORT_BLACKLIST_LEN	16
92 #define IWL_SCAN_MAX_PROFILES		11
93 #define SCAN_OFFLOAD_PROBE_REQ_SIZE	512
94 
95 /* Default watchdog (in MS) for scheduled scan iteration */
96 #define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
97 
98 #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
99 #define CAN_ABORT_STATUS 1
100 
101 #define IWL_FULL_SCAN_MULTIPLIER 5
102 #define IWL_FAST_SCHED_SCAN_ITERATIONS 3
103 #define IWL_MAX_SCHED_SCAN_PLANS 2
104 
105 enum scan_framework_client {
106 	SCAN_CLIENT_SCHED_SCAN		= BIT(0),
107 	SCAN_CLIENT_NETDETECT		= BIT(1),
108 	SCAN_CLIENT_ASSET_TRACKING	= BIT(2),
109 };
110 
111 /**
112  * struct iwl_scan_offload_blacklist - SCAN_OFFLOAD_BLACKLIST_S
113  * @ssid:		MAC address to filter out
114  * @reported_rssi:	AP rssi reported to the host
115  * @client_bitmap: clients ignore this entry  - enum scan_framework_client
116  */
117 struct iwl_scan_offload_blacklist {
118 	u8 ssid[ETH_ALEN];
119 	u8 reported_rssi;
120 	u8 client_bitmap;
121 } __packed;
122 
123 enum iwl_scan_offload_network_type {
124 	IWL_NETWORK_TYPE_BSS	= 1,
125 	IWL_NETWORK_TYPE_IBSS	= 2,
126 	IWL_NETWORK_TYPE_ANY	= 3,
127 };
128 
129 enum iwl_scan_offload_band_selection {
130 	IWL_SCAN_OFFLOAD_SELECT_2_4	= 0x4,
131 	IWL_SCAN_OFFLOAD_SELECT_5_2	= 0x8,
132 	IWL_SCAN_OFFLOAD_SELECT_ANY	= 0xc,
133 };
134 
135 /**
136  * struct iwl_scan_offload_profile - SCAN_OFFLOAD_PROFILE_S
137  * @ssid_index:		index to ssid list in fixed part
138  * @unicast_cipher:	encryption algorithm to match - bitmap
139  * @auth_alg:		authentication algorithm to match - bitmap
140  * @network_type:	enum iwl_scan_offload_network_type
141  * @band_selection:	enum iwl_scan_offload_band_selection
142  * @client_bitmap:	clients waiting for match - enum scan_framework_client
143  * @reserved:		reserved
144  */
145 struct iwl_scan_offload_profile {
146 	u8 ssid_index;
147 	u8 unicast_cipher;
148 	u8 auth_alg;
149 	u8 network_type;
150 	u8 band_selection;
151 	u8 client_bitmap;
152 	u8 reserved[2];
153 } __packed;
154 
155 /**
156  * struct iwl_scan_offload_profile_cfg - SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1
157  * @profiles:		profiles to search for match
158  * @blacklist_len:	length of blacklist
159  * @num_profiles:	num of profiles in the list
160  * @match_notify:	clients waiting for match found notification
161  * @pass_match:		clients waiting for the results
162  * @active_clients:	active clients bitmap - enum scan_framework_client
163  * @any_beacon_notify:	clients waiting for match notification without match
164  * @reserved:		reserved
165  */
166 struct iwl_scan_offload_profile_cfg {
167 	struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES];
168 	u8 blacklist_len;
169 	u8 num_profiles;
170 	u8 match_notify;
171 	u8 pass_match;
172 	u8 active_clients;
173 	u8 any_beacon_notify;
174 	u8 reserved[2];
175 } __packed;
176 
177 /**
178  * struct iwl_scan_schedule_lmac - schedule of scan offload
179  * @delay:		delay between iterations, in seconds.
180  * @iterations:		num of scan iterations
181  * @full_scan_mul:	number of partial scans before each full scan
182  */
183 struct iwl_scan_schedule_lmac {
184 	__le16 delay;
185 	u8 iterations;
186 	u8 full_scan_mul;
187 } __packed; /* SCAN_SCHEDULE_API_S */
188 
189 enum iwl_scan_offload_complete_status {
190 	IWL_SCAN_OFFLOAD_COMPLETED	= 1,
191 	IWL_SCAN_OFFLOAD_ABORTED	= 2,
192 };
193 
194 enum iwl_scan_ebs_status {
195 	IWL_SCAN_EBS_SUCCESS,
196 	IWL_SCAN_EBS_FAILED,
197 	IWL_SCAN_EBS_CHAN_NOT_FOUND,
198 	IWL_SCAN_EBS_INACTIVE,
199 };
200 
201 /**
202  * struct iwl_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
203  * @tx_flags: combination of TX_CMD_FLG_*
204  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
205  *	cleared. Combination of RATE_MCS_*
206  * @sta_id: index of destination station in FW station table
207  * @reserved: for alignment and future use
208  */
209 struct iwl_scan_req_tx_cmd {
210 	__le32 tx_flags;
211 	__le32 rate_n_flags;
212 	u8 sta_id;
213 	u8 reserved[3];
214 } __packed;
215 
216 enum iwl_scan_channel_flags_lmac {
217 	IWL_UNIFIED_SCAN_CHANNEL_FULL		= BIT(27),
218 	IWL_UNIFIED_SCAN_CHANNEL_PARTIAL	= BIT(28),
219 };
220 
221 /**
222  * struct iwl_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
223  * @flags:		bits 1-20: directed scan to i'th ssid
224  *			other bits &enum iwl_scan_channel_flags_lmac
225  * @channel_num:	channel number 1-13 etc
226  * @iter_count:		scan iteration on this channel
227  * @iter_interval:	interval in seconds between iterations on one channel
228  */
229 struct iwl_scan_channel_cfg_lmac {
230 	__le32 flags;
231 	__le16 channel_num;
232 	__le16 iter_count;
233 	__le32 iter_interval;
234 } __packed;
235 
236 /*
237  * struct iwl_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
238  * @offset: offset in the data block
239  * @len: length of the segment
240  */
241 struct iwl_scan_probe_segment {
242 	__le16 offset;
243 	__le16 len;
244 } __packed;
245 
246 /* iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_2
247  * @mac_header: first (and common) part of the probe
248  * @band_data: band specific data
249  * @common_data: last (and common) part of the probe
250  * @buf: raw data block
251  */
252 struct iwl_scan_probe_req {
253 	struct iwl_scan_probe_segment mac_header;
254 	struct iwl_scan_probe_segment band_data[2];
255 	struct iwl_scan_probe_segment common_data;
256 	u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
257 } __packed;
258 
259 enum iwl_scan_channel_flags {
260 	IWL_SCAN_CHANNEL_FLAG_EBS		= BIT(0),
261 	IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE	= BIT(1),
262 	IWL_SCAN_CHANNEL_FLAG_CACHE_ADD		= BIT(2),
263 };
264 
265 /* struct iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
266  * @flags: enum iwl_scan_channel_flags
267  * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
268  *	involved.
269  *	1 - EBS is disabled.
270  *	2 - every second scan will be full scan(and so on).
271  */
272 struct iwl_scan_channel_opt {
273 	__le16 flags;
274 	__le16 non_ebs_ratio;
275 } __packed;
276 
277 /**
278  * enum iwl_mvm_lmac_scan_flags - LMAC scan flags
279  * @IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
280  *	without filtering.
281  * @IWL_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
282  * @IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
283  * @IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
284  * @IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS: multiple SSID matching
285  * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
286  * @IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
287  *	and DS parameter set IEs into probe requests.
288  * @IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
289  *	1, 6 and 11.
290  * @IWL_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
291  */
292 enum iwl_mvm_lmac_scan_flags {
293 	IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL		= BIT(0),
294 	IWL_MVM_LMAC_SCAN_FLAG_PASSIVE		= BIT(1),
295 	IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION	= BIT(2),
296 	IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE	= BIT(3),
297 	IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS	= BIT(4),
298 	IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED	= BIT(5),
299 	IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED	= BIT(6),
300 	IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL	= BIT(7),
301 	IWL_MVM_LMAC_SCAN_FLAG_MATCH		= BIT(9),
302 };
303 
304 enum iwl_scan_priority {
305 	IWL_SCAN_PRIORITY_LOW,
306 	IWL_SCAN_PRIORITY_MEDIUM,
307 	IWL_SCAN_PRIORITY_HIGH,
308 };
309 
310 enum iwl_scan_priority_ext {
311 	IWL_SCAN_PRIORITY_EXT_0_LOWEST,
312 	IWL_SCAN_PRIORITY_EXT_1,
313 	IWL_SCAN_PRIORITY_EXT_2,
314 	IWL_SCAN_PRIORITY_EXT_3,
315 	IWL_SCAN_PRIORITY_EXT_4,
316 	IWL_SCAN_PRIORITY_EXT_5,
317 	IWL_SCAN_PRIORITY_EXT_6,
318 	IWL_SCAN_PRIORITY_EXT_7_HIGHEST,
319 };
320 
321 /**
322  * struct iwl_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
323  * @reserved1: for alignment and future use
324  * @n_channels: num of channels to scan
325  * @active_dwell: dwell time for active channels
326  * @passive_dwell: dwell time for passive channels
327  * @fragmented_dwell: dwell time for fragmented passive scan
328  * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
329  * @reserved2: for alignment and future use
330  * @rx_chain_select: PHY_RX_CHAIN_* flags
331  * @scan_flags: &enum iwl_mvm_lmac_scan_flags
332  * @max_out_time: max time (in TU) to be out of associated channel
333  * @suspend_time: pause scan this long (TUs) when returning to service channel
334  * @flags: RXON flags
335  * @filter_flags: RXON filter
336  * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
337  * @direct_scan: list of SSIDs for directed active scan
338  * @scan_prio: enum iwl_scan_priority
339  * @iter_num: number of scan iterations
340  * @delay: delay in seconds before first iteration
341  * @schedule: two scheduling plans. The first one is finite, the second one can
342  *	be infinite.
343  * @channel_opt: channel optimization options, for full and partial scan
344  * @data: channel configuration and probe request packet.
345  */
346 struct iwl_scan_req_lmac {
347 	/* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
348 	__le32 reserved1;
349 	u8 n_channels;
350 	u8 active_dwell;
351 	u8 passive_dwell;
352 	u8 fragmented_dwell;
353 	u8 extended_dwell;
354 	u8 reserved2;
355 	__le16 rx_chain_select;
356 	__le32 scan_flags;
357 	__le32 max_out_time;
358 	__le32 suspend_time;
359 	/* RX_ON_FLAGS_API_S_VER_1 */
360 	__le32 flags;
361 	__le32 filter_flags;
362 	struct iwl_scan_req_tx_cmd tx_cmd[2];
363 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
364 	__le32 scan_prio;
365 	/* SCAN_REQ_PERIODIC_PARAMS_API_S */
366 	__le32 iter_num;
367 	__le32 delay;
368 	struct iwl_scan_schedule_lmac schedule[IWL_MAX_SCHED_SCAN_PLANS];
369 	struct iwl_scan_channel_opt channel_opt[2];
370 	u8 data[];
371 } __packed;
372 
373 /**
374  * struct iwl_scan_results_notif - scan results for one channel -
375  *	SCAN_RESULT_NTF_API_S_VER_3
376  * @channel: which channel the results are from
377  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
378  * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
379  * @num_probe_not_sent: # of request that weren't sent due to not enough time
380  * @duration: duration spent in channel, in usecs
381  */
382 struct iwl_scan_results_notif {
383 	u8 channel;
384 	u8 band;
385 	u8 probe_status;
386 	u8 num_probe_not_sent;
387 	__le32 duration;
388 } __packed;
389 
390 /**
391  * struct iwl_lmac_scan_complete_notif - notifies end of scanning (all channels)
392  *	SCAN_COMPLETE_NTF_API_S_VER_3
393  * @scanned_channels: number of channels scanned (and number of valid results)
394  * @status: one of SCAN_COMP_STATUS_*
395  * @bt_status: BT on/off status
396  * @last_channel: last channel that was scanned
397  * @tsf_low: TSF timer (lower half) in usecs
398  * @tsf_high: TSF timer (higher half) in usecs
399  * @results: an array of scan results, only "scanned_channels" of them are valid
400  */
401 struct iwl_lmac_scan_complete_notif {
402 	u8 scanned_channels;
403 	u8 status;
404 	u8 bt_status;
405 	u8 last_channel;
406 	__le32 tsf_low;
407 	__le32 tsf_high;
408 	struct iwl_scan_results_notif results[];
409 } __packed;
410 
411 /**
412  * struct iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
413  * @last_schedule_line: last schedule line executed (fast or regular)
414  * @last_schedule_iteration: last scan iteration executed before scan abort
415  * @status: &enum iwl_scan_offload_complete_status
416  * @ebs_status: EBS success status &enum iwl_scan_ebs_status
417  * @time_after_last_iter: time in seconds elapsed after last iteration
418  * @reserved: reserved
419  */
420 struct iwl_periodic_scan_complete {
421 	u8 last_schedule_line;
422 	u8 last_schedule_iteration;
423 	u8 status;
424 	u8 ebs_status;
425 	__le32 time_after_last_iter;
426 	__le32 reserved;
427 } __packed;
428 
429 /* UMAC Scan API */
430 
431 /* The maximum of either of these cannot exceed 8, because we use an
432  * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h).
433  */
434 #define IWL_MVM_MAX_UMAC_SCANS 8
435 #define IWL_MVM_MAX_LMAC_SCANS 1
436 
437 enum scan_config_flags {
438 	SCAN_CONFIG_FLAG_ACTIVATE			= BIT(0),
439 	SCAN_CONFIG_FLAG_DEACTIVATE			= BIT(1),
440 	SCAN_CONFIG_FLAG_FORBID_CHUB_REQS		= BIT(2),
441 	SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS		= BIT(3),
442 	SCAN_CONFIG_FLAG_SET_TX_CHAINS			= BIT(8),
443 	SCAN_CONFIG_FLAG_SET_RX_CHAINS			= BIT(9),
444 	SCAN_CONFIG_FLAG_SET_AUX_STA_ID			= BIT(10),
445 	SCAN_CONFIG_FLAG_SET_ALL_TIMES			= BIT(11),
446 	SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES		= BIT(12),
447 	SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS		= BIT(13),
448 	SCAN_CONFIG_FLAG_SET_LEGACY_RATES		= BIT(14),
449 	SCAN_CONFIG_FLAG_SET_MAC_ADDR			= BIT(15),
450 	SCAN_CONFIG_FLAG_SET_FRAGMENTED			= BIT(16),
451 	SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED		= BIT(17),
452 	SCAN_CONFIG_FLAG_SET_CAM_MODE			= BIT(18),
453 	SCAN_CONFIG_FLAG_CLEAR_CAM_MODE			= BIT(19),
454 	SCAN_CONFIG_FLAG_SET_PROMISC_MODE		= BIT(20),
455 	SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE		= BIT(21),
456 	SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED		= BIT(22),
457 	SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED		= BIT(23),
458 
459 	/* Bits 26-31 are for num of channels in channel_array */
460 #define SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
461 };
462 
463 enum scan_config_rates {
464 	/* OFDM basic rates */
465 	SCAN_CONFIG_RATE_6M	= BIT(0),
466 	SCAN_CONFIG_RATE_9M	= BIT(1),
467 	SCAN_CONFIG_RATE_12M	= BIT(2),
468 	SCAN_CONFIG_RATE_18M	= BIT(3),
469 	SCAN_CONFIG_RATE_24M	= BIT(4),
470 	SCAN_CONFIG_RATE_36M	= BIT(5),
471 	SCAN_CONFIG_RATE_48M	= BIT(6),
472 	SCAN_CONFIG_RATE_54M	= BIT(7),
473 	/* CCK basic rates */
474 	SCAN_CONFIG_RATE_1M	= BIT(8),
475 	SCAN_CONFIG_RATE_2M	= BIT(9),
476 	SCAN_CONFIG_RATE_5M	= BIT(10),
477 	SCAN_CONFIG_RATE_11M	= BIT(11),
478 
479 	/* Bits 16-27 are for supported rates */
480 #define SCAN_CONFIG_SUPPORTED_RATE(rate)	((rate) << 16)
481 };
482 
483 enum iwl_channel_flags {
484 	IWL_CHANNEL_FLAG_EBS				= BIT(0),
485 	IWL_CHANNEL_FLAG_ACCURATE_EBS			= BIT(1),
486 	IWL_CHANNEL_FLAG_EBS_ADD			= BIT(2),
487 	IWL_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE	= BIT(3),
488 };
489 
490 /**
491  * struct iwl_scan_dwell
492  * @active:		default dwell time for active scan
493  * @passive:		default dwell time for passive scan
494  * @fragmented:		default dwell time for fragmented scan
495  * @extended:		default dwell time for channels 1, 6 and 11
496  */
497 struct iwl_scan_dwell {
498 	u8 active;
499 	u8 passive;
500 	u8 fragmented;
501 	u8 extended;
502 } __packed;
503 
504 /**
505  * struct iwl_scan_config
506  * @flags:			enum scan_config_flags
507  * @tx_chains:			valid_tx antenna - ANT_* definitions
508  * @rx_chains:			valid_rx antenna - ANT_* definitions
509  * @legacy_rates:		default legacy rates - enum scan_config_rates
510  * @out_of_channel_time:	default max out of serving channel time
511  * @suspend_time:		default max suspend time
512  * @dwell:			dwells for the scan
513  * @mac_addr:			default mac address to be used in probes
514  * @bcast_sta_id:		the index of the station in the fw
515  * @channel_flags:		default channel flags - enum iwl_channel_flags
516  *				scan_config_channel_flag
517  * @channel_array:		default supported channels
518  */
519 struct iwl_scan_config_v1 {
520 	__le32 flags;
521 	__le32 tx_chains;
522 	__le32 rx_chains;
523 	__le32 legacy_rates;
524 	__le32 out_of_channel_time;
525 	__le32 suspend_time;
526 	struct iwl_scan_dwell dwell;
527 	u8 mac_addr[ETH_ALEN];
528 	u8 bcast_sta_id;
529 	u8 channel_flags;
530 	u8 channel_array[];
531 } __packed; /* SCAN_CONFIG_DB_CMD_API_S */
532 
533 #define SCAN_TWO_LMACS 2
534 #define SCAN_LB_LMAC_IDX 0
535 #define SCAN_HB_LMAC_IDX 1
536 
537 struct iwl_scan_config {
538 	__le32 flags;
539 	__le32 tx_chains;
540 	__le32 rx_chains;
541 	__le32 legacy_rates;
542 	__le32 out_of_channel_time[SCAN_TWO_LMACS];
543 	__le32 suspend_time[SCAN_TWO_LMACS];
544 	struct iwl_scan_dwell dwell;
545 	u8 mac_addr[ETH_ALEN];
546 	u8 bcast_sta_id;
547 	u8 channel_flags;
548 	u8 channel_array[];
549 } __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */
550 
551 /**
552  * enum iwl_umac_scan_flags - UMAC scan flags
553  * @IWL_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
554  *	can be preempted by other scan requests with higher priority.
555  *	The low priority scan will be resumed when the higher proirity scan is
556  *	completed.
557  * @IWL_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
558  *	when scan starts.
559  */
560 enum iwl_umac_scan_flags {
561 	IWL_UMAC_SCAN_FLAG_PREEMPTIVE		= BIT(0),
562 	IWL_UMAC_SCAN_FLAG_START_NOTIF		= BIT(1),
563 };
564 
565 enum iwl_umac_scan_uid_offsets {
566 	IWL_UMAC_SCAN_UID_TYPE_OFFSET		= 0,
567 	IWL_UMAC_SCAN_UID_SEQ_OFFSET		= 8,
568 };
569 
570 enum iwl_umac_scan_general_flags {
571 	IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC		= BIT(0),
572 	IWL_UMAC_SCAN_GEN_FLAGS_OVER_BT			= BIT(1),
573 	IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL		= BIT(2),
574 	IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE			= BIT(3),
575 	IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT		= BIT(4),
576 	IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE		= BIT(5),
577 	IWL_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID		= BIT(6),
578 	IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED		= BIT(7),
579 	IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED		= BIT(8),
580 	IWL_UMAC_SCAN_GEN_FLAGS_MATCH			= BIT(9),
581 	IWL_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL		= BIT(10),
582 	IWL_UMAC_SCAN_GEN_FLAGS_LMAC2_FRAGMENTED	= BIT(11),
583 	IWL_UMAC_SCAN_GEN_FLAGS_ADAPTIVE_DWELL		= BIT(13),
584 };
585 
586 /**
587  * struct iwl_scan_channel_cfg_umac
588  * @flags:		bitmap - 0-19:	directed scan to i'th ssid.
589  * @channel_num:	channel number 1-13 etc.
590  * @iter_count:		repetition count for the channel.
591  * @iter_interval:	interval between two scan iterations on one channel.
592  */
593 struct iwl_scan_channel_cfg_umac {
594 	__le32 flags;
595 	u8 channel_num;
596 	u8 iter_count;
597 	__le16 iter_interval;
598 } __packed; /* SCAN_CHANNEL_CFG_S_VER2 */
599 
600 /**
601  * struct iwl_scan_umac_schedule
602  * @interval: interval in seconds between scan iterations
603  * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
604  * @reserved: for alignment and future use
605  */
606 struct iwl_scan_umac_schedule {
607 	__le16 interval;
608 	u8 iter_count;
609 	u8 reserved;
610 } __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
611 
612 /**
613  * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command
614  *      parameters following channels configuration array.
615  * @schedule: two scheduling plans.
616  * @delay: delay in TUs before starting the first scan iteration
617  * @reserved: for future use and alignment
618  * @preq: probe request with IEs blocks
619  * @direct_scan: list of SSIDs for directed active scan
620  */
621 struct iwl_scan_req_umac_tail {
622 	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
623 	struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
624 	__le16 delay;
625 	__le16 reserved;
626 	/* SCAN_PROBE_PARAMS_API_S_VER_1 */
627 	struct iwl_scan_probe_req preq;
628 	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
629 } __packed;
630 
631 /**
632  * struct iwl_scan_req_umac
633  * @flags: &enum iwl_umac_scan_flags
634  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
635  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
636  * @general_flags: &enum iwl_umac_scan_general_flags
637  * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
638  * @extended_dwell: dwell time for channels 1, 6 and 11
639  * @active_dwell: dwell time for active scan
640  * @passive_dwell: dwell time for passive scan
641  * @fragmented_dwell: dwell time for fragmented passive scan
642  * @adwell_default_n_aps: for adaptive dwell the default number of APs
643  *	per channel
644  * @adwell_default_n_aps_social: for adaptive dwell the default
645  *	number of APs per social (1,6,11) channel
646  * @adwell_max_budget: for adaptive dwell the maximal budget of TU to be added
647  *	to total scan time
648  * @max_out_time: max out of serving channel time, per LMAC - for CDB there
649  *	are 2 LMACs
650  * @suspend_time: max suspend time, per LMAC - for CDB there are 2 LMACs
651  * @scan_priority: scan internal prioritization &enum iwl_scan_priority
652  * @channel_flags: &enum iwl_scan_channel_flags
653  * @n_channels: num of channels in scan request
654  * @reserved: for future use and alignment
655  * @reserved2: for future use and alignment
656  * @reserved3: for future use and alignment
657  * @data: &struct iwl_scan_channel_cfg_umac and
658  *	&struct iwl_scan_req_umac_tail
659  */
660 struct iwl_scan_req_umac {
661 	__le32 flags;
662 	__le32 uid;
663 	__le32 ooc_priority;
664 	__le16 general_flags;
665 	u8 reserved;
666 	u8 scan_start_mac_id;
667 	union {
668 		struct {
669 			u8 extended_dwell;
670 			u8 active_dwell;
671 			u8 passive_dwell;
672 			u8 fragmented_dwell;
673 			__le32 max_out_time;
674 			__le32 suspend_time;
675 			__le32 scan_priority;
676 			/* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
677 			u8 channel_flags;
678 			u8 n_channels;
679 			__le16 reserved2;
680 			u8 data[];
681 		} v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
682 		struct {
683 			u8 extended_dwell;
684 			u8 active_dwell;
685 			u8 passive_dwell;
686 			u8 fragmented_dwell;
687 			__le32 max_out_time[SCAN_TWO_LMACS];
688 			__le32 suspend_time[SCAN_TWO_LMACS];
689 			__le32 scan_priority;
690 			/* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
691 			u8 channel_flags;
692 			u8 n_channels;
693 			__le16 reserved2;
694 			u8 data[];
695 		} v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
696 		struct {
697 			u8 active_dwell;
698 			u8 passive_dwell;
699 			u8 fragmented_dwell;
700 			u8 adwell_default_n_aps;
701 			u8 adwell_default_n_aps_social;
702 			u8 reserved3;
703 			__le16 adwell_max_budget;
704 			__le32 max_out_time[SCAN_TWO_LMACS];
705 			__le32 suspend_time[SCAN_TWO_LMACS];
706 			__le32 scan_priority;
707 			/* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
708 			u8 channel_flags;
709 			u8 n_channels;
710 			__le16 reserved2;
711 			u8 data[];
712 		} v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
713 	};
714 } __packed;
715 
716 #define IWL_SCAN_REQ_UMAC_SIZE_V7 sizeof(struct iwl_scan_req_umac)
717 #define IWL_SCAN_REQ_UMAC_SIZE_V6 (sizeof(struct iwl_scan_req_umac) - \
718 				   2 * sizeof(u8) - sizeof(__le16))
719 #define IWL_SCAN_REQ_UMAC_SIZE_V1 (sizeof(struct iwl_scan_req_umac) - \
720 				   2 * sizeof(__le32) - 2 * sizeof(u8) - \
721 				   sizeof(__le16))
722 
723 /**
724  * struct iwl_umac_scan_abort
725  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
726  * @flags: reserved
727  */
728 struct iwl_umac_scan_abort {
729 	__le32 uid;
730 	__le32 flags;
731 } __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
732 
733 /**
734  * struct iwl_umac_scan_complete
735  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
736  * @last_schedule: last scheduling line
737  * @last_iter: last scan iteration number
738  * @status: &enum iwl_scan_offload_complete_status
739  * @ebs_status: &enum iwl_scan_ebs_status
740  * @time_from_last_iter: time elapsed from last iteration
741  * @reserved: for future use
742  */
743 struct iwl_umac_scan_complete {
744 	__le32 uid;
745 	u8 last_schedule;
746 	u8 last_iter;
747 	u8 status;
748 	u8 ebs_status;
749 	__le32 time_from_last_iter;
750 	__le32 reserved;
751 } __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
752 
753 #define SCAN_OFFLOAD_MATCHING_CHANNELS_LEN 5
754 /**
755  * struct iwl_scan_offload_profile_match - match information
756  * @bssid: matched bssid
757  * @reserved: reserved
758  * @channel: channel where the match occurred
759  * @energy: energy
760  * @matching_feature: feature matches
761  * @matching_channels: bitmap of channels that matched, referencing
762  *	the channels passed in tue scan offload request
763  */
764 struct iwl_scan_offload_profile_match {
765 	u8 bssid[ETH_ALEN];
766 	__le16 reserved;
767 	u8 channel;
768 	u8 energy;
769 	u8 matching_feature;
770 	u8 matching_channels[SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
771 } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
772 
773 /**
774  * struct iwl_scan_offload_profiles_query - match results query response
775  * @matched_profiles: bitmap of matched profiles, referencing the
776  *	matches passed in the scan offload request
777  * @last_scan_age: age of the last offloaded scan
778  * @n_scans_done: number of offloaded scans done
779  * @gp2_d0u: GP2 when D0U occurred
780  * @gp2_invoked: GP2 when scan offload was invoked
781  * @resume_while_scanning: not used
782  * @self_recovery: obsolete
783  * @reserved: reserved
784  * @matches: array of match information, one for each match
785  */
786 struct iwl_scan_offload_profiles_query {
787 	__le32 matched_profiles;
788 	__le32 last_scan_age;
789 	__le32 n_scans_done;
790 	__le32 gp2_d0u;
791 	__le32 gp2_invoked;
792 	u8 resume_while_scanning;
793 	u8 self_recovery;
794 	__le16 reserved;
795 	struct iwl_scan_offload_profile_match matches[IWL_SCAN_MAX_PROFILES];
796 } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
797 
798 /**
799  * struct iwl_umac_scan_iter_complete_notif - notifies end of scanning iteration
800  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
801  * @scanned_channels: number of channels scanned and number of valid elements in
802  *	results array
803  * @status: one of SCAN_COMP_STATUS_*
804  * @bt_status: BT on/off status
805  * @last_channel: last channel that was scanned
806  * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
807  *	in &struct iwl_scan_req_umac.
808  * @results: array of scan results, length in @scanned_channels
809  */
810 struct iwl_umac_scan_iter_complete_notif {
811 	__le32 uid;
812 	u8 scanned_channels;
813 	u8 status;
814 	u8 bt_status;
815 	u8 last_channel;
816 	__le64 start_tsf;
817 	struct iwl_scan_results_notif results[];
818 } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
819 
820 #endif /* __iwl_fw_api_scan_h__ */
821