From 3c629905cc9eeb420572ee5702137a235ee5c592 Mon Sep 17 00:00:00 2001 From: Krishna Reddy Date: Fri, 5 Jul 2019 12:42:29 +0530 Subject: [PATCH] qcacld-3.0: Prevent 2.4G connection when SAP is on DFS channel On single MAC devices, when a SAP or P2P-GO is already operating on a DFS channel, MCC mode is not allowed. It is currently possible, even with a SAP on DFS channel, to connect to a 2.4G AP using the command: iw interface connect SSID [AP freq] Add additional checks in policy manager to prevent this MCC situation. Change-Id: I9adf063fbc1cb4c2d3f22f6b4d1bb00beb079007 CRs-Fixed: 2485436 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 12 ++++ .../src/wlan_policy_mgr_get_set_utils.c | 58 ++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) 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 7796d6ef4fbe..f14630fcb3a8 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 @@ -1986,6 +1986,18 @@ void policy_mgr_hw_mode_transition_cb(uint32_t old_hw_mode_index, */ bool policy_mgr_current_concurrency_is_mcc(struct wlan_objmgr_psoc *psoc); +/** + * policy_mgr_is_sap_p2pgo_on_dfs() - check if there is a P2PGO or SAP + * operating in a DFS channel + * @psoc: PSOC object information + * This routine is called to check if there is a P2PGO/SAP on DFS channel + * + * Return: True - P2PGO/SAP present on DFS Channel + * False - Otherwise + */ + +bool policy_mgr_is_sap_p2pgo_on_dfs(struct wlan_objmgr_psoc *psoc); + /** * policy_mgr_register_sme_cb() - register SME callbacks * @psoc: PSOC object information 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 85b3489fdb6c..92da8c306113 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 @@ -1455,6 +1455,51 @@ bool policy_mgr_current_concurrency_is_mcc(struct wlan_objmgr_psoc *psoc) return is_mcc; } +bool policy_mgr_is_sap_p2pgo_on_dfs(struct wlan_objmgr_psoc *psoc) +{ + int index, count; + uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS]; + struct policy_mgr_psoc_priv_obj *pm_ctx = NULL; + + if (psoc) + pm_ctx = policy_mgr_get_context(psoc); + + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return false; + } + + index = 0; + qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); + count = policy_mgr_mode_specific_connection_count(psoc, + PM_SAP_MODE, + list); + while (index < count) { + if (wlan_reg_is_dfs_ch(pm_ctx->pdev, + pm_conc_connection_list + [list[index]].chan)){ + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return true; + } + index++; + } + count = policy_mgr_mode_specific_connection_count(psoc, + PM_P2P_GO_MODE, + list); + index = 0; + while (index < count) { + if (wlan_reg_is_dfs_ch(pm_ctx->pdev, + pm_conc_connection_list + [list[index]].chan)){ + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return true; + } + index++; + } + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return false; +} + /** * policy_mgr_set_concurrency_mode() - To set concurrency mode * @psoc: PSOC object data @@ -2045,6 +2090,9 @@ bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc, * DFS channel then allow concurrency but make sure it is * going to DBS and send PCL to firmware indicating that * don't allow STA to roam to 5G channels. + * 4) On a single MAC device, if a SAP/P2PGO is already on a DFS + * channel, don't allow a 2 channel as it will result + * in MCC which is not allowed. */ if (!policy_mgr_is_5g_channel_allowed(psoc, channel, list, PM_P2P_GO_MODE)) @@ -2067,6 +2115,15 @@ bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc, policy_mgr_err("No MCC, SAP/GO about to come up on DFS channel"); goto done; } + if ((policy_mgr_is_hw_dbs_capable(psoc) != true) && + num_connections) { + if (WLAN_REG_IS_24GHZ_CH(channel)) { + if (policy_mgr_is_sap_p2pgo_on_dfs(psoc)) { + policy_mgr_err("MCC not allowed: SAP/P2PGO on DFS"); + goto done; + } + } + } } count = policy_mgr_mode_specific_connection_count(psoc, PM_STA_MODE, @@ -2176,7 +2233,6 @@ bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc, policy_mgr_err("This concurrency combination is not allowed"); goto done; } - /* don't allow two P2P GO on same band */ if (channel && (mode == PM_P2P_GO_MODE) && num_connections) { index = 0;