src/dpdk/drivers/net/i40e/i40e_ethdev.c
static int
i40e_parse_dcb_configure(struct rte_eth_dev *dev,
			 struct i40e_dcbx_config *dcb_cfg,
			 uint8_t *tc_map)
{
	struct rte_eth_dcb_rx_conf *dcb_rx_conf;
	uint8_t i, tc_bw, bw_lf;

	memset(dcb_cfg, 0, sizeof(struct i40e_dcbx_config));

	dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
	if (dcb_rx_conf->nb_tcs > I40E_MAX_TRAFFIC_CLASS) {
		PMD_INIT_LOG(ERR, "number of tc exceeds max.");
		return -EINVAL;
	}

	/* assume each tc has the same bw */
	tc_bw = I40E_MAX_PERCENT / dcb_rx_conf->nb_tcs;
	for (i = 0; i < dcb_rx_conf->nb_tcs; i++)
		dcb_cfg->etscfg.tcbwtable[i] = tc_bw;
	/* to ensure the sum of tcbw is equal to 100 */
	bw_lf = I40E_MAX_PERCENT % dcb_rx_conf->nb_tcs;
	for (i = 0; i < bw_lf; i++)
		dcb_cfg->etscfg.tcbwtable[i]++;

	/* assume each tc has the same Transmission Selection Algorithm */
	for (i = 0; i < dcb_rx_conf->nb_tcs; i++)
		dcb_cfg->etscfg.tsatable[i] = I40E_IEEE_TSA_ETS;

	for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
		dcb_cfg->etscfg.prioritytable[i] =
				dcb_rx_conf->dcb_tc[i];

	/* FW needs one App to configure HW */
	dcb_cfg->numapps = I40E_DEFAULT_DCB_APP_NUM;
	dcb_cfg->app[0].selector = I40E_APP_SEL_ETHTYPE;
	dcb_cfg->app[0].priority = I40E_DEFAULT_DCB_APP_PRIO;
	dcb_cfg->app[0].protocolid = I40E_APP_PROTOID_FCOE;

	if (dcb_rx_conf->nb_tcs == 0)
		*tc_map = 1; /* tc0 only */
	else
		*tc_map = RTE_LEN2MASK(dcb_rx_conf->nb_tcs, uint8_t);

	if (dev->data->dev_conf.dcb_capability_en & ETH_DCB_PFC_SUPPORT) {
		dcb_cfg->pfc.willing = 0;
		dcb_cfg->pfc.pfccap = I40E_MAX_TRAFFIC_CLASS;
		dcb_cfg->pfc.pfcenable = *tc_map;
	}
	return 0;
}
/*
 * i40e_parse_dcb_configure - parse dcb configure from user
 * @dev: the device being configured
 * @dcb_cfg: pointer of the result of parse
 * @*tc_map: bit map of enabled traffic classes
 *
 * Returns 0 on success, negative value on failure
 */
parse dcb configure from user
@dev: the device being configured
@dcb_cfg: pointer of the result of parse
@*tc_map: bit map of enabled traffic classes

