Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d50a0076 authored by Rajeev Kumar's avatar Rajeev Kumar
Browse files

qcacmn: Separate WMI diag rx event logging

FW generates too many diag events and these diag events
also come on CE-2 together with other critical control
path WMI events and easily over-run useful control path
WMI RX even log buffer. Separate WMI diag rx event loggig
in a separate log buffer such that useful control path WMI
log event buffer is not over-run.

Change-Id: I89b5d88036bc9d7e57e8e16858bc556be4e2ed41
CRs-Fixed: 2318083
parent b7e89de2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@
#define WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH (16)
/* wmi_mgmt commands */
#define WMI_MGMT_EVENT_DEBUG_MAX_ENTRY (256)
/* wmi diag rx events max buffer */
#ifndef WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY
#define WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY (256)
#endif

/**
 * struct wmi_command_debug - WMI command log buffer data type
@@ -137,12 +141,11 @@ struct wmi_log_buf_t {
 * @wmi_mgmt_command_tx_cmp_log_buf_info - Buffer info for WMI Management
 * Command Tx completion log
 * @wmi_mgmt_event_log_buf_info - Buffer info for WMI Management event log
 * @wmi_diag_event_log_buf_info - Buffer info for WMI diag event log
 * @wmi_record_lock - Lock WMI recording
 * @wmi_logging_enable - Enable/Disable state for WMI logging
 * @buf_offset_command - Offset from where WMI command data should be logged
 * @buf_offset_event - Offset from where WMI event data should be logged
 * @is_management_record - Function refernce to check if command/event is
 *  management record
 * @wmi_id_to_name - Function refernce to API to convert Command id to
 * string name
 * @wmi_log_debugfs_dir - refernce to debugfs directory
@@ -157,6 +160,7 @@ struct wmi_debug_log_info {
	struct wmi_log_buf_t wmi_mgmt_command_log_buf_info;
	struct wmi_log_buf_t wmi_mgmt_command_tx_cmp_log_buf_info;
	struct wmi_log_buf_t wmi_mgmt_event_log_buf_info;
	struct wmi_log_buf_t wmi_diag_event_log_buf_info;

	qdf_spinlock_t wmi_record_lock;
	bool wmi_logging_enable;
@@ -1470,6 +1474,7 @@ QDF_STATUS (*extract_peer_delete_response_event)(
			struct wmi_host_peer_delete_response_event *param);

bool (*is_management_record)(uint32_t cmd_id);
bool (*is_diag_event)(uint32_t event_id);
uint8_t *(*wmi_id_to_name)(uint32_t cmd_id);
QDF_STATUS (*send_dfs_phyerr_offload_en_cmd)(wmi_unified_t wmi_handle,
		uint32_t pdev_id);
+86 −16
Original line number Diff line number Diff line
@@ -217,10 +217,15 @@ uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0;
struct wmi_command_debug
wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];

/* wmi_mgmt events when processed */
uint32_t g_wmi_mgmt_event_buf_idx = 0;
/* wmi_mgmt events when received */
uint32_t g_wmi_mgmt_rx_event_buf_idx = 0;
struct wmi_event_debug
wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
wmi_mgmt_rx_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];

/* wmi_diag events when received */
uint32_t g_wmi_diag_rx_event_buf_idx = 0;
struct wmi_event_debug
wmi_diag_rx_event_log_buffer[WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY];
#endif

#define WMI_MGMT_COMMAND_RECORD(h, a, b) {                              \
@@ -270,7 +275,7 @@ wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
	h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.length++;	\
}

#define WMI_MGMT_EVENT_RECORD(h, a, b) {				\
#define WMI_MGMT_RX_EVENT_RECORD(h, a, b) do {				\
	if (wmi_mgmt_log_max_entry <=					\
		*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))\
		*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx) = 0;\
@@ -286,11 +291,30 @@ wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
			time = qdf_get_log_timestamp();			\
	(*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))++;	\
	h->log_info.wmi_mgmt_event_log_buf_info.length++;		\
}
} while (0);

