src/dpdk/drivers/net/qede/qede_debug.c
static enum dbg_status
qed_mcp_trace_alloc_meta_data(struct ecore_hwfn *p_hwfn,
			      const u32 *meta_buf)
{
	struct dbg_tools_user_data *dev_user_data;
	u32 offset = 0, signature, i;
	struct mcp_trace_meta *meta;
	u8 *meta_buf_bytes = (u8 *)(osal_uintptr_t)meta_buf;

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

	/* Free the previous meta before loading a new one. */
	if (meta->is_allocated)
		qed_mcp_trace_free_meta_data(p_hwfn);

	OSAL_MEMSET(meta, 0, sizeof(*meta));

	/* Read first signature */
	signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	if (signature != NVM_MAGIC_VALUE)
		return DBG_STATUS_INVALID_TRACE_SIGNATURE;

	/* Read no. of modules and allocate memory for their pointers */
	meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
	meta->modules = (char **)OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
				    meta->modules_num * sizeof(char *));
	if (!meta->modules)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;

	/* Allocate and read all module strings */
	for (i = 0; i < meta->modules_num; i++) {
		u8 module_len = qed_read_byte_from_buf(meta_buf_bytes, &offset);

		*(meta->modules + i) = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
							   GFP_KERNEL,
							   module_len);
		if (!(*(meta->modules + i))) {
			/* Update number of modules to be released */
			meta->modules_num = i ? i - 1 : 0;
			return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
		}

		qed_read_str_from_buf(meta_buf_bytes, &offset, module_len,
				      *(meta->modules + i));
		if (module_len > MCP_TRACE_MAX_MODULE_LEN)
			(*(meta->modules + i))[MCP_TRACE_MAX_MODULE_LEN] = '\0';
	}

	/* Read second signature */
	signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	if (signature != NVM_MAGIC_VALUE)
		return DBG_STATUS_INVALID_TRACE_SIGNATURE;

	/* Read number of formats and allocate memory for all formats */
	meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	meta->formats =
		(struct mcp_trace_format *)OSAL_ZALLOC(p_hwfn->p_dev,
						       GFP_KERNEL,
						       meta->formats_num *
					       sizeof(struct mcp_trace_format));
	if (!meta->formats)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;

	/* Allocate and read all strings */
	for (i = 0; i < meta->formats_num; i++) {
		struct mcp_trace_format *format_ptr = &meta->formats[i];
		u8 format_len;

		format_ptr->data = qed_read_dword_from_buf(meta_buf_bytes,
							   &offset);
		format_len = GET_MFW_FIELD(format_ptr->data,
					   MCP_TRACE_FORMAT_LEN);
		format_ptr->format_str = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
							     GFP_KERNEL,
							     format_len);
		if (!format_ptr->format_str) {
			/* Update number of modules to be released */
			meta->formats_num = i ? i - 1 : 0;
			return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
		}

		qed_read_str_from_buf(meta_buf_bytes,
				      &offset,
				      format_len, format_ptr->format_str);
	}

	meta->is_allocated = true;
	return DBG_STATUS_OK;
}
/* Allocates and fills MCP Trace meta data based on the specified meta data
 * dump buffer.
 * Returns debug status code.
 */
