From b79fb55f0eb2337b5ac1f8fd4747acd380c19a6e Mon Sep 17 00:00:00 2001 From: Nitesh Shah Date: Wed, 26 Apr 2017 20:02:34 +0530 Subject: [PATCH] qcacmn: Get channel properly from conc_connection_list table The channel information is obtained from the conc_connetion_list table using the index equal to the session_id. But the session in conc_connection_list table is not kept in the increasing order of session_id. Thus, the wrong channel information can be obtained. Thus, the fix is to obtain the channel information from the conc_connection_list table corresponding to the index whose vdev_id matches the session_id. Change-Id: If289ea7c0567b892dba495b878540f9cb5df5668 CRs-Fixed: 2039474 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 13 ++++++ .../src/wlan_policy_mgr_get_set_utils.c | 46 +++++++++++++++++-- 2 files changed, 55 insertions(+), 4 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 803f0df633e9..53cf435021fb 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 @@ -1180,6 +1180,19 @@ bool policy_mgr_is_any_mode_active_on_band_along_with_session( struct wlan_objmgr_psoc *psoc, uint8_t session_id, enum policy_mgr_band band); +/** + * policy_mgr_get_chan_by_session_id() - Get channel for a given session ID + * @psoc: PSOC object information + * @session_id: Session ID + * @chan: Pointer to the channel + * + * Gets the channel for a given session ID + * + * Return: QDF_STATUS + */ +QDF_STATUS policy_mgr_get_chan_by_session_id(struct wlan_objmgr_psoc *psoc, + uint8_t session_id, uint8_t *chan); + /** * policy_mgr_get_mac_id_by_session_id() - Get MAC ID for a given session ID * @psoc: PSOC object information 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 9af7f9cda062..a9885f68a7cc 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 @@ -2219,6 +2219,32 @@ send_status: return status; } +QDF_STATUS policy_mgr_get_chan_by_session_id(struct wlan_objmgr_psoc *psoc, + uint8_t session_id, uint8_t *chan) +{ + uint32_t i; + 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_E_FAILURE; + } + + 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 == session_id) && + (pm_conc_connection_list[i].in_use)) { + *chan = pm_conc_connection_list[i].chan; + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + return QDF_STATUS_SUCCESS; + } + } + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + + return QDF_STATUS_E_FAILURE; +} + QDF_STATUS policy_mgr_get_mac_id_by_session_id(struct wlan_objmgr_psoc *psoc, uint8_t session_id, uint8_t *mac_id) { @@ -2250,7 +2276,8 @@ QDF_STATUS policy_mgr_get_mcc_session_id_on_mac(struct wlan_objmgr_psoc *psoc, uint8_t *mcc_session_id) { uint32_t i; - uint8_t chan = pm_conc_connection_list[session_id].chan; + QDF_STATUS status; + uint8_t chan; struct policy_mgr_psoc_priv_obj *pm_ctx; pm_ctx = policy_mgr_get_context(psoc); @@ -2259,6 +2286,13 @@ QDF_STATUS policy_mgr_get_mcc_session_id_on_mac(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_FAILURE; } + status = policy_mgr_get_chan_by_session_id(psoc, session_id, &chan); + if (QDF_IS_STATUS_ERROR(status)) { + policy_mgr_err("Failed to get channel for session id:%d", + session_id); + return QDF_STATUS_E_FAILURE; + } + 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].mac != mac_id) @@ -2305,9 +2339,13 @@ uint8_t policy_mgr_get_mcc_operating_channel(struct wlan_objmgr_psoc *psoc, return INVALID_CHANNEL_ID; } - qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); - chan = pm_conc_connection_list[mcc_session_id].chan; - qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + status = policy_mgr_get_chan_by_session_id(psoc, mcc_session_id, + &chan); + if (QDF_IS_STATUS_ERROR(status)) { + policy_mgr_err("Failed to get channel for MCC session ID:%d", + mcc_session_id); + return INVALID_CHANNEL_ID; + } return chan; }