qcacmn: Add raw buffer support in WMI layer

To send received raw event buffer to event handler
Send without processed buffer to registered event with buffer
type WMI_RX_RAW_BUFF

Change-Id: I2a401e2e7afbfd8f32d4bd521d184ed9ddcdb264
This commit is contained in:
aloksing
2020-08-05 16:27:25 +05:30
committed by snandini
parent b08f3994ef
commit f103f00807
4 changed files with 116 additions and 70 deletions

View File

@@ -163,6 +163,17 @@ enum wmi_rx_exec_ctx {
WMI_RX_SERIALIZER_CTX = 2 WMI_RX_SERIALIZER_CTX = 2
}; };
/**
* enum wmi_rx_buff_type - wmi rx event buffer type
* @WMI_RX_PROCESSED_BUFF: processed event buffer provided by WMI layer
* @WMI_RX_RAW_BUFF: raw event buffer provided by WMI layer
*
*/
enum wmi_rx_buff_type {
WMI_RX_PROCESSED_BUFF,
WMI_RX_RAW_BUFF
};
/** /**
* enum wmi_fw_mem_prio - defines FW Memory requirement type * enum wmi_fw_mem_prio - defines FW Memory requirement type
* @WMI_FW_MEM_HIGH_PRIORITY: Memory requires contiguous memory allocation * @WMI_FW_MEM_HIGH_PRIORITY: Memory requires contiguous memory allocation
@@ -196,6 +207,16 @@ struct wmi_unified_attach_params {
uint32_t soc_id; uint32_t soc_id;
}; };
/**
* struct wmi_unified_exec_ctx - wmi execution ctx and handler buff
* @exec_ctx: execution context of event
* @buff_type: buffer type for event handler
*/
struct wmi_unified_exec_ctx {
enum wmi_rx_exec_ctx exec_ctx;
enum wmi_rx_buff_type buff_type;
};
/** /**
* attach for unified WMI * attach for unified WMI
* *
@@ -394,6 +415,24 @@ int
wmi_unified_unregister_event(wmi_unified_t wmi_handle, wmi_unified_unregister_event(wmi_unified_t wmi_handle,
uint32_t event_id); uint32_t event_id);
/**
* wmi_unified_register_raw_event_handler() - WMI event handler
* registration function.
* @wmi_handle: handle to WMI.
* @event_id: WMI event ID
* @handler_func: Event handler call back function
* @rx_ctx: rx event processing context
*
* Register event handler to get struct wmi_raw_event_buffer as arg
*
* @return: 0 on success and -ve on failure.
*/
int
wmi_unified_register_raw_event_handler(wmi_unified_t wmi_handle,
wmi_conv_event_id event_id,
wmi_unified_event_handler handler_func,
enum wmi_rx_exec_ctx rx_ctx);
/** /**
* WMI event handler unregister function * WMI event handler unregister function
* *

View File

@@ -8330,4 +8330,15 @@ enum wmi_host_tbtt_offset_cmd_type {
WMI_HOST_PDEV_GET_TBTT_OFFSET, WMI_HOST_PDEV_GET_TBTT_OFFSET,
WMI_HOST_PDEV_SET_TBTT_OFFSET, WMI_HOST_PDEV_SET_TBTT_OFFSET,
}; };
/**
* struct wmi_raw_event_buffer - fw event buffers
* @evt_raw_buf: event raw buffer
* @evt_processed_buf: event processed buffer
*/
struct wmi_raw_event_buffer {
void *evt_raw_buf;
void *evt_processed_buf;
};
#endif /* _WMI_UNIFIED_PARAM_H_ */ #endif /* _WMI_UNIFIED_PARAM_H_ */

View File

