From 497e83eeeae2a303e10638dc9178b313b1d4e942 Mon Sep 17 00:00:00 2001 From: Himanshu Agarwal Date: Wed, 24 Jan 2018 17:41:05 +0530 Subject: [PATCH] qcacmn: Add support to get objmgr pdev from scn handle Add support to get objmgr pdev from scn handle in wmi event handler functions. Change-Id: I9003692958bf5ae47b6054f1ef8a0d6d3e33193b CRs-Fixed: 2178124 --- target_if/core/inc/target_if.h | 28 +++++++++++++++++++++++++- target_if/core/src/target_if_main.c | 31 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/target_if/core/inc/target_if.h b/target_if/core/inc/target_if.h index eeeb41bb31..b4b9687533 100644 --- a/target_if/core/inc/target_if.h +++ b/target_if/core/inc/target_if.h @@ -64,6 +64,9 @@ typedef struct wlan_objmgr_psoc *(*get_psoc_handle_callback)( void *scn_handle); +typedef struct wlan_objmgr_pdev *(*get_pdev_handle_callback)( + void *scn_handle); + typedef int (*wmi_legacy_service_ready_callback)(uint32_t event_id, void *handle, uint8_t *event_data, @@ -72,12 +75,14 @@ typedef int (*wmi_legacy_service_ready_callback)(uint32_t event_id, /** * struct target_if_ctx - target_interface context * @magic: magic for target if ctx - * @get_wmi_handle: function pointer to get wmi handle + * @get_psoc_hdl_cb: function pointer to get psoc + * @get_pdev_hdl_cb: function pointer to get pdev * @lock: spin lock for protecting the ctx */ struct target_if_ctx { uint32_t magic; get_psoc_handle_callback get_psoc_hdl_cb; + get_pdev_handle_callback get_pdev_hdl_cb; wmi_legacy_service_ready_callback service_ready_cb; qdf_spinlock_t lock; }; @@ -293,6 +298,15 @@ QDF_STATUS target_if_open(get_psoc_handle_callback psoc_hdl_cb); */ QDF_STATUS target_if_close(void); +/** + * target_if_store_pdev_target_if_ctx() - stores objmgr pdev in target if ctx + * @pdev_hdl_cb: function pointer to get objmgr pdev + * + * Return: QDF_STATUS_SUCCESS - in case of success + */ +QDF_STATUS target_if_store_pdev_target_if_ctx( + get_pdev_handle_callback pdev_hdl_cb); + /** * wlan_get_tgt_if_ctx() -Get target if ctx * @@ -312,6 +326,18 @@ struct target_if_ctx *target_if_get_ctx(void); */ struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle); +/** + * target_if_get_pdev_from_scn_hdl() - get pdev from scn handle + * @scn_handle: scn handle + * + * This API is generally used while processing wmi event. + * In wmi event SCN handle will be passed by wmi hence + * using this API we can get pdev from scn handle. + * + * Return: pdev for matching scn handle + */ +struct wlan_objmgr_pdev *target_if_get_pdev_from_scn_hdl(void *scn_handle); + /** target_if_register_tx_ops() - register tx_ops * @tx_ops: tx_ops structure * diff --git a/target_if/core/src/target_if_main.c b/target_if/core/src/target_if_main.c index 1a8981b618..0cbb7ab288 100644 --- a/target_if/core/src/target_if_main.c +++ b/target_if/core/src/target_if_main.c @@ -94,6 +94,20 @@ struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle) return psoc; } +struct wlan_objmgr_pdev *target_if_get_pdev_from_scn_hdl(void *scn_handle) +{ + struct wlan_objmgr_pdev *pdev; + + qdf_spin_lock_bh(&g_target_if_ctx->lock); + if (scn_handle && g_target_if_ctx->get_pdev_hdl_cb) + pdev = g_target_if_ctx->get_pdev_hdl_cb(scn_handle); + else + pdev = NULL; + qdf_spin_unlock_bh(&g_target_if_ctx->lock); + + return pdev; +} + #ifdef DIRECT_BUF_RX_ENABLE static QDF_STATUS target_if_direct_buf_rx_init(void) { @@ -148,6 +162,7 @@ QDF_STATUS target_if_close(void) qdf_spin_lock_bh(&g_target_if_ctx->lock); g_target_if_ctx->magic = 0; g_target_if_ctx->get_psoc_hdl_cb = NULL; + g_target_if_ctx->get_pdev_hdl_cb = NULL; g_target_if_ctx->service_ready_cb = NULL; qdf_spin_unlock_bh(&g_target_if_ctx->lock); @@ -160,6 +175,22 @@ QDF_STATUS target_if_close(void) return QDF_STATUS_SUCCESS; } +QDF_STATUS target_if_store_pdev_target_if_ctx( + get_pdev_handle_callback pdev_hdl_cb) +{ + if (!g_target_if_ctx) { + QDF_ASSERT(0); + target_if_err("target if ctx is null"); + return QDF_STATUS_E_INVAL; + } + + qdf_spin_lock_bh(&g_target_if_ctx->lock); + g_target_if_ctx->get_pdev_hdl_cb = pdev_hdl_cb; + qdf_spin_unlock_bh(&g_target_if_ctx->lock); + + return QDF_STATUS_SUCCESS; +} + #ifndef WLAN_OFFCHAN_TXRX_ENABLE static void target_if_offchan_txrx_ops_register( struct wlan_lmac_if_tx_ops *tx_ops)