src/dpdk/drivers/net/i40e/i40e_ethdev.c
static enum i40e_status_code
i40e_vsi_get_bw_config(struct i40e_vsi *vsi)
{
	struct i40e_aqc_query_vsi_bw_config_resp bw_config;
	struct i40e_aqc_query_vsi_ets_sla_config_resp ets_sla_config;
	struct i40e_hw *hw = &vsi->adapter->hw;
	i40e_status ret;
	int i;
	uint32_t bw_max;

	memset(&bw_config, 0, sizeof(bw_config));
	ret = i40e_aq_query_vsi_bw_config(hw, vsi->seid, &bw_config, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR, "VSI failed to get bandwidth configuration %u",
			    hw->aq.asq_last_status);
		return ret;
	}

	memset(&ets_sla_config, 0, sizeof(ets_sla_config));
	ret = i40e_aq_query_vsi_ets_sla_config(hw, vsi->seid,
					&ets_sla_config, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"VSI failed to get TC bandwdith configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}

	/* store and print out BW info */
	vsi->bw_info.bw_limit = rte_le_to_cpu_16(bw_config.port_bw_limit);
	vsi->bw_info.bw_max = bw_config.max_bw;
	PMD_DRV_LOG(DEBUG, "VSI bw limit:%u", vsi->bw_info.bw_limit);
	PMD_DRV_LOG(DEBUG, "VSI max_bw:%u", vsi->bw_info.bw_max);
	bw_max = rte_le_to_cpu_16(ets_sla_config.tc_bw_max[0]) |
		    (rte_le_to_cpu_16(ets_sla_config.tc_bw_max[1]) <<
		     I40E_16_BIT_WIDTH);
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		vsi->bw_info.bw_ets_share_credits[i] =
				ets_sla_config.share_credits[i];
		vsi->bw_info.bw_ets_credits[i] =
				rte_le_to_cpu_16(ets_sla_config.credits[i]);
		/* 4 bits per TC, 4th bit is reserved */
		vsi->bw_info.bw_ets_max[i] =
			(uint8_t)((bw_max >> (i * I40E_4_BIT_WIDTH)) &
				  RTE_LEN2MASK(3, uint8_t));
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u:share credits %u", i,
			    vsi->bw_info.bw_ets_share_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u:credits %u", i,
			    vsi->bw_info.bw_ets_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u: max credits: %u", i,
			    vsi->bw_info.bw_ets_max[i]);
	}

	return I40E_SUCCESS;
}
/*
 * i40e_vsi_get_bw_config - Query VSI BW Information
 * @vsi: the VSI to be queried
 *
 * Returns 0 on success, negative value on failure
 */
Query VSI BW Information
@vsi: the VSI to be queried

