From 327f9b6998f7bd9db63139a6d8793e95fe1a9458 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Sirasanagandla Date: Mon, 10 Sep 2018 19:13:35 +0530 Subject: [PATCH] qcacld-3.0: Add support to store vdev object in sap context Add support to store vdev object in sap context and acquire and release its reference count during sap_set_session_param() and sap_clear_session_param() respectively. Change-Id: I61ab4a443ed2de5c58b62012a08c106aee7909d7 CRs-Fixed: 2312356 --- core/sap/src/sap_fsm.c | 47 +++++++++++++++++++++++++++++++++++++ core/sap/src/sap_internal.h | 27 +++++++++++++++++++++ core/sap/src/sap_module.c | 2 ++ 3 files changed, 76 insertions(+) diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 1fa5bd429699..285f82eb0971 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -1215,11 +1215,47 @@ static QDF_STATUS sap_clear_global_dfs_param(tHalHandle hal) return QDF_STATUS_SUCCESS; } +QDF_STATUS sap_acquire_vdev_ref(tpAniSirGlobal mac, + struct sap_context *sap_ctx, + uint8_t session_id) +{ + struct wlan_objmgr_vdev *vdev; + + if (sap_ctx->vdev) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("Invalid vdev obj in sap context")); + return QDF_STATUS_E_FAULT; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac->psoc, + session_id, + WLAN_LEGACY_SAP_ID); + if (!vdev) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + FL("vdev is NULL for vdev_id: %u"), session_id); + return QDF_STATUS_E_FAILURE; + } + + sap_ctx->vdev = vdev; + return QDF_STATUS_SUCCESS; +} + +void sap_release_vdev_ref(struct sap_context *sap_ctx) +{ + struct wlan_objmgr_vdev *vdev; + + vdev = sap_ctx->vdev; + sap_ctx->vdev = NULL; + if (vdev) + wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SAP_ID); +} + QDF_STATUS sap_set_session_param(tHalHandle hal, struct sap_context *sapctx, uint32_t session_id) { tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); int i; + QDF_STATUS status; sapctx->sessionId = session_id; sapctx->is_pre_cac_on = false; @@ -1231,6 +1267,15 @@ QDF_STATUS sap_set_session_param(tHalHandle hal, struct sap_context *sapctx, if (mac_ctx->sap.sapCtxList[i].sap_context == sapctx) mac_ctx->sap.sapCtxList[i].sap_context = NULL; } + + status = sap_acquire_vdev_ref(mac_ctx, sapctx, session_id); + if (!QDF_IS_STATUS_SUCCESS(status)) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("sap context init failed for session_id: %u"), + session_id); + return status; + } + mac_ctx->sap.sapCtxList[sapctx->sessionId].sessionID = sapctx->sessionId; mac_ctx->sap.sapCtxList[sapctx->sessionId].sap_context = sapctx; @@ -1251,6 +1296,8 @@ QDF_STATUS sap_clear_session_param(tHalHandle hal, struct sap_context *sapctx, if (sapctx->sessionId >= SAP_MAX_NUM_SESSION) return QDF_STATUS_E_FAILURE; + sap_release_vdev_ref(sapctx); + mac_ctx->sap.sapCtxList[sapctx->sessionId].sessionID = CSR_SESSION_ID_INVALID; mac_ctx->sap.sapCtxList[sapctx->sessionId].sap_context = NULL; diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 24996ee90d4f..97b5d7d8de78 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -137,6 +137,9 @@ struct sap_context { /* Include the SME(CSR) sessionId here */ uint8_t sessionId; + /* vdev object corresponding to sessionId */ + struct wlan_objmgr_vdev *vdev; + /* Include the associations MAC addresses */ uint8_t self_mac_addr[CDS_MAC_ADDRESS_LEN]; @@ -479,6 +482,30 @@ uint8_t sap_channel_in_acs_channel_list(uint8_t channel_num, struct sap_context *sap_ctx, tSapChSelSpectInfo *spect_info_params); +/** + * sap_acquire_vdev_ref() - Increment reference count for vdev object + * @mac: mac handle + * @sap_ctx: to store vdev object pointer + * @session_id: used to get vdev object + * + * This function is used to increment vdev object reference count and store + * vdev pointer in sap_ctx. + * + * Return: QDF_STATUS_SUCCESS - If able to get vdev object reference + * else qdf status failure codes + */ +QDF_STATUS sap_acquire_vdev_ref(tpAniSirGlobal mac, + struct sap_context *sap_ctx, + uint8_t session_id); + +/** + * sap_release_vdev_ref() - Decrement reference count for vdev object + * @sap_ctx: for which vdev reference is to be decremented + * + * Return: None + */ +void sap_release_vdev_ref(struct sap_context *sap_ctx); + #ifdef __cplusplus } #endif diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index ff5a56681dae..89c40a10faab 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -2619,6 +2619,8 @@ QDF_STATUS wlansap_set_invalid_session(struct sap_context *sap_ctx) return QDF_STATUS_E_FAILURE; } + sap_release_vdev_ref(sap_ctx); + sap_ctx->sessionId = CSR_SESSION_ID_INVALID; return QDF_STATUS_SUCCESS;