From ca919bd184b8508c0f919c2f3a3e6a1a4504a0af Mon Sep 17 00:00:00 2001 From: Nitesh Shah Date: Wed, 7 Jun 2017 15:25:07 +0530 Subject: [PATCH] qcacmn: Validate mode and vdev while decrementing session The function policy_mgr_decr_active_session() decrements mode and then remove the session from the pm_conn_connection_info table after validating vdev. This change adds a check to validate if the session is present with specific mode and vdev_id, and then decrement the session. If not present, then return without doing any change. Change-Id: If53d7fc9356b2c3bb72b22b228103389396910ce CRs-Fixed: 2057599 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 20 ++++++++- .../src/wlan_policy_mgr_get_set_utils.c | 44 ++++++++++++++++++- .../policy_mgr/src/wlan_policy_mgr_pcl.c | 7 ++- 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index 728d32eb7f..6c18c484ed 100644 --- a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -245,9 +245,9 @@ void policy_mgr_incr_active_session(struct wlan_objmgr_psoc *psoc, * mode. In the case of STA/P2P CLI/IBSS upon disconnection it is decremented * In the case of SAP/P2P GO upon bss stop it is decremented * - * Return: None + * Return: QDF_STATUS */ -void policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, +QDF_STATUS policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, enum tQDF_ADAPTER_MODE mode, uint8_t sessionId); /** @@ -1360,6 +1360,22 @@ uint32_t policy_mgr_mode_specific_connection_count( struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode, uint32_t *list); +/** + * policy_mgr_check_conn_with_mode_and_vdev_id() - checks if any active + * session with specific mode and vdev_id + * @psoc: PSOC object information + * @mode: type of connection + * @vdev_id: vdev_id of the connection + * + * This function checks if any active session with specific mode and vdev_id + * is present + * + * Return: QDF STATUS with success if active session is found, else failure + */ +QDF_STATUS policy_mgr_check_conn_with_mode_and_vdev_id( + struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode, + uint32_t vdev_id); + /** * policy_mgr_hw_mode_transition_cb() - Callback for HW mode * transition from FW diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c index 9d16bdd63c..2bdebb638c 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c @@ -838,6 +838,33 @@ uint32_t policy_mgr_mode_specific_connection_count( return count; } +QDF_STATUS policy_mgr_check_conn_with_mode_and_vdev_id( + struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode, + uint32_t vdev_id) +{ + QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; + uint32_t conn_index = 0; + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return qdf_status; + } + + qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); + while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { + if ((pm_conc_connection_list[conn_index].mode == mode) && + (pm_conc_connection_list[conn_index].vdev_id == vdev_id)) { + qdf_status = QDF_STATUS_SUCCESS; + break; + } + conn_index++; + } + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return qdf_status; +} + void policy_mgr_soc_set_dual_mac_cfg_cb(enum set_hw_mode_status status, uint32_t scan_config, uint32_t fw_mode_config) @@ -1122,16 +1149,27 @@ void policy_mgr_incr_active_session(struct wlan_objmgr_psoc *psoc, qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); } -void policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, +QDF_STATUS policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, enum tQDF_ADAPTER_MODE mode, uint8_t session_id) { struct policy_mgr_psoc_priv_obj *pm_ctx; + QDF_STATUS qdf_status; pm_ctx = policy_mgr_get_context(psoc); if (!pm_ctx) { policy_mgr_err("context is NULL"); - return; + return QDF_STATUS_E_EMPTY; + } + + qdf_status = policy_mgr_check_conn_with_mode_and_vdev_id(psoc, + policy_mgr_convert_device_mode_to_qdf_type(mode), + session_id); + if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { + policy_mgr_err("No connection with mode:%d vdev_id:%d", + policy_mgr_convert_device_mode_to_qdf_type(mode), + session_id); + return qdf_status; } switch (mode) { @@ -1157,6 +1195,8 @@ void policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, pm_ctx->tdls_cbacks.tdls_notify_decrement_session(psoc); policy_mgr_dump_current_concurrency(psoc); + + return qdf_status; } QDF_STATUS policy_mgr_incr_connection_count( diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c index ad0b2c9d06..6c2a697112 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c @@ -103,7 +103,12 @@ void policy_mgr_decr_session_set_pcl(struct wlan_objmgr_psoc *psoc, return; } - policy_mgr_decr_active_session(psoc, mode, session_id); + qdf_status = policy_mgr_decr_active_session(psoc, mode, session_id); + if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { + policy_mgr_err("Invalid active session"); + return; + } + /* * After the removal of this connection, we need to check if * a STA connection still exists. The reason for this is that