xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_public_structs.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * DOC: contains scan structure definations
21  */
22 
23 #ifndef _WLAN_SCAN_STRUCTS_H_
24 #define _WLAN_SCAN_STRUCTS_H_
25 #include <wlan_cmn.h>
26 #include <qdf_time.h>
27 #include <qdf_list.h>
28 #include <qdf_atomic.h>
29 #include <wlan_cmn_ieee80211.h>
30 #include <wlan_mgmt_txrx_utils_api.h>
31 #include <reg_services_public_struct.h>
32 
33 typedef uint16_t wlan_scan_requester;
34 typedef uint32_t wlan_scan_id;
35 
36 #define WLAN_SCAN_MAX_HINT_S_SSID        10
37 #define WLAN_SCAN_MAX_HINT_BSSID         10
38 #define MAX_RNR_BSS                      5
39 #define WLAN_SCAN_MAX_NUM_SSID          16
40 #define WLAN_SCAN_MAX_NUM_BSSID         4
41 
42 #define SCM_CANCEL_SCAN_WAIT_TIME 50
43 #define SCM_CANCEL_SCAN_WAIT_ITERATION 600
44 
45 #define INVAL_SCAN_ID        0xFFFFFFFF
46 #define CANCEL_HOST_SCAN_ID  0xFFFFFFFE
47 #define INVAL_VDEV_ID        0xFFFFFFFF
48 #define INVAL_PDEV_ID        0xFFFFFFFF
49 
50 #define USER_SCAN_REQUESTOR_ID  0xA0000
51 #define PREAUTH_REQUESTOR_ID    0xC0000
52 
53 #define BURST_SCAN_MAX_NUM_OFFCHANNELS 3
54 #define P2P_SCAN_MAX_BURST_DURATION 180
55 /* Increase dwell time for P2P search in ms */
56 #define P2P_SEARCH_DWELL_TIME_INC 20
57 
58 #define PROBE_REQ_BITMAP_LEN 8
59 #define MAX_PROBE_REQ_OUIS 16
60 
61 /* forward declaration */
62 struct wlan_objmgr_vdev;
63 struct wlan_objmgr_pdev;
64 struct wlan_objmgr_psoc;
65 
66 /**
67  * struct channel_info - BSS channel information
68  * @chan_freq: channel frequency
69  * @cfreq0: channel frequency index0
70  * @cfreq1: channel frequency index1
71  * @priv: channel private information
72  */
73 struct channel_info {
74 	uint32_t chan_freq;
75 	uint32_t cfreq0;
76 	uint32_t cfreq1;
77 	void *priv;
78 };
79 
80 /**
81  * struct ie_list - pointers to various IEs
82  * @tim:        pointer to tim ie
83  * @country:    pointer to country ie
84  * @ssid:       pointer to ssid ie
85  * @rates:      pointer to supported rates ie
86  * @xrates:     pointer to extended supported rate ie
87  * @ds_param:   pointer to ds params
88  * @csa:        pointer to csa ie
89  * @xcsa:       pointer to extended csa ie
90  * @mcst:       pointer to maximum channel switch time ie
91  * @wpa:        pointer to wpa ie
92  * @wcn:        pointer to wcn ie
93  * @rsn:        pointer to rsn ie
94  * @wps:        pointer to wps ie
95  * @wmeinfo:    pointer to wmeinfo ie
96  * @wmeparam:   pointer to wmeparam ie
97  * @quiet:      pointer to quiet ie
98  * @htcap:      pointer to htcap ie
99  * @htinfo:     pointer to htinfo ie
100  * @athcaps:    pointer to athcaps ie
101  * @athextcaps: pointer to extended athcaps ie
102  * @sfa:        pointer to sfa ie
103  * @vendor:     pointer to vendor ie
104  * @qbssload:   pointer to qbssload ie
105  * @wapi:       pointer to wapi ie
106  * @p2p:        pointer to p2p ie
107  * @alt_wcn:    pointer to alternate wcn ie
108  * @extcaps:    pointer to extended caps ie
109  * @ibssdfs:    pointer to ibssdfs ie
110  * @sonadv:     pointer to wifi son ie
111  * @vhtcap:     pointer to vhtcap ie
112  * @vhtop:      pointer to vhtop ie
113  * @opmode:     pointer to opmode ie
114  * @tpe:        array of pointers to transmit power envelope ie
115  * @cswrp:      pointer to channel switch announcement wrapper ie
116  * @widebw:     pointer to wide band channel switch sub ie
117  * @txpwrenvlp: pointer to tx power envelop sub ie
118  * @hecap:      pointer to hecap ie
119  * @hecap_6g:   pointer to he 6ghz cap ie
120  * @srp: pointer to spatial reuse parameter sub extended ie
121  * @fils_indication: pointer to FILS indication ie
122  * @esp: pointer to ESP indication ie
123  * @mbo_oce: pointer to mbo/oce indication ie
124  * @rnrie: reduced neighbor report IE
125  * @adaptive_11r: pointer to adaptive 11r IE
126  * @single_pmk: Pointer to sae single pmk IE
127  * @rsnxe: Pointer to rsnxe IE
128  */
129 struct ie_list {
130 	uint8_t *tim;
131 	uint8_t *country;
132 	uint8_t *ssid;
133 	uint8_t *rates;
134 	uint8_t *xrates;
135 	uint8_t *ds_param;
136 	uint8_t *csa;
137 	uint8_t *xcsa;
138 	uint8_t *mcst;
139 	uint8_t *wpa;
140 	uint8_t *wcn;
141 	uint8_t *rsn;
142 	uint8_t *wps;
143 	uint8_t *wmeinfo;
144 	uint8_t *wmeparam;
145 	uint8_t *quiet;
146 	uint8_t *htcap;
147 	uint8_t *htinfo;
148 	uint8_t *athcaps;
149 	uint8_t *athextcaps;
150 	uint8_t *sfa;
151 	uint8_t *vendor;
152 	uint8_t *qbssload;
153 	uint8_t *wapi;
154 	uint8_t *p2p;
155 	uint8_t *alt_wcn;
156 	uint8_t *extcaps;
157 	uint8_t *ibssdfs;
158 	uint8_t *sonadv;
159 	uint8_t *vhtcap;
160 	uint8_t *vhtop;
161 	uint8_t *opmode;
162 	uint8_t *tpe[WLAN_MAX_NUM_TPE_IE];
163 	uint8_t *cswrp;
164 	uint8_t *widebw;
165 	uint8_t *txpwrenvlp;
166 	uint8_t *bwnss_map;
167 	uint8_t *secchanoff;
168 	uint8_t *mdie;
169 	uint8_t *hecap;
170 	uint8_t *hecap_6g;
171 	uint8_t *heop;
172 	uint8_t *srp;
173 	uint8_t *fils_indication;
174 	uint8_t *esp;
175 	uint8_t *mbo_oce;
176 	uint8_t *muedca;
177 	uint8_t *rnrie;
178 	uint8_t *extender;
179 	uint8_t *adaptive_11r;
180 	uint8_t *single_pmk;
181 	uint8_t *rsnxe;
182 };
183 
184 enum scan_entry_connection_state {
185 	SCAN_ENTRY_CON_STATE_NONE,
186 	SCAN_ENTRY_CON_STATE_AUTH,
187 	SCAN_ENTRY_CON_STATE_ASSOC
188 };
189 
190 /**
191  * struct mlme_info - mlme specific info
192  * temporarily maintained in scan cache for backward compatibility.
193  * must be removed as part of umac convergence.
194  * @bad_ap_time: time when this ap was marked bad
195  * @status: status
196  * @rank: rank
197  * @utility: utility
198  * @assoc_state: association state
199  * @chanload: channel load
200  */
201 struct mlme_info {
202 	qdf_time_t bad_ap_time;
203 	uint32_t status;
204 	uint32_t rank;
205 	uint32_t utility;
206 	uint32_t assoc_state;
207 	uint32_t chanload;
208 };
209 
210 /**
211  * struct bss_info - information required to uniquely define a bss
212  * @freq: freq of operating primary channel
213  * @ssid: ssid of bss
214  * @bssid: bssid of bss
215  */
216 struct bss_info {
217 	uint32_t freq;
218 	struct wlan_ssid ssid;
219 	struct qdf_mac_addr bssid;
220 };
221 
222 #define SCAN_NODE_ACTIVE_COOKIE 0x1248F842
223 /**
224  * struct scan_cache_node - Scan cache entry node
225  * @node: node pointers
226  * @ref_cnt: ref count if in use
227  * @cookie: cookie to check if entry is logically active
228  * @entry: scan entry pointer
229  */
230 struct scan_cache_node {
231 	qdf_list_node_t node;
232 	qdf_atomic_t ref_cnt;
233 	uint32_t cookie;
234 	struct scan_cache_entry *entry;
235 };
236 
237 /**
238  * struct security_info - Scan cache security info
239  * @authmodeset: auth mode
240  * @key_mgmt: key management
241  * @ucastcipherset: unicast cipher set
242  * @mcastcipherset: multicast cipher set
243  * @mgmtcipherset: mgmt cipher set
244  * @rsn_caps: rsn caps of scan entry
245  */
246 struct security_info {
247 	uint32_t authmodeset;
248 	uint32_t key_mgmt;
249 	uint32_t ucastcipherset;
250 	uint32_t mcastcipherset;
251 	uint32_t mgmtcipherset;
252 	uint16_t rsn_caps;
253 };
254 
255 /**
256  * struct scan_mbssid_info - Scan mbssid information
257  * @profile_num: profile number
258  * @profile_count: total profile count
259  * @trans_bssid: TX BSSID address
260  */
261 struct scan_mbssid_info {
262 	uint8_t profile_num;
263 	uint8_t profile_count;
264 	uint8_t trans_bssid[QDF_MAC_ADDR_SIZE];
265 };
266 
267 /**
268  * struct rnr_bss_info - Reduced Neighbor Report BSS information
269  * @neighbor_ap_tbtt_offset: Neighbor AP TBTT offset
270  * @channel_number: channel number
271  * @operating_class: operting class
272  * @bssid: BSS MAC address
273  * @short_ssid: short ssid
274  * @bss_params: BSS parameters
275  * @psd_20mhz: 20MHz power spectral density
276  */
277 struct rnr_bss_info {
278 	uint8_t neighbor_ap_tbtt_offset;
279 	uint32_t channel_number;
280 	uint32_t operating_class;
281 	struct qdf_mac_addr bssid;
282 	uint32_t short_ssid;
283 	uint8_t bss_params;
284 	uint8_t psd_20mhz;
285 };
286 
287 /**
288  * struct tbtt_information_header - TBTT information header
289  * @tbbt_info_fieldtype: TBTT information field type
290  * @filter_neighbor_ap: filtered neighbor ap
291  * @tbbt_info_count: TBTT information count
292  * @tbtt_info_length: TBTT informaiton length
293  */
294 struct tbtt_information_header {
295 	uint16_t tbbt_info_fieldtype:2;
296 	uint16_t filtered_neighbor_ap:1;
297 	uint16_t reserved:1;
298 	uint16_t tbtt_info_count:4;
299 	uint16_t tbtt_info_length:8;
300 };
301 
302 /**
303  * struct neighbor_ap_info_field - Neighbor information field
304  * @tbtt_info_header: TBTT information header
305  * @operting_class: operating class
306  * @channel_number: channel number
307  */
308 struct neighbor_ap_info_field {
309 	struct tbtt_information_header tbtt_header;
310 	uint8_t operting_class;
311 	uint8_t channel_number;
312 };
313 
314 /**
315  * enum tbtt_information_field - TBTT information field
316  * @TBTT_NEIGHBOR_AP_OFFSET_ONLY: TBTT information field type
317  * @TBTT_NEIGHBOR_AP_BSS_PARAM: neighbor AP and bss param
318  * @TBTT_NEIGHBOR_AP_SHORTSSID: neighbor AP and Short ssid
319  * @TBTT_NEIGHBOR_AP_S_SSID_BSS_PARAM: neighbor AP, short ssid and bss param
320  * @TBTT_NEIGHBOR_AP_BSSID: neighbor AP and bssid
321  * @TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM: neighbor AP, bssid and bss param
322  * @TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM_20MHZ_PSD: neighbor AP, bssid and bss
323  * param and 20MHz PSD
324  * @TBTT_NEIGHBOR_AP_BSSSID_S_SSID: neighbor AP, bssid and short ssid
325  * @TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM: neighbor AP, bssid, short ssid
326  * and bss params
327  * @TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD: neighbor AP, bssid,
328  * short ssid, bss params and 20MHz PSD
329  */
330 enum tbtt_information_field {
331 	TBTT_NEIGHBOR_AP_OFFSET_ONLY = 1,
332 	TBTT_NEIGHBOR_AP_BSS_PARAM = 2,
333 	TBTT_NEIGHBOR_AP_SHORTSSID = 5,
334 	TBTT_NEIGHBOR_AP_S_SSID_BSS_PARAM = 6,
335 	TBTT_NEIGHBOR_AP_BSSID = 7,
336 	TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM = 8,
337 	TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM_20MHZ_PSD = 9,
338 	TBTT_NEIGHBOR_AP_BSSSID_S_SSID = 11,
339 	TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM = 12,
340 	TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD = 13
341 };
342 
343 /**
344  * struct reduced_neighbor_report - Reduced Neighbor Report
345  * @bss_info: RNR BSS Information
346  */
347 struct reduced_neighbor_report {
348 	struct rnr_bss_info bss_info[MAX_RNR_BSS];
349 };
350 
351 #define SCAN_SECURITY_TYPE_WEP 0x01
352 #define SCAN_SECURITY_TYPE_WPA 0x02
353 #define SCAN_SECURITY_TYPE_WAPI 0x04
354 #define SCAN_SECURITY_TYPE_RSN 0x08
355 
356 /**
357  * struct scan_cache_entry: structure containing scan entry
358  * @frm_subtype: updated from beacon/probe
359  * @bssid: bssid
360  * @mac_addr: mac address
361  * @ssid: ssid
362  * @is_hidden_ssid: is AP having hidden ssid.
363  * @security_type: security supported
364  * @seq_num: sequence number
365  * @phy_mode: Phy mode of the AP
366  * @avg_rssi: Average RSSI of the AP
367  * @rssi_raw: The rssi of the last beacon/probe received
368  * @snr: The snr of the last beacon/probe received
369  * @avg_snr: Average SNR of the AP
370  * @bcn_int: Beacon interval of the AP
371  * @cap_info: Capability of the AP
372  * @tsf_info: TSF info
373  * @erp: erp info
374  * @dtim_period: dtime period
375  * @air_time_fraction: Air time fraction from ESP param
376  * @qbss_chan_load: Qbss channel load
377  * @nss: supported NSS information
378  * @is_p2p_ssid: is P2P entry
379  * @adaptive_11r_ap: flag to check if AP supports adaptive 11r
380  * @scan_entry_time: boottime in microsec when last beacon/probe is received
381  * @rssi_timestamp: boottime in microsec when RSSI was updated
382  * @hidden_ssid_timestamp: boottime in microsec when hidden
383  *                         ssid was received
384  * @mbssid_info: Multi bssid information
385  * @rnr: Reduced neighbor report information
386  * @channel: channel info on which AP is present
387  * @channel_mismatch: if channel received in metadata
388  *                    doesnot match the one in beacon
389  * @tsf_delta: TSF delta
390  * @bss_score: bss score calculated on basis of RSSI/caps etc.
391  * @neg_sec_info: negotiated security info
392  * @per_chain_rssi: per chain RSSI value received.
393  * boottime_ns: boottime in ns.
394  * @rrm_parent_tsf: RRM parent tsf
395  * @mlme_info: Mlme info, this will be updated by MLME for the scan entry
396  * @alt_wcn_ie: alternate WCN IE
397  * @ie_list: IE list pointers
398  * @raw_frame: contain raw frame and the length of the raw frame
399  * @pdev_id: pdev id
400  */
401 struct scan_cache_entry {
402 	uint8_t frm_subtype;
403 	struct qdf_mac_addr bssid;
404 	struct qdf_mac_addr mac_addr;
405 	struct wlan_ssid ssid;
406 	bool is_hidden_ssid;
407 	uint8_t security_type;
408 	uint16_t seq_num;
409 	enum wlan_phymode phy_mode;
410 	int32_t avg_rssi;
411 	int8_t rssi_raw;
412 	uint8_t snr;
413 	uint32_t avg_snr;
414 	uint16_t bcn_int;
415 	union wlan_capability cap_info;
416 	union {
417 		uint8_t data[8];
418 		uint64_t tsf;
419 	} tsf_info;
420 	uint8_t erp;
421 	uint8_t dtim_period;
422 	uint8_t air_time_fraction;
423 	uint8_t qbss_chan_load;
424 	uint8_t nss;
425 	bool is_p2p;
426 	bool adaptive_11r_ap;
427 	qdf_time_t scan_entry_time;
428 	qdf_time_t rssi_timestamp;
429 	qdf_time_t hidden_ssid_timestamp;
430 	struct scan_mbssid_info mbssid_info;
431 	struct reduced_neighbor_report rnr;
432 	struct channel_info channel;
433 	bool channel_mismatch;
434 	struct mlme_info mlme_info;
435 	uint32_t tsf_delta;
436 	uint32_t bss_score;
437 	struct security_info neg_sec_info;
438 	uint8_t per_chain_rssi[WLAN_MGMT_TXRX_HOST_MAX_ANTENNA];
439 	uint64_t boottime_ns;
440 	uint32_t rrm_parent_tsf;
441 	struct element_info alt_wcn_ie;
442 	struct ie_list ie_list;
443 	struct element_info raw_frame;
444 	/*
445 	 * This is added temporarily for 6GHz channel to freq conversion
446 	 * to get pdev wherever it requores to convert frequency to
447 	 * channel as regulatory apis requires pdev as argument
448 	 */
449 	uint8_t pdev_id;
450 };
451 
452 #define MAX_FAVORED_BSSID 16
453 #define MAX_ALLOWED_SSID_LIST 4
454 
455 #define WLAN_SCAN_FILTER_NUM_SSID 5
456 #define WLAN_SCAN_FILTER_NUM_BSSID 5
457 
458 #define REALM_HASH_LEN 2
459 #define CACHE_IDENTIFIER_LEN 2
460 #define HESSID_LEN 6
461 
462 #ifdef WLAN_FEATURE_FILS_SK
463 /**
464  * struct fils_filter_info: FILS info present in scan filter
465  * @realm_check: whether realm check is required
466  * @fils_realm: realm hash value
467  * @security_type: type of security supported
468  */
469 struct fils_filter_info {
470 	bool realm_check;
471 	uint8_t fils_realm[REALM_HASH_LEN];
472 	uint8_t security_type;
473 };
474 #endif
475 
476 /*
477  * struct filter_arg: Opaque pointer for the filter arguments
478  */
479 struct filter_arg;
480 typedef struct filter_arg *bss_filter_arg_t;
481 
482 /**
483  * enum dot11_mode_filter - Filter APs according to dot11mode
484  * @ALLOW_ALL: ignore check
485  * @ALLOW_11N_ONLY: allow only 11n AP
486  * @ALLOW_11AC_ONLY: allow only 11ac AP
487  * @ALLOW_11AX_ONLY: allow only 11ax AP
488  */
489 enum dot11_mode_filter {
490 	ALLOW_ALL,
491 	ALLOW_11N_ONLY,
492 	ALLOW_11AC_ONLY,
493 	ALLOW_11AX_ONLY,
494 };
495 
496 /**
497  * struct scan_filter: scan filter
498  * @enable_adaptive_11r:    flag to check if adaptive 11r ini is enabled
499  * @rrm_measurement_filter: For measurement reports.if set, only SSID, BSSID
500  *                          and channel is considered for filtering.
501  * @ignore_pmf_cap: Ignore pmf capability match
502  * @ignore_auth_enc_type: Ignore enc type if
503  *                        this is set (For WPS/OSEN connection)
504  * @ignore_nol_chan: Ignore entry with channel in the NOL list
505  * @ignore_6ghz_channel: ignore 6Ghz channels
506  * @age_threshold: If set return entry which are newer than the age_threshold
507  * @num_of_bssid: number of bssid passed
508  * @num_of_ssid: number of ssid
509  * @num_of_channels: number of  channels
510  * @pmf_cap: Pmf capability
511  * @dot11mode: Filter APs based upon dot11mode
512  * @band: to get specific band 2.4G, 5G or 4.9 G
513  * @rssi_threshold: AP having RSSI greater than
514  *                  rssi threasholed (ignored if set 0)
515  * @mobility_domain: Mobility domain for 11r
516  * @authmodeset: auth mode
517  * @key_mgmt: key management
518  * @ucastcipherset: unicast cipher set
519  * @mcastcipherset: multicast cipher set
520  * @mgmtcipherset: mgmt cipher set
521  * @fils_scan_filter: FILS info
522  * @bssid_hint: Mac address of bssid_hint
523  * @bssid_list: bssid list
524  * @ssid_list: ssid list
525  * @chan_freq_list: channel frequency list, frequency unit: MHz
526  * @match_security_func: Function pointer to custom security filter
527  * @match_security_func_arg: Function argument to custom security filter
528  * @ccx_validate_bss: Function pointer to custom bssid filter
529  * @ccx_validate_bss_arg: Function argument to custom bssid filter
530  */
531 struct scan_filter {
532 	uint8_t enable_adaptive_11r:1,
533 		rrm_measurement_filter:1,
534 		ignore_pmf_cap:1,
535 		ignore_auth_enc_type:1,
536 		ignore_nol_chan:1,
537 		ignore_6ghz_channel:1;
538 	qdf_time_t age_threshold;
539 	uint8_t num_of_bssid;
540 	uint8_t num_of_ssid;
541 	uint16_t num_of_channels;
542 	enum wlan_pmf_cap pmf_cap;
543 	enum dot11_mode_filter dot11mode;
544 	enum wlan_band band;
545 	uint8_t rssi_threshold;
546 	uint32_t mobility_domain;
547 	uint32_t authmodeset;
548 	uint32_t key_mgmt;
549 	uint32_t ucastcipherset;
550 	uint32_t mcastcipherset;
551 	uint32_t mgmtcipherset;
552 #ifdef WLAN_FEATURE_FILS_SK
553 	struct fils_filter_info fils_scan_filter;
554 #endif
555 	struct qdf_mac_addr bssid_hint;
556 	/* Variable params list */
557 	struct qdf_mac_addr bssid_list[WLAN_SCAN_FILTER_NUM_BSSID];
558 	struct wlan_ssid ssid_list[WLAN_SCAN_FILTER_NUM_SSID];
559 	qdf_freq_t chan_freq_list[NUM_CHANNELS];
560 	bool (*match_security_func)(void *, struct scan_cache_entry *);
561 	bss_filter_arg_t match_security_func_arg;
562 	bool (*ccx_validate_bss)(void *, struct scan_cache_entry *, int);
563 	bss_filter_arg_t ccx_validate_bss_arg;
564 };
565 
566 /**
567  * enum scan_disable_reason - scan enable/disable reason
568  * @REASON_SUSPEND: reason is suspend
569  * @REASON_SYSTEM_DOWN: reason is system going down
570  * @REASON_USER_SPACE: reason is user space initiated
571  * @REASON_VDEV_DOWN: reason is vdev going down
572  */
573 enum scan_disable_reason {
574 	REASON_SUSPEND  = 0x1,
575 	REASON_SYSTEM_DOWN = 0x2,
576 	REASON_USER_SPACE = 0x4,
577 	REASON_VDEV_DOWN = 0x8,
578 };
579 
580 /**
581  * enum scan_priority - scan priority definitions
582  * @SCAN_PRIORITY_VERY_LOW: very low priority
583  * @SCAN_PRIORITY_LOW: low scan priority
584  * @SCAN_PRIORITY_MEDIUM: medium priority
585  * @SCAN_PRIORITY_HIGH: high priority
586  * @SCAN_PRIORITY_VERY_HIGH: very high priority
587  * @SCAN_PRIORITY_COUNT: number of priorities supported
588  */
589 enum scan_priority {
590 	SCAN_PRIORITY_VERY_LOW,
591 	SCAN_PRIORITY_LOW,
592 	SCAN_PRIORITY_MEDIUM,
593 	SCAN_PRIORITY_HIGH,
594 	SCAN_PRIORITY_VERY_HIGH,
595 	SCAN_PRIORITY_COUNT,
596 };
597 
598 /**
599  * enum scan_phy_mode - phymode used for scan
600  * @SCAN_PHY_MODE_11A: 11a mode
601  * @SCAN_PHY_MODE_11G: 11g mode
602  * @SCAN_PHY_MODE_11B: 11b mode
603  * @SCAN_PHY_MODE_11GONLY: 11g only mode
604  * @SCAN_PHY_MODE_11NA_HT20: 11na ht20 mode
605  * @SCAN_PHY_MODE_11NG_HT20: 11ng ht20 mode
606  * @SCAN_PHY_MODE_11NA_HT40: 11na ht40 mode
607  * @SCAN_PHY_MODE_11NG_HT40: 11ng ht40 mode
608  * @SCAN_PHY_MODE_11AC_VHT20: 11ac vht20 mode
609  * @SCAN_PHY_MODE_11AC_VHT40: 11ac vht40 mode
610  * @SCAN_PHY_MODE_11AC_VHT80: 11ac vht80 mode
611  * @SCAN_PHY_MODE_11AC_VHT20_2G: 2GHz 11ac vht20 mode
612  * @SCAN_PHY_MODE_11AC_VHT40_2G: 2GHz 11ac vht40 mode
613  * @SCAN_PHY_MODE_11AC_VHT80_2G: 2GHz 11ac vht80 mode
614  * @SCAN_PHY_MODE_11AC_VHT80_80: 11ac vht 80+80 mode
615  * @SCAN_PHY_MODE_11AC_VHT160: 11ac vht160 mode
616  * @SCAN_PHY_MODE_11AX_HE20: 11ax he20 mode
617  * @SCAN_PHY_MODE_11AX_HE40: 11ax he40 mode
618  * @SCAN_PHY_MODE_11AX_HE80: 11ax he80 mode
619  * @SCAN_PHY_MODE_11AX_HE80_80: 11ax he80+80 mode
620  * @SCAN_PHY_MODE_11AX_HE160: 11ax he160 mode
621  * @SCAN_PHY_MODE_11AX_HE20_2G: 2GHz 11ax he20 mode
622  * @SCAN_PHY_MODE_11AX_HE40_2G: 2GHz 11ax he40 mode
623  * @SCAN_PHY_MODE_11AX_HE80_2G: 2GHz 11ax he80 mode
624  * @SCAN_PHY_MODE_UNKNOWN: unknown phy mode
625  * @SCAN_PHY_MODE_MAX: max valid phymode
626  */
627 enum scan_phy_mode {
628 	SCAN_PHY_MODE_11A = 0,
629 	SCAN_PHY_MODE_11G = 1,
630 	SCAN_PHY_MODE_11B = 2,
631 	SCAN_PHY_MODE_11GONLY = 3,
632 	SCAN_PHY_MODE_11NA_HT20 = 4,
633 	SCAN_PHY_MODE_11NG_HT20 = 5,
634 	SCAN_PHY_MODE_11NA_HT40 = 6,
635 	SCAN_PHY_MODE_11NG_HT40 = 7,
636 	SCAN_PHY_MODE_11AC_VHT20 = 8,
637 	SCAN_PHY_MODE_11AC_VHT40 = 9,
638 	SCAN_PHY_MODE_11AC_VHT80 = 10,
639 	SCAN_PHY_MODE_11AC_VHT20_2G = 11,
640 	SCAN_PHY_MODE_11AC_VHT40_2G = 12,
641 	SCAN_PHY_MODE_11AC_VHT80_2G = 13,
642 	SCAN_PHY_MODE_11AC_VHT80_80 = 14,
643 	SCAN_PHY_MODE_11AC_VHT160 = 15,
644 	SCAN_PHY_MODE_11AX_HE20 = 16,
645 	SCAN_PHY_MODE_11AX_HE40 = 17,
646 	SCAN_PHY_MODE_11AX_HE80 = 18,
647 	SCAN_PHY_MODE_11AX_HE80_80 = 19,
648 	SCAN_PHY_MODE_11AX_HE160 = 20,
649 	SCAN_PHY_MODE_11AX_HE20_2G = 21,
650 	SCAN_PHY_MODE_11AX_HE40_2G = 22,
651 	SCAN_PHY_MODE_11AX_HE80_2G = 23,
652 	SCAN_PHY_MODE_UNKNOWN = 24,
653 	SCAN_PHY_MODE_MAX = 24
654 };
655 
656 /**
657  * enum scan_dwelltime_adaptive_mode: dwelltime_mode
658  * @SCAN_DWELL_MODE_DEFAULT: Use firmware default mode
659  * @SCAN_DWELL_MODE_CONSERVATIVE: Conservative adaptive mode
660  * @SCAN_DWELL_MODE_MODERATE: Moderate adaptive mode
661  * @SCAN_DWELL_MODE_AGGRESSIVE: Aggressive adaptive mode
662  * @SCAN_DWELL_MODE_STATIC: static adaptive mode
663  */
664 enum scan_dwelltime_adaptive_mode {
665 	SCAN_DWELL_MODE_DEFAULT = 0,
666 	SCAN_DWELL_MODE_CONSERVATIVE = 1,
667 	SCAN_DWELL_MODE_MODERATE = 2,
668 	SCAN_DWELL_MODE_AGGRESSIVE = 3,
669 	SCAN_DWELL_MODE_STATIC = 4
670 };
671 
672 /**
673  * struct scan_random_attr - holds scan randomization attrs
674  * @randomize: set to true for scan randomization
675  * @mac_addr: mac addr to be randomized
676  * @mac_mask: used to represent bits in mac_addr for randomization
677  */
678 struct scan_random_attr {
679 	bool randomize;
680 	uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
681 	uint8_t mac_mask[QDF_MAC_ADDR_SIZE];
682 };
683 
684 /**
685  * struct probe_req_whitelist_attr - holds probe req ie whitelist attrs
686  * @white_list: enable/disable whitelist
687  * @ie_bitmap: bitmap of IEs to be enabled
688  * @num_vendor_oui: number of vendor OUIs
689  * @voui: vendor oui buffer
690  */
691 struct probe_req_whitelist_attr {
692 	bool white_list;
693 	uint32_t ie_bitmap[PROBE_REQ_BITMAP_LEN];
694 	uint32_t num_vendor_oui;
695 	uint32_t voui[MAX_PROBE_REQ_OUIS];
696 };
697 
698 /**
699  * Set this flag for a 6g channel to scan it only if an RNR IE is found
700  * with that channel while scanning 2g/5g bands
701  */
702 #define FLAG_SCAN_ONLY_IF_RNR_FOUND 0x1
703 
704 /**
705  * struct chan_info - channel information
706  * @freq: frequency to scan
707  * @phymode: phymode in which @frequency should be scanned
708  * @flags: Flags to define channel property. Firmware can use this info for
709  *  different operations, e.g.: scan
710  */
711 struct chan_info {
712 	qdf_freq_t freq;
713 	uint32_t phymode;
714 	uint8_t flags;
715 };
716 
717 /**
718  * struct chan_list - list of frequencies to be scanned
719  *  and their phymode
720  * @num_chan: number of channels to scan
721  * @chan: channel parameters used for this scan
722  */
723 struct chan_list {
724 	uint8_t num_chan;
725 	struct chan_info chan[NUM_CHANNELS];
726 };
727 
728 /**
729  * struct hint_short_ssid - short SSID hint
730  *  and their phymode
731  * @freq_flags: freq unit: MHz (upper 16bits)
732  *              flags (lower 16bits)
733  * @short_ssid: short SSID
734  */
735 struct hint_short_ssid {
736 	uint32_t freq_flags;
737 	uint32_t short_ssid;
738 };
739 
740 /**
741  * struct hint_bssid - BSSID hint
742  *  and their phymode
743  * @freq_flags: freq unit: MHz (upper 16bits)
744  *              flags (lower 16bits)
745  * @bssid: BSSID
746  */
747 struct hint_bssid {
748 	uint32_t freq_flags;
749 	struct qdf_mac_addr bssid;
750 };
751 
752 /**
753  * enum scan_request_type: scan type
754  * @SCAN_TYPE_DEFAULT: Def scan
755  * @SCAN_TYPE_P2P_SEARCH: P2P Search
756  * @SCAN_TYPE_P2P_LISTEN: P2P listed
757  * @SCAN_TYPE_RRM: RRM scan request
758  * @SCAN_TYPE_SCAN_FOR_CONNECT : Scan for connect
759  */
760 enum scan_request_type {
761 	SCAN_TYPE_DEFAULT = 0,
762 	SCAN_TYPE_P2P_SEARCH = 1,
763 	SCAN_TYPE_P2P_LISTEN = 2,
764 	SCAN_TYPE_RRM = 3,
765 	SCAN_TYPE_SCAN_FOR_CONNECT = 4
766 };
767 
768 /**
769  * struct scan_req_params - start scan request parameter
770  * @scan_id: scan id
771  * @scan_req_id: scan requester id
772  * @vdev_id: vdev id where scan was originated
773  * @pdev_id: pdev id of parent pdev
774  * @scan_priority: scan priority
775  * @scan_ev_started: notify scan started event
776  * @scan_ev_completed: notify scan completed event
777  * @scan_ev_bss_chan: notify bss chan event
778  * @scan_ev_foreign_chan: notify foreign chan event
779  * @scan_ev_dequeued: notify scan request dequed event
780  * @scan_ev_preempted: notify scan preempted event
781  * @scan_ev_start_failed: notify scan start failed event
782  * @scan_ev_restarted: notify scan restarted event
783  * @scan_ev_foreign_chn_exit: notify foreign chan exit event
784  * @scan_ev_invalid: notify invalid scan request event
785  * @scan_ev_gpio_timeout: notify gpio timeout event
786  * @scan_ev_suspended: notify scan suspend event
787  * @scan_ev_resumed: notify scan resumed event
788  * @scan_events: variable to read and set scan_ev_* flags in one shot
789  *               can be used to dump all scan_ev_* flags for debug
790  * @dwell_time_active: active dwell time
791  * @dwell_time_active_2g: active dwell time for 2G channels, if it's not zero
792  * @dwell_time_passive: passive dwell time
793  * @dwell_time_active_6g: 6Ghz active dwell time
794  * @dwell_time_passive_6g: 6Ghz passive dwell time
795  * @min_rest_time: min rest time
796  * @max_rest_time: max rest time
797  * @repeat_probe_time: repeat probe time
798  * @probe_spacing_time: probe spacing time
799  * @idle_time: idle time
800  * @max_scan_time: max scan time
801  * @probe_delay: probe delay
802  * @scan_offset_time: Support split scanning on the
803  *                    same channel for CBS feature.
804  * @scan_f_passive: passively scan all channels including active channels
805  * @scan_f_bcast_probe: add wild card ssid prbreq even if ssid_list is specified
806  * @scan_f_cck_rates: add cck rates to rates/xrates ie in prb req
807  * @scan_f_ofdm_rates: add ofdm rates to rates/xrates ie in prb req
808  * @scan_f_chan_stat_evnt: enable indication of chan load and noise floor
809  * @scan_f_filter_prb_req: filter Probe request frames
810  * @scan_f_bypass_dfs_chn: when set, do not scan DFS channels
811  * @scan_f_continue_on_err:continue scan even if few certain erros have occurred
812  * @scan_f_offchan_mgmt_tx: allow mgmt transmission during off channel scan
813  * @scan_f_offchan_data_tx: allow data transmission during off channel scan
814  * @scan_f_promisc_mode: scan with promiscuous mode
815  * @scan_f_capture_phy_err: enable capture ppdu with phy errrors
816  * @scan_f_strict_passive_pch: do passive scan on passive channels
817  * @scan_f_half_rate: enable HALF (10MHz) rate support
818  * @scan_f_quarter_rate: set Quarter (5MHz) rate support
819  * @scan_f_force_active_dfs_chn: allow to send probe req on DFS channel
820  * @scan_f_add_tpc_ie_in_probe: add TPC ie in probe req frame
821  * @scan_f_add_ds_ie_in_probe: add DS ie in probe req frame
822  * @scan_f_add_spoofed_mac_in_probe: use random mac address for TA in probe
823  * @scan_f_add_rand_seq_in_probe: use random sequence number in probe
824  * @scan_f_en_ie_whitelist_in_probe: enable ie whitelist in probe
825  * @scan_f_forced: force scan even in presence of data traffic
826  * @scan_f_2ghz: scan 2.4 GHz channels
827  * @scan_f_5ghz: scan 5 GHz channels
828  * @scan_f_wide_band: scan in 40 MHz or higher bandwidth
829  * @scan_flags: variable to read and set scan_f_* flags in one shot
830  *              can be used to dump all scan_f_* flags for debug
831  * @burst_duration: burst duration
832  * @num_bssid: no of bssid
833  * @num_ssids: no of ssid
834  * @n_probes: no of probe
835  * @chan_list: channel list
836  * @ssid: ssid list
837  * @bssid_list: Lisst of bssid to scan
838  * @scan_random: scan randomization params
839  * @ie_whitelist: probe req IE whitelist attrs
840  * @extraie: list of optional/vendor specific ie's to be added in probe requests
841  * @htcap: htcap ie
842  * @vhtcap: vhtcap ie
843  * @scan_ctrl_flags_ext: scan control flag extended
844  * @num_hint_s_ssid: number of short SSID hints
845  * @num_hint_bssid: number of BSSID hints
846  * @hint_s_ssid: short SSID hints
847  * @hint_bssid: BSSID hints
848  */
849 
850 struct scan_req_params {
851 	uint32_t scan_id;
852 	uint32_t scan_req_id;
853 	uint32_t vdev_id;
854 	uint32_t pdev_id;
855 	enum scan_priority scan_priority;
856 	enum scan_request_type scan_type;
857 	union {
858 		struct {
859 			uint32_t scan_ev_started:1,
860 				 scan_ev_completed:1,
861 				 scan_ev_bss_chan:1,
862 				 scan_ev_foreign_chan:1,
863 				 scan_ev_dequeued:1,
864 				 scan_ev_preempted:1,
865 				 scan_ev_start_failed:1,
866 				 scan_ev_restarted:1,
867 				 scan_ev_foreign_chn_exit:1,
868 				 scan_ev_invalid:1,
869 				 scan_ev_gpio_timeout:1,
870 				 scan_ev_suspended:1,
871 				 scan_ev_resumed:1;
872 		};
873 		uint32_t scan_events;
874 	};
875 	uint32_t dwell_time_active;
876 	uint32_t dwell_time_active_2g;
877 	uint32_t dwell_time_passive;
878 	uint32_t dwell_time_active_6g;
879 	uint32_t dwell_time_passive_6g;
880 	uint32_t min_rest_time;
881 	uint32_t max_rest_time;
882 	uint32_t repeat_probe_time;
883 	uint32_t probe_spacing_time;
884 	uint32_t idle_time;
885 	uint32_t max_scan_time;
886 	uint32_t probe_delay;
887 	uint32_t scan_offset_time;
888 	union {
889 		struct {
890 			uint32_t scan_f_passive:1,
891 				 scan_f_bcast_probe:1,
892 				 scan_f_cck_rates:1,
893 				 scan_f_ofdm_rates:1,
894 				 scan_f_chan_stat_evnt:1,
895 				 scan_f_filter_prb_req:1,
896 				 scan_f_bypass_dfs_chn:1,
897 				 scan_f_continue_on_err:1,
898 				 scan_f_offchan_mgmt_tx:1,
899 				 scan_f_offchan_data_tx:1,
900 				 scan_f_promisc_mode:1,
901 				 scan_f_capture_phy_err:1,
902 				 scan_f_strict_passive_pch:1,
903 				 scan_f_half_rate:1,
904 				 scan_f_quarter_rate:1,
905 				 scan_f_force_active_dfs_chn:1,
906 				 scan_f_add_tpc_ie_in_probe:1,
907 				 scan_f_add_ds_ie_in_probe:1,
908 				 scan_f_add_spoofed_mac_in_probe:1,
909 				 scan_f_add_rand_seq_in_probe:1,
910 				 scan_f_en_ie_whitelist_in_probe:1,
911 				 scan_f_forced:1,
912 				 scan_f_2ghz:1,
913 				 scan_f_5ghz:1,
914 				 scan_f_wide_band:1;
915 		};
916 		uint32_t scan_flags;
917 	};
918 	union {
919 		struct {
920 			uint32_t scan_policy_high_accuracy:1,
921 				 scan_policy_low_span:1,
922 				 scan_policy_low_power:1;
923 		};
924 		uint32_t scan_policy_type;
925 	};
926 
927 	enum scan_dwelltime_adaptive_mode adaptive_dwell_time_mode;
928 	uint32_t burst_duration;
929 	uint32_t num_bssid;
930 	uint32_t num_ssids;
931 	uint32_t n_probes;
932 	struct chan_list chan_list;
933 	struct wlan_ssid ssid[WLAN_SCAN_MAX_NUM_SSID];
934 	struct qdf_mac_addr bssid_list[WLAN_SCAN_MAX_NUM_BSSID];
935 	struct scan_random_attr scan_random;
936 	struct probe_req_whitelist_attr ie_whitelist;
937 	struct element_info extraie;
938 	struct element_info htcap;
939 	struct element_info vhtcap;
940 	uint32_t scan_ctrl_flags_ext;
941 	uint32_t num_hint_s_ssid;
942 	uint32_t num_hint_bssid;
943 	struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
944 	struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID];
945 };
946 
947 /**
948  * struct scan_start_request - scan request config
949  * @vdev: vdev
950  * @scan_req: common scan start request parameters
951  */
952 struct scan_start_request {
953 	struct wlan_objmgr_vdev *vdev;
954 	struct scan_req_params scan_req;
955 };
956 
957 /**
958  * enum scan_cancel_type - type specifiers for cancel scan request
959  * @WLAN_SCAN_CANCEL_SINGLE: cancel particular scan specified by scan_id
960  * @WLAN_SCAN_CANCEL_VAP_ALL: cancel all scans running on a particular vdevid
961  * @WLAN_SCAN_CANCEL_PDEV_ALL: cancel all scans running on parent pdev of vdevid
962  * @WLAN_SCAN_CANCEL_HOST_VDEV_ALL: Cancel all host triggered scans alone on
963  * vdev
964  */
965 enum scan_cancel_req_type {
966 	WLAN_SCAN_CANCEL_SINGLE = 1,
967 	WLAN_SCAN_CANCEL_VDEV_ALL,
968 	WLAN_SCAN_CANCEL_PDEV_ALL,
969 	WLAN_SCAN_CANCEL_HOST_VDEV_ALL,
970 };
971 
972 /**
973  * struct scan_cancel_param - stop scan cmd parameter
974  * @requester: scan requester
975  * @scan_id: scan id
976  * @req_type: scan request type
977  * @vdev_id: vdev id
978  * @pdev_id: pdev id of parent pdev
979  */
980 struct scan_cancel_param {
981 	uint32_t requester;
982 	uint32_t scan_id;
983 	enum scan_cancel_req_type req_type;
984 	uint32_t vdev_id;
985 	uint32_t pdev_id;
986 };
987 
988 /**
989  * struct scan_cancel_request - stop scan cmd
990  * @vdev: vdev object
991  * @wait_tgt_cancel: wait for target to cancel scan
992  * @cancel_req: stop scan cmd parameter
993  */
994 struct scan_cancel_request {
995 	/* Extra parameters consumed by scan module or serialization */
996 	struct wlan_objmgr_vdev *vdev;
997 	bool wait_tgt_cancel;
998 	/* Actual scan cancel request parameters */
999 	struct scan_cancel_param cancel_req;
1000 };
1001 
1002 /**
1003  * enum scan_event_type - scan event types
1004  * @SCAN_EVENT_TYPE_STARTED: scan started
1005  * @SCAN_EVENT_TYPE_COMPLETED: scan completed
1006  * @SCAN_EVENT_TYPE_BSS_CHANNEL: HW came back to home channel
1007  * @SCAN_EVENT_TYPE_FOREIGN_CHANNEL: HW moved to foreign channel
1008  * @SCAN_EVENT_TYPE_DEQUEUED: scan request dequeued
1009  * @SCAN_EVENT_TYPE_PREEMPTED: scan got preempted
1010  * @SCAN_EVENT_TYPE_START_FAILED: couldn't start scan
1011  * @SCAN_EVENT_TYPE_RESTARTED: scan restarted
1012  * @SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT: HW exited foreign channel
1013  * @SCAN_EVENT_TYPE_SUSPENDED: scan got suspended
1014  * @SCAN_EVENT_TYPE_RESUMED: scan resumed
1015  * @SCAN_EVENT_TYPE_NLO_COMPLETE: NLO completed
1016  * @SCAN_EVENT_TYPE_NLO_MATCH: NLO match event
1017  * @SCAN_EVENT_TYPE_INVALID: invalid request
1018  * @SCAN_EVENT_TYPE_GPIO_TIMEOUT: gpio timeout
1019  * @SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START: radio measurement start
1020  * @SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END: radio measurement end
1021  * @SCAN_EVENT_TYPE_BSSID_MATCH: bssid match found
1022  * @SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF: foreign channel noise floor
1023  * @SCAN_EVENT_TYPE_MAX: marker for invalid event
1024  */
1025 enum scan_event_type {
1026 	SCAN_EVENT_TYPE_STARTED,
1027 	SCAN_EVENT_TYPE_COMPLETED,
1028 	SCAN_EVENT_TYPE_BSS_CHANNEL,
1029 	SCAN_EVENT_TYPE_FOREIGN_CHANNEL,
1030 	SCAN_EVENT_TYPE_DEQUEUED,
1031 	SCAN_EVENT_TYPE_PREEMPTED,
1032 	SCAN_EVENT_TYPE_START_FAILED,
1033 	SCAN_EVENT_TYPE_RESTARTED,
1034 	SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT,
1035 	SCAN_EVENT_TYPE_SUSPENDED,
1036 	SCAN_EVENT_TYPE_RESUMED,
1037 	SCAN_EVENT_TYPE_NLO_COMPLETE,
1038 	SCAN_EVENT_TYPE_NLO_MATCH,
1039 	SCAN_EVENT_TYPE_INVALID,
1040 	SCAN_EVENT_TYPE_GPIO_TIMEOUT,
1041 	SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START,
1042 	SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END,
1043 	SCAN_EVENT_TYPE_BSSID_MATCH,
1044 	SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF,
1045 	SCAN_EVENT_TYPE_MAX,
1046 };
1047 
1048 /**
1049  * enum scan_completion_reason - scan completion reason
1050  * @SCAN_REASON_NONE: un specified reason
1051  * @SCAN_REASON_COMPLETED: scan successfully completed
1052  * @SCAN_REASON_CANCELLED: scan got cancelled
1053  * @SCAN_REASON_PREEMPTED: scan got preempted
1054  * @SCAN_REASON_TIMEDOUT: couldnt complete within specified time
1055  * @SCAN_REASON_INTERNAL_FAILURE: cancelled because of some failure
1056  * @SCAN_REASON_SUSPENDED: scan suspended
1057  * @SCAN_REASON_RUN_FAILED: run failed
1058  * @SCAN_REASON_TERMINATION_FUNCTION: termination function
1059  * @SCAN_REASON_MAX_OFFCHAN_RETRIES: max retries exceeded thresold
1060  * @SCAN_REASON_DFS_VIOLATION: Scan start failure due to DFS violation.
1061  * @SCAN_REASON_MAX: invalid completion reason marker
1062  */
1063 enum scan_completion_reason {
1064 	SCAN_REASON_NONE,
1065 	SCAN_REASON_COMPLETED,
1066 	SCAN_REASON_CANCELLED,
1067 	SCAN_REASON_PREEMPTED,
1068 	SCAN_REASON_TIMEDOUT,
1069 	SCAN_REASON_INTERNAL_FAILURE,
1070 	SCAN_REASON_SUSPENDED,
1071 	SCAN_REASON_RUN_FAILED,
1072 	SCAN_REASON_TERMINATION_FUNCTION,
1073 	SCAN_REASON_MAX_OFFCHAN_RETRIES,
1074 	SCAN_REASON_DFS_VIOLATION,
1075 	SCAN_REASON_MAX,
1076 };
1077 
1078 /**
1079  * struct scan_event - scan event definition
1080  * @vdev_id: vdev where scan was run
1081  * @type: type of scan event
1082  * @reason: completion reason
1083  * @chan_freq: channel centre frequency
1084  * @requester: requester id
1085  * @scan_id: scan id
1086  * @timestamp: timestamp in microsec recorded by target for the scan event
1087  * @scan_start_req: scan request object used to start this scan
1088  */
1089 struct scan_event {
1090 	uint32_t vdev_id;
1091 	enum scan_event_type type;
1092 	enum scan_completion_reason reason;
1093 	uint32_t chan_freq;
1094 	uint32_t requester;
1095 	uint32_t scan_id;
1096 	uint32_t timestamp;
1097 	struct scan_start_request *scan_start_req;
1098 };
1099 
1100 /**
1101  * struct scan_event_info - scan event information
1102  * @vdev: vdev object
1103  * @event: scan event
1104  */
1105 struct scan_event_info {
1106 	struct wlan_objmgr_vdev *vdev;
1107 	struct scan_event event;
1108 };
1109 
1110 /**
1111  * enum scm_scan_status - scan status
1112  * @SCAN_NOT_IN_PROGRESS: Neither active nor pending scan in progress
1113  * @SCAN_IS_ACTIVE: scan request is present only in active list
1114  * @SCAN_IS_PENDING: scan request is present only in pending list
1115  * @SCAN_IS_ACTIVE_AND_PENDING: scan request is present in active
1116  *                               and pending both lists
1117  */
1118 enum scm_scan_status {
1119 	SCAN_NOT_IN_PROGRESS = 0, /* Must be 0 */
1120 	SCAN_IS_ACTIVE,
1121 	SCAN_IS_PENDING,
1122 	SCAN_IS_ACTIVE_AND_PENDING,
1123 };
1124 
1125 /**
1126  * scan_event_handler() - function prototype of scan event handlers
1127  * @vdev: vdev object
1128  * @event: scan event
1129  * @arg: argument
1130  *
1131  * PROTO TYPE, scan event handler call back function prototype
1132  *
1133  * @Return: void
1134  */
1135 typedef void (*scan_event_handler) (struct wlan_objmgr_vdev *vdev,
1136 	struct scan_event *event, void *arg);
1137 
1138 /**
1139  * enum scan_cb_type - update beacon cb type
1140  * @SCAN_CB_TYPE_INFORM_BCN: Calback to indicate beacon to OS
1141  * @SCAN_CB_TYPE_UPDATE_BCN: Calback to indicate beacon
1142  * @SCAN_CB_TYPE_UNLINK_BSS: cb to unlink bss entry
1143  *                    to MLME and update MLME info
1144  *
1145  */
1146 enum scan_cb_type {
1147 	SCAN_CB_TYPE_INFORM_BCN,
1148 	SCAN_CB_TYPE_UPDATE_BCN,
1149 	SCAN_CB_TYPE_UNLINK_BSS,
1150 };
1151 
1152 /* Set PNO */
1153 #define SCAN_PNO_MAX_PLAN_REQUEST   2
1154 #define SCAN_PNO_MAX_NETW_CHANNELS_EX  (NUM_CHANNELS)
1155 #define SCAN_PNO_MAX_SUPP_NETWORKS  16
1156 #define SCAN_PNO_DEF_SLOW_SCAN_MULTIPLIER 6
1157 #define SCAN_PNO_DEF_SCAN_TIMER_REPEAT 20
1158 #define SCAN_PNO_MATCH_WAKE_LOCK_TIMEOUT         (5 * 1000)     /* in msec */
1159 #define SCAN_MAX_IE_LENGTH 255
1160 #ifdef CONFIG_SLUB_DEBUG_ON
1161 #define SCAN_PNO_SCAN_COMPLETE_WAKE_LOCK_TIMEOUT (2 * 1000)     /* in msec */
1162 #else
1163 #define SCAN_PNO_SCAN_COMPLETE_WAKE_LOCK_TIMEOUT (1 * 1000)     /* in msec */
1164 #endif /* CONFIG_SLUB_DEBUG_ON */
1165 
1166 /**
1167  * enum ssid_bc_type - SSID broadcast type
1168  * @SSID_BC_TYPE_UNKNOWN: Broadcast unknown
1169  * @SSID_BC_TYPE_NORMAL: Broadcast normal
1170  * @SSID_BC_TYPE_HIDDEN: Broadcast hidden
1171  */
1172 enum ssid_bc_type {
1173 	SSID_BC_TYPE_UNKNOWN = 0,
1174 	SSID_BC_TYPE_NORMAL = 1,
1175 	SSID_BC_TYPE_HIDDEN = 2,
1176 };
1177 
1178 /**
1179  * struct pno_nw_type - pno nw type
1180  * @ssid: ssid
1181  * @authentication: authentication type
1182  * @encryption: encryption type
1183  * @bcastNetwType: broadcast nw type
1184  * @ucChannelCount: uc channel count
1185  * @aChannels: pno channel
1186  * @rssiThreshold: rssi threshold
1187  */
1188 struct pno_nw_type {
1189 	struct wlan_ssid ssid;
1190 	uint32_t authentication;
1191 	uint32_t encryption;
1192 	uint32_t bc_new_type;
1193 	uint8_t channel_cnt;
1194 	uint32_t channels[SCAN_PNO_MAX_NETW_CHANNELS_EX];
1195 	int32_t rssi_thresh;
1196 };
1197 
1198 /**
1199  * struct connected_pno_band_rssi_pref - BSS preference based on band
1200  * and RSSI
1201  * @band: band preference
1202  * @rssi_pref: RSSI preference
1203  */
1204 struct cpno_band_rssi_pref {
1205 	int8_t band;
1206 	int8_t rssi;
1207 };
1208 
1209 /**
1210  * struct nlo_mawc_params - Motion Aided Wireless Connectivity based
1211  *                          Network List Offload configuration
1212  * @vdev_id: VDEV ID on which the configuration needs to be applied
1213  * @enable: flag to enable or disable
1214  * @exp_backoff_ratio: ratio of exponential backoff
1215  * @init_scan_interval: initial scan interval(msec)
1216  * @max_scan_interval:  max scan interval(msec)
1217  */
1218 struct nlo_mawc_params {
1219 	uint8_t vdev_id;
1220 	bool enable;
1221 	uint32_t exp_backoff_ratio;
1222 	uint32_t init_scan_interval;
1223 	uint32_t max_scan_interval;
1224 };
1225 
1226 /**
1227  * struct pno_scan_req_params - PNO Scan request structure
1228  * @networks_cnt: Number of networks
1229  * @do_passive_scan: Flag to request passive scan to fw
1230  * @vdev_id: vdev id
1231  * @fast_scan_period: Fast Scan period
1232  * @slow_scan_period: Slow scan period
1233  * @delay_start_time: delay in seconds to use before starting the first scan
1234  * @fast_scan_max_cycles: Fast scan max cycles
1235  * @scan_backoff_multiplier: multiply fast scan period by this after max cycles
1236  * @pno_channel_prediction: PNO channel prediction feature status
1237  * @uint32_t active_dwell_time: active dwell time
1238  * @uint32_t passive_dwell_time: passive dwell time
1239  * @top_k_num_of_channels: top K number of channels are used for tanimoto
1240  * distance calculation.
1241  * @stationary_thresh: threshold value to determine that the STA is stationary.
1242  * @adaptive_dwell_mode: adaptive dwelltime mode for pno scan
1243  * @channel_prediction_full_scan: periodic timer upon which a full scan needs
1244  * to be triggered.
1245  * @networks_list: Preferred network list
1246  * @scan_random: scan randomization params
1247  * @ie_whitelist: probe req IE whitelist attrs
1248  * @relative_rssi_set: Flag to check whether realtive_rssi is set or not
1249  * @relative_rssi: Relative rssi threshold, used for connected pno
1250  * @band_rssi_pref: Band and RSSI preference that can be given to one BSS
1251  *     over the other BSS
1252  *
1253  * E.g.
1254  *	{ fast_scan_period=120, fast_scan_max_cycles=2,
1255  *	  slow_scan_period=1800, scan_backoff_multiplier=2 }
1256  *	Result: 120s x2, 240s x2, 480s x2, 960s x2, 1800s xN
1257  * @mawc_params: Configuration parameters for NLO MAWC.
1258  */
1259 struct pno_scan_req_params {
1260 	uint32_t networks_cnt;
1261 	bool     do_passive_scan;
1262 	uint32_t vdev_id;
1263 	uint32_t fast_scan_period;
1264 	uint32_t slow_scan_period;
1265 	uint32_t delay_start_time;
1266 	uint32_t fast_scan_max_cycles;
1267 	uint8_t scan_backoff_multiplier;
1268 	uint32_t active_dwell_time;
1269 	uint32_t passive_dwell_time;
1270 	uint32_t pno_channel_prediction;
1271 	uint32_t top_k_num_of_channels;
1272 	uint32_t stationary_thresh;
1273 	enum scan_dwelltime_adaptive_mode adaptive_dwell_mode;
1274 	uint32_t channel_prediction_full_scan;
1275 	struct pno_nw_type networks_list[SCAN_PNO_MAX_SUPP_NETWORKS];
1276 	struct scan_random_attr scan_random;
1277 	struct probe_req_whitelist_attr ie_whitelist;
1278 	bool relative_rssi_set;
1279 	int8_t relative_rssi;
1280 	struct cpno_band_rssi_pref band_rssi_pref;
1281 	struct nlo_mawc_params mawc_params;
1282 };
1283 
1284 /**
1285  * struct scan_user_cfg - user configuration required for for scan
1286  * @ie_whitelist: probe req IE whitelist attrs
1287  * @sta_miracast_mcc_rest_time: sta miracast mcc rest time
1288  */
1289 struct scan_user_cfg {
1290 	struct probe_req_whitelist_attr ie_whitelist;
1291 	uint32_t sta_miracast_mcc_rest_time;
1292 };
1293 
1294 /**
1295  * update_beacon_cb() - cb to inform/update beacon
1296  * @psoc: psoc pointer
1297  * @scan_params:  scan entry to inform/update
1298  *
1299  * @Return: void
1300  */
1301 typedef void (*update_beacon_cb) (struct wlan_objmgr_pdev *pdev,
1302 	struct scan_cache_entry *scan_entry);
1303 
1304 /**
1305  * scan_iterator_func() - function prototype of scan iterator function
1306  * @scan_entry: scan entry object
1307  * @arg: extra argument
1308  *
1309  * PROTO TYPE, scan iterator function prototype
1310  *
1311  * @Return: QDF_STATUS
1312  */
1313 typedef QDF_STATUS (*scan_iterator_func) (void *arg,
1314 	struct scan_cache_entry *scan_entry);
1315 
1316 /**
1317  * enum scan_priority - scan priority definitions
1318  * @SCAN_CFG_DISABLE_SCAN_COMMAND_TIMEOUT: disable scan command timeout
1319  * @SCAN_CFG_DROP_BCN_ON_CHANNEL_MISMATCH: config to drop beacon/probe
1320  *  response frames if received channel and IE channels do not match
1321  */
1322 enum scan_config {
1323 	SCAN_CFG_DISABLE_SCAN_COMMAND_TIMEOUT,
1324 	SCAN_CFG_DROP_BCN_ON_CHANNEL_MISMATCH,
1325 };
1326 
1327 /**
1328  * enum ext_cap_bit_field - Extended capabilities bit field
1329  * @BSS_2040_COEX_MGMT_SUPPORT: 20/40 BSS Coexistence Management Support field
1330  * @OBSS_NARROW_BW_RU_IN_ULOFDMA_TOLERENT_SUPPORT: OBSS Narrow  Bandwidth RU
1331  *     in UL OFDMA  Tolerance Support
1332  */
1333 enum ext_cap_bit_field {
1334 	BSS_2040_COEX_MGMT_SUPPORT = 0,
1335 	OBSS_NARROW_BW_RU_IN_ULOFDMA_TOLERENT_SUPPORT = 79,
1336 };
1337 
1338 /**
1339  * scan_rnr_info - RNR information
1340  * @timestamp: time stamp of beacon/probe
1341  * @short_ssid: Short SSID
1342  * @bssid: BSSID
1343  */
1344 struct scan_rnr_info {
1345 	qdf_time_t timestamp;
1346 	uint32_t short_ssid;
1347 	struct qdf_mac_addr bssid;
1348 };
1349 
1350 /**
1351  * struct scan_rnr_node - Scan RNR entry node
1352  * @node: node pointers
1353  * @entry: scan RNR entry pointer
1354  */
1355 struct scan_rnr_node {
1356 	qdf_list_node_t node;
1357 	struct scan_rnr_info entry;
1358 };
1359 
1360 /**
1361  * meta_rnr_channel - Channel information for scan priority algorithm
1362  * @chan_freq: channel frequency
1363  * @bss_beacon_probe_count: Beacon and probe request count
1364  * @saved_profile_count: Saved profile count
1365  * @beacon_probe_last_time_found: Timestamp of beacon/probe observed
1366  * @rnr_list: RNR list to store RNR IE information
1367  */
1368 struct meta_rnr_channel {
1369 	uint32_t chan_freq;
1370 	uint32_t bss_beacon_probe_count;
1371 	uint32_t saved_profile_count;
1372 	qdf_time_t beacon_probe_last_time_found;
1373 	qdf_list_t rnr_list;
1374 };
1375 
1376 #define RNR_UPDATE_SCAN_CNT_THRESHOLD 2
1377 /**
1378  * channel_list_db - Database for channel information
1379  * @channel: channel meta information
1380  * @scan_count: scan count since the db was updated
1381  */
1382 struct channel_list_db {
1383 	struct meta_rnr_channel channel[NUM_6GHZ_CHANNELS];
1384 	uint8_t scan_count;
1385 };
1386 
1387 /**
1388  * rnr_chan_weight - RNR channel weightage
1389  * @chan_freq: channel frequency
1390  * @weight: weightage of the channel
1391  */
1392 struct rnr_chan_weight {
1393 	uint32_t chan_freq;
1394 	uint32_t weight;
1395 };
1396 #endif
1397