diff --git a/disa/core/inc/wlan_disa_main.h b/disa/core/inc/wlan_disa_main.h index 0125b0cc6d..26caad4b70 100644 --- a/disa/core/inc/wlan_disa_main.h +++ b/disa/core/inc/wlan_disa_main.h @@ -84,13 +84,4 @@ QDF_STATUS disa_core_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, encrypt_decrypt_resp_callback cb, void *cookie); -/** - * disa_core_encrypt_decrypt_resp() - Collect encrypt/decrypt request resp - * @psoc: objmgr psoc object - * @resp: DISA encrypt/decrypt request response parameters - * - * Return: QDF status success or failure - */ -QDF_STATUS disa_core_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, - struct disa_encrypt_decrypt_resp_params *resp); #endif /* end of _WLAN_DISA_MAIN_H_ */ diff --git a/disa/core/inc/wlan_disa_priv.h b/disa/core/inc/wlan_disa_priv.h index 2ab76fa5a1..71107d194d 100644 --- a/disa/core/inc/wlan_disa_priv.h +++ b/disa/core/inc/wlan_disa_priv.h @@ -51,6 +51,7 @@ struct disa_psoc_priv_obj { struct wlan_disa_ctx { encrypt_decrypt_resp_callback callback; void *callback_context; + bool request_active; qdf_spinlock_t lock; }; diff --git a/disa/core/src/wlan_disa_main.c b/disa/core/src/wlan_disa_main.c index 9ace362023..73033944d7 100644 --- a/disa/core/src/wlan_disa_main.c +++ b/disa/core/src/wlan_disa_main.c @@ -28,11 +28,34 @@ static struct wlan_disa_ctx *gp_disa_ctx; QDF_STATUS disa_allocate_ctx(void) { + /* If it is already created, ignore */ + if (gp_disa_ctx != NULL) { + disa_debug("already allocated disa_ctx"); + return QDF_STATUS_SUCCESS; + } + + /* allocate DISA ctx */ + gp_disa_ctx = qdf_mem_malloc(sizeof(*gp_disa_ctx)); + if (!gp_disa_ctx) { + disa_err("unable to allocate disa_ctx"); + QDF_ASSERT(0); + return QDF_STATUS_E_NOMEM; + } + qdf_spinlock_create(&gp_disa_ctx->lock); + return QDF_STATUS_SUCCESS; } void disa_free_ctx(void) { + if (!gp_disa_ctx) { + disa_err("disa ctx is already freed"); + QDF_ASSERT(0); + return; + } + qdf_spinlock_destroy(&gp_disa_ctx->lock); + qdf_mem_free(gp_disa_ctx); + gp_disa_ctx = NULL; } struct wlan_disa_ctx *disa_get_context(void) @@ -45,11 +68,40 @@ QDF_STATUS disa_core_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, encrypt_decrypt_resp_callback cb, void *cookie) { - return tgt_disa_encrypt_decrypt_req(psoc, req); -} + struct wlan_disa_ctx *disa_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; -QDF_STATUS disa_core_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, - struct disa_encrypt_decrypt_resp_params *resp) -{ - return QDF_STATUS_SUCCESS; + DISA_ENTER(); + disa_ctx = disa_get_context(); + if (!disa_ctx) { + disa_err("DISA context is NULL!"); + return QDF_STATUS_E_INVAL; + } + + qdf_spin_lock_bh(&disa_ctx->lock); + if (!disa_ctx->request_active) { + disa_ctx->callback = cb; + disa_ctx->callback_context = cookie; + disa_ctx->request_active = true; + } else { + status = QDF_STATUS_E_INVAL; + } + qdf_spin_unlock_bh(&disa_ctx->lock); + + if (status != QDF_STATUS_SUCCESS) { + disa_err("A request is already active!"); + return status; + } + + status = disa_psoc_get_ref(psoc); + if (status != QDF_STATUS_SUCCESS) { + disa_err("DISA cannot get the reference out of psoc"); + return status; + } + + status = tgt_disa_encrypt_decrypt_req(psoc, req); + disa_psoc_put_ref(psoc); + + DISA_EXIT(); + return status; } diff --git a/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h b/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h index f8ecd174d1..2f4b0674a4 100644 --- a/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h +++ b/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h @@ -32,7 +32,14 @@ * * Return: QDF_STATUS_SUCCESS - in case of success else return error */ +#ifdef WLAN_FEATURE_DISA QDF_STATUS disa_init(void); +#else +static inline QDF_STATUS disa_init(void) +{ + return QDF_STATUS_SUCCESS; +} +#endif /** * disa_deinit() - unregister disa notification handlers. @@ -41,7 +48,44 @@ QDF_STATUS disa_init(void); * * Return: QDF_STATUS_SUCCESS - in case of success else return error */ +#ifdef WLAN_FEATURE_DISA QDF_STATUS disa_deinit(void); +#else +static inline QDF_STATUS disa_deinit(void) +{ + return QDF_STATUS_SUCCESS; +} +#endif + +/** + * disa_psoc_enable() - Trigger psoc enable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +#ifdef WLAN_FEATURE_DISA +QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc); +#else +static inline QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} +#endif + +/** + * disa_psoc_disable() - Trigger psoc disable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +#ifdef WLAN_FEATURE_DISA +QDF_STATUS disa_psoc_disable(struct wlan_objmgr_psoc *psoc); +#else +static inline QDF_STATUS disa_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} +#endif /** * disa_psoc_object_created_notification(): disa psoc create handler @@ -67,19 +111,4 @@ QDF_STATUS disa_psoc_object_created_notification( QDF_STATUS disa_psoc_object_destroyed_notification( struct wlan_objmgr_psoc *psoc, void *arg); -/** - * disa_psoc_enable() - Trigger psoc enable for DISA - * @psoc: objmgr psoc object - * - * Return: QDF status success or failure - */ -QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc); - -/** - * disa_psoc_disable() - Trigger psoc disable for DISA - * @psoc: objmgr psoc object - * - * Return: QDF status success or failure - */ -QDF_STATUS disa_psoc_disable(struct wlan_objmgr_psoc *psoc); #endif /* end of _WLAN_DISA_OBJ_MGMT_API_H_ */ diff --git a/disa/dispatcher/inc/wlan_disa_tgt_api.h b/disa/dispatcher/inc/wlan_disa_tgt_api.h index 9d07863b59..3360074b38 100644 --- a/disa/dispatcher/inc/wlan_disa_tgt_api.h +++ b/disa/dispatcher/inc/wlan_disa_tgt_api.h @@ -26,7 +26,7 @@ #include "wlan_disa_public_struct.h" #define GET_DISA_TX_OPS_FROM_VDEV(vedv) \ - (disa_psoc_get_priv(psoc)->disa_tx_ops) + (&disa_psoc_get_priv(psoc)->disa_tx_ops) /** * tgt_disa_encrypt_decrypt_req() - send encrypt/decrypt request to target if diff --git a/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c b/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c index 67bdaf210f..c28cebc209 100644 --- a/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c +++ b/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c @@ -193,7 +193,6 @@ QDF_STATUS disa_psoc_object_destroyed_notification( QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc) { return tgt_disa_register_ev_handlers(psoc); - } /** diff --git a/disa/dispatcher/src/wlan_disa_tgt_api.c b/disa/dispatcher/src/wlan_disa_tgt_api.c index 331e740042..5576ff1b60 100644 --- a/disa/dispatcher/src/wlan_disa_tgt_api.c +++ b/disa/dispatcher/src/wlan_disa_tgt_api.c @@ -33,7 +33,19 @@ QDF_STATUS tgt_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, struct disa_encrypt_decrypt_req_params *req) { - return QDF_STATUS_SUCCESS; + struct wlan_disa_tx_ops *disa_tx_ops; + QDF_STATUS status = QDF_STATUS_E_FAILURE; + + DISA_ENTER(); + + disa_tx_ops = GET_DISA_TX_OPS_FROM_VDEV(psoc); + QDF_ASSERT(disa_tx_ops->disa_encrypt_decrypt_req); + + if (disa_tx_ops->disa_encrypt_decrypt_req) + status = disa_tx_ops->disa_encrypt_decrypt_req(psoc, req); + + DISA_EXIT(); + return status; } /** @@ -47,6 +59,35 @@ QDF_STATUS tgt_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, QDF_STATUS tgt_disa_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, struct disa_encrypt_decrypt_resp_params *resp) { + struct wlan_disa_ctx *disa_ctx; + encrypt_decrypt_resp_callback cb; + void *cookie; + + DISA_ENTER(); + + if (!resp) { + disa_err("encrypt/decrypt resp is null"); + return QDF_STATUS_E_NULL_VALUE; + } + + disa_ctx = disa_get_context(); + if (!disa_ctx) { + disa_err("DISA context is NULL!"); + return QDF_STATUS_E_INVAL; + } + + qdf_spin_lock_bh(&disa_ctx->lock); + cb = disa_ctx->callback; + disa_ctx->callback = NULL; + cookie = disa_ctx->callback_context; + disa_ctx->callback_context = NULL; + disa_ctx->request_active = false; + qdf_spin_unlock_bh(&disa_ctx->lock); + + if (cb) + cb(cookie, resp); + + DISA_EXIT(); return QDF_STATUS_SUCCESS; } @@ -58,6 +99,15 @@ QDF_STATUS tgt_disa_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, */ QDF_STATUS tgt_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc) { + struct wlan_disa_tx_ops *disa_tx_ops; + + disa_tx_ops = GET_DISA_TX_OPS_FROM_VDEV(psoc); + + QDF_ASSERT(disa_tx_ops->disa_register_ev_handlers); + + if (disa_tx_ops->disa_register_ev_handlers) + return disa_tx_ops->disa_register_ev_handlers(psoc); + return QDF_STATUS_SUCCESS; } @@ -69,6 +119,15 @@ QDF_STATUS tgt_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc) */ QDF_STATUS tgt_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc) { + struct wlan_disa_tx_ops *disa_tx_ops; + + disa_tx_ops = GET_DISA_TX_OPS_FROM_VDEV(psoc); + + QDF_ASSERT(disa_tx_ops->disa_unregister_ev_handlers); + + if (disa_tx_ops->disa_unregister_ev_handlers) + return disa_tx_ops->disa_unregister_ev_handlers(psoc); + return QDF_STATUS_SUCCESS; } diff --git a/target_if/disa/src/target_if_disa.c b/target_if/disa/src/target_if_disa.c index 9f3face1bc..96a037f59c 100644 --- a/target_if/disa/src/target_if_disa.c +++ b/target_if/disa/src/target_if_disa.c @@ -29,29 +29,83 @@ int target_if_encrypt_decrypt_event_handler(ol_scn_t scn_handle, uint8_t *data, uint32_t data_len) { + struct disa_encrypt_decrypt_resp_params resp; + struct wlan_objmgr_psoc *psoc; + + if (data == NULL) { + target_if_err("%s: invalid pointer", __func__); + return -EINVAL; + } + + psoc = target_if_get_psoc_from_scn_hdl(scn_handle); + if (!psoc) { + target_if_err("psoc ptr is NULL"); + return -EINVAL; + } + + if (wmi_extract_encrypt_decrypt_resp_params( + GET_WMI_HDL_FROM_PSOC(psoc), + data, &resp) != QDF_STATUS_SUCCESS) { + target_if_err("Extraction of encrypt decrypt resp params failed"); + return -EINVAL; + } + + tgt_disa_encrypt_decrypt_resp(psoc, &resp); + return 0; } QDF_STATUS target_if_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc) { - return QDF_STATUS_SUCCESS; + QDF_STATUS status; + + status = wmi_unified_register_event(GET_WMI_HDL_FROM_PSOC(psoc), + wmi_vdev_encrypt_decrypt_data_rsp_event_id, + target_if_encrypt_decrypt_event_handler); + if (status) { + target_if_err("Failed to register Scan match event cb"); + return QDF_STATUS_E_FAILURE; + } + + return status; } QDF_STATUS target_if_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc) { - return QDF_STATUS_SUCCESS; + QDF_STATUS status; + + status = wmi_unified_unregister_event(GET_WMI_HDL_FROM_PSOC(psoc), + wmi_vdev_encrypt_decrypt_data_rsp_event_id); + if (status) { + target_if_err("Failed to unregister Scan match event cb"); + return QDF_STATUS_E_FAILURE; + } + + return status; } QDF_STATUS target_if_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, struct disa_encrypt_decrypt_req_params *req) { - return QDF_STATUS_SUCCESS; + return wmi_unified_encrypt_decrypt_send_cmd(GET_WMI_HDL_FROM_PSOC(psoc), + req); } void target_if_disa_register_tx_ops(struct wlan_disa_tx_ops *disa_tx_ops) { + if (!disa_tx_ops) { + target_if_err("disa_tx_ops is null"); + return; + } + + disa_tx_ops->disa_encrypt_decrypt_req = + target_if_disa_encrypt_decrypt_req; + disa_tx_ops->disa_register_ev_handlers = + target_if_disa_register_ev_handlers; + disa_tx_ops->disa_unregister_ev_handlers = + target_if_disa_unregister_ev_handlers; }