From 948e2bfa0a09e9cf55fd50826d664dcf6a678245 Mon Sep 17 00:00:00 2001 From: Srinivas Girigowda Date: Tue, 13 Apr 2021 18:42:48 -0700 Subject: [PATCH] qcacld-3.0: Add support to reject TWT setup incase of concurrency Add support to reject TWT setup request if received when the below mentioned concurrency scenario exists. STA + SAP: SCC or MCC: Reject TWT setup STA + P2P: SCC or MCC: Reject TWT setup Change-Id: I5c4c2bcc032276a0b83b7a46a44dbf7933cda29f CRs-Fixed: 2923726 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 14 ++++++++ .../src/wlan_policy_mgr_get_set_utils.c | 36 +++++++++++++++++++ core/hdd/src/wlan_hdd_twt.c | 12 +++++++ 3 files changed, 62 insertions(+) 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 06924330bcd3..eb4b9156bf32 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 @@ -1637,6 +1637,20 @@ void policy_mgr_set_dual_mac_scan_config(struct wlan_objmgr_psoc *psoc, void policy_mgr_set_dual_mac_fw_mode_config(struct wlan_objmgr_psoc *psoc, uint8_t dbs, uint8_t dfs); +/** + * policy_mgr_is_scc_with_this_vdev_id() - Check if this vdev_id has SCC with + * other vdev_id's + * @psoc: PSOC object information + * @vdev_id: vdev_id + * + * This function checks if the given vdev_id has SCC with any other vdev's + * or not. + * + * Return: true if SCC exists, false otherwise + */ +bool policy_mgr_is_scc_with_this_vdev_id(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id); + /** * policy_mgr_soc_set_dual_mac_cfg_cb() - Callback for set dual mac config * @status: Status of set dual mac config 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 32a06d89ff8e..5bf580fd7a70 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 @@ -1573,6 +1573,42 @@ void policy_mgr_set_dual_mac_fw_mode_config(struct wlan_objmgr_psoc *psoc, policy_mgr_err("sme_soc_set_dual_mac_config failed %d", status); } +bool policy_mgr_is_scc_with_this_vdev_id(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + uint32_t i, ch_freq; + QDF_STATUS status = QDF_STATUS_E_FAILURE; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return false; + } + + /* Get the channel freq for a given vdev_id */ + status = policy_mgr_get_chan_by_session_id(psoc, vdev_id, + &ch_freq); + if (QDF_IS_STATUS_ERROR(status)) { + policy_mgr_err("Failed to get channel for vdev:%d", vdev_id); + return false; + } + + /* Compare given vdev_id freq against other vdev_id's */ + qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); + for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { + if ((pm_conc_connection_list[i].vdev_id != vdev_id) && + (pm_conc_connection_list[i].in_use) && + (pm_conc_connection_list[i].freq == ch_freq)) { + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return true; + } + } + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + + return false; +} + bool policy_mgr_current_concurrency_is_mcc(struct wlan_objmgr_psoc *psoc) { uint32_t num_connections = 0; diff --git a/core/hdd/src/wlan_hdd_twt.c b/core/hdd/src/wlan_hdd_twt.c index c7a7d14199b3..80bffd1b5802 100644 --- a/core/hdd/src/wlan_hdd_twt.c +++ b/core/hdd/src/wlan_hdd_twt.c @@ -1372,6 +1372,13 @@ int hdd_send_twt_add_dialog_cmd(struct hdd_context *hdd_ctx, return ret; } +static bool hdd_twt_setup_conc_allowed(struct hdd_context *hdd_ctx, + uint8_t vdev_id) +{ + return policy_mgr_current_concurrency_is_mcc(hdd_ctx->psoc) || + policy_mgr_is_scc_with_this_vdev_id(hdd_ctx->psoc, vdev_id); +} + /** * hdd_twt_setup_session() - Process TWT setup operation in the * received vendor command and send it to firmare @@ -1417,6 +1424,11 @@ static int hdd_twt_setup_session(struct hdd_adapter *adapter, if (hdd_is_roaming_in_progress(hdd_ctx)) return -EBUSY; + if (hdd_twt_setup_conc_allowed(hdd_ctx, adapter->vdev_id)) { + hdd_err_rl("TWT setup reject: SCC or MCC concurrency exists"); + return -EAGAIN; + } + qdf_mem_copy(params.peer_macaddr, hdd_sta_ctx->conn_info.bssid.bytes, QDF_MAC_ADDR_SIZE);