Returns 0 on success, negative value on failure
Query VSI BW Information @vsi : the VSI to be queried Returns 0 on success negative value on failure
static enum i40e_status_code
i40e_vsi_get_bw_config(struct i40e_vsi *vsi)
{
	struct i40e_aqc_query_vsi_bw_config_resp bw_config;
	struct i40e_aqc_query_vsi_ets_sla_config_resp ets_sla_config;
	struct i40e_hw *hw = &vsi->adapter->hw;
	i40e_status ret;
	int i;
	uint32_t bw_max;
	memset(&bw_config, 0, sizeof(bw_config));
	ret = i40e_aq_query_vsi_bw_config(hw, vsi->seid, &bw_config, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR, "VSI failed to get bandwidth configuration %u",
			    hw->aq.asq_last_status);
		return ret;
	}
	memset(&ets_sla_config, 0, sizeof(ets_sla_config));
	ret = i40e_aq_query_vsi_ets_sla_config(hw, vsi->seid,
					&ets_sla_config, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"VSI failed to get TC bandwdith configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}
	vsi->bw_info.bw_limit = rte_le_to_cpu_16(bw_config.port_bw_limit);
	vsi->bw_info.bw_max = bw_config.max_bw;
	PMD_DRV_LOG(DEBUG, "VSI bw limit:%u", vsi->bw_info.bw_limit);
	PMD_DRV_LOG(DEBUG, "VSI max_bw:%u", vsi->bw_info.bw_max);
	bw_max = rte_le_to_cpu_16(ets_sla_config.tc_bw_max[0]) |
		    (rte_le_to_cpu_16(ets_sla_config.tc_bw_max[1]) <<
		     I40E_16_BIT_WIDTH);
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		vsi->bw_info.bw_ets_share_credits[i] =
				ets_sla_config.share_credits[i];
		vsi->bw_info.bw_ets_credits[i] =
				rte_le_to_cpu_16(ets_sla_config.credits[i]);
		vsi->bw_info.bw_ets_max[i] =
			(uint8_t)((bw_max >> (i * I40E_4_BIT_WIDTH)) &
				  RTE_LEN2MASK(3, uint8_t));
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u:share credits %u", i,
			    vsi->bw_info.bw_ets_share_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u:credits %u", i,
			    vsi->bw_info.bw_ets_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVSI TC%u: max credits: %u", i,
			    vsi->bw_info.bw_ets_max[i]);
	}
	return I40E_SUCCESS;
}
static enum i40e_status_code i40e_vsi_get_bw_config ( struct i40e_vsi * vsi ) { struct i40e_aqc_query_vsi_bw_config_resp bw_config ; struct i40e_aqc_query_vsi_ets_sla_config_resp ets_sla_config ; struct i40e_hw * hw = & vsi -> adapter -> hw ; i40e_status ret ; int i ; uint32_t bw_max ; memset ( & bw_config , 0 , sizeof ( bw_config ) ) ; ret = i40e_aq_query_vsi_bw_config ( hw , vsi -> seid , & bw_config , NULL ) ; if ( ret != I40E_SUCCESS ) { PMD_DRV_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; return ret ; } memset ( & ets_sla_config , 0 , sizeof ( ets_sla_config ) ) ; ret = i40e_aq_query_vsi_ets_sla_config ( hw , vsi -> seid , & ets_sla_config , NULL ) ; if ( ret != I40E_SUCCESS ) { PMD_DRV_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; return ret ; } vsi -> bw_info . bw_limit = rte_le_to_cpu_16 ( bw_config . port_bw_limit ) ; vsi -> bw_info . bw_max = bw_config . max_bw ; PMD_DRV_LOG ( DEBUG , " " , vsi -> bw_info . bw_limit ) ; PMD_DRV_LOG ( DEBUG , " " , vsi -> bw_info . bw_max ) ; bw_max = rte_le_to_cpu_16 ( ets_sla_config . tc_bw_max [ 0 ] ) | ( rte_le_to_cpu_16 ( ets_sla_config . tc_bw_max [ 1 ] ) << I40E_16_BIT_WIDTH ) ; for ( i = 0 ; i < I40E_MAX_TRAFFIC_CLASS ; i ++ ) { vsi -> bw_info . bw_ets_share_credits [ i ] = ets_sla_config . share_credits [ i ] ; vsi -> bw_info . bw_ets_credits [ i ] = rte_le_to_cpu_16 ( ets_sla_config . credits [ i ] ) ; vsi -> bw_info . bw_ets_max [ i ] = ( uint8_t ) ( ( bw_max >> ( i * I40E_4_BIT_WIDTH ) ) & RTE_LEN2MASK ( 3 , uint8_t ) ) ; PMD_DRV_LOG ( DEBUG , " \t " , i , vsi -> bw_info . bw_ets_share_credits [ i ] ) ; PMD_DRV_LOG ( DEBUG , " \t " , i , vsi -> bw_info . bw_ets_credits [ i ] ) ; PMD_DRV_LOG ( DEBUG , " \t " , i , vsi -> bw_info . bw_ets_max [ i ] ) ; } return I40E_SUCCESS ; }
i40e_vsi_get_bw_config - Query VSI BW Information
 @vsi: the VSI to be queried
i40e_vsi_get_bw_config - Query VSI BW Information @vsi : the VSI to be queried
/* store and print out BW info */ /* 4 bits per TC, 4th bit is reserved */