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