xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/core/src/wlan_scan_cache_db_i.h (revision bea437e2293c3d4fb1b5704fcf633aedac996962)
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 internal api
21  */
22 
23 #ifndef _WLAN_SCAN_CACHE_DB_I_H_
24 #define _WLAN_SCAN_CACHE_DB_I_H_
25 
26 /**
27  * scm_filter_match() - private API to check if entry is match to filter
28  * psoc: psoc ptr;
29  * @db_entry: db entry
30  * @filter: filter
31  * @security: negotiated security if match is found
32  *
33  * Return: true if entry match filter
34  */
35 bool scm_filter_match(struct wlan_objmgr_psoc *psoc,
36 	struct scan_cache_entry *db_entry,
37 	struct scan_filter *filter,
38 	struct security_info *security);
39 
40 /**
41  * scm_is_better_bss() - Is bss1 better than bss2
42  * @params: scan params
43  * @bss1: Pointer to the first BSS.
44  * @bss2: Pointer to the second BSS.
45  *
46  * This routine helps in determining the preference value
47  * of a particular BSS in the scan result which is further
48  * used in the sorting logic of the final candidate AP's.
49  *
50  * Return: true, if bss1 is better than bss2
51  *         false, if bss2 is better than bss1.
52  */
53 bool scm_is_better_bss(struct scan_default_params *params,
54 	struct scan_cache_entry *bss1,
55 	struct scan_cache_entry *bss2);
56 
57 /**
58  * scm_calculate_bss_score() - calculate BSS score used to get
59  * the preference
60  * @psoc: psoc ptr;
61  * @params: scan params
62  * @entry: scan entry for which score needs to be calculated
63  * @pcl_chan_weight: weight for pcl channel
64  *
65  * Return: scan db for the pdev id
66  */
67 int scm_calculate_bss_score(
68 		struct wlan_objmgr_psoc *psoc,
69 		struct scan_default_params *params,
70 		struct scan_cache_entry *entry,
71 		int pcl_chan_weight);
72 
73 /**
74  * wlan_pdevid_get_scan_db() - private API to get scan db from pdev id
75  * @psoc: psoc object
76  * @pdev_id: Pdev_id
77  * Return: scan db for the pdev id
78  */
79 static inline struct scan_dbs *
80 wlan_pdevid_get_scan_db(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id)
81 {
82 	struct wlan_scan_obj *scan_obj = NULL;
83 
84 	if (pdev_id > WLAN_UMAC_MAX_PDEVS) {
85 		scm_err("invalid pdev_id %d", pdev_id);
86 		return NULL;
87 	}
88 	scan_obj = wlan_psoc_get_scan_obj(psoc);
89 
90 	if (!scan_obj)
91 		return NULL;
92 
93 	return &(scan_obj->scan_db[pdev_id]);
94 }
95 
96 /**
97  * wlan_pdev_get_scan_db() - private API to get scan db from pdev
98  * @psoc: psoc object
99  * @pdev: Pdev
100  *
101  * Return: scan db for the pdev
102  */
103 static inline struct scan_dbs *
104 wlan_pdev_get_scan_db(struct wlan_objmgr_psoc *psoc,
105 	struct wlan_objmgr_pdev *pdev)
106 {
107 	uint8_t pdev_id;
108 
109 	if (!pdev) {
110 		scm_err("pdev is NULL");
111 		return NULL;
112 	}
113 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
114 
115 	return wlan_pdevid_get_scan_db(psoc, pdev_id);
116 }
117 
118 /**
119  * scm_get_pcl_weight_of_channel() - Get PCL weight if channel is present in pcl
120  * @chan_freq: channel frequency of bss, unit: MHz
121  * @filter: filter
122  * @pcl_chan_weight: Get PCL weight for corresponding channel
123  * @weight_list: Weight list for all the pcl channels.
124  *
125  * Get pcl_chan_weight if provided channel is present in pcl list
126  *
127  * Return: true or false
128  */
129 bool scm_get_pcl_weight_of_channel(uint32_t chan_freq,
130 				   struct scan_filter *filter,
131 				   int *pcl_chan_weight,
132 				   uint8_t *weight_list);
133 #endif
134