@@ -2449,7 +2449,7 @@ struct wmi_unified {
uint16_t max_msg_len; uint16_t max_msg_len;
uint32_t *event_id; uint32_t *event_id;
wmi_unified_event_handler *event_handler; wmi_unified_event_handler *event_handler;
enum wmi_rx_exec_ctx *ctx; struct wmi_unified_exec_ctx *ctx;
HTC_HANDLE htc_handle; HTC_HANDLE htc_handle;
qdf_spinlock_t eventq_lock; qdf_spinlock_t eventq_lock;
qdf_nbuf_queue_t event_queue; qdf_nbuf_queue_t event_queue;
@@ -2514,7 +2514,7 @@ struct wmi_soc {
uint32_t event_id[WMI_UNIFIED_MAX_EVENT]; uint32_t event_id[WMI_UNIFIED_MAX_EVENT];
wmi_unified_event_handler event_handler[WMI_UNIFIED_MAX_EVENT]; wmi_unified_event_handler event_handler[WMI_UNIFIED_MAX_EVENT];
uint32_t max_event_idx; uint32_t max_event_idx;
enum wmi_rx_exec_ctx ctx[WMI_UNIFIED_MAX_EVENT]; struct wmi_unified_exec_ctx ctx[WMI_UNIFIED_MAX_EVENT];
qdf_spinlock_t ctx_lock; qdf_spinlock_t ctx_lock;
struct wmi_unified *wmi_pdev[WMI_MAX_RADIOS]; struct wmi_unified *wmi_pdev[WMI_MAX_RADIOS];
HTC_ENDPOINT_ID wmi_endpoint_id[WMI_MAX_RADIOS]; HTC_ENDPOINT_ID wmi_endpoint_id[WMI_MAX_RADIOS];

View File

@@ -1843,73 +1843,22 @@ static int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
} }
/** /**
* wmi_unified_register_event() - register wmi event handler * wmi_register_event_handler_with_ctx() - register event handler with
* @wmi_handle: handle to wmi * exec ctx and buffer type
* @event_id: wmi event id
* @handler_func: wmi event handler function
*
* Return: 0 on success
*/
int wmi_unified_register_event(wmi_unified_t wmi_handle,
uint32_t event_id,
wmi_unified_event_handler handler_func)
{
uint32_t idx = 0;
uint32_t evt_id;
struct wmi_soc *soc;
if (!wmi_handle) {
WMI_LOGE("WMI handle is NULL");
return QDF_STATUS_E_FAILURE;
}
soc = wmi_handle->soc;
if (event_id >= wmi_events_max ||
wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
"%s: Event id %d is unavailable",
__func__, event_id);
return QDF_STATUS_E_FAILURE;
}
evt_id = wmi_handle->wmi_events[event_id];
if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
"%s : event handler already registered 0x%x",
__func__, evt_id);
return QDF_STATUS_E_FAILURE;
}
if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
"%s : no more event handlers 0x%x",
__func__, evt_id);
return QDF_STATUS_E_FAILURE;
}
idx = soc->max_event_idx;
wmi_handle->event_handler[idx] = handler_func;
wmi_handle->event_id[idx] = evt_id;
qdf_spin_lock_bh(&soc->ctx_lock);
wmi_handle->ctx[idx] = WMI_RX_UMAC_CTX;
qdf_spin_unlock_bh(&soc->ctx_lock);
soc->max_event_idx++;
return 0;
}
/**
* wmi_unified_register_event_handler() - register wmi event handler
* @wmi_handle: handle to wmi * @wmi_handle: handle to wmi
* @event_id: wmi event id * @event_id: wmi event id
* @handler_func: wmi event handler function * @handler_func: wmi event handler function
* @rx_ctx: rx execution context for wmi rx events * @rx_ctx: rx execution context for wmi rx events
* @rx_buf_type: rx execution context for wmi rx events
* *
* This API is to support legacy requirements. Will be deprecated in future. * Return: QDF_STATUS_SUCCESS on successful register event else failure.
* Return: 0 on success
*/ */
int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, static QDF_STATUS
wmi_conv_event_id event_id, wmi_register_event_handler_with_ctx(wmi_unified_t wmi_handle,
wmi_unified_event_handler handler_func, uint32_t event_id,
uint8_t rx_ctx) wmi_unified_event_handler handler_func,
enum wmi_rx_exec_ctx rx_ctx,
enum wmi_rx_buff_type rx_buf_type)
{ {
uint32_t idx = 0; uint32_t idx = 0;
uint32_t evt_id; uint32_t evt_id;
@@ -1938,7 +1887,7 @@ int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
} }
if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) { if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
WMI_LOGE("no more event handlers 0x%x", WMI_LOGE("no more event handlers 0x%x",
evt_id); evt_id);
return QDF_STATUS_E_FAILURE; return QDF_STATUS_E_FAILURE;
} }
QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG, QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
@@ -1946,15 +1895,51 @@ int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
idx = soc->max_event_idx; idx = soc->max_event_idx;
wmi_handle->event_handler[idx] = handler_func; wmi_handle->event_handler[idx] = handler_func;
wmi_handle->event_id[idx] = evt_id; wmi_handle->event_id[idx] = evt_id;
qdf_spin_lock_bh(&soc->ctx_lock); qdf_spin_lock_bh(&soc->ctx_lock);
wmi_handle->ctx[idx] = rx_ctx; wmi_handle->ctx[idx].exec_ctx = rx_ctx;
wmi_handle->ctx[idx].buff_type = rx_buf_type;
qdf_spin_unlock_bh(&soc->ctx_lock); qdf_spin_unlock_bh(&soc->ctx_lock);
soc->max_event_idx++; soc->max_event_idx++;
return 0; return QDF_STATUS_SUCCESS;
} }
int wmi_unified_register_event(wmi_unified_t wmi_handle,
uint32_t event_id,
wmi_unified_event_handler handler_func)
{
return wmi_register_event_handler_with_ctx(wmi_handle, event_id,
handler_func,
WMI_RX_UMAC_CTX,
WMI_RX_PROCESSED_BUFF);
}
int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
wmi_conv_event_id event_id,
wmi_unified_event_handler handler_func,
uint8_t rx_ctx)
{
return wmi_register_event_handler_with_ctx(wmi_handle, event_id,
handler_func, rx_ctx,
WMI_RX_PROCESSED_BUFF);
}
qdf_export_symbol(wmi_unified_register_event_handler); qdf_export_symbol(wmi_unified_register_event_handler);
int
wmi_unified_register_raw_event_handler(wmi_unified_t wmi_handle,
wmi_conv_event_id event_id,
wmi_unified_event_handler handler_func,
enum wmi_rx_exec_ctx rx_ctx)
{
return wmi_register_event_handler_with_ctx(wmi_handle, event_id,
handler_func, rx_ctx,
WMI_RX_RAW_BUFF);
}
qdf_export_symbol(wmi_unified_register_raw_event_handler);
/** /**
* wmi_unified_unregister_event() - unregister wmi event handler * wmi_unified_unregister_event() - unregister wmi event handler
* @wmi_handle: handle to wmi * @wmi_handle: handle to wmi
@@ -2230,7 +2215,7 @@ static void wmi_process_control_rx(struct wmi_unified *wmi_handle,
} }
wmi_mtrace_rx(id, 0xFF, idx); wmi_mtrace_rx(id, 0xFF, idx);
qdf_spin_lock_bh(&soc->ctx_lock); qdf_spin_lock_bh(&soc->ctx_lock);
exec_ctx = wmi_handle->ctx[idx]; exec_ctx = wmi_handle->ctx[idx].exec_ctx;
qdf_spin_unlock_bh(&soc->ctx_lock); qdf_spin_unlock_bh(&soc->ctx_lock);
#ifdef WMI_INTERFACE_EVENT_LOGGING #ifdef WMI_INTERFACE_EVENT_LOGGING
@@ -2395,6 +2380,8 @@ void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
int tlv_ok_status = 0; int tlv_ok_status = 0;
#endif #endif
uint32_t idx = 0; uint32_t idx = 0;
struct wmi_raw_event_buffer ev_buf;
enum wmi_rx_buff_type ev_buff_type;
id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID); id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
@@ -2455,9 +2442,18 @@ void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
} }
#endif #endif
/* Call the WMI registered event handler */ /* Call the WMI registered event handler */
if (wmi_handle->target_type == WMI_TLV_TARGET) if (wmi_handle->target_type == WMI_TLV_TARGET) {
wmi_handle->event_handler[idx] (wmi_handle->scn_handle, ev_buff_type = wmi_handle->ctx[idx].buff_type;
wmi_cmd_struct_ptr, len); if (ev_buff_type == WMI_RX_PROCESSED_BUFF) {
wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
wmi_cmd_struct_ptr, len);
} else if (ev_buff_type == WMI_RX_RAW_BUFF) {
ev_buf.evt_raw_buf = data;
ev_buf.evt_processed_buf = wmi_cmd_struct_ptr;
wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
(void *)&ev_buf, len);
}
}
else else
wmi_handle->event_handler[idx] (wmi_handle->scn_handle, wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
data, len); data, len);