1 /* 2 * Copyright (c) 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 uint32_t best_rssi_threshold; 72 uint32_t good_rssi_threshold; 73 uint32_t bad_rssi_threshold; 74 uint32_t good_rssi_pcnt; 75 uint32_t bad_rssi_pcnt; 76 uint32_t good_rssi_bucket_size; 77 uint32_t bad_rssi_bucket_size; 78 uint32_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 uint32_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 */ 128 struct scoring_cfg { 129 struct weight_cfg weight_config; 130 struct rssi_config_score rssi_score; 131 struct per_slot_score esp_qbss_scoring; 132 struct per_slot_score oce_wan_scoring; 133 uint32_t bandwidth_weight_per_index; 134 uint32_t nss_weight_per_index; 135 uint32_t band_weight_per_index; 136 bool is_bssid_hint_priority; 137 }; 138 139 /** 140 * struct pcl_freq_weight_list - pcl freq weight info 141 * @num_of_pcl_channels: number of pcl channel 142 * @pcl_freq_list: pcl freq list 143 * @pcl_weight_list: pcl freq weight list 144 */ 145 struct pcl_freq_weight_list { 146 uint32_t num_of_pcl_channels; 147 uint32_t pcl_freq_list[NUM_CHANNELS]; 148 uint8_t pcl_weight_list[NUM_CHANNELS]; 149 }; 150 151 /** 152 * wlan_cm_calculate_bss_score() - calculate bss score for the scan list 153 * @psoc: pointer to psoc object 154 * @pcl_list: pcl list for scoring 155 * @scan_list: scan list, contains the input list and after the 156 * func it will have sorted list 157 * @bssid_hint: bssid hint 158 * 159 * Return: void 160 */ 161 void wlan_cm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, 162 struct pcl_freq_weight_list *pcl_lst, 163 qdf_list_t *scan_list, 164 struct qdf_mac_addr *bssid_hint); 165 166 /** 167 * wlan_cm_init_score_config() - Init score INI and config 168 * @psoc: pointer to psoc object 169 * @score_cfg: score config 170 * 171 * Return: void 172 */ 173 void wlan_cm_init_score_config(struct wlan_objmgr_psoc *psoc, 174 struct scoring_cfg *score_cfg); 175 #endif 176