src/dpdk/drivers/net/i40e/i40e_ethdev.c
static enum i40e_status_code
i40e_vsi_config_tc(struct i40e_vsi *vsi, uint8_t tc_map)
{
	struct i40e_aqc_configure_vsi_tc_bw_data bw_data;
	struct i40e_vsi_context ctxt;
	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
	enum i40e_status_code ret = I40E_SUCCESS;
	int i;

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

	/* configure tc bandwidth */
	memset(&bw_data, 0, sizeof(bw_data));
	bw_data.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))
			bw_data.tc_bw_credits[i] = 1;
	}
	ret = i40e_aq_config_vsi_tc_bw(hw, vsi->seid, &bw_data, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR,
			"AQ command Config VSI BW allocation per TC failed = %d",
			hw->aq.asq_last_status);
		goto out;
	}
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
		vsi->info.qs_handle[i] = bw_data.qs_handles[i];

	/* Update Queue Pairs Mapping for currently enabled UPs */
	ctxt.seid = vsi->seid;
	ctxt.pf_num = hw->pf_id;
	ctxt.vf_num = 0;
	ctxt.uplink_seid = vsi->uplink_seid;
	ctxt.info = vsi->info;
	i40e_get_cap(hw);
	ret = i40e_vsi_update_queue_mapping(vsi, &ctxt.info, tc_map);
	if (ret)
		goto out;

	/* Update the VSI after updating the VSI queue-mapping information */
	ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR, "Failed to configure TC queue mapping = %d",
			hw->aq.asq_last_status);
		goto out;
	}
	/* update the local VSI info with updated queue map */
	rte_memcpy(&vsi->info.tc_mapping, &ctxt.info.tc_mapping,
					sizeof(vsi->info.tc_mapping));
	rte_memcpy(&vsi->info.queue_mapping,
			&ctxt.info.queue_mapping,
		sizeof(vsi->info.queue_mapping));
	vsi->info.mapping_flags = ctxt.info.mapping_flags;
	vsi->info.valid_sections = 0;

	/* query and update current VSI BW information */
	ret = i40e_vsi_get_bw_config(vsi);
	if (ret) {
		PMD_INIT_LOG(ERR,
			 "Failed updating vsi bw info, err %s aq_err %s",
			 i40e_stat_str(hw, ret),
			 i40e_aq_str(hw, hw->aq.asq_last_status));
		goto out;
	}

	vsi->enabled_tc = tc_map;

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

Returns 0 on success, negative value on failure
Configure VSI tc setting for given TC map @vsi : VSI to be configured @tc_map : enabled TC bitmap Returns 0 on success negative value on failure
static enum i40e_status_code
i40e_vsi_config_tc(struct i40e_vsi *vsi, uint8_t tc_map)
{
	struct i40e_aqc_configure_vsi_tc_bw_data bw_data;
	struct i40e_vsi_context ctxt;
	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
	enum i40e_status_code ret = I40E_SUCCESS;
	int i;
	if (vsi->enabled_tc == tc_map)
		return ret;
	memset(&bw_data, 0, sizeof(bw_data));
	bw_data.tc_valid_bits = tc_map;
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
		if (tc_map & BIT_ULL(i))
			bw_data.tc_bw_credits[i] = 1;
	}
	ret = i40e_aq_config_vsi_tc_bw(hw, vsi->seid, &bw_data, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR,
			"AQ command Config VSI BW allocation per TC failed = %d",
			hw->aq.asq_last_status);
		goto out;
	}
	for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
		vsi->info.qs_handle[i] = bw_data.qs_handles[i];
	ctxt.seid = vsi->seid;
	ctxt.pf_num = hw->pf_id;
	ctxt.vf_num = 0;
	ctxt.uplink_seid = vsi->uplink_seid;
	ctxt.info = vsi->info;
	i40e_get_cap(hw);
	ret = i40e_vsi_update_queue_mapping(vsi, &ctxt.info, tc_map);
	if (ret)
		goto out;
	ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
	if (ret) {
		PMD_INIT_LOG(ERR, "Failed to configure TC queue mapping = %d",
			hw->aq.asq_last_status);
		goto out;
	}
	rte_memcpy(&vsi->info.tc_mapping, &ctxt.info.tc_mapping,
					sizeof(vsi->info.tc_mapping));
	rte_memcpy(&vsi->info.queue_mapping,
			&ctxt.info.queue_mapping,
		sizeof(vsi->info.queue_mapping));
	vsi->info.mapping_flags = ctxt.info.mapping_flags;
	vsi->info.valid_sections = 0;
	ret = i40e_vsi_get_bw_config(vsi);
	if (ret) {
		PMD_INIT_LOG(ERR,
			 "Failed updating vsi bw info, err %s aq_err %s",
			 i40e_stat_str(hw, ret),
			 i40e_aq_str(hw, hw->aq.asq_last_status));
		goto out;
	}
	vsi->enabled_tc = tc_map;
