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