#define WMI_DIAG_RX_EVENT_RECORD(h, a, b) do {                             \
	if (wmi_mgmt_log_max_entry <=                                   \
		*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx))\
		*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx) = 0;\
	((struct wmi_event_debug *)h->log_info.wmi_diag_event_log_buf_info.buf)\
		[*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)]\
					.event = a;                     \
	qdf_mem_copy(((struct wmi_event_debug *)h->log_info.            \
				wmi_diag_event_log_buf_info.buf)        \
		[*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)].\
			data, b, wmi_record_max_length);                \
	((struct wmi_event_debug *)h->log_info.wmi_diag_event_log_buf_info.buf)\
		[*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)].\
			time = qdf_get_log_timestamp();                 \
	(*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx))++;  \
	h->log_info.wmi_diag_event_log_buf_info.length++;               \
} while (0);

/* These are defined to made it as module param, which can be configured */
uint32_t wmi_log_max_entry = WMI_EVENT_DEBUG_MAX_ENTRY;
uint32_t wmi_mgmt_log_max_entry = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
uint32_t wmi_diag_log_max_entry = WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY;
uint32_t wmi_record_max_length = WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH;
uint32_t wmi_display_size = 100;

@@ -319,6 +343,8 @@ static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
		&wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info;
	struct wmi_log_buf_t *mgmt_event_log_buf =
			&wmi_handle->log_info.wmi_mgmt_event_log_buf_info;
	struct wmi_log_buf_t *diag_event_log_buf =
			&wmi_handle->log_info.wmi_diag_event_log_buf_info;

	/* WMI commands */
	cmd_log_buf->length = 0;
@@ -363,13 +389,20 @@ static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
		&g_wmi_mgmt_command_tx_cmp_buf_idx;
	mgmt_cmd_tx_cmp_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;

	/* WMI Management events when processed*/
	/* WMI Management events when received */
	mgmt_event_log_buf->length = 0;
	mgmt_event_log_buf->buf_tail_idx = 0;
	mgmt_event_log_buf->buf = wmi_mgmt_event_log_buffer;
	mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_event_buf_idx;
	mgmt_event_log_buf->buf = wmi_mgmt_rx_event_log_buffer;
	mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_rx_event_buf_idx;
	mgmt_event_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;

	/* WMI diag events when received */
	diag_event_log_buf->length = 0;
	diag_event_log_buf->buf_tail_idx = 0;
	diag_event_log_buf->buf = wmi_diag_rx_event_log_buffer;
	diag_event_log_buf->p_buf_tail_idx = &g_wmi_diag_rx_event_buf_idx;
	diag_event_log_buf->size = WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY;

	qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
	wmi_handle->log_info.wmi_logging_enable = 1;

@@ -394,6 +427,8 @@ static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
		&wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info;
	struct wmi_log_buf_t *mgmt_event_log_buf =
			&wmi_handle->log_info.wmi_mgmt_event_log_buf_info;
	struct wmi_log_buf_t *diag_event_log_buf =
			&wmi_handle->log_info.wmi_diag_event_log_buf_info;

	wmi_handle->log_info.wmi_logging_enable = 0;

@@ -479,7 +514,7 @@ static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
	mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx =
		&mgmt_cmd_tx_cmp_log_buf->buf_tail_idx;

	/* WMI Management events when processed*/
	/* WMI Management events when received */
	mgmt_event_log_buf->length = 0;
	mgmt_event_log_buf->buf_tail_idx = 0;

@@ -494,6 +529,21 @@ static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
	}
	mgmt_event_log_buf->p_buf_tail_idx = &mgmt_event_log_buf->buf_tail_idx;

	/* WMI diag events when received */
	diag_event_log_buf->length = 0;
	diag_event_log_buf->buf_tail_idx = 0;

	diag_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
		wmi_diag_log_max_entry *
		sizeof(struct wmi_event_debug));
	diag_event_log_buf->size = wmi_diag_log_max_entry;

	if (!diag_event_log_buf->buf) {
		qdf_print("no memory for WMI diag event log buffer..\n");
		return QDF_STATUS_E_NOMEM;
	}
	diag_event_log_buf->p_buf_tail_idx = &diag_event_log_buf->buf_tail_idx;

	qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
	wmi_handle->log_info.wmi_logging_enable = 1;