Allocates and fills MCP Trace meta data based on the specified meta data
dump buffer.
Returns debug status code.
Allocates and fills MCP Trace meta data based on the specified meta data dump buffer . Returns debug status code .
static enum dbg_status
qed_mcp_trace_alloc_meta_data(struct ecore_hwfn *p_hwfn,
			      const u32 *meta_buf)
{
	struct dbg_tools_user_data *dev_user_data;
	u32 offset = 0, signature, i;
	struct mcp_trace_meta *meta;
	u8 *meta_buf_bytes = (u8 *)(osal_uintptr_t)meta_buf;
	dev_user_data = qed_dbg_get_user_data(p_hwfn);
	meta = &dev_user_data->mcp_trace_meta;
	if (meta->is_allocated)
		qed_mcp_trace_free_meta_data(p_hwfn);
	OSAL_MEMSET(meta, 0, sizeof(*meta));
	signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	if (signature != NVM_MAGIC_VALUE)
		return DBG_STATUS_INVALID_TRACE_SIGNATURE;
	meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
	meta->modules = (char **)OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
				    meta->modules_num * sizeof(char *));
	if (!meta->modules)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
	for (i = 0; i < meta->modules_num; i++) {
		u8 module_len = qed_read_byte_from_buf(meta_buf_bytes, &offset);
		*(meta->modules + i) = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
							   GFP_KERNEL,
							   module_len);
		if (!(*(meta->modules + i))) {
			meta->modules_num = i ? i - 1 : 0;
			return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
		}
		qed_read_str_from_buf(meta_buf_bytes, &offset, module_len,
				      *(meta->modules + i));
		if (module_len > MCP_TRACE_MAX_MODULE_LEN)
			(*(meta->modules + i))[MCP_TRACE_MAX_MODULE_LEN] = '\0';
	}
	signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	if (signature != NVM_MAGIC_VALUE)
		return DBG_STATUS_INVALID_TRACE_SIGNATURE;
	meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
	meta->formats =
		(struct mcp_trace_format *)OSAL_ZALLOC(p_hwfn->p_dev,
						       GFP_KERNEL,
						       meta->formats_num *
					       sizeof(struct mcp_trace_format));
	if (!meta->formats)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
	for (i = 0; i < meta->formats_num; i++) {
		struct mcp_trace_format *format_ptr = &meta->formats[i];
		u8 format_len;
		format_ptr->data = qed_read_dword_from_buf(meta_buf_bytes,
							   &offset);
		format_len = GET_MFW_FIELD(format_ptr->data,
					   MCP_TRACE_FORMAT_LEN);
		format_ptr->format_str = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
							     GFP_KERNEL,
							     format_len);
		if (!format_ptr->format_str) {
			meta->formats_num = i ? i - 1 : 0;
			return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
		}
		qed_read_str_from_buf(meta_buf_bytes,
				      &offset,
				      format_len, format_ptr->format_str);
	}
	meta->is_allocated = true;
	return DBG_STATUS_OK;
}
static enum dbg_status qed_mcp_trace_alloc_meta_data ( struct ecore_hwfn * p_hwfn , const u32 * meta_buf ) { struct dbg_tools_user_data * dev_user_data ; u32 offset = 0 , signature , i ; struct mcp_trace_meta * meta ; u8 * meta_buf_bytes = ( u8 * ) ( osal_uintptr_t ) meta_buf ; dev_user_data = qed_dbg_get_user_data ( p_hwfn ) ; meta = & dev_user_data -> mcp_trace_meta ; if ( meta -> is_allocated ) qed_mcp_trace_free_meta_data ( p_hwfn ) ; OSAL_MEMSET ( meta , 0 , sizeof ( * meta ) ) ; signature = qed_read_dword_from_buf ( meta_buf_bytes , & offset ) ; if ( signature != NVM_MAGIC_VALUE ) return DBG_STATUS_INVALID_TRACE_SIGNATURE ; meta -> modules_num = qed_read_byte_from_buf ( meta_buf_bytes , & offset ) ; meta -> modules = ( char * * ) OSAL_ZALLOC ( p_hwfn -> p_dev , GFP_KERNEL , meta -> modules_num * sizeof ( char * ) ) ; if ( ! meta -> modules ) return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; for ( i = 0 ; i < meta -> modules_num ; i ++ ) { u8 module_len = qed_read_byte_from_buf ( meta_buf_bytes , & offset ) ; * ( meta -> modules + i ) = ( char * ) OSAL_ZALLOC ( p_hwfn -> p_dev , GFP_KERNEL , module_len ) ; if ( ! ( * ( meta -> modules + i ) ) ) { meta -> modules_num = i ? i - 1 : 0 ; return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; } qed_read_str_from_buf ( meta_buf_bytes , & offset , module_len , * ( meta -> modules + i ) ) ; if ( module_len > MCP_TRACE_MAX_MODULE_LEN ) ( * ( meta -> modules + i ) ) [ MCP_TRACE_MAX_MODULE_LEN ] = ' \0 ' ; } signature = qed_read_dword_from_buf ( meta_buf_bytes , & offset ) ; if ( signature != NVM_MAGIC_VALUE ) return DBG_STATUS_INVALID_TRACE_SIGNATURE ; meta -> formats_num = qed_read_dword_from_buf ( meta_buf_bytes , & offset ) ; meta -> formats = ( struct mcp_trace_format * ) OSAL_ZALLOC ( p_hwfn -> p_dev , GFP_KERNEL , meta -> formats_num * sizeof ( struct mcp_trace_format ) ) ; if ( ! meta -> formats ) return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; for ( i = 0 ; i < meta -> formats_num ; i ++ ) { struct mcp_trace_format * format_ptr = & meta -> formats [ i ] ; u8 format_len ; format_ptr -> data = qed_read_dword_from_buf ( meta_buf_bytes , & offset ) ; format_len = GET_MFW_FIELD ( format_ptr -> data , MCP_TRACE_FORMAT_LEN ) ; format_ptr -> format_str = ( char * ) OSAL_ZALLOC ( p_hwfn -> p_dev , GFP_KERNEL , format_len ) ; if ( ! format_ptr -> format_str ) { meta -> formats_num = i ? i - 1 : 0 ; return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; } qed_read_str_from_buf ( meta_buf_bytes , & offset , format_len , format_ptr -> format_str ) ; } meta -> is_allocated = true ; return DBG_STATUS_OK ; }
Allocates and fills MCP Trace meta data based on the specified meta data
 dump buffer.
Allocates and fills MCP Trace meta data based on the specified meta data dump buffer .
/* Free the previous meta before loading a new one. */ /* Read first signature */ /* Read no. of modules and allocate memory for their pointers */ /* Allocate and read all module strings */ /* Update number of modules to be released */ /* Read second signature */ /* Read number of formats and allocate memory for all formats */ /* Allocate and read all strings */ /* Update number of modules to be released */