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 */ 43 struct weight_cfg { 44 uint8_t rssi_weightage; 45 uint8_t ht_caps_weightage; 46 uint8_t vht_caps_weightage; 47 uint8_t he_caps_weightage; 48 uint8_t chan_width_weightage; 49 uint8_t chan_band_weightage; 50 uint8_t nss_weightage; 51 uint8_t beamforming_cap_weightage; 52 uint8_t pcl_weightage; 53 uint8_t channel_congestion_weightage; 54 uint8_t oce_wan_weightage; 55 uint8_t oce_ap_tx_pwr_weightage; 56 uint8_t oce_subnet_id_weightage; 57 }; 58 59 /** 60 * struct rssi_config_score - rssi related params for scoring logic 61 * @best_rssi_threshold: RSSI weightage 62 * @good_rssi_threshold: HT caps weightage 63 * @bad_rssi_threshold: VHT caps weightage 64 * @good_rssi_pcnt: HE caps weightage 65 * @bad_rssi_pcnt: Channel width weightage 66 * @good_rssi_bucket_size: Channel band weightage 67 * @bad_rssi_bucket_size: NSS weightage 68 * @rssi_pref_5g_rssi_thresh: Beamforming caps weightage 69 */ 70 struct rssi_config_score { 71 uint8_t best_rssi_threshold; 72 uint8_t good_rssi_threshold; 73 uint8_t bad_rssi_threshold; 74 uint8_t good_rssi_pcnt; 75 uint8_t bad_rssi_pcnt; 76 uint8_t good_rssi_bucket_size; 77 uint8_t bad_rssi_bucket_size; 78 uint8_t rssi_pref_5g_rssi_thresh; 79 }; 80 81 /** 82 * struct per_slot_score - define % score for differents slots for a 83 * scoring param. 84 * num_slot: number of slots in which the param will be divided. 85 * Max 15. index 0 is used for 'not_present. Num_slot will 86 * equally divide 100. e.g, if num_slot = 4 slot 0 = 0-25%, slot 87 * 1 = 26-50% slot 2 = 51-75%, slot 3 = 76-100% 88 * score_pcnt3_to_0: Conatins score percentage for slot 0-3 89 * BITS 0-7 :- the scoring pcnt when not present 90 * BITS 8-15 :- SLOT_1 91 * BITS 16-23 :- SLOT_2 92 * BITS 24-31 :- SLOT_3 93 * score_pcnt7_to_4: Conatins score percentage for slot 4-7 94 * BITS 0-7 :- SLOT_4 95 * BITS 8-15 :- SLOT_5 96 * BITS 16-23 :- SLOT_6 97 * BITS 24-31 :- SLOT_7 98 * score_pcnt11_to_8: Conatins score percentage for slot 8-11 99 * BITS 0-7 :- SLOT_8 100 * BITS 8-15 :- SLOT_9 101 * BITS 16-23 :- SLOT_10 102 * BITS 24-31 :- SLOT_11 103 * score_pcnt15_to_12: Conatins score percentage for slot 12-15 104 * BITS 0-7 :- SLOT_12 105 * BITS 8-15 :- SLOT_13 106 * BITS 16-23 :- SLOT_14 107 * BITS 24-31 :- SLOT_15 108 */ 109 struct per_slot_score { 110 uint8_t num_slot; 111 uint32_t score_pcnt3_to_0; 112 uint32_t score_pcnt7_to_4; 113 uint32_t score_pcnt11_to_8; 114 uint32_t score_pcnt15_to_12; 115 }; 116 117 /** 118 * struct scoring_cfg - Scoring related configuration 119 * @weight_cfg: weigtage config for config 120 * @rssi_score: Rssi related config for scoring config 121 * @esp_qbss_scoring: esp and qbss related scoring config 122 * @oce_wan_scoring: oce related scoring config 123 * @bandwidth_weight_per_index: BW wight per index 124 * @nss_weight_per_index: nss weight per index 125 * @band_weight_per_index: band weight per index 126 * @is_bssid_hint_priority: True if bssid_hint is given priority 127 * @check_assoc_disallowed: Should assoc be disallowed if MBO OCE IE indicate so 128 */ 129 struct scoring_cfg { 130 struct weight_cfg weight_config; 131 struct rssi_config_score rssi_score; 132 struct per_slot_score esp_qbss_scoring; 133 struct per_slot_score oce_wan_scoring; 134 uint32_t bandwidth_weight_per_index; 135 uint32_t nss_weight_per_index; 136 uint32_t band_weight_per_index; 137 bool is_bssid_hint_priority; 138 bool check_assoc_disallowed; 139 }; 140 141 /** 142 * struct pcl_freq_weight_list - pcl freq weight info 143 * @num_of_pcl_channels: number of pcl channel 144 * @pcl_freq_list: pcl freq list 145 * @pcl_weight_list: pcl freq weight list 146 */ 147 struct pcl_freq_weight_list { 148 uint32_t num_of_pcl_channels; 149 uint32_t pcl_freq_list[NUM_CHANNELS]; 150 uint8_t pcl_weight_list[NUM_CHANNELS]; 151 }; 152 153 /** 154 * enum cm_blacklist_action - action taken by blacklist manager for the bssid 155 * @CM_BLM_NO_ACTION: No operation to be taken for the BSSID in the scan list. 156 * @CM_BLM_REMOVE: Remove the BSSID from the scan list (AP is blacklisted) 157 * @CM_BLM_AVOID: Add the Ap at last of the scan list (AP to Avoid) 158 */ 159 enum cm_blacklist_action { 160 CM_BLM_NO_ACTION, 161 CM_BLM_REMOVE, 162 CM_BLM_AVOID, 163 }; 164 165 #ifdef FEATURE_BLACKLIST_MGR 166 enum cm_blacklist_action 167 wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev, 168 struct scan_cache_entry *entry); 169 #else 170 static inline enum cm_blacklist_action 171 wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev, 172 struct scan_cache_entry *entry) 173 { 174 return CM_BLM_NO_ACTION; 175 } 176 #endif 177 178 /** 179 * wlan_cm_calculate_bss_score() - calculate bss score for the scan list 180 * @pdev: pointer to pdev object 181 * @pcl_list: pcl list for scoring 182 * @scan_list: scan list, contains the input list and after the 183 * func it will have sorted list 184 * @bssid_hint: bssid hint 185 * 186 * Return: void 187 */ 188 void wlan_cm_calculate_bss_score(struct wlan_objmgr_pdev *pdev, 189 struct pcl_freq_weight_list *pcl_lst, 190 qdf_list_t *scan_list, 191 struct qdf_mac_addr *bssid_hint); 192 193 /** 194 * wlan_cm_init_score_config() - Init score INI and config 195 * @psoc: pointer to psoc object 196 * @score_cfg: score config 197 * 198 * Return: void 199 */ 200 void wlan_cm_init_score_config(struct wlan_objmgr_psoc *psoc, 201 struct scoring_cfg *score_cfg); 202 203 /** 204 * wlan_cm_set_check_assoc_disallowed() - Set check assoc disallowed param 205 * @psoc: pointer to psoc object 206 * @value: value to be set 207 * 208 * Return: void 209 */ 210 void wlan_cm_set_check_assoc_disallowed(struct wlan_objmgr_psoc *psoc, 211 bool value); 212 213 #endif 214