src/dpdk/drivers/net/qede/qede_debug.c
static enum dbg_status qed_dbg_dump(struct ecore_hwfn *p_hwfn,
				    struct ecore_ptt *p_ptt,
				    enum ecore_dbg_features feature_idx)
{
	struct ecore_dbg_feature *feature =
	    &p_hwfn->p_dev->dbg_params.features[feature_idx];
	u32 buf_size_dwords;
	enum dbg_status rc;

	DP_NOTICE(p_hwfn->p_dev, false, "Collecting a debug feature [\"%s\"]\n",
		  qed_features_lookup[feature_idx].name);

	/* Dump_buf was already allocated need to free (this can happen if dump
	 * was called but file was never read).
	 * We can't use the buffer as is since size may have changed.
	 */
	if (feature->dump_buf) {
		OSAL_VFREE(p_hwfn, feature->dump_buf);
		feature->dump_buf = NULL;
	}

	/* Get buffer size from hsi, allocate accordingly, and perform the
	 * dump.
	 */
	rc = qed_features_lookup[feature_idx].get_size(p_hwfn, p_ptt,
						       &buf_size_dwords);
	if (rc != DBG_STATUS_OK && rc != DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
		return rc;

	if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS) {
		feature->buf_size = 0;
		DP_NOTICE(p_hwfn->p_dev, false,
			  "Debug feature [\"%s\"] size (0x%x dwords) exceeds maximum size (0x%x dwords)\n",
			  qed_features_lookup[feature_idx].name,
			  buf_size_dwords, MAX_DBG_FEATURE_SIZE_DWORDS);

		return DBG_STATUS_OK;
	}

	feature->buf_size = buf_size_dwords * sizeof(u32);
	feature->dump_buf = OSAL_ZALLOC(p_hwfn, GFP_KERNEL, feature->buf_size);
	if (!feature->dump_buf)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;

	rc = qed_features_lookup[feature_idx].perform_dump(p_hwfn, p_ptt,
					(u32 *)feature->dump_buf,
					feature->buf_size / sizeof(u32),
					&feature->dumped_dwords);

	/* If mcp is stuck we get DBG_STATUS_NVRAM_GET_IMAGE_FAILED error.
	 * In this case the buffer holds valid binary data, but we won't able
	 * to parse it (since parsing relies on data in NVRAM which is only
	 * accessible when MFW is responsive). skip the formatting but return
	 * success so that binary data is provided.
	 */
	if (rc == DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
		return DBG_STATUS_OK;

	if (rc != DBG_STATUS_OK)
		return rc;

	/* Format output */
	rc = format_feature(p_hwfn, feature_idx);
	return rc;
}
/* Generic function for performing the dump of a debug feature. */
Generic function for performing the dump of a debug feature.
Generic function for performing the dump of a debug feature .
static enum dbg_status qed_dbg_dump(struct ecore_hwfn *p_hwfn,
				    struct ecore_ptt *p_ptt,
				    enum ecore_dbg_features feature_idx)
{
	struct ecore_dbg_feature *feature =
	    &p_hwfn->p_dev->dbg_params.features[feature_idx];
	u32 buf_size_dwords;
	enum dbg_status rc;
	DP_NOTICE(p_hwfn->p_dev, false, "Collecting a debug feature [\"%s\"]\n",
		  qed_features_lookup[feature_idx].name);
	if (feature->dump_buf) {
		OSAL_VFREE(p_hwfn, feature->dump_buf);
		feature->dump_buf = NULL;
	}
	rc = qed_features_lookup[feature_idx].get_size(p_hwfn, p_ptt,
						       &buf_size_dwords);
	if (rc != DBG_STATUS_OK && rc != DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
		return rc;
	if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS) {
		feature->buf_size = 0;
		DP_NOTICE(p_hwfn->p_dev, false,
			  "Debug feature [\"%s\"] size (0x%x dwords) exceeds maximum size (0x%x dwords)\n",
			  qed_features_lookup[feature_idx].name,
			  buf_size_dwords, MAX_DBG_FEATURE_SIZE_DWORDS);
		return DBG_STATUS_OK;
	}
	feature->buf_size = buf_size_dwords * sizeof(u32);
	feature->dump_buf = OSAL_ZALLOC(p_hwfn, GFP_KERNEL, feature->buf_size);
	if (!feature->dump_buf)
		return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
	rc = qed_features_lookup[feature_idx].perform_dump(p_hwfn, p_ptt,
					(u32 *)feature->dump_buf,
					feature->buf_size / sizeof(u32),
					&feature->dumped_dwords);
	if (rc == DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
		return DBG_STATUS_OK;
	if (rc != DBG_STATUS_OK)
		return rc;
	rc = format_feature(p_hwfn, feature_idx);
	return rc;
}
static enum dbg_status qed_dbg_dump ( struct ecore_hwfn * p_hwfn , struct ecore_ptt * p_ptt , enum ecore_dbg_features feature_idx ) { struct ecore_dbg_feature * feature = & p_hwfn -> p_dev -> dbg_params . features [ feature_idx ] ; u32 buf_size_dwords ; enum dbg_status rc ; DP_NOTICE ( p_hwfn -> p_dev , false , " \" \" \n " , qed_features_lookup [ feature_idx ] . name ) ; if ( feature -> dump_buf ) { OSAL_VFREE ( p_hwfn , feature -> dump_buf ) ; feature -> dump_buf = NULL ; } rc = qed_features_lookup [ feature_idx ] . get_size ( p_hwfn , p_ptt , & buf_size_dwords ) ; if ( rc != DBG_STATUS_OK && rc != DBG_STATUS_NVRAM_GET_IMAGE_FAILED ) return rc ; if ( buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS ) { feature -> buf_size = 0 ; DP_NOTICE ( p_hwfn -> p_dev , false , " \" \" \n " , qed_features_lookup [ feature_idx ] . name , buf_size_dwords , MAX_DBG_FEATURE_SIZE_DWORDS ) ; return DBG_STATUS_OK ; } feature -> buf_size = buf_size_dwords * sizeof ( u32 ) ; feature -> dump_buf = OSAL_ZALLOC ( p_hwfn , GFP_KERNEL , feature -> buf_size ) ; if ( ! feature -> dump_buf ) return DBG_STATUS_VIRT_MEM_ALLOC_FAILED ; rc = qed_features_lookup [ feature_idx ] . perform_dump ( p_hwfn , p_ptt , ( u32 * ) feature -> dump_buf , feature -> buf_size / sizeof ( u32 ) , & feature -> dumped_dwords ) ; if ( rc == DBG_STATUS_NVRAM_GET_IMAGE_FAILED ) return DBG_STATUS_OK ; if ( rc != DBG_STATUS_OK ) return rc ; rc = format_feature ( p_hwfn , feature_idx ) ; return rc ; }
Generic function for performing the dump of a debug feature.
Generic function for performing the dump of a debug feature .
/* Dump_buf was already allocated need to free (this can happen if dump
	 * was called but file was never read).
	 * We can't use the buffer as is since size may have changed.
	 */ /* Get buffer size from hsi, allocate accordingly, and perform the
	 * dump.
	 */ /* If mcp is stuck we get DBG_STATUS_NVRAM_GET_IMAGE_FAILED error.
	 * In this case the buffer holds valid binary data, but we won't able
	 * to parse it (since parsing relies on data in NVRAM which is only
	 * accessible when MFW is responsive). skip the formatting but return
	 * success so that binary data is provided.
	 */ /* Format output */