src/dpdk/drivers/net/qede/qede_debug.c
static enum dbg_status format_feature(struct ecore_hwfn *p_hwfn,
				      enum ecore_dbg_features feature_idx)
{
	struct ecore_dbg_feature *feature =
	    &p_hwfn->p_dev->dbg_params.features[feature_idx];
	u32 text_size_bytes, null_char_pos, i;
	enum dbg_status rc;
	char *text_buf;

	/* Check if feature supports formatting capability */
	if (!qed_features_lookup[feature_idx].results_buf_size)
		return DBG_STATUS_OK;

	/* Obtain size of formatted output */
	rc = qed_features_lookup[feature_idx].results_buf_size(p_hwfn,
						(u32 *)feature->dump_buf,
						feature->dumped_dwords,
						&text_size_bytes);
	if (rc != DBG_STATUS_OK)
		return rc;

	/* Make sure that the allocated size is a multiple of dword (4 bytes) */
	null_char_pos = text_size_bytes - 1;
	text_size_bytes = (text_size_bytes + 3) & ~0x3;

	if (text_size_bytes < QED_RESULTS_BUF_MIN_SIZE) {
		DP_NOTICE(p_hwfn->p_dev, false,
			  "formatted size of feature was too small %d. Aborting\n",
			  text_size_bytes);
		return DBG_STATUS_INVALID_ARGS;
	}

	/* Allocate temp text buf */
	text_buf = OSAL_VZALLOC(p_hwfn, text_size_bytes);
	if (!text_buf) {
		DP_NOTICE(p_hwfn->p_dev, false,
			  "failed to allocate text buffer. Aborting\n");
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
	}

	/* Decode feature opcodes to string on temp buf */
	rc = qed_features_lookup[feature_idx].print_results(p_hwfn,
						(u32 *)feature->dump_buf,
						feature->dumped_dwords,
						text_buf);
	if (rc != DBG_STATUS_OK) {
		OSAL_VFREE(p_hwfn, text_buf);
		return rc;
	}

	/* Replace the original null character with a '\n' character.
	 * The bytes that were added as a result of the dword alignment are also
	 * padded with '\n' characters.
	 */
	for (i = null_char_pos; i < text_size_bytes; i++)
		text_buf[i] = '\n';


	/* Free the old dump_buf and point the dump_buf to the newly allocagted
	 * and formatted text buffer.
	 */
	OSAL_VFREE(p_hwfn, feature->dump_buf);
	feature->dump_buf = (u8 *)text_buf;
	feature->buf_size = text_size_bytes;
	feature->dumped_dwords = text_size_bytes / 4;
	return rc;
}
/* Generic function for decoding debug feature info */
Generic function for decoding debug feature info
Generic function for decoding debug feature info
static enum dbg_status format_feature(struct ecore_hwfn *p_hwfn,
				      enum ecore_dbg_features feature_idx)
{
	struct ecore_dbg_feature *feature =
	    &p_hwfn->p_dev->dbg_params.features[feature_idx];
	u32 text_size_bytes, null_char_pos, i;
	enum dbg_status rc;
	char *text_buf;
	if (!qed_features_lookup[feature_idx].results_buf_size)
		return DBG_STATUS_OK;
	rc = qed_features_lookup[feature_idx].results_buf_size(p_hwfn,
						(u32 *)feature->dump_buf,
						feature->dumped_dwords,
						&text_size_bytes);
	if (rc != DBG_STATUS_OK)
		return rc;
	null_char_pos = text_size_bytes - 1;
	text_size_bytes = (text_size_bytes + 3) & ~0x3;
	if (text_size_bytes < QED_RESULTS_BUF_MIN_SIZE) {
		DP_NOTICE(p_hwfn->p_dev, false,
			  "formatted size of feature was too small %d. Aborting\n",
			  text_size_bytes);
		return DBG_STATUS_INVALID_ARGS;
	}
	text_buf = OSAL_VZALLOC(p_hwfn, text_size_bytes);
	if (!text_buf) {
		DP_NOTICE(p_hwfn->p_dev, false,
			  "failed to allocate text buffer. Aborting\n");
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
	}
	rc = qed_features_lookup[feature_idx].print_results(p_hwfn,
						(u32 *)feature->dump_buf,
						feature->dumped_dwords,
						text_buf);
	if (rc != DBG_STATUS_OK) {
		OSAL_VFREE(p_hwfn, text_buf);
		return rc;
	}
	for (i = null_char_pos; i < text_size_bytes; i++)
		text_buf[i] = '\n';
	OSAL_VFREE(p_hwfn, feature->dump_buf);
	feature->dump_buf = (u8 *)text_buf;
	feature->buf_size = text_size_bytes;
	feature->dumped_dwords = text_size_bytes / 4;
	return rc;
}
static enum dbg_status format_feature ( struct ecore_hwfn * p_hwfn , enum ecore_dbg_features feature_idx ) { struct ecore_dbg_feature * feature = & p_hwfn -> p_dev -> dbg_params . features [ feature_idx ] ; u32 text_size_bytes , null_char_pos , i ; enum dbg_status rc ; char * text_buf ; if ( ! qed_features_lookup [ feature_idx ] . results_buf_size ) return DBG_STATUS_OK ; rc = qed_features_lookup [ feature_idx ] . results_buf_size ( p_hwfn , ( u32 * ) feature -> dump_buf , feature -> dumped_dwords , & text_size_bytes ) ; if ( rc != DBG_STATUS_OK ) return rc ; null_char_pos = text_size_bytes - 1 ; text_size_bytes = ( text_size_bytes + 3 ) & ~ 0x3 ; if ( text_size_bytes < QED_RESULTS_BUF_MIN_SIZE ) { DP_NOTICE ( p_hwfn -> p_dev , false , " \n " , text_size_bytes ) ; return DBG_STATUS_INVALID_ARGS ; } text_buf = OSAL_VZALLOC ( p_hwfn , text_size_bytes ) ; if ( ! text_buf ) { DP_NOTICE ( p_hwfn -> p_dev , false , " \n " ) ; return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; } rc = qed_features_lookup [ feature_idx ] . print_results ( p_hwfn , ( u32 * ) feature -> dump_buf , feature -> dumped_dwords , text_buf ) ; if ( rc != DBG_STATUS_OK ) { OSAL_VFREE ( p_hwfn , text_buf ) ; return rc ; } for ( i = null_char_pos ; i < text_size_bytes ; i ++ ) text_buf [ i ] = ' \n ' ; OSAL_VFREE ( p_hwfn , feature -> dump_buf ) ; feature -> dump_buf = ( u8 * ) text_buf ; feature -> buf_size = text_size_bytes ; feature -> dumped_dwords = text_size_bytes / 4 ; return rc ; }
Generic function for decoding debug feature info
Generic function for decoding debug feature info
/* Check if feature supports formatting capability */ /* Obtain size of formatted output */ /* Make sure that the allocated size is a multiple of dword (4 bytes) */ /* Allocate temp text buf */ /* Decode feature opcodes to string on temp buf */ /* Replace the original null character with a '\n' character.
	 * The bytes that were added as a result of the dword alignment are also
	 * padded with '\n' characters.
	 */ /* Free the old dump_buf and point the dump_buf to the newly allocagted
	 * and formatted text buffer.
	 */