diff --git a/inc/wlan_policy_mgr_api.h b/inc/wlan_policy_mgr_api.h index c58f81812595..9b866395dabf 100644 --- a/inc/wlan_policy_mgr_api.h +++ b/inc/wlan_policy_mgr_api.h @@ -2391,4 +2391,17 @@ bool policy_mgr_dual_beacon_on_single_mac_mcc_capable( bool policy_mgr_sta_sap_scc_on_lte_coex_chan( struct wlan_objmgr_psoc *psoc); +/** + * policy_mgr_valid_channel_for_channel_switch() - check for valid channel for + * channel switch. + * @psoc: poniter to psoc + * @channel: channel to be validated. + * This function validates whether the given channel is valid for channel + * switch. + * + * Return: true or false + */ +bool policy_mgr_is_valid_for_channel_switch(struct wlan_objmgr_psoc *psoc, + uint8_t channel); + #endif /* __WLAN_POLICY_MGR_API_H */ diff --git a/src/wlan_policy_mgr_get_set_utils.c b/src/wlan_policy_mgr_get_set_utils.c index c43a06f0d489..fcc811dbf5c1 100644 --- a/src/wlan_policy_mgr_get_set_utils.c +++ b/src/wlan_policy_mgr_get_set_utils.c @@ -3104,3 +3104,37 @@ bool policy_mgr_sta_sap_scc_on_lte_coex_chan( } return pm_ctx->user_cfg.sta_sap_scc_on_lte_coex_chan; } + +bool policy_mgr_is_valid_for_channel_switch(struct wlan_objmgr_psoc *psoc, + uint8_t channel) +{ + uint32_t sta_sap_scc_on_dfs_chan; + uint32_t sap_count; + enum channel_state state; + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return false; + } + + sta_sap_scc_on_dfs_chan = + policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc); + sap_count = policy_mgr_mode_specific_connection_count(psoc, + PM_SAP_MODE, + NULL); + state = reg_get_channel_state(pm_ctx->pdev, channel); + + policy_mgr_debug("sta_sap_scc_on_dfs_chan %u, sap_count %u, channel %u, state %u", + sta_sap_scc_on_dfs_chan, sap_count, channel, state); + + if ((state == CHANNEL_STATE_ENABLE) || (sap_count == 0) || + ((state == CHANNEL_STATE_DFS) && sta_sap_scc_on_dfs_chan)) { + policy_mgr_debug("Valid channel for channel switch"); + return true; + } + + policy_mgr_debug("Invalid channel for channel switch"); + return false; +}