@@ -530,6 +580,9 @@ static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle)
	if (wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf)
		qdf_mem_free(
			wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf);
	if (wmi_handle->log_info.wmi_diag_event_log_buf_info.buf)
		qdf_mem_free(
			wmi_handle->log_info.wmi_diag_event_log_buf_info.buf);
	wmi_handle->log_info.wmi_logging_enable = 0;
	qdf_spinlock_destroy(&wmi_handle->log_info.wmi_record_lock);
}
@@ -1780,8 +1833,18 @@ static void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)

		qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
		/* Exclude 4 bytes of TLV header */
		WMI_RX_EVENT_RECORD(wmi_handle, id, data +
				wmi_handle->log_info.buf_offset_event);
		if (wmi_handle->ops->is_diag_event(id)) {
			WMI_DIAG_RX_EVENT_RECORD(wmi_handle, id,
				((uint8_t *) data +
				wmi_handle->log_info.buf_offset_event));
		} else if (wmi_handle->ops->is_management_record(id)) {
			WMI_MGMT_RX_EVENT_RECORD(wmi_handle, id,
				((uint8_t *) data +
				wmi_handle->log_info.buf_offset_event));
		} else {
			WMI_RX_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data +
				wmi_handle->log_info.buf_offset_event));
		}
		qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
	}
#endif
@@ -1866,12 +1929,19 @@ void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
	if (wmi_handle->log_info.wmi_logging_enable) {
		qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
		/* Exclude 4 bytes of TLV header */
		if (wmi_handle->ops->is_management_record(id)) {
			WMI_MGMT_EVENT_RECORD(wmi_handle, id, data
				+ wmi_handle->log_info.buf_offset_event);
		if (wmi_handle->ops->is_diag_event(id)) {
			/*
			 * skip diag event logging in WMI event buffer
			 * as its already logged in WMI RX event buffer
			 */
		} else if (wmi_handle->ops->is_management_record(id)) {
			/*
			 * skip wmi mgmt event logging in WMI event buffer
			 * as its already logged in WMI RX event buffer
			 */
		} else {
			WMI_EVENT_RECORD(wmi_handle, id, data +
					wmi_handle->log_info.buf_offset_event);
			WMI_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data +
					wmi_handle->log_info.buf_offset_event));
		}
		qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
	}
+9 −0
Original line number Diff line number Diff line
@@ -8338,6 +8338,14 @@ static bool is_management_record_non_tlv(uint32_t cmd_id)
	return false;
}

static bool is_diag_event_non_tlv(uint32_t event_id)
{
	if (WMI_DEBUG_MESG_EVENTID == event_id)
		return true;

	return false;
}

/**
 * wmi_set_htc_tx_tag_non_tlv() - set HTC TX tag for WMI commands
 * @wmi_handle: WMI handle
@@ -8724,6 +8732,7 @@ struct wmi_ops non_tlv_ops = {
	.extract_pdev_utf_event = extract_pdev_utf_event_non_tlv,
	.wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_non_tlv,
	.is_management_record = is_management_record_non_tlv,
	.is_diag_event = is_diag_event_non_tlv,
	.send_dfs_phyerr_offload_en_cmd =
		send_dfs_phyerr_offload_en_cmd_non_tlv,
	.send_dfs_phyerr_offload_dis_cmd =
+9 −0
Original line number Diff line number Diff line
@@ -19914,6 +19914,14 @@ static bool is_management_record_tlv(uint32_t cmd_id)
	return false;
}
static bool is_diag_event_tlv(uint32_t event_id)
{
	if (WMI_DIAG_EVENTID == event_id)
		return true;
	return false;
}
static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
{
	wmi_vdev_set_param_cmd_fixed_param *set_cmd;
@@ -22442,6 +22450,7 @@ struct wmi_ops tlv_ops = {
	.extract_peer_delete_response_event =
				extract_peer_delete_response_event_tlv,
	.is_management_record = is_management_record_tlv,
	.is_diag_event = is_diag_event_tlv,
	.extract_pdev_csa_switch_count_status =
				extract_pdev_csa_switch_count_status_tlv,
	.extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,