src/dpdk/drivers/net/qede/qede_debug.c
static enum dbg_status qed_parse_mcp_trace_buf(struct ecore_hwfn *p_hwfn,
					       u8 *trace_buf,
					       u32 trace_buf_size,
					       u32 data_offset,
					       u32 data_size,
					       char *parsed_buf,
					       u32 *parsed_results_bytes)
{
	struct dbg_tools_user_data *dev_user_data;
	struct mcp_trace_meta *meta;
	u32 param_mask, param_shift;
	enum dbg_status status;

	dev_user_data = qed_dbg_get_user_data(p_hwfn);
	meta = &dev_user_data->mcp_trace_meta;
	*parsed_results_bytes = 0;

	if (!meta->is_allocated)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;

	status = DBG_STATUS_OK;

	while (data_size) {
		struct mcp_trace_format *format_ptr;
		u8 format_level, format_module;
		u32 params[3] = { 0, 0, 0 };
		u32 header, format_idx, i;

		if (data_size < MFW_TRACE_ENTRY_SIZE)
			return DBG_STATUS_MCP_TRACE_BAD_DATA;

		header = qed_read_from_cyclic_buf(trace_buf,
						  &data_offset,
						  trace_buf_size,
						  MFW_TRACE_ENTRY_SIZE);
		data_size -= MFW_TRACE_ENTRY_SIZE;
		format_idx = header & MFW_TRACE_EVENTID_MASK;

		/* Skip message if its index doesn't exist in the meta data */
		if (format_idx >= meta->formats_num) {
			u8 format_size = (u8)GET_MFW_FIELD(header,
							   MFW_TRACE_PRM_SIZE);

			if (data_size < format_size)
				return DBG_STATUS_MCP_TRACE_BAD_DATA;

			data_offset = qed_cyclic_add(data_offset,
						     format_size,
						     trace_buf_size);
			data_size -= format_size;
			continue;
		}

		format_ptr =
			(struct mcp_trace_format *)&meta->formats[format_idx];

		for (i = 0,
		     param_mask = MCP_TRACE_FORMAT_P1_SIZE_MASK, param_shift =
		     MCP_TRACE_FORMAT_P1_SIZE_OFFSET;
		     i < MCP_TRACE_FORMAT_MAX_PARAMS;
		     i++, param_mask <<= MCP_TRACE_FORMAT_PARAM_WIDTH,
		     param_shift += MCP_TRACE_FORMAT_PARAM_WIDTH) {
			/* Extract param size (0..3) */
			u8 param_size = (u8)((format_ptr->data & param_mask) >>
					     param_shift);

			/* If the param size is zero, there are no other
			 * parameters.
			 */
			if (!param_size)
				break;

			/* Size is encoded using 2 bits, where 3 is used to
			 * encode 4.
			 */
			if (param_size == 3)
				param_size = 4;

			if (data_size < param_size)
				return DBG_STATUS_MCP_TRACE_BAD_DATA;

			params[i] = qed_read_from_cyclic_buf(trace_buf,
							     &data_offset,
							     trace_buf_size,
							     param_size);
			data_size -= param_size;
		}

		format_level = (u8)GET_MFW_FIELD(format_ptr->data,
						 MCP_TRACE_FORMAT_LEVEL);
		format_module = (u8)GET_MFW_FIELD(format_ptr->data,
						  MCP_TRACE_FORMAT_MODULE);
		if (format_level >= OSAL_ARRAY_SIZE(s_mcp_trace_level_str))
			return DBG_STATUS_MCP_TRACE_BAD_DATA;

		/* Print current message to results buffer */
		*parsed_results_bytes +=
			OSAL_SPRINTF(qed_get_buf_ptr(parsed_buf,
						*parsed_results_bytes),
				"%s %-8s: ",
				s_mcp_trace_level_str[format_level],
				meta->modules[format_module]);
		*parsed_results_bytes +=
		    sprintf(qed_get_buf_ptr(parsed_buf, *parsed_results_bytes),
			    format_ptr->format_str,
			    params[0], params[1], params[2]);
	}

	/* Add string NULL terminator */
	(*parsed_results_bytes)++;

	return status;
}
/* Parses an MCP trace buffer. If result_buf is not NULL, the MCP Trace results
 * are printed to it. The parsing status is returned.
 * Arguments:
 * trace_buf - MCP trace cyclic buffer
 * trace_buf_size - MCP trace cyclic buffer size in bytes
 * data_offset - offset in bytes of the data to parse in the MCP trace cyclic
 *		 buffer.
 * data_size - size in bytes of data to parse.
 * parsed_buf - destination buffer for parsed data.
 * parsed_results_bytes - size of parsed data in bytes.
 */
