diff --git a/umac/scan/core/src/wlan_scan_cache_db.h b/umac/scan/core/src/wlan_scan_cache_db.h index c91a9c5b5f73..a250313d19a5 100644 --- a/umac/scan/core/src/wlan_scan_cache_db.h +++ b/umac/scan/core/src/wlan_scan_cache_db.h @@ -54,24 +54,12 @@ #define HIGH_CHANNEL_CONGESTION 75 #define EXTREME_CHANNEL_CONGESTION 100 -#define RSSI_WEIGHTAGE 25 -#define HT_CAPABILITY_WEIGHTAGE 7 -#define VHT_CAP_WEIGHTAGE 5 -#define CHAN_WIDTH_WEIGHTAGE 10 -#define CHAN_BAND_WEIGHTAGE 5 -#define NSS_WEIGHTAGE 5 -#define BEAMFORMING_CAP_WEIGHTAGE 2 -#define PCL_WEIGHT 10 -#define CHANNEL_CONGESTION_WEIGHTAGE 5 -#define RESERVED_WEIGHT 31 - #define EXCELLENT_RSSI -55 #define BAD_RSSI -80 #define EXCELLENT_RSSI_WEIGHT 100 #define RSSI_BUCKET 5 #define RSSI_WEIGHT_BUCKET 250 -#define BEST_CANDIDATE_MAX_WEIGHT 100 #define BEST_CANDIDATE_80MHZ 100 #define BEST_CANDIDATE_40MHZ 70 #define BEST_CANDIDATE_20MHZ 30 diff --git a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h index 7cb76c9020d3..87b60d5c6d10 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h +++ b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h @@ -62,6 +62,34 @@ typedef uint32_t wlan_scan_id; #define PROBE_REQ_BITMAP_LEN 8 #define MAX_PROBE_REQ_OUIS 16 +#define RSSI_WEIGHTAGE 20 +#define HT_CAPABILITY_WEIGHTAGE 2 +#define VHT_CAP_WEIGHTAGE 1 +#define HE_CAP_WEIGHTAGE 2 +#define CHAN_WIDTH_WEIGHTAGE 17 +#define CHAN_BAND_WEIGHTAGE 2 +#define NSS_WEIGHTAGE 16 +#define BEAMFORMING_CAP_WEIGHTAGE 2 +#define PCL_WEIGHT 10 +#define CHANNEL_CONGESTION_WEIGHTAGE 5 +#define OCE_WAN_WEIGHTAGE 0 +#define BEST_CANDIDATE_MAX_WEIGHT 100 +#define MAX_INDEX_SCORE 100 +#define MAX_INDEX_PER_INI 4 + +#define WLAN_GET_BITS(_val, _index, _num_bits) \ + (((_val) >> (_index)) & ((1 << (_num_bits)) - 1)) + +#define WLAN_SET_BITS(_var, _index, _num_bits, _val) do { \ + (_var) &= ~(((1 << (_num_bits)) - 1) << (_index)); \ + (_var) |= (((_val) & ((1 << (_num_bits)) - 1)) << (_index)); \ + } while (0) + +#define WLAN_GET_SCORE_PERCENTAGE(value32, bw_index) \ + WLAN_GET_BITS(value32, (8 * (bw_index)), 8) +#define WLAN_SET_SCORE_PERCENTAGE(value32, score_pcnt, bw_index) \ + WLAN_SET_BITS(value32, (8 * (bw_index)), 8, score_pcnt) + /* forward declaration */ struct wlan_objmgr_vdev; struct wlan_objmgr_pdev; diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 42f22d0d3567..c1128c264cb4 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -895,8 +895,7 @@ QDF_STATUS wmi_unified_roam_scan_offload_cmd(void *wmi_hdl, #ifdef CONFIG_MCL QDF_STATUS wmi_unified_send_roam_scan_offload_ap_cmd(void *wmi_hdl, - wmi_ap_profile *ap_profile_p, - uint32_t vdev_id); + struct ap_profile_params *ap_profile); #endif QDF_STATUS wmi_unified_roam_scan_offload_scan_period(void *wmi_hdl, diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index 901d6413b7d2..4791c6a4e72b 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -2025,6 +2025,166 @@ struct roam_offload_scan_rssi_params { uint32_t flags; }; +/** + * struct ap_profile - Structure ap profile to match candidate + * @flags: flags + * @rssi_threshold: the value of the the candidate AP should higher by this + * threshold than the rssi of the currrently associated AP + * @ssid: ssid vlaue to be matched + * @rsn_authmode: security params to be matched + * @rsn_ucastcipherset: unicast cipher set + * @rsn_mcastcipherset: mcast/group cipher set + * @rsn_mcastmgmtcipherset: mcast/group management frames cipher set + * @rssi_abs_thresh: the value of the candidate AP should higher than this + * absolute RSSI threshold. Zero means no absolute minimum + * RSSI is required. units are the offset from the noise + * floor in dB + */ +struct ap_profile { + uint32_t flags; + uint32_t rssi_threshold; + struct mac_ssid ssid; + uint32_t rsn_authmode; + uint32_t rsn_ucastcipherset; + uint32_t rsn_mcastcipherset; + uint32_t rsn_mcastmgmtcipherset; + uint32_t rssi_abs_thresh; +}; + +/** + * struct rssi_scoring - rssi scoring param to sortlist selected AP + * @best_rssi_threshold: Roamable AP RSSI equal or better than this threshold, + * full rssi score 100. Units in dBm. + * @good_rssi_threshold: Below threshold, scoring linear percentage between + * rssi_good_pnt and 100. Units in dBm. + * @bad_rssi_threshold: Between good and bad rssi threshold, scoring linear + * % between rssi_bad_pcnt and rssi_good_pct in dBm. + * @good_rssi_pcnt: Used to assigned scoring percentage of each slot between + * best to good rssi threshold. Units in percentage. + * @bad_rssi_pcnt: Used to assigned scoring percentage of each slot between good + * to bad rssi threshold. Unites in percentage. + * @good_bucket_size : bucket size of slot in good zone + * @bad_bucket_size : bucket size of slot in bad zone + * @rssi_pref_5g_rssi_thresh: Below rssi threshold, 5G AP have given preference + * of band percentage. Units in dBm. + */ +struct rssi_scoring { + int32_t best_rssi_threshold; + int32_t good_rssi_threshold; + int32_t bad_rssi_threshold; + uint32_t good_rssi_pcnt; + uint32_t bad_rssi_pcnt; + uint32_t good_bucket_size; + uint32_t bad_bucket_size; + int32_t rssi_pref_5g_rssi_thresh; +}; + +/** + * struct param_slot_scoring - define % score for differents slots for a + * scoring param. + * @num_slot: number of slots in which the param will be divided. + * Max 15. index 0 is used for 'not_present. Num_slot will + * equally divide 100. e.g, if num_slot = 4 slot 0 = 0-25%, slot + * 1 = 26-50% slot 2 = 51-75%, slot 3 = 76-100% + * @score_pcnt3_to_0: Conatins score percentage for slot 0-3 + * BITS 0-7 :- the scoring pcnt when not present + * BITS 8-15 :- SLOT_1 + * BITS 16-23 :- SLOT_2 + * BITS 24-31 :- SLOT_3 + * @score_pcnt7_to_4: Conatins score percentage for slot 4-7 + * BITS 0-7 :- SLOT_4 + * BITS 8-15 :- SLOT_5 + * BITS 16-23 :- SLOT_6 + * BITS 24-31 :- SLOT_7 + * @score_pcnt11_to_8: Conatins score percentage for slot 8-11 + * BITS 0-7 :- SLOT_8 + * BITS 8-15 :- SLOT_9 + * BITS 16-23 :- SLOT_10 + * BITS 24-31 :- SLOT_11 + * @score_pcnt15_to_12: Conatins score percentage for slot 12-15 + * BITS 0-7 :- SLOT_12 + * BITS 8-15 :- SLOT_13 + * BITS 16-23 :- SLOT_14 + * BITS 24-31 :- SLOT_15 + */ +struct param_slot_scoring { + uint32_t num_slot; + uint32_t score_pcnt3_to_0; + uint32_t score_pcnt7_to_4; + uint32_t score_pcnt11_to_8; + uint32_t score_pcnt15_to_12; +}; + +/** + * struct scoring_param - scoring param to sortlist selected AP + * @disable_bitmap: Each bit will be either allow(0)/disallow(1) to + * considered the roam score param. + * @rssi_weightage: RSSI weightage out of total score in % + * @ht_weightage: HT weightage out of total score in %. + * @vht_weightage: VHT weightage out of total score in %. + * @he_weightaget: 11ax weightage out of total score in %. + * @bw_weightage: Bandwidth weightage out of total score in %. + * @band_weightage: Band(2G/5G) weightage out of total score in %. + * @nss_weightage: NSS(1x1 / 2x2)weightage out of total score in %. + * @esp_qbss_weightage: ESP/QBSS weightage out of total score in %. + * @beamforming_weightage: Beamforming weightage out of total score in %. + * @pcl_weightage: PCL weightage out of total score in %. + * @oce_wan_weightage OCE WAN metrics weightage out of total score in %. + * @bw_index_score: channel BW scoring percentage information. + * BITS 0-7 :- It contains scoring percentage of 20MHz BW + * BITS 8-15 :- It contains scoring percentage of 40MHz BW + * BITS 16-23 :- It contains scoring percentage of 80MHz BW + * BITS 24-31 :- It contains scoring percentage of 1600MHz BW + * The value of each index must be 0-100 + * @band_index_score: band scording percentage information. + * BITS 0-7 :- It contains scoring percentage of 2G + * BITS 8-15 :- It contains scoring percentage of 5G + * BITS 16-23 :- reserved + * BITS 24-31 :- reserved + * The value of each index must be 0-100 + * @nss_index_score: NSS scoring percentage information. + * BITS 0-7 :- It contains scoring percentage of 1x1 + * BITS 8-15 :- It contains scoring percentage of 2x2 + * BITS 16-23 :- It contains scoring percentage of 3x3 + * BITS 24-31 :- It contains scoring percentage of 4x4 + * The value of each index must be 0-100 + * @rssi_scoring: RSSI scoring information. + * @esp_qbss_scoring: ESP/QBSS scoring percentage information + * @oce_wan_scoring: OCE WAN metrics percentage information +*/ +struct scoring_param { + uint32_t disable_bitmap; + int32_t rssi_weightage; + int32_t ht_weightage; + int32_t vht_weightage; + int32_t he_weightage; + int32_t bw_weightage; + int32_t band_weightage; + int32_t nss_weightage; + int32_t esp_qbss_weightage; + int32_t beamforming_weightage; + int32_t pcl_weightage; + int32_t oce_wan_weightage; + uint32_t bw_index_score; + uint32_t band_index_score; + uint32_t nss_index_score; + struct rssi_scoring rssi_scoring; + struct param_slot_scoring esp_qbss_scoring; + struct param_slot_scoring oce_wan_scoring; +}; + +/** + * struct ap_profile_params - ap profile params + * @vdev_id: vdev id + * @profile: ap profile to match candidate + * @param: scoring params to short candidate + */ +struct ap_profile_params { + uint8_t vdev_id; + struct ap_profile profile; + struct scoring_param param; +}; + /** * struct wifi_epno_network - enhanced pno network block * @ssid: ssid diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 163d49edb86d..4c5ed207758b 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -585,8 +585,7 @@ QDF_STATUS (*send_roam_scan_offload_mode_cmd)(wmi_unified_t wmi_handle, struct roam_offload_scan_params *roam_req); QDF_STATUS (*send_roam_scan_offload_ap_profile_cmd)(wmi_unified_t wmi_handle, - wmi_ap_profile * ap_profile_p, - uint32_t vdev_id); + struct ap_profile_params *ap_profile); QDF_STATUS (*send_pktlog_wmi_send_cmd)(wmi_unified_t wmi_handle, WMI_PKTLOG_EVENT pktlog_event, diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 8fb1e2385b40..710377bbd716 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -3151,22 +3151,20 @@ QDF_STATUS wmi_unified_roam_scan_offload_cmd(void *wmi_hdl, /** * wmi_unified_send_roam_scan_offload_ap_cmd() - set roam ap profile in fw * @wmi_hdl: wmi handle - * @ap_profile_p: ap profile - * @vdev_id: vdev id + * @ap_profile: ap profile params * * Send WMI_ROAM_AP_PROFILE to firmware * * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure */ QDF_STATUS wmi_unified_send_roam_scan_offload_ap_cmd(void *wmi_hdl, - wmi_ap_profile *ap_profile_p, - uint32_t vdev_id) + struct ap_profile_params *ap_profile) { wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; if (wmi_handle->ops->send_roam_scan_offload_ap_profile_cmd) - return wmi_handle->ops->send_roam_scan_offload_ap_profile_cmd(wmi_handle, - ap_profile_p, vdev_id); + return wmi_handle->ops->send_roam_scan_offload_ap_profile_cmd( + wmi_handle, ap_profile); return QDF_STATUS_E_FAILURE; } diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 4d61bdf587f0..ac3169f947af 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -14944,17 +14944,18 @@ error: * Return: CDF status */ static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle, - wmi_ap_profile *ap_profile_p, - uint32_t vdev_id) + struct ap_profile_params *ap_profile) { wmi_buf_t buf = NULL; QDF_STATUS status; int len; uint8_t *buf_ptr; wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp; + wmi_roam_cnd_scoring_param *score_param; + wmi_ap_profile *profile; len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile); - + len += sizeof(*score_param); buf = wmi_buf_alloc(wmi_handle, len); if (!buf) { WMI_LOGE("%s : wmi_buf_alloc failed", __func__); @@ -14968,14 +14969,143 @@ static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_ha WMITLV_GET_STRUCT_TLVLEN (wmi_roam_ap_profile_fixed_param)); /* fill in threshold values */ - roam_ap_profile_fp->vdev_id = vdev_id; + roam_ap_profile_fp->vdev_id = ap_profile->vdev_id; roam_ap_profile_fp->id = 0; buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param); - qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile)); - WMITLV_SET_HDR(buf_ptr, + profile = (wmi_ap_profile *)buf_ptr; + WMITLV_SET_HDR(&profile->tlv_header, WMITLV_TAG_STRUC_wmi_ap_profile, WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile)); + profile->flags = ap_profile->profile.flags; + profile->rssi_threshold = ap_profile->profile.rssi_threshold; + profile->ssid.ssid_len = ap_profile->profile.ssid.length; + qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid, + profile->ssid.ssid_len); + profile->rsn_authmode = ap_profile->profile.rsn_authmode; + profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset; + profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset; + profile->rsn_mcastmgmtcipherset = + ap_profile->profile.rsn_mcastmgmtcipherset; + profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh; + + WMI_LOGD("AP profile: flags %x rssi_threshold %d ssid:%.*s authmode %d uc cipher %d mc cipher %d mc mgmt cipher %d rssi abs thresh %d", + profile->flags, profile->rssi_threshold, + profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid, + profile->rsn_authmode, profile->rsn_ucastcipherset, + profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset, + profile->rssi_abs_thresh); + + buf_ptr += sizeof(wmi_ap_profile); + + score_param = (wmi_roam_cnd_scoring_param *)buf_ptr; + WMITLV_SET_HDR(&score_param->tlv_header, + WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param)); + score_param->disable_bitmap = ap_profile->param.disable_bitmap; + score_param->rssi_weightage_pcnt = + ap_profile->param.rssi_weightage; + score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage; + score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage; + score_param->he_weightage_pcnt = ap_profile->param.he_weightage; + score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage; + score_param->band_weightage_pcnt = ap_profile->param.band_weightage; + score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage; + score_param->esp_qbss_weightage_pcnt = + ap_profile->param.esp_qbss_weightage; + score_param->beamforming_weightage_pcnt = + ap_profile->param.beamforming_weightage; + score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage; + score_param->oce_wan_weightage_pcnt = + ap_profile->param.oce_wan_weightage; + + WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d", + score_param->disable_bitmap, score_param->rssi_weightage_pcnt, + score_param->ht_weightage_pcnt, + score_param->vht_weightage_pcnt, + score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt, + score_param->band_weightage_pcnt, + score_param->nss_weightage_pcnt, + score_param->esp_qbss_weightage_pcnt, + score_param->beamforming_weightage_pcnt, + score_param->pcl_weightage_pcnt, + score_param->oce_wan_weightage_pcnt); + + score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score; + score_param->band_scoring.score_pcnt = + ap_profile->param.band_index_score; + score_param->nss_scoring.score_pcnt = + ap_profile->param.nss_index_score; + + WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x", + score_param->bw_scoring.score_pcnt, + score_param->band_scoring.score_pcnt, + score_param->nss_scoring.score_pcnt); + + score_param->rssi_scoring.best_rssi_threshold = + (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold; + score_param->rssi_scoring.good_rssi_threshold = + (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold; + score_param->rssi_scoring.bad_rssi_threshold = + (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold; + score_param->rssi_scoring.good_rssi_pcnt = + ap_profile->param.rssi_scoring.good_rssi_pcnt; + score_param->rssi_scoring.bad_rssi_pcnt = + ap_profile->param.rssi_scoring.bad_rssi_pcnt; + score_param->rssi_scoring.good_bucket_size = + ap_profile->param.rssi_scoring.good_bucket_size; + score_param->rssi_scoring.bad_bucket_size = + ap_profile->param.rssi_scoring.bad_bucket_size; + score_param->rssi_scoring.rssi_pref_5g_rssi_thresh = + (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh; + + WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d", + score_param->rssi_scoring.best_rssi_threshold, + score_param->rssi_scoring.good_rssi_threshold, + score_param->rssi_scoring.bad_rssi_threshold, + score_param->rssi_scoring.rssi_pref_5g_rssi_thresh); + WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d", + score_param->rssi_scoring.good_rssi_pcnt, + score_param->rssi_scoring.bad_rssi_pcnt, + score_param->rssi_scoring.good_bucket_size, + score_param->rssi_scoring.bad_bucket_size); + + score_param->esp_qbss_scoring.num_slot = + ap_profile->param.esp_qbss_scoring.num_slot; + score_param->esp_qbss_scoring.score_pcnt3_to_0 = + ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0; + score_param->esp_qbss_scoring.score_pcnt7_to_4 = + ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4; + score_param->esp_qbss_scoring.score_pcnt11_to_8 = + ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8; + score_param->esp_qbss_scoring.score_pcnt15_to_12 = + ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12; + + WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x", + score_param->esp_qbss_scoring.num_slot, + score_param->esp_qbss_scoring.score_pcnt3_to_0, + score_param->esp_qbss_scoring.score_pcnt7_to_4, + score_param->esp_qbss_scoring.score_pcnt11_to_8, + score_param->esp_qbss_scoring.score_pcnt15_to_12); + + score_param->oce_wan_scoring.num_slot = + ap_profile->param.oce_wan_scoring.num_slot; + score_param->oce_wan_scoring.score_pcnt3_to_0 = + ap_profile->param.oce_wan_scoring.score_pcnt3_to_0; + score_param->oce_wan_scoring.score_pcnt7_to_4 = + ap_profile->param.oce_wan_scoring.score_pcnt7_to_4; + score_param->oce_wan_scoring.score_pcnt11_to_8 = + ap_profile->param.oce_wan_scoring.score_pcnt11_to_8; + score_param->oce_wan_scoring.score_pcnt15_to_12 = + ap_profile->param.oce_wan_scoring.score_pcnt15_to_12; + + WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x", + score_param->oce_wan_scoring.num_slot, + score_param->oce_wan_scoring.score_pcnt3_to_0, + score_param->oce_wan_scoring.score_pcnt7_to_4, + score_param->oce_wan_scoring.score_pcnt11_to_8, + score_param->oce_wan_scoring.score_pcnt15_to_12); + status = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ROAM_AP_PROFILE); if (QDF_IS_STATUS_ERROR(status)) {