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 7da38039ddcf..fc15ea720391 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 @@ -3347,4 +3347,19 @@ bool policy_mgr_dump_channel_list(uint32_t len, uint32_t *pcl_channels, uint8_t *pcl_weight); +/** + * policy_mgr_is_restart_sap_required() - check whether sap need restart + * @psoc: psoc pointer + * @freq: sap current freq + * @scc_mode: mcc to scc switch mode + * + * If there is no STA/P2P CLI on same MAC of SAP/P2P GO, + * SAP/P2P Go needn't switch channel to force scc. + * + * Return: True or false + */ +bool policy_mgr_is_restart_sap_required(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq, + tQDF_MCC_TO_SCC_SWITCH_MODE scc_mode); + #endif /* __WLAN_POLICY_MGR_API_H */ 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 791ed6354a87..bd931665e7b0 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 @@ -4318,3 +4318,49 @@ bool policy_mgr_get_5g_scc_prefer( return pm_ctx->cfg.prefer_5g_scc_to_dbs & (1 << mode); } + +bool policy_mgr_is_restart_sap_required(struct wlan_objmgr_psoc *psoc, + qdf_freq_t freq, + tQDF_MCC_TO_SCC_SWITCH_MODE scc_mode) +{ + uint32_t i; + bool restart_required = false; + bool is_sta_p2p_cli; + bool is_same_band; + struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_conc_connection_info *connection; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid psoc"); + return false; + } + if (scc_mode == QDF_MCC_TO_SCC_SWITCH_DISABLE) { + policy_mgr_debug("No scc required"); + return false; + } + + qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); + connection = pm_conc_connection_list; + for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { + is_sta_p2p_cli = + connection[i].in_use && + (connection[i].mode == PM_STA_MODE || + connection[i].mode == PM_P2P_CLIENT_MODE); + + is_same_band = + wlan_reg_is_24ghz_ch_freq(freq) == + wlan_reg_is_24ghz_ch_freq(connection[i].freq) && + connection[i].freq != freq; + + if (is_sta_p2p_cli && + (is_same_band || !policy_mgr_is_dbs_enable(psoc))) { + restart_required = true; + break; + } + } + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + + return restart_required; +} + diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index a6f8e0c28aa9..ce654ca11330 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -3189,8 +3189,16 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart( hdd_debug("p2p go no scc required"); return QDF_STATUS_E_FAILURE; } + ucfg_policy_mgr_get_mcc_scc_switch(hdd_ctx->psoc, &mcc_to_scc_switch); + if (!policy_mgr_is_restart_sap_required(hdd_ctx->psoc, *ch_freq, + mcc_to_scc_switch)) { + wlansap_context_put(sap_context); + hdd_debug("SAP needn't restart"); + return QDF_STATUS_E_FAILURE; + } + /* * Check if STA's channel is DFS or passive or part of LTE avoided * channel list. In that case move SAP to other band if DBS is