src/dpdk/drivers/net/qede/qede_debug.c
static enum dbg_status qed_parse_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
						u32 *dump_buf,
						char *results_buf,
						u32 *parsed_results_bytes,
						bool free_meta_data)
{
	const char *section_name, *param_name, *param_str_val;
	u32 data_size, trace_data_dwords, trace_meta_dwords;
	u32 offset, results_offset, results_buf_bytes;
	u32 param_num_val, num_section_params;
	struct mcp_trace *trace;
	enum dbg_status status;
	const u32 *meta_buf;
	u8 *trace_buf;

	*parsed_results_bytes = 0;

	/* Read global_params section */
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "global_params"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;

	/* Print global params */
	dump_buf += qed_print_section_params(dump_buf,
					     num_section_params,
					     results_buf, &results_offset);

	/* Read trace_data section */
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "mcp_trace_data") || num_section_params != 1)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	dump_buf += qed_read_param(dump_buf,
				   &param_name, &param_str_val, &param_num_val);
	if (strcmp(param_name, "size"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	trace_data_dwords = param_num_val;

	/* Prepare trace info */
	trace = (struct mcp_trace *)dump_buf;
	if (trace->signature != MFW_TRACE_SIGNATURE || !trace->size)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;

	trace_buf = (u8 *)dump_buf + sizeof(*trace);
	offset = trace->trace_oldest;
	data_size = qed_cyclic_sub(trace->trace_prod, offset, trace->size);
	dump_buf += trace_data_dwords;

	/* Read meta_data section */
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "mcp_trace_meta"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	dump_buf += qed_read_param(dump_buf,
				   &param_name, &param_str_val, &param_num_val);
	if (strcmp(param_name, "size"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	trace_meta_dwords = param_num_val;

	/* Choose meta data buffer */
	if (!trace_meta_dwords) {
		/* Dump doesn't include meta data */
		struct dbg_tools_user_data *dev_user_data =
			qed_dbg_get_user_data(p_hwfn);

		if (!dev_user_data->mcp_trace_user_meta_buf)
			return DBG_STATUS_MCP_TRACE_NO_META;

		meta_buf = dev_user_data->mcp_trace_user_meta_buf;
	} else {
		/* Dump includes meta data */
		meta_buf = dump_buf;
	}

	/* Allocate meta data memory */
	status = qed_mcp_trace_alloc_meta_data(p_hwfn, meta_buf);
	if (status != DBG_STATUS_OK)
		return status;

	status = qed_parse_mcp_trace_buf(p_hwfn,
					 trace_buf,
					 trace->size,
					 offset,
					 data_size,
					 results_buf ?
					 results_buf + results_offset :
					 NULL,
					 &results_buf_bytes);
	if (status != DBG_STATUS_OK)
		return status;

	if (free_meta_data)
		qed_mcp_trace_free_meta_data(p_hwfn);

	*parsed_results_bytes = results_offset + results_buf_bytes;

	return DBG_STATUS_OK;
}
/* Parses an MCP Trace dump buffer.
 * If result_buf is not NULL, the MCP Trace results are printed to it.
 * In any case, the required results buffer size is assigned to
 * parsed_results_bytes.
 * The parsing status is returned.
 */
Parses an MCP Trace dump buffer.
If result_buf is not NULL, the MCP Trace results are printed to it.
In any case, the required results buffer size is assigned to
parsed_results_bytes.
The parsing status is returned.
Parses an MCP Trace dump buffer . If result_buf is not NULL the MCP Trace results are printed to it . In any case the required results buffer size is assigned to parsed_results_bytes . The parsing status is returned .
static enum dbg_status qed_parse_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
						u32 *dump_buf,
						char *results_buf,
						u32 *parsed_results_bytes,
						bool free_meta_data)
{
	const char *section_name, *param_name, *param_str_val;
	u32 data_size, trace_data_dwords, trace_meta_dwords;
	u32 offset, results_offset, results_buf_bytes;
	u32 param_num_val, num_section_params;
	struct mcp_trace *trace;
	enum dbg_status status;
	const u32 *meta_buf;
	u8 *trace_buf;
	*parsed_results_bytes = 0;
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "global_params"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	dump_buf += qed_print_section_params(dump_buf,
					     num_section_params,
					     results_buf, &results_offset);
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "mcp_trace_data") || num_section_params != 1)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	dump_buf += qed_read_param(dump_buf,
				   &param_name, &param_str_val, &param_num_val);
	if (strcmp(param_name, "size"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	trace_data_dwords = param_num_val;
	trace = (struct mcp_trace *)dump_buf;
	if (trace->signature != MFW_TRACE_SIGNATURE || !trace->size)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	trace_buf = (u8 *)dump_buf + sizeof(*trace);
	offset = trace->trace_oldest;
	data_size = qed_cyclic_sub(trace->trace_prod, offset, trace->size);
	dump_buf += trace_data_dwords;
	dump_buf += qed_read_section_hdr(dump_buf,
					 &section_name, &num_section_params);
	if (strcmp(section_name, "mcp_trace_meta"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	dump_buf += qed_read_param(dump_buf,
				   &param_name, &param_str_val, &param_num_val);
	if (strcmp(param_name, "size"))
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	trace_meta_dwords = param_num_val;
	if (!trace_meta_dwords) {
		struct dbg_tools_user_data *dev_user_data =
			qed_dbg_get_user_data(p_hwfn);
		if (!dev_user_data->mcp_trace_user_meta_buf)
			return DBG_STATUS_MCP_TRACE_NO_META;
		meta_buf = dev_user_data->mcp_trace_user_meta_buf;
	} else {
		meta_buf = dump_buf;
	}
	status = qed_mcp_trace_alloc_meta_data(p_hwfn, meta_buf);
	if (status != DBG_STATUS_OK)
		return status;
	status = qed_parse_mcp_trace_buf(p_hwfn,
					 trace_buf,
					 trace->size,
					 offset,
					 data_size,
					 results_buf ?
					 results_buf + results_offset :
					 NULL,
					 &results_buf_bytes);
	if (status != DBG_STATUS_OK)
		return status;
	if (free_meta_data)
		qed_mcp_trace_free_meta_data(p_hwfn);
	*parsed_results_bytes = results_offset + results_buf_bytes;
	return DBG_STATUS_OK;
}
static enum dbg_status qed_parse_mcp_trace_dump ( struct ecore_hwfn * p_hwfn , u32 * dump_buf , char * results_buf , u32 * parsed_results_bytes , bool free_meta_data ) { const char * section_name , * param_name , * param_str_val ; u32 data_size , trace_data_dwords , trace_meta_dwords ; u32 offset , results_offset , results_buf_bytes ; u32 param_num_val , num_section_params ; struct mcp_trace * trace ; enum dbg_status status ; const u32 * meta_buf ; u8 * trace_buf ; * parsed_results_bytes = 0 ; dump_buf += qed_read_section_hdr ( dump_buf , & section_name , & num_section_params ) ; if ( strcmp ( section_name , " " ) ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; dump_buf += qed_print_section_params ( dump_buf , num_section_params , results_buf , & results_offset ) ; dump_buf += qed_read_section_hdr ( dump_buf , & section_name , & num_section_params ) ; if ( strcmp ( section_name , " " ) || num_section_params != 1 ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; dump_buf += qed_read_param ( dump_buf , & param_name , & param_str_val , & param_num_val ) ; if ( strcmp ( param_name , " " ) ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; trace_data_dwords = param_num_val ; trace = ( struct mcp_trace * ) dump_buf ; if ( trace -> signature != MFW_TRACE_SIGNATURE || ! trace -> size ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; trace_buf = ( u8 * ) dump_buf + sizeof ( * trace ) ; offset = trace -> trace_oldest ; data_size = qed_cyclic_sub ( trace -> trace_prod , offset , trace -> size ) ; dump_buf += trace_data_dwords ; dump_buf += qed_read_section_hdr ( dump_buf , & section_name , & num_section_params ) ; if ( strcmp ( section_name , " " ) ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; dump_buf += qed_read_param ( dump_buf , & param_name , & param_str_val , & param_num_val ) ; if ( strcmp ( param_name , " " ) ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; trace_meta_dwords = param_num_val ; if ( ! trace_meta_dwords ) { struct dbg_tools_user_data * dev_user_data = qed_dbg_get_user_data ( p_hwfn ) ; if ( ! dev_user_data -> mcp_trace_user_meta_buf ) return DBG_STATUS_MCP_TRACE_NO_META ; meta_buf = dev_user_data -> mcp_trace_user_meta_buf ; } else { meta_buf = dump_buf ; } status = qed_mcp_trace_alloc_meta_data ( p_hwfn , meta_buf ) ; if ( status != DBG_STATUS_OK ) return status ; status = qed_parse_mcp_trace_buf ( p_hwfn , trace_buf , trace -> size , offset , data_size , results_buf ? results_buf + results_offset : NULL , & results_buf_bytes ) ; if ( status != DBG_STATUS_OK ) return status ; if ( free_meta_data ) qed_mcp_trace_free_meta_data ( p_hwfn ) ; * parsed_results_bytes = results_offset + results_buf_bytes ; return DBG_STATUS_OK ; }
Parses an MCP Trace dump buffer.
Parses an MCP Trace dump buffer .
/* Read global_params section */ /* Print global params */ /* Read trace_data section */ /* Prepare trace info */ /* Read meta_data section */ /* Choose meta data buffer */ /* Dump doesn't include meta data */ /* Dump includes meta data */ /* Allocate meta data memory */