out:
	return ret;
}
static enum i40e_status_code i40e_vsi_config_tc ( struct i40e_vsi * vsi , uint8_t tc_map ) { struct i40e_aqc_configure_vsi_tc_bw_data bw_data ; struct i40e_vsi_context ctxt ; struct i40e_hw * hw = I40E_VSI_TO_HW ( vsi ) ; enum i40e_status_code ret = I40E_SUCCESS ; int i ; if ( vsi -> enabled_tc == tc_map ) return ret ; memset ( & bw_data , 0 , sizeof ( bw_data ) ) ; bw_data . tc_valid_bits = tc_map ; for ( i = 0 ; i < I40E_MAX_TRAFFIC_CLASS ; i ++ ) { if ( tc_map & BIT_ULL ( i ) ) bw_data . tc_bw_credits [ i ] = 1 ; } ret = i40e_aq_config_vsi_tc_bw ( hw , vsi -> seid , & bw_data , NULL ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; goto out ; } for ( i = 0 ; i < I40E_MAX_TRAFFIC_CLASS ; i ++ ) vsi -> info . qs_handle [ i ] = bw_data . qs_handles [ i ] ; ctxt . seid = vsi -> seid ; ctxt . pf_num = hw -> pf_id ; ctxt . vf_num = 0 ; ctxt . uplink_seid = vsi -> uplink_seid ; ctxt . info = vsi -> info ; i40e_get_cap ( hw ) ; ret = i40e_vsi_update_queue_mapping ( vsi , & ctxt . info , tc_map ) ; if ( ret ) goto out ; ret = i40e_aq_update_vsi_params ( hw , & ctxt , NULL ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , hw -> aq . asq_last_status ) ; goto out ; } rte_memcpy ( & vsi -> info . tc_mapping , & ctxt . info . tc_mapping , sizeof ( vsi -> info . tc_mapping ) ) ; rte_memcpy ( & vsi -> info . queue_mapping , & ctxt . info . queue_mapping , sizeof ( vsi -> info . queue_mapping ) ) ; vsi -> info . mapping_flags = ctxt . info . mapping_flags ; vsi -> info . valid_sections = 0 ; ret = i40e_vsi_get_bw_config ( vsi ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , i40e_stat_str ( hw , ret ) , i40e_aq_str ( hw , hw -> aq . asq_last_status ) ) ; goto out ; } vsi -> enabled_tc = tc_map ; out : return ret ; }
i40e_vsi_config_tc - Configure VSI tc setting for given TC map
 @vsi: VSI to be configured
 @tc_map: enabled TC bitmap
i40e_vsi_config_tc - Configure VSI tc setting for given TC map @vsi : VSI 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 */ /* Update Queue Pairs Mapping for currently enabled UPs */ /* Update the VSI after updating the VSI queue-mapping information */ /* update the local VSI info with updated queue map */ /* query and update current VSI BW information */