From 1fde9cdcbf74b0a0cae0077ecdb652697a26c83c Mon Sep 17 00:00:00 2001 From: Utkarsh Bhatnagar Date: Wed, 29 Sep 2021 10:07:44 +0530 Subject: [PATCH] qcacld-3.0: Add Policy Mgr Util APIs for SBS Add Policy Mgr Util APIs such as: policy_mgr_are_2_freq_on_same_mac() policy_mgr_are_3_freq_on_same_mac() policy_mgr_are_sbs_chan() policy_mgr_is_current_hwmode_dbs() policy_mgr_is_current_hwmode_sbs() policy_mgr_are_3_freq_in_freq_range() policy_mgr_are_2_freq_in_freq_range() policy_mgr_is_cur_freq_range_sbs() Change-Id: Ic85e48fa48c1c0cc7fa9e7ca6c8dbf2c8abfb94a CRs-Fixed: 3047019 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 82 +++++- .../src/wlan_policy_mgr_get_set_utils.c | 273 +++++++++++++++++- .../policy_mgr/src/wlan_policy_mgr_i.h | 21 +- 3 files changed, 355 insertions(+), 21 deletions(-) diff --git a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index b7bf52f04b..479a3af9b6 100644 --- a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -2681,14 +2681,88 @@ bool policy_mgr_is_dbs_scan_allowed(struct wlan_objmgr_psoc *psoc); bool policy_mgr_is_hw_sbs_capable(struct wlan_objmgr_psoc *psoc); /** - * policy_mgr_is_current_hwmode_dbs() - Check if current hw mode is DBS - * @psoc: PSOC object information - * Checks if current hardware mode of the system is DBS or no + * policy_mgr_are_2_freq_on_same_mac() - Function to check whether both the + * input frequencies are on same mac + * + * @psoc: Pointer to Psoc + * @freq_1: Frequency 1 to check + * @freq_2: Frequency 2 to check + * + * This Function check whether both the input frequency exist in the same mac + * + * Return:True if both the frequency exist on the same mac. + * + */ +bool +policy_mgr_are_2_freq_on_same_mac(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq_1, + qdf_freq_t freq_2); + +/** + * policy_mgr_are_3_freq_on_same_mac() - Function to check whether all three + * input frequencies are in same mac + * + * @psoc: Pointer to Psoc + * @freq_1: Frequency 1 to check + * @freq_2: Frequency 2 to check + * @freq_3: Frequency 3 to check + * + * This Function check whether all three input frequencies exist in the same + * mac. + * + * Return:True if all three frequency exist on the same mac + * + */ +bool +policy_mgr_are_3_freq_on_same_mac(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq_1, qdf_freq_t freq_2, + qdf_freq_t freq_3); + +/** + * policy_mgr_are_sbs_chan() - Function to check whether both the + * input frequency are in SBS frequency range + * + * @pm_ctx: Policy Mgr context + * @freq_range: freq range to check + * @freq_1: Frequency 1 to check + * @freq_2: Frequency 2 to check + * + * This Function check whether both the input frequency exist in the SBS + * frequency range. + * + * Return:True if both the frequency exist on the SBS frequency range. + * + */ +bool +policy_mgr_are_sbs_chan(struct wlan_objmgr_psoc *psoc, qdf_freq_t freq_1, + qdf_freq_t freq_2); + +/** + * policy_mgr_is_current_hwmode_dbs() - Function to check if current HW mode is + * DBS + * + * @psoc: Pointer to Psoc + * + * This Function checks if current HW mode is DBS + * + * Return:True if current HW mode is DBS. * - * Return: true or false */ bool policy_mgr_is_current_hwmode_dbs(struct wlan_objmgr_psoc *psoc); +/** + * policy_mgr_is_current_hwmode_sbs() - Function to check if current HW mode is + * SBS + * + * @psoc: Pointer to Psoc + * + * This Function checks if current HW mode is SBS + * + * Return:True if current HW mode is SBS. + * + */ +bool policy_mgr_is_current_hwmode_sbs(struct wlan_objmgr_psoc *psoc); + /** * policy_mgr_is_dp_hw_dbs_2x2_capable() - if hardware is capable of dbs 2x2 * for Data Path. diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c index 79b2e1c107..70213f370f 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c @@ -42,6 +42,12 @@ /* invalid channel id. */ #define INVALID_CHANNEL_ID 0 +#define IS_FREQ_ON_MAC_ID(freq_range, freq, mac_id) \ + ((freq >= freq_range[mac_id].low_2ghz_freq && \ + freq <= freq_range[mac_id].high_2ghz_freq) || \ + (freq >= freq_range[mac_id].low_5ghz_freq && \ + freq <= freq_range[mac_id].high_5ghz_freq)) + /** * policy_mgr_debug_alert() - fatal error alert * @@ -952,7 +958,7 @@ policy_mgr_dump_curr_freq_range(struct policy_mgr_psoc_priv_obj *pm_ctx) freq_range[i].high_5ghz_freq); } -static void +void policy_mgr_dump_freq_range_per_mac(struct policy_mgr_freq_range *freq_range, enum policy_mgr_mode hw_mode) { @@ -1084,6 +1090,232 @@ QDF_STATUS policy_mgr_update_hw_mode_list(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_SUCCESS; } +static bool +policy_mgr_are_2_freq_in_freq_range(struct policy_mgr_psoc_priv_obj *pm_ctx, + struct policy_mgr_freq_range *freq_range, + qdf_freq_t freq_1, qdf_freq_t freq_2) +{ + uint8_t i; + + for (i = 0; i < MAX_MAC; i++) { + if (IS_FREQ_ON_MAC_ID(freq_range, freq_1, i) && + IS_FREQ_ON_MAC_ID(freq_range, freq_2, i)) + return true; + } + + return false; +} + +bool policy_mgr_are_2_freq_on_same_mac(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq_1, + qdf_freq_t freq_2) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_freq_range *freq_range; + struct policy_mgr_hw_mode_params hw_mode; + QDF_STATUS status; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) + return false; + + /* if HW is not DBS return true*/ + if (!policy_mgr_is_hw_dbs_capable(psoc)) + return true; + + policy_mgr_debug("freq_1 %d freq_2 %d", freq_1, freq_2); + if (!policy_mgr_is_hw_sbs_capable(psoc)) { + /* If not SBS capable but DBS capable */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_DBS); + return policy_mgr_are_2_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2); + } + + /* HW is DBS/SBS capable */ + status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); + if (!QDF_IS_STATUS_SUCCESS(status)) { + policy_mgr_err("policy_mgr_get_current_hw_mode failed"); + return false; + } + + policy_mgr_debug("dbs_cap %d sbs_cap %d", hw_mode.dbs_cap, + hw_mode.sbs_cap); + policy_mgr_dump_curr_freq_range(pm_ctx); + freq_range = pm_ctx->hw_mode.cur_mac_freq_range; + /* current HW is DBS OR SBS check current DBS/SBS freq range */ + if (hw_mode.dbs_cap || hw_mode.sbs_cap) + return policy_mgr_are_2_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2); + + /* + * Current HW is SMM check, if they can lead to SBS or DBS without being + * in same mac, return true only if Both will lead to same mac + */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_SBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_SBS); + if (!policy_mgr_are_2_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2)) + return false; + + /* + * If SBS lead to same mac, check if DBS mode will also lead to same + * mac + */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_DBS); + + return policy_mgr_are_2_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2); +} + +static bool +policy_mgr_are_3_freq_in_freq_range(struct policy_mgr_psoc_priv_obj *pm_ctx, + struct policy_mgr_freq_range *freq_range, + qdf_freq_t freq_1, qdf_freq_t freq_2, + qdf_freq_t freq_3) +{ + uint8_t i; + + for (i = 0 ; i < MAX_MAC; i++) { + if (IS_FREQ_ON_MAC_ID(freq_range, freq_1, i) && + IS_FREQ_ON_MAC_ID(freq_range, freq_2, i) && + IS_FREQ_ON_MAC_ID(freq_range, freq_3, i)) + return true; + } + + return false; +} + +bool +policy_mgr_are_3_freq_on_same_mac(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq_1, qdf_freq_t freq_2, + qdf_freq_t freq_3) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_freq_range *freq_range; + QDF_STATUS status; + struct policy_mgr_hw_mode_params hw_mode; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) + return false; + + /* if HW is not DBS return true*/ + if (!policy_mgr_is_hw_dbs_capable(psoc)) + return true; + + policy_mgr_debug("freq_1 %d freq_2 %d freq_3 %d", freq_1, freq_2, + freq_3); + if (!policy_mgr_is_hw_sbs_capable(psoc)) { + /* If not SBS capable but DBS capable */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_DBS); + return policy_mgr_are_3_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2, + freq_3); + } + + /* HW is DBS/SBS capable, get current HW mode */ + status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); + if (!QDF_IS_STATUS_SUCCESS(status)) { + policy_mgr_err("policy_mgr_get_current_hw_mode failed"); + return false; + } + + policy_mgr_debug("dbs_cap %d sbs_cap %d", hw_mode.dbs_cap, + hw_mode.sbs_cap); + policy_mgr_dump_curr_freq_range(pm_ctx); + freq_range = pm_ctx->hw_mode.cur_mac_freq_range; + + /* current HW is DBS OR SBS check current DBS/SBS freq range */ + if (hw_mode.dbs_cap || hw_mode.sbs_cap) + return policy_mgr_are_3_freq_in_freq_range(pm_ctx, freq_range, + freq_1, freq_2, + freq_3); + /* + * Current HW is SMM check, if they can lead to SBS or DBS without being + * in same mac, return true only if both will lead to same mac + */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_SBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_SBS); + if (!policy_mgr_are_3_freq_in_freq_range(pm_ctx, freq_range, freq_1, + freq_2, freq_3)) + return false; + /* + * If SBS lead to same mac, check if DBS mode will also lead to same mac + */ + freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_DBS]; + policy_mgr_dump_freq_range_per_mac(freq_range, MODE_DBS); + + return policy_mgr_are_3_freq_in_freq_range(pm_ctx, freq_range, freq_1, + freq_2, freq_3); +} + +bool policy_mgr_are_sbs_chan(struct wlan_objmgr_psoc *psoc, qdf_freq_t freq_1, + qdf_freq_t freq_2) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_freq_range *sbs_freq_range; + + pm_ctx = policy_mgr_get_context(psoc); + + if (!pm_ctx) + return false; + + if (!policy_mgr_is_hw_sbs_capable(psoc)) + return false; + + policy_mgr_debug("freq_1 %d freq_2 %d", freq_1, freq_2); + + if (WLAN_REG_IS_24GHZ_CH_FREQ(freq_1) || + WLAN_REG_IS_24GHZ_CH_FREQ(freq_2)) + return false; + + sbs_freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_SBS]; + policy_mgr_dump_freq_range_per_mac(sbs_freq_range, MODE_SBS); + + return !policy_mgr_are_2_freq_in_freq_range(pm_ctx, sbs_freq_range, + freq_1, freq_2); +} + +static bool +policy_mgr_is_cur_freq_range_sbs(struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_freq_range *freq_range, *sbs_freq_range; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) + return false; + + policy_mgr_dump_curr_freq_range(pm_ctx); + freq_range = pm_ctx->hw_mode.cur_mac_freq_range; + sbs_freq_range = pm_ctx->hw_mode.freq_range_caps[MODE_SBS]; + + if (!qdf_mem_cmp(freq_range, sbs_freq_range, sizeof(freq_range))) + return true; + + return false; +} + +bool policy_mgr_is_current_hwmode_sbs(struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_hw_mode_params hw_mode; + + if (!policy_mgr_is_hw_sbs_capable(psoc)) + return false; + + if (QDF_STATUS_SUCCESS != + policy_mgr_get_current_hw_mode(psoc, &hw_mode)) + return false; + + if (hw_mode.sbs_cap && policy_mgr_is_cur_freq_range_sbs(psoc)) + return true; + + return false; +} + void policy_mgr_init_dbs_hw_mode(struct wlan_objmgr_psoc *psoc, uint32_t num_dbs_hw_modes, uint32_t *ev_wlan_dbs_hw_mode_list) @@ -1430,6 +1662,31 @@ bool policy_mgr_is_hw_dbs_capable(struct wlan_objmgr_psoc *psoc) return true; } +bool policy_mgr_is_current_hwmode_dbs(struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_hw_mode_params hw_mode; + + if (!policy_mgr_is_hw_dbs_capable(psoc)) + return false; + + if (QDF_STATUS_SUCCESS != policy_mgr_get_current_hw_mode(psoc, + &hw_mode)) + return false; + + if (!hw_mode.dbs_cap) + return false; + + /* sbs is not enabled and dbs_cap is set return true */ + if (!policy_mgr_is_hw_sbs_capable(psoc)) + return true; + + /* sbs is enabled and dbs_cap is set then check the freq range */ + if (!policy_mgr_is_cur_freq_range_sbs(psoc)) + return true; + + return false; +} + bool policy_mgr_is_pcl_weightage_required(struct wlan_objmgr_psoc *psoc) { struct wlan_mlme_psoc_ext_obj *mlme_obj; @@ -1599,20 +1856,6 @@ QDF_STATUS policy_mgr_get_current_hw_mode(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_SUCCESS; } -bool policy_mgr_is_current_hwmode_dbs(struct wlan_objmgr_psoc *psoc) -{ - struct policy_mgr_hw_mode_params hw_mode; - - if (!policy_mgr_is_hw_dbs_capable(psoc)) - return false; - if (QDF_STATUS_SUCCESS != - policy_mgr_get_current_hw_mode(psoc, &hw_mode)) - return false; - if (hw_mode.dbs_cap) - return true; - return false; -} - bool policy_mgr_is_dbs_enable(struct wlan_objmgr_psoc *psoc) { struct policy_mgr_psoc_priv_obj *pm_ctx; diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h index d954ee1558..2bd1939c23 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h @@ -681,6 +681,23 @@ enum policy_mgr_conc_next_action QDF_STATUS policy_mgr_reset_sap_mandatory_channels( struct policy_mgr_psoc_priv_obj *pm_ctx); +/** + * policy_mgr_update_hw_mode_list() - Function to print frequency range + * for both MAC 0 and MAC1 for given Hw mode + * + * @freq_range: Policy Mgr context + * @hw_mode: HW mode + * + * This Function will print frequency range for both MAC 0 and MAC1 for given + * Hw mode + * + * Return: void + * + */ +void +policy_mgr_dump_freq_range_per_mac(struct policy_mgr_freq_range *freq_range, + enum policy_mgr_mode hw_mode); + /** * policy_mgr_fill_curr_mac_freq_by_hwmode() - Fill Current Mac frequency with * the frequency range of the given Hw Mode @@ -702,7 +719,7 @@ policy_mgr_fill_curr_mac_freq_by_hwmode(struct policy_mgr_psoc_priv_obj *pm_ctx, * * @pm_ctx: Policy Mgr context * - * This function to Function to print every frequency range + * This function will print every frequency range * for both MAC 0 and MAC1 for every Hw mode * * Return: void @@ -717,7 +734,7 @@ policy_mgr_dump_freq_range(struct policy_mgr_psoc_priv_obj *pm_ctx); * * @pm_ctx: Policy Mgr context * - * This function to Function to print current frequency range + * This function will print current frequency range * for both MAC 0 and MAC1 for every Hw mode * * Return: void