xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlme/connection_mgr/dispatcher/inc/wlan_cm_bss_score_param.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  * DOC: Define bss scoring structures and APIs
19  */
20 
21 #ifndef _WLAN_CM_BSS_SCORE_H
22 #define _WLAN_CM_BSS_SCORE_H
23 
24 #include <wlan_scan_utils_api.h>
25 #include "wlan_reg_services_api.h"
26 
27 /**
28  * struct weight_cfg - weight params to calculate best candidate
29  * @rssi_weightage: RSSI weightage
30  * @ht_caps_weightage: HT caps weightage
31  * @vht_caps_weightage: VHT caps weightage
32  * @he_caps_weightage: HE caps weightage
33  * @chan_width_weightage: Channel width weightage
34  * @chan_band_weightage: Channel band weightage
35  * @nss_weightage: NSS weightage
36  * @beamforming_cap_weightage: Beamforming caps weightage
37  * @pcl_weightage: PCL weightage
38  * @channel_congestion_weightage: channel congestion weightage
39  * @oce_wan_weightage: OCE WAN metrics weightage
40  * @oce_ap_tx_pwr_weightage: OCE AP tx power weigtage
41  * @oce_subnet_id_weightage: OCE subnet id weigtage
42  * @sae_pk_ap_weightage: SAE-PK AP weigtage
43  */
44 struct weight_cfg {
45 	uint8_t rssi_weightage;
46 	uint8_t ht_caps_weightage;
47 	uint8_t vht_caps_weightage;
48 	uint8_t he_caps_weightage;
49 	uint8_t chan_width_weightage;
50 	uint8_t chan_band_weightage;
51 	uint8_t nss_weightage;
52 	uint8_t beamforming_cap_weightage;
53 	uint8_t pcl_weightage;
54 	uint8_t channel_congestion_weightage;
55 	uint8_t oce_wan_weightage;
56 	uint8_t oce_ap_tx_pwr_weightage;
57 	uint8_t oce_subnet_id_weightage;
58 	uint8_t sae_pk_ap_weightage;
59 };
60 
61 /**
62  * struct rssi_config_score - rssi related params for scoring logic
63  * @best_rssi_threshold: RSSI weightage
64  * @good_rssi_threshold: HT caps weightage
65  * @bad_rssi_threshold: VHT caps weightage
66  * @good_rssi_pcnt: HE caps weightage
67  * @bad_rssi_pcnt: Channel width weightage
68  * @good_rssi_bucket_size: Channel band weightage
69  * @bad_rssi_bucket_size: NSS weightage
70  * @rssi_pref_5g_rssi_thresh: Beamforming caps weightage
71  */
72 struct rssi_config_score  {
73 	uint8_t best_rssi_threshold;
74 	uint8_t good_rssi_threshold;
75 	uint8_t bad_rssi_threshold;
76 	uint8_t good_rssi_pcnt;
77 	uint8_t bad_rssi_pcnt;
78 	uint8_t good_rssi_bucket_size;
79 	uint8_t bad_rssi_bucket_size;
80 	uint8_t rssi_pref_5g_rssi_thresh;
81 };
82 
83 /**
84  * struct per_slot_score - define % score for differents slots for a
85  *                               scoring param.
86  * num_slot: number of slots in which the param will be divided.
87  *           Max 15. index 0 is used for 'not_present. Num_slot will
88  *           equally divide 100. e.g, if num_slot = 4 slot 0 = 0-25%, slot
89  *           1 = 26-50% slot 2 = 51-75%, slot 3 = 76-100%
90  * score_pcnt3_to_0: Conatins score percentage for slot 0-3
91  *             BITS 0-7   :- the scoring pcnt when not present
92  *             BITS 8-15  :- SLOT_1
93  *             BITS 16-23 :- SLOT_2
94  *             BITS 24-31 :- SLOT_3
95  * score_pcnt7_to_4: Conatins score percentage for slot 4-7
96  *             BITS 0-7   :- SLOT_4
97  *             BITS 8-15  :- SLOT_5
98  *             BITS 16-23 :- SLOT_6
99  *             BITS 24-31 :- SLOT_7
100  * score_pcnt11_to_8: Conatins score percentage for slot 8-11
101  *             BITS 0-7   :- SLOT_8
102  *             BITS 8-15  :- SLOT_9
103  *             BITS 16-23 :- SLOT_10
104  *             BITS 24-31 :- SLOT_11
105  * score_pcnt15_to_12: Conatins score percentage for slot 12-15
106  *             BITS 0-7   :- SLOT_12
107  *             BITS 8-15  :- SLOT_13
108  *             BITS 16-23 :- SLOT_14
109  *             BITS 24-31 :- SLOT_15
110  */
111 struct per_slot_score {
112 	uint8_t num_slot;
113 	uint32_t score_pcnt3_to_0;
114 	uint32_t score_pcnt7_to_4;
115 	uint32_t score_pcnt11_to_8;
116 	uint32_t score_pcnt15_to_12;
117 };
118 
119 /**
120  * struct scoring_cfg - Scoring related configuration
121  * @weight_cfg: weigtage config for config
122  * @rssi_score: Rssi related config for scoring config
123  * @esp_qbss_scoring: esp and qbss related scoring config
124  * @oce_wan_scoring: oce related scoring config
125  * @bandwidth_weight_per_index: BW wight per index
126  * @nss_weight_per_index: nss weight per index
127  * @band_weight_per_index: band weight per index
128  * @is_bssid_hint_priority: True if bssid_hint is given priority
129  * @check_assoc_disallowed: Should assoc be disallowed if MBO OCE IE indicate so
130  * @vendor_roam_score_algorithm: Preferred ETP vendor roam score algorithm
131  * @check_6ghz_security: check security for 6Ghz candidate
132  * @key_mgmt_mask_6ghz: user configurable mask for 6ghz AKM
133  */
134 struct scoring_cfg {
135 	struct weight_cfg weight_config;
136 	struct rssi_config_score rssi_score;
137 	struct per_slot_score esp_qbss_scoring;
138 	struct per_slot_score oce_wan_scoring;
139 	uint32_t bandwidth_weight_per_index;
140 	uint32_t nss_weight_per_index;
141 	uint32_t band_weight_per_index;
142 	uint8_t is_bssid_hint_priority:1,
143 		 check_assoc_disallowed:1,
144 		 vendor_roam_score_algorithm:1,
145 		 check_6ghz_security:1;
146 	uint32_t key_mgmt_mask_6ghz;
147 };
148 
149 /**
150  * struct pcl_freq_weight_list - pcl freq weight info
151  * @num_of_pcl_channels: number of pcl channel
152  * @pcl_freq_list: pcl freq list
153  * @pcl_weight_list: pcl freq weight list
154  */
155 struct pcl_freq_weight_list {
156 	uint32_t num_of_pcl_channels;
157 	uint32_t pcl_freq_list[NUM_CHANNELS];
158 	uint8_t pcl_weight_list[NUM_CHANNELS];
159 };
160 
161 /**
162  * enum cm_blacklist_action - action taken by blacklist manager for the bssid
163  * @CM_BLM_NO_ACTION: No operation to be taken for the BSSID in the scan list.
164  * @CM_BLM_REMOVE: Remove the BSSID from the scan list (AP is blacklisted)
165  * This param is a way to inform the caller that this BSSID is blacklisted
166  * but it is a driver blacklist and we can connect to them if required.
167  * @CM_BLM_FORCE_REMOVE: Forcefully remove the BSSID from scan list.
168  * This param is introduced as we want to differentiate between optional
169  * mandatory blacklisting. Driver blacklisting is optional and won't
170  * fail any CERT or protocol violations as it is internal implementation.
171  * hence FORCE_REMOVE will mean that driver cannot connect to this BSSID
172  * in any situation.
173  * @CM_BLM_AVOID: Add the Ap at last of the scan list (AP to Avoid)
174  */
175 enum cm_blacklist_action {
176 	CM_BLM_NO_ACTION,
177 	CM_BLM_REMOVE,
178 	CM_BLM_FORCE_REMOVE,
179 	CM_BLM_AVOID,
180 };
181 
182 /**
183  * struct etp_params - params for estimated throughput
184  * @airtime_fraction: Portion of airtime available for outbound transmissions
185  * @data_ppdu_dur_target_us: Expected duration of a single PPDU, in us
186  * @ba_window_size: Block ack window size of the transmitter
187  */
188 struct etp_params {
189 	uint32_t airtime_fraction;
190 	uint32_t data_ppdu_dur_target_us;
191 	uint32_t ba_window_size;
192 };
193 
194 #ifdef FEATURE_BLACKLIST_MGR
195 enum cm_blacklist_action
196 wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev,
197 			       struct scan_cache_entry *entry);
198 #else
199 static inline enum cm_blacklist_action
200 wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev,
201 			       struct scan_cache_entry *entry)
202 {
203 	return CM_BLM_NO_ACTION;
204 }
205 #endif
206 
207 /**
208  * wlan_cm_calculate_bss_score() - calculate bss score for the scan list
209  * @pdev: pointer to pdev object
210  * @pcl_list: pcl list for scoring
211  * @scan_list: scan list, contains the input list and after the
212  *             func it will have sorted list
213  * @bssid_hint: bssid hint
214  *
215  * Return: void
216  */
217 void wlan_cm_calculate_bss_score(struct wlan_objmgr_pdev *pdev,
218 				 struct pcl_freq_weight_list *pcl_lst,
219 				 qdf_list_t *scan_list,
220 				 struct qdf_mac_addr *bssid_hint);
221 
222 /**
223  * wlan_cm_init_score_config() - Init score INI and config
224  * @psoc: pointer to psoc object
225  * @score_cfg: score config
226  *
227  * Return: void
228  */
229 void wlan_cm_init_score_config(struct wlan_objmgr_psoc *psoc,
230 			       struct scoring_cfg *score_cfg);
231 
232 /**
233  * wlan_cm_6ghz_allowed_for_akm() - check if 6Ghz channel can be allowed for AKM
234  * @psoc: pointer to psoc object
235  * @key_mgmt: key mgmt used
236  * @rsn_caps: rsn caps
237  * @rsnxe: rsnxe pointer if present
238  * @sae_pwe: support for SAE password
239  *
240  * Return: bool
241  */
242 #ifdef CONFIG_BAND_6GHZ
243 bool wlan_cm_6ghz_allowed_for_akm(struct wlan_objmgr_psoc *psoc,
244 				  uint32_t key_mgmt, uint16_t rsn_caps,
245 				  const uint8_t *rsnxe, uint8_t sae_pwe);
246 
247 /**
248  * wlan_cm_set_check_6ghz_security() - Set check 6Ghz security
249  * @psoc: pointer to psoc object
250  * @value: value to be set
251  *
252  * Return: void
253  */
254 void wlan_cm_set_check_6ghz_security(struct wlan_objmgr_psoc *psoc,
255 				     bool value);
256 
257 /**
258  * wlan_cm_reset_check_6ghz_security() - reset check 6Ghz security to orignal
259  * value
260  * @psoc: pointer to psoc object
261  *
262  * Return: void
263  */
264 void wlan_cm_reset_check_6ghz_security(struct wlan_objmgr_psoc *psoc);
265 
266 /**
267  * wlan_cm_get_check_6ghz_security() - Get 6Ghz allowe AKM mask
268  * @psoc: pointer to psoc object
269  * @value: value to be set
270  *
271  * Return: value
272  */
273 bool wlan_cm_get_check_6ghz_security(struct wlan_objmgr_psoc *psoc);
274 
275 /**
276  * wlan_cm_set_6ghz_key_mgmt_mask() - Set 6Ghz allowe AKM mask
277  * @psoc: pointer to psoc object
278  *
279  * Return: void
280  */
281 void wlan_cm_set_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc,
282 				    uint32_t value);
283 
284 /**
285  * wlan_cm_get_6ghz_key_mgmt_mask() - Get 6Ghz allowe AKM mask
286  * @psoc: pointer to psoc object
287  *
288  * Return: value
289  */
290 uint32_t wlan_cm_get_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc);
291 
292 #else
293 static inline bool
294 wlan_cm_6ghz_allowed_for_akm(struct wlan_objmgr_psoc *psoc,
295 			     uint32_t key_mgmt, uint16_t rsn_caps,
296 			     const uint8_t *rsnxe, uint8_t sae_pwe)
297 {
298 	return true;
299 }
300 
301 static inline
302 void wlan_cm_set_check_6ghz_security(struct wlan_objmgr_psoc *psoc,
303 				     bool value) {}
304 
305 static inline
306 void wlan_cm_reset_check_6ghz_security(struct wlan_objmgr_psoc *psoc) {}
307 
308 static inline
309 bool wlan_cm_get_check_6ghz_security(struct wlan_objmgr_psoc *psoc)
310 {
311 	return false;
312 }
313 
314 static inline
315 void wlan_cm_set_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc,
316 				    uint32_t value) {}
317 
318 static inline
319 uint32_t wlan_cm_get_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc)
320 {
321 	return DEFAULT_KEYMGMT_6G_MASK;
322 }
323 #endif
324 
325 #ifdef CONN_MGR_ADV_FEATURE
326 /**
327  * wlan_cm_set_check_assoc_disallowed() - Set check assoc disallowed param
328  * @psoc: pointer to psoc object
329  * @value: value to be set
330  *
331  * Return: void
332  */
333 void wlan_cm_set_check_assoc_disallowed(struct wlan_objmgr_psoc *psoc,
334 					bool value);
335 
336 /**
337  * wlan_cm_get_check_assoc_disallowed() - get check assoc disallowed param
338  * @psoc: pointer to psoc object
339  * @value: value to be filled
340  *
341  * Return: void
342  */
343 void wlan_cm_get_check_assoc_disallowed(struct wlan_objmgr_psoc *psoc,
344 					bool *value);
345 #endif
346 #endif
347