Returns 0 on success, negative value on failure
parse dcb configure from user @dev : the device being configured @dcb_cfg : pointer of the result of parse @ * tc_map : bit map of enabled traffic classes Returns 0 on success negative value on failure
static int
i40e_parse_dcb_configure(struct rte_eth_dev *dev,
			 struct i40e_dcbx_config *dcb_cfg,
			 uint8_t *tc_map)
{
	struct rte_eth_dcb_rx_conf *dcb_rx_conf;
	uint8_t i, tc_bw, bw_lf;
	memset(dcb_cfg, 0, sizeof(struct i40e_dcbx_config));
	dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
	if (dcb_rx_conf->nb_tcs > I40E_MAX_TRAFFIC_CLASS) {
		PMD_INIT_LOG(ERR, "number of tc exceeds max.");
		return -EINVAL;
	}
	tc_bw = I40E_MAX_PERCENT / dcb_rx_conf->nb_tcs;
	for (i = 0; i < dcb_rx_conf->nb_tcs; i++)
		dcb_cfg->etscfg.tcbwtable[i] = tc_bw;
	bw_lf = I40E_MAX_PERCENT % dcb_rx_conf->nb_tcs;
	for (i = 0; i < bw_lf; i++)
		dcb_cfg->etscfg.tcbwtable[i]++;
	for (i = 0; i < dcb_rx_conf->nb_tcs; i++)
		dcb_cfg->etscfg.tsatable[i] = I40E_IEEE_TSA_ETS;
	for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
		dcb_cfg->etscfg.prioritytable[i] =
				dcb_rx_conf->dcb_tc[i];
	dcb_cfg->numapps = I40E_DEFAULT_DCB_APP_NUM;
	dcb_cfg->app[0].selector = I40E_APP_SEL_ETHTYPE;
	dcb_cfg->app[0].priority = I40E_DEFAULT_DCB_APP_PRIO;
	dcb_cfg->app[0].protocolid = I40E_APP_PROTOID_FCOE;
	if (dcb_rx_conf->nb_tcs == 0)
		*tc_map = 1; 
	else
		*tc_map = RTE_LEN2MASK(dcb_rx_conf->nb_tcs, uint8_t);
	if (dev->data->dev_conf.dcb_capability_en & ETH_DCB_PFC_SUPPORT) {
		dcb_cfg->pfc.willing = 0;
		dcb_cfg->pfc.pfccap = I40E_MAX_TRAFFIC_CLASS;
		dcb_cfg->pfc.pfcenable = *tc_map;
	}
	return 0;
}
static int i40e_parse_dcb_configure ( struct rte_eth_dev * dev , struct i40e_dcbx_config * dcb_cfg , uint8_t * tc_map ) { struct rte_eth_dcb_rx_conf * dcb_rx_conf ; uint8_t i , tc_bw , bw_lf ; memset ( dcb_cfg , 0 , sizeof ( struct i40e_dcbx_config ) ) ; dcb_rx_conf = & dev -> data -> dev_conf . rx_adv_conf . dcb_rx_conf ; if ( dcb_rx_conf -> nb_tcs > I40E_MAX_TRAFFIC_CLASS ) { PMD_INIT_LOG ( ERR , " " ) ; return - EINVAL ; } tc_bw = I40E_MAX_PERCENT / dcb_rx_conf -> nb_tcs ; for ( i = 0 ; i < dcb_rx_conf -> nb_tcs ; i ++ ) dcb_cfg -> etscfg . tcbwtable [ i ] = tc_bw ; bw_lf = I40E_MAX_PERCENT % dcb_rx_conf -> nb_tcs ; for ( i = 0 ; i < bw_lf ; i ++ ) dcb_cfg -> etscfg . tcbwtable [ i ] ++ ; for ( i = 0 ; i < dcb_rx_conf -> nb_tcs ; i ++ ) dcb_cfg -> etscfg . tsatable [ i ] = I40E_IEEE_TSA_ETS ; for ( i = 0 ; i < I40E_MAX_USER_PRIORITY ; i ++ ) dcb_cfg -> etscfg . prioritytable [ i ] = dcb_rx_conf -> dcb_tc [ i ] ; dcb_cfg -> numapps = I40E_DEFAULT_DCB_APP_NUM ; dcb_cfg -> app [ 0 ] . selector = I40E_APP_SEL_ETHTYPE ; dcb_cfg -> app [ 0 ] . priority = I40E_DEFAULT_DCB_APP_PRIO ; dcb_cfg -> app [ 0 ] . protocolid = I40E_APP_PROTOID_FCOE ; if ( dcb_rx_conf -> nb_tcs == 0 ) * tc_map = 1 ; else * tc_map = RTE_LEN2MASK ( dcb_rx_conf -> nb_tcs , uint8_t ) ; if ( dev -> data -> dev_conf . dcb_capability_en & ETH_DCB_PFC_SUPPORT ) { dcb_cfg -> pfc . willing = 0 ; dcb_cfg -> pfc . pfccap = I40E_MAX_TRAFFIC_CLASS ; dcb_cfg -> pfc . pfcenable = * tc_map ; } return 0 ; }
i40e_parse_dcb_configure - parse dcb configure from user
 @dev: the device being configured
 @dcb_cfg: pointer of the result of parse
 @*tc_map: bit map of enabled traffic classes
i40e_parse_dcb_configure - parse dcb configure from user @dev : the device being configured @dcb_cfg : pointer of the result of parse @ * tc_map : bit map of enabled traffic classes
/* assume each tc has the same bw */ /* to ensure the sum of tcbw is equal to 100 */ /* assume each tc has the same Transmission Selection Algorithm */ /* FW needs one App to configure HW */ /* tc0 only */