From 01dd33e9c7e331492b095bbcb5e624f1166a75af Mon Sep 17 00:00:00 2001 From: Govind Singh Date: Thu, 4 Feb 2016 18:42:30 +0530 Subject: [PATCH] qcacmn: Modify wmi handle and api for common wmi layer Modify wmi handle and wmi unified interface API for common wmi layer. Register UMAC callbacks using opaque callbacks. CRs-Fixed: 978579 Change-Id: I505fe4ac339213db30bb00695234c4cfea5a5908 --- wmi/inc/wmi_unified_api.h | 39 ++++++++++++++++++++++++------ wmi/inc/wmi_unified_priv.h | 5 ++++ wmi/src/wmi_unified.c | 49 +++++++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 21 deletions(-) diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index f96c128aa1..04cb185639 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -26,7 +26,8 @@ */ /* - * This file contains the API definitions for the Unified Wireless Module Interface (WMI). + * This file contains the API definitions for the Unified Wireless Module + * Interface (WMI). */ #ifndef _WMI_UNIFIED_API_H_ @@ -41,6 +42,32 @@ typedef cdf_nbuf_t wmi_buf_t; #define wmi_buf_data(_buf) cdf_nbuf_data(_buf) +/** + * struct wmi_ops - service callbacks to upper layer + * @service_ready_cbk: service ready callback + * @service_ready_ext_cbk: service ready ext callback + * @ready_cbk: ready calback + * @wma_process_fw_event_handler_cbk: generic event handler callback + */ +struct wmi_ops { + void (*service_ready_cbk)(void *ctx, void *ev); + void (*service_ready_ext_cbk)(void *ctx, void *ev); + void (*ready_cbk)(void *ctx, void *ev); + int (*wma_process_fw_event_handler_cbk)(void *ctx, + void *ev); +}; + +/** + * enum wmi_target_type - type of supported wmi command + * @WMI_TLV_TARGET: tlv based target + * @WMI_NON_TLV_TARGET: non-tlv based target + * + */ +enum wmi_target_type { + WMI_TLV_TARGET, + WMI_NON_TLV_TARGET +}; + /** * attach for unified WMI * @@ -48,7 +75,9 @@ typedef cdf_nbuf_t wmi_buf_t; * @return opaque handle. */ void *wmi_unified_attach(void *scn_handle, - int (*func)(struct wmi_unified *, wmi_buf_t)); + osdev_t osdev, enum wmi_target_type target_type, + bool use_cookie, struct wmi_ops *ops); + /** * detach for unified WMI * @@ -92,7 +121,7 @@ void wmi_buf_free(wmi_buf_t net_buf); * @return 0 on success and -ve on failure. */ int -wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, int buflen, +wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t buflen, WMI_CMD_ID cmd_id); /** @@ -168,13 +197,9 @@ static inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle) } #endif - /** * WMA Callback to process fw event. */ -typedef int (*wma_process_fw_event_handler_cbk)(struct wmi_unified *wmi_handle, - wmi_buf_t evt_buf); - void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf); uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle); #endif /* _WMI_UNIFIED_API_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 293480dba4..80322f8759 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -69,6 +69,7 @@ struct fwdebug { struct wmi_unified { ol_scn_t scn_handle; /* handle to device */ + osdev_t osdev; /* handle to use OS-independent services */ cdf_atomic_t pending_cmds; HTC_ENDPOINT_ID wmi_endpoint_id; uint16_t max_msg_len; @@ -79,6 +80,7 @@ struct wmi_unified { cdf_spinlock_t eventq_lock; cdf_nbuf_queue_t event_queue; struct work_struct rx_event_work; + int wmi_stop_in_progress; #ifdef WLAN_OPEN_SOURCE struct fwdebug dbglog; struct dentry *debugfs_phy; @@ -96,5 +98,8 @@ struct wmi_unified { int (*wma_process_fw_event_handler_cbk)(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf); + struct wmi_ops ops; + void *event_handler_cookie[WMI_UNIFIED_MAX_EVENT]; + bool use_cookie; }; #endif diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index 58c157d9ea..8340c667f4 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -818,7 +818,7 @@ bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id) * * Return: 0 on success */ -int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, int len, +int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t len, WMI_CMD_ID cmd_id) { HTC_PACKET *pkt; @@ -1034,7 +1034,7 @@ static void wmi_process_fw_event_mc_thread_ctx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf; evt_buf = (wmi_buf_t) htc_packet->pPktContext; - wmi_handle->wma_process_fw_event_handler_cbk(wmi_handle, evt_buf); + wmi_handle->ops.wma_process_fw_event_handler_cbk(wmi_handle, evt_buf); return; } @@ -1204,18 +1204,19 @@ void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) break; case WMI_SERVICE_READY_EVENTID: cdf_print("%s: WMI UNIFIED SERVICE READY event\n", __func__); - wma_rx_service_ready_event(wmi_handle->scn_handle, + wmi_handle->ops.service_ready_cbk(wmi_handle->scn_handle, wmi_cmd_struct_ptr); break; case WMI_SERVICE_READY_EXT_EVENTID: WMA_LOGA("%s: WMI UNIFIED SERVICE READY Extended event", __func__); - wma_rx_service_ready_ext_event(wmi_handle->scn_handle, + wmi_handle->ops.service_ready_ext_cbk(wmi_handle->scn_handle, wmi_cmd_struct_ptr); break; case WMI_READY_EVENTID: cdf_print("%s: WMI UNIFIED READY event\n", __func__); - wma_rx_ready_event(wmi_handle->scn_handle, wmi_cmd_struct_ptr); + wmi_handle->ops.ready_cbk(wmi_handle->scn_handle, + wmi_cmd_struct_ptr); break; } end: @@ -1267,14 +1268,17 @@ void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) /** * wmi_unified_attach() - attach for unified WMI - * - * @param scn_handle : handle to SCN. - * @wma_process_fw_event_handler_cbk: rx callbacks + * @scn_handle: handle to SCN + * @osdev: OS device context + * @target_type: TLV or not-TLV based target + * @use_cookie: cookie based allocation enabled/disabled + * @ops: umac rx callbacks * * @Return: wmi handle. */ -void *wmi_unified_attach(ol_scn_t scn_handle, - wma_process_fw_event_handler_cbk func) +void *wmi_unified_attach(void *scn_handle, + osdev_t osdev, enum wmi_target_type target_type, + bool use_cookie, struct wmi_ops *ops) { struct wmi_unified *wmi_handle; @@ -1283,12 +1287,12 @@ void *wmi_unified_attach(ol_scn_t scn_handle, sizeof(struct wmi_unified), GFP_ATOMIC); if (wmi_handle == NULL) { - cdf_print("allocation of wmi handle failed %zu \n", - sizeof(struct wmi_unified)); + cdf_print("allocation of wmi handle failed %zu\n", + sizeof(struct wmi_unified), GFP_ATOMIC); return NULL; } OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); - wmi_handle->scn_handle = scn_handle; + wmi_handle->scn_handle = (ol_scn_t *)scn_handle; cdf_atomic_init(&wmi_handle->pending_cmds); cdf_atomic_init(&wmi_handle->is_target_suspended); wmi_runtime_pm_init(wmi_handle); @@ -1302,7 +1306,24 @@ void *wmi_unified_attach(ol_scn_t scn_handle, #ifdef WMI_INTERFACE_EVENT_LOGGING cdf_spinlock_init(&wmi_handle->wmi_record_lock); #endif - wmi_handle->wma_process_fw_event_handler_cbk = func; + /* Attach mc_thread context processing function */ + wmi_handle->ops.wma_process_fw_event_handler_cbk = + ops->wma_process_fw_event_handler_cbk; + /* Attach service ready callback function */ + wmi_handle->ops.service_ready_cbk = + ops->service_ready_cbk; + /* Attach service ready extended callback function */ + wmi_handle->ops.service_ready_ext_cbk = + ops->service_ready_ext_cbk; + /* Attach fw ready callback function */ + wmi_handle->ops.ready_cbk = ops->ready_cbk; + if (target_type == WMI_TLV_TARGET) + WMA_LOGD("Target is TLV compliant"); + else + WMA_LOGD("Target is NoN-TLV compliant"); + /* Assign target cookie capablity */ + wmi_handle->use_cookie = use_cookie; + wmi_handle->osdev = osdev; return wmi_handle; }