Parses an MCP trace buffer. If result_buf is not NULL, the MCP Trace results
are printed to it. The parsing status is returned.
Arguments:
trace_buf - MCP trace cyclic buffer
trace_buf_size - MCP trace cyclic buffer size in bytes
data_offset - offset in bytes of the data to parse in the MCP trace cyclic
buffer.
data_size - size in bytes of data to parse.
parsed_buf - destination buffer for parsed data.
parsed_results_bytes - size of parsed data in bytes.
Parses an MCP trace buffer . If result_buf is not NULL the MCP Trace results are printed to it . The parsing status is returned . Arguments : trace_buf - MCP trace cyclic buffer trace_buf_size - MCP trace cyclic buffer size in bytes data_offset - offset in bytes of the data to parse in the MCP trace cyclic buffer . data_size - size in bytes of data to parse . parsed_buf - destination buffer for parsed data . parsed_results_bytes - size of parsed data in bytes .
static enum dbg_status qed_parse_mcp_trace_buf(struct ecore_hwfn *p_hwfn,
					       u8 *trace_buf,
					       u32 trace_buf_size,
					       u32 data_offset,
					       u32 data_size,
					       char *parsed_buf,
					       u32 *parsed_results_bytes)
{
	struct dbg_tools_user_data *dev_user_data;
	struct mcp_trace_meta *meta;
	u32 param_mask, param_shift;
	enum dbg_status status;
	dev_user_data = qed_dbg_get_user_data(p_hwfn);
	meta = &dev_user_data->mcp_trace_meta;
	*parsed_results_bytes = 0;
	if (!meta->is_allocated)
		return DBG_STATUS_MCP_TRACE_BAD_DATA;
	status = DBG_STATUS_OK;
	while (data_size) {
		struct mcp_trace_format *format_ptr;
		u8 format_level, format_module;
		u32 params[3] = { 0, 0, 0 };
		u32 header, format_idx, i;
		if (data_size < MFW_TRACE_ENTRY_SIZE)
			return DBG_STATUS_MCP_TRACE_BAD_DATA;
		header = qed_read_from_cyclic_buf(trace_buf,
						  &data_offset,
						  trace_buf_size,
						  MFW_TRACE_ENTRY_SIZE);
		data_size -= MFW_TRACE_ENTRY_SIZE;
		format_idx = header & MFW_TRACE_EVENTID_MASK;
		if (format_idx >= meta->formats_num) {
			u8 format_size = (u8)GET_MFW_FIELD(header,
							   MFW_TRACE_PRM_SIZE);
			if (data_size < format_size)
				return DBG_STATUS_MCP_TRACE_BAD_DATA;
			data_offset = qed_cyclic_add(data_offset,
						     format_size,
						     trace_buf_size);
			data_size -= format_size;
			continue;
		}
		format_ptr =
			(struct mcp_trace_format *)&meta->formats[format_idx];
		for (i = 0,
		     param_mask = MCP_TRACE_FORMAT_P1_SIZE_MASK, param_shift =
		     MCP_TRACE_FORMAT_P1_SIZE_OFFSET;
		     i < MCP_TRACE_FORMAT_MAX_PARAMS;
		     i++, param_mask <<= MCP_TRACE_FORMAT_PARAM_WIDTH,
		     param_shift += MCP_TRACE_FORMAT_PARAM_WIDTH) {
			u8 param_size = (u8)((format_ptr->data & param_mask) >>
					     param_shift);
			if (!param_size)
				break;
			if (param_size == 3)
				param_size = 4;
			if (data_size < param_size)
				return DBG_STATUS_MCP_TRACE_BAD_DATA;
			params[i] = qed_read_from_cyclic_buf(trace_buf,
							     &data_offset,
							     trace_buf_size,
							     param_size);
			data_size -= param_size;
		}
		format_level = (u8)GET_MFW_FIELD(format_ptr->data,
						 MCP_TRACE_FORMAT_LEVEL);
		format_module = (u8)GET_MFW_FIELD(format_ptr->data,
						  MCP_TRACE_FORMAT_MODULE);
		if (format_level >= OSAL_ARRAY_SIZE(s_mcp_trace_level_str))
			return DBG_STATUS_MCP_TRACE_BAD_DATA;
		*parsed_results_bytes +=
			OSAL_SPRINTF(qed_get_buf_ptr(parsed_buf,
						*parsed_results_bytes),
				"%s %-8s: ",
				s_mcp_trace_level_str[format_level],
				meta->modules[format_module]);
		*parsed_results_bytes +=
		    sprintf(qed_get_buf_ptr(parsed_buf, *parsed_results_bytes),
			    format_ptr->format_str,
			    params[0], params[1], params[2]);
	}
	(*parsed_results_bytes)++;
	return status;
}
static enum dbg_status qed_parse_mcp_trace_buf ( struct ecore_hwfn * p_hwfn , u8 * trace_buf , u32 trace_buf_size , u32 data_offset , u32 data_size , char * parsed_buf , u32 * parsed_results_bytes ) { struct dbg_tools_user_data * dev_user_data ; struct mcp_trace_meta * meta ; u32 param_mask , param_shift ; enum dbg_status status ; dev_user_data = qed_dbg_get_user_data ( p_hwfn ) ; meta = & dev_user_data -> mcp_trace_meta ; * parsed_results_bytes = 0 ; if ( ! meta -> is_allocated ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; status = DBG_STATUS_OK ; while ( data_size ) { struct mcp_trace_format * format_ptr ; u8 format_level , format_module ; u32 params [ 3 ] = { 0 , 0 , 0 } ; u32 header , format_idx , i ; if ( data_size < MFW_TRACE_ENTRY_SIZE ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; header = qed_read_from_cyclic_buf ( trace_buf , & data_offset , trace_buf_size , MFW_TRACE_ENTRY_SIZE ) ; data_size -= MFW_TRACE_ENTRY_SIZE ; format_idx = header & MFW_TRACE_EVENTID_MASK ; if ( format_idx >= meta -> formats_num ) { u8 format_size = ( u8 ) GET_MFW_FIELD ( header , MFW_TRACE_PRM_SIZE ) ; if ( data_size < format_size ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; data_offset = qed_cyclic_add ( data_offset , format_size , trace_buf_size ) ; data_size -= format_size ; continue ; } format_ptr = ( struct mcp_trace_format * ) & meta -> formats [ format_idx ] ; for ( i = 0 , param_mask = MCP_TRACE_FORMAT_P1_SIZE_MASK , param_shift = MCP_TRACE_FORMAT_P1_SIZE_OFFSET ; i < MCP_TRACE_FORMAT_MAX_PARAMS ; i ++ , param_mask <<= MCP_TRACE_FORMAT_PARAM_WIDTH , param_shift += MCP_TRACE_FORMAT_PARAM_WIDTH ) { u8 param_size = ( u8 ) ( ( format_ptr -> data & param_mask ) >> param_shift ) ; if ( ! param_size ) break ; if ( param_size == 3 ) param_size = 4 ; if ( data_size < param_size ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; params [ i ] = qed_read_from_cyclic_buf ( trace_buf , & data_offset , trace_buf_size , param_size ) ; data_size -= param_size ; } format_level = ( u8 ) GET_MFW_FIELD ( format_ptr -> data , MCP_TRACE_FORMAT_LEVEL ) ; format_module = ( u8 ) GET_MFW_FIELD ( format_ptr -> data , MCP_TRACE_FORMAT_MODULE ) ; if ( format_level >= OSAL_ARRAY_SIZE ( s_mcp_trace_level_str ) ) return DBG_STATUS_MCP_TRACE_BAD_DATA ; * parsed_results_bytes += OSAL_SPRINTF ( qed_get_buf_ptr ( parsed_buf , * parsed_results_bytes ) , " " , s_mcp_trace_level_str [ format_level ] , meta -> modules [ format_module ] ) ; * parsed_results_bytes += sprintf ( qed_get_buf_ptr ( parsed_buf , * parsed_results_bytes ) , format_ptr -> format_str , params [ 0 ] , params [ 1 ] , params [ 2 ] ) ; } ( * parsed_results_bytes ) ++ ; return status ; }
Parses an MCP trace buffer.
Parses an MCP trace buffer .
/* Skip message if its index doesn't exist in the meta data */ /* Extract param size (0..3) */ /* If the param size is zero, there are no other
			 * parameters.
			 */ /* Size is encoded using 2 bits, where 3 is used to
			 * encode 4.
			 */ /* Print current message to results buffer */ /* Add string NULL terminator */