src/dpdk/drivers/net/i40e/i40e_ethdev.c
static enum i40e_status_code
i40e_config_switch_comp_tc(struct i40e_veb *veb, uint8_t tc_map)
{
	struct i40e_aqc_configure_switching_comp_bw_config_data veb_bw;
	struct i40e_aqc_query_switching_comp_bw_config_resp bw_query;
	struct i40e_aqc_query_switching_comp_ets_config_resp ets_query;
	struct i40e_hw *hw = I40E_VSI_TO_HW(veb->associate_vsi);
	enum i40e_status_code ret = I40E_SUCCESS;
	int i;
	uint32_t bw_max;

	/* Check if enabled_tc is same as existing or new TCs */
	if (veb->enabled_tc == tc_map)
		return ret;

	/* configure tc bandwidth */
	memset(&veb_bw, 0, sizeof(veb_bw));
	veb_bw.tc_valid_bits = tc_map;
	/* Enable ETS TCs with equal BW Share for now across all VSIs */
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		if (tc_map & BIT_ULL(i))
			veb_bw.tc_bw_share_credits[i] = 1;
	}
	ret = i40e_aq_config_switch_comp_bw_config(hw, veb->seid,
						   &veb_bw, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR,
			"AQ command Config switch_comp BW allocation per TC failed = %d",
			hw->aq.asq_last_status);
		return ret;
	}

	memset(&ets_query, 0, sizeof(ets_query));
	ret = i40e_aq_query_switch_comp_ets_config(hw, veb->seid,
						   &ets_query, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"Failed to get switch_comp ETS configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}
	memset(&bw_query, 0, sizeof(bw_query));
	ret = i40e_aq_query_switch_comp_bw_config(hw, veb->seid,
						  &bw_query, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"Failed to get switch_comp bandwidth configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}

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

	veb->enabled_tc = tc_map;

	return ret;
}
/*
 * i40e_config_switch_comp_tc - Configure VEB tc setting for given TC map
 * @veb: VEB to be configured
 * @tc_map: enabled TC bitmap
 *
 * Returns 0 on success, negative value on failure
 */
Configure VEB tc setting for given TC map
@veb: VEB to be configured
@tc_map: enabled TC bitmap

Returns 0 on success, negative value on failure
Configure VEB tc setting for given TC map @veb : VEB to be configured @tc_map : enabled TC bitmap Returns 0 on success negative value on failure
static enum i40e_status_code
i40e_config_switch_comp_tc(struct i40e_veb *veb, uint8_t tc_map)
{
	struct i40e_aqc_configure_switching_comp_bw_config_data veb_bw;
	struct i40e_aqc_query_switching_comp_bw_config_resp bw_query;
	struct i40e_aqc_query_switching_comp_ets_config_resp ets_query;
	struct i40e_hw *hw = I40E_VSI_TO_HW(veb->associate_vsi);
	enum i40e_status_code ret = I40E_SUCCESS;
	int i;
	uint32_t bw_max;
	if (veb->enabled_tc == tc_map)
		return ret;
	memset(&veb_bw, 0, sizeof(veb_bw));
	veb_bw.tc_valid_bits = tc_map;
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		if (tc_map & BIT_ULL(i))
			veb_bw.tc_bw_share_credits[i] = 1;
	}
	ret = i40e_aq_config_switch_comp_bw_config(hw, veb->seid,
						   &veb_bw, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR,
			"AQ command Config switch_comp BW allocation per TC failed = %d",
			hw->aq.asq_last_status);
		return ret;
	}
	memset(&ets_query, 0, sizeof(ets_query));
	ret = i40e_aq_query_switch_comp_ets_config(hw, veb->seid,
						   &ets_query, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"Failed to get switch_comp ETS configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}
	memset(&bw_query, 0, sizeof(bw_query));
	ret = i40e_aq_query_switch_comp_bw_config(hw, veb->seid,
						  &bw_query, NULL);
	if (ret != I40E_SUCCESS) {
		PMD_DRV_LOG(ERR,
			"Failed to get switch_comp bandwidth configuration %u",
			hw->aq.asq_last_status);
		return ret;
	}
	veb->bw_info.bw_limit = rte_le_to_cpu_16(ets_query.port_bw_limit);
	veb->bw_info.bw_max = ets_query.tc_bw_max;
	PMD_DRV_LOG(DEBUG, "switch_comp bw limit:%u", veb->bw_info.bw_limit);
	PMD_DRV_LOG(DEBUG, "switch_comp max_bw:%u", veb->bw_info.bw_max);
	bw_max = rte_le_to_cpu_16(bw_query.tc_bw_max[0]) |
		    (rte_le_to_cpu_16(bw_query.tc_bw_max[1]) <<
		     I40E_16_BIT_WIDTH);
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		veb->bw_info.bw_ets_share_credits[i] =
				bw_query.tc_bw_share_credits[i];
		veb->bw_info.bw_ets_credits[i] =
				rte_le_to_cpu_16(bw_query.tc_bw_limits[i]);
		veb->bw_info.bw_ets_max[i] =
			(uint8_t)((bw_max >> (i * I40E_4_BIT_WIDTH)) &
				  RTE_LEN2MASK(3, uint8_t));
		PMD_DRV_LOG(DEBUG, "\tVEB TC%u:share credits %u", i,
			    veb->bw_info.bw_ets_share_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVEB TC%u:credits %u", i,
			    veb->bw_info.bw_ets_credits[i]);
		PMD_DRV_LOG(DEBUG, "\tVEB TC%u: max credits: %u", i,
			    veb->bw_info.bw_ets_max[i]);
	}
	veb->enabled_tc = tc_map;
	return ret;
}
static enum i40e_status_code i40e_config_switch_comp_tc ( struct i40e_veb * veb , uint8_t tc_map ) { struct i40e_aqc_configure_switching_comp_bw_config_data veb_bw ; struct i40e_aqc_query_switching_comp_bw_config_resp bw_query ; struct i40e_aqc_query_switching_comp_ets_config_resp ets_query ; struct i40e_hw * hw = I40E_VSI_TO_HW ( veb -> associate_vsi ) ; enum i40e_status_code ret = I40E_SUCCESS ; int i ; uint32_t bw_max ; if ( veb -> enabled_tc == tc_map ) return ret ; memset ( & veb_bw , 0 , sizeof ( veb_bw ) ) ; veb_bw . tc_valid_bits = tc_map ; for ( i = 0 ; i < I40E_MAX_TRAFFIC_CLASS ; i ++ ) { if ( tc_map & BIT_ULL ( i ) ) veb_bw . tc_bw_share_credits [ i ] = 1 ; } ret = i40e_aq_config_switch_comp_bw_config ( hw , veb -> seid , & veb_bw , NULL ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; return ret ; } memset ( & ets_query , 0 , sizeof ( ets_query ) ) ; ret = i40e_aq_query_switch_comp_ets_config ( hw , veb -> seid , & ets_query , NULL ) ; if ( ret != I40E_SUCCESS ) { PMD_DRV_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; return ret ; } memset ( & bw_query , 0 , sizeof ( bw_query ) ) ; ret = i40e_aq_query_switch_comp_bw_config ( hw , veb -> seid , & bw_query , NULL ) ; if ( ret != I40E_SUCCESS ) { PMD_DRV_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; return ret ; } veb -> bw_info . bw_limit = rte_le_to_cpu_16 ( ets_query . port_bw_limit ) ; veb -> bw_info . bw_max = ets_query . tc_bw_max ; PMD_DRV_LOG ( DEBUG , " " , veb -> bw_info . bw_limit ) ; PMD_DRV_LOG ( DEBUG , " " , veb -> bw_info . bw_max ) ; bw_max = rte_le_to_cpu_16 ( bw_query . tc_bw_max [ 0 ] ) | ( rte_le_to_cpu_16 ( bw_query . tc_bw_max [ 1 ] ) << I40E_16_BIT_WIDTH ) ; for ( i = 0 ; i < I40E_MAX_TRAFFIC_CLASS ; i ++ ) { veb -> bw_info . bw_ets_share_credits [ i ] = bw_query . tc_bw_share_credits [ i ] ; veb -> bw_info . bw_ets_credits [ i ] = rte_le_to_cpu_16 ( bw_query . tc_bw_limits [ i ] ) ; veb -> 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 , veb -> bw_info . bw_ets_share_credits [ i ] ) ; PMD_DRV_LOG ( DEBUG , " \t " , i , veb -> bw_info . bw_ets_credits [ i ] ) ; PMD_DRV_LOG ( DEBUG , " \t " , i , veb -> bw_info . bw_ets_max [ i ] ) ; } veb -> enabled_tc = tc_map ; return ret ; }
i40e_config_switch_comp_tc - Configure VEB tc setting for given TC map
 @veb: VEB to be configured
 @tc_map: enabled TC bitmap
i40e_config_switch_comp_tc - Configure VEB tc setting for given TC map @veb : VEB to be configured @tc_map : enabled TC bitmap
/* Check if enabled_tc is same as existing or new TCs */ /* configure tc bandwidth */ /* Enable ETS TCs with equal BW Share for now across all VSIs */ /* store and print out BW info */ /* 4 bits per TC, 4th bit is reserved */