src/dpdk/drivers/net/i40e/i40e_ethdev.c
static enum i40e_status_code
i40e_dcb_hw_configure(struct i40e_pf *pf,
		      struct i40e_dcbx_config *new_cfg,
		      uint8_t tc_map)
{
	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
	struct i40e_dcbx_config *old_cfg = &hw->local_dcbx_config;
	struct i40e_vsi *main_vsi = pf->main_vsi;
	struct i40e_vsi_list *vsi_list;
	enum i40e_status_code ret;
	int i;
	uint32_t val;

	/* Use the FW API if FW > v4.4*/
	if (!(((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver >= 4)) ||
	      (hw->aq.fw_maj_ver >= 5))) {
		PMD_INIT_LOG(ERR,
			"FW < v4.4, can not use FW LLDP API to configure DCB");
		return I40E_ERR_FIRMWARE_API_VERSION;
	}

	/* Check if need reconfiguration */
	if (!memcmp(new_cfg, old_cfg, sizeof(struct i40e_dcbx_config))) {
		PMD_INIT_LOG(ERR, "No Change in DCB Config required.");
		return I40E_SUCCESS;
	}

	/* Copy the new config to the current config */
	*old_cfg = *new_cfg;
	old_cfg->etsrec = old_cfg->etscfg;
	ret = i40e_set_dcb_config(hw);
	if (ret) {
		PMD_INIT_LOG(ERR, "Set DCB Config failed, err %s aq_err %s",
			 i40e_stat_str(hw, ret),
			 i40e_aq_str(hw, hw->aq.asq_last_status));
		return ret;
	}
	/* set receive Arbiter to RR mode and ETS scheme by default */
	for (i = 0; i <= I40E_PRTDCB_RETSTCC_MAX_INDEX; i++) {
		val = I40E_READ_REG(hw, I40E_PRTDCB_RETSTCC(i));
		val &= ~(I40E_PRTDCB_RETSTCC_BWSHARE_MASK     |
			 I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK |
			 I40E_PRTDCB_RETSTCC_ETSTC_SHIFT);
		val |= ((uint32_t)old_cfg->etscfg.tcbwtable[i] <<
			I40E_PRTDCB_RETSTCC_BWSHARE_SHIFT) &
			 I40E_PRTDCB_RETSTCC_BWSHARE_MASK;
		val |= ((uint32_t)1 << I40E_PRTDCB_RETSTCC_UPINTC_MODE_SHIFT) &
			 I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK;
		val |= ((uint32_t)1 << I40E_PRTDCB_RETSTCC_ETSTC_SHIFT) &
			 I40E_PRTDCB_RETSTCC_ETSTC_MASK;
		I40E_WRITE_REG(hw, I40E_PRTDCB_RETSTCC(i), val);
	}
	/* get local mib to check whether it is configured correctly */
	/* IEEE mode */
	hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_IEEE;
	/* Get Local DCB Config */
	i40e_aq_get_dcb_config(hw, I40E_AQ_LLDP_MIB_LOCAL, 0,
				     &hw->local_dcbx_config);

	/* if Veb is created, need to update TC of it at first */
	if (main_vsi->veb) {
		ret = i40e_config_switch_comp_tc(main_vsi->veb, tc_map);
		if (ret)
			PMD_INIT_LOG(WARNING,
				 "Failed configuring TC for VEB seid=%d",
				 main_vsi->veb->seid);
	}
	/* Update each VSI */
	i40e_vsi_config_tc(main_vsi, tc_map);
	if (main_vsi->veb) {
		TAILQ_FOREACH(vsi_list, &main_vsi->veb->head, list) {
			/* Beside main VSI and VMDQ VSIs, only enable default
			 * TC for other VSIs
			 */
			if (vsi_list->vsi->type == I40E_VSI_VMDQ2)
				ret = i40e_vsi_config_tc(vsi_list->vsi,
							 tc_map);
			else
				ret = i40e_vsi_config_tc(vsi_list->vsi,
							 I40E_DEFAULT_TCMAP);
			if (ret)
				PMD_INIT_LOG(WARNING,
					"Failed configuring TC for VSI seid=%d",
					vsi_list->vsi->seid);
			/* continue */
		}
	}
	return I40E_SUCCESS;
}
/*
 * i40e_dcb_hw_configure - program the dcb setting to hw
 * @pf: pf the configuration is taken on
 * @new_cfg: new configuration
 * @tc_map: enabled TC bitmap
 *
 * Returns 0 on success, negative value on failure
 */
program the dcb setting to hw
@pf: pf the configuration is taken on
@new_cfg: new configuration
@tc_map: enabled TC bitmap

Returns 0 on success, negative value on failure
program the dcb setting to hw @pf : pf the configuration is taken on @new_cfg : new configuration @tc_map : enabled TC bitmap Returns 0 on success negative value on failure
static enum i40e_status_code
i40e_dcb_hw_configure(struct i40e_pf *pf,
		      struct i40e_dcbx_config *new_cfg,
		      uint8_t tc_map)
{
	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
	struct i40e_dcbx_config *old_cfg = &hw->local_dcbx_config;
	struct i40e_vsi *main_vsi = pf->main_vsi;
	struct i40e_vsi_list *vsi_list;
	enum i40e_status_code ret;
	int i;
	uint32_t val;
	if (!(((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver >= 4)) ||
	      (hw->aq.fw_maj_ver >= 5))) {
		PMD_INIT_LOG(ERR,
			"FW < v4.4, can not use FW LLDP API to configure DCB");
		return I40E_ERR_FIRMWARE_API_VERSION;
	}
	if (!memcmp(new_cfg, old_cfg, sizeof(struct i40e_dcbx_config))) {
		PMD_INIT_LOG(ERR, "No Change in DCB Config required.");
		return I40E_SUCCESS;
	}
	*old_cfg = *new_cfg;
	old_cfg->etsrec = old_cfg->etscfg;
	ret = i40e_set_dcb_config(hw);
	if (ret) {
		PMD_INIT_LOG(ERR, "Set DCB Config failed, err %s aq_err %s",
			 i40e_stat_str(hw, ret),
			 i40e_aq_str(hw, hw->aq.asq_last_status));
		return ret;
	}
	for (i = 0; i <= I40E_PRTDCB_RETSTCC_MAX_INDEX; i++) {
		val = I40E_READ_REG(hw, I40E_PRTDCB_RETSTCC(i));
		val &= ~(I40E_PRTDCB_RETSTCC_BWSHARE_MASK     |
			 I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK |
			 I40E_PRTDCB_RETSTCC_ETSTC_SHIFT);
		val |= ((uint32_t)old_cfg->etscfg.tcbwtable[i] <<
			I40E_PRTDCB_RETSTCC_BWSHARE_SHIFT) &
			 I40E_PRTDCB_RETSTCC_BWSHARE_MASK;
		val |= ((uint32_t)1 << I40E_PRTDCB_RETSTCC_UPINTC_MODE_SHIFT) &
			 I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK;
		val |= ((uint32_t)1 << I40E_PRTDCB_RETSTCC_ETSTC_SHIFT) &
			 I40E_PRTDCB_RETSTCC_ETSTC_MASK;
		I40E_WRITE_REG(hw, I40E_PRTDCB_RETSTCC(i), val);
	}
	hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_IEEE;
	i40e_aq_get_dcb_config(hw, I40E_AQ_LLDP_MIB_LOCAL, 0,
				     &hw->local_dcbx_config);
	if (main_vsi->veb) {
		ret = i40e_config_switch_comp_tc(main_vsi->veb, tc_map);
		if (ret)
			PMD_INIT_LOG(WARNING,
				 "Failed configuring TC for VEB seid=%d",
				 main_vsi->veb->seid);
	}
	i40e_vsi_config_tc(main_vsi, tc_map);
	if (main_vsi->veb) {
		TAILQ_FOREACH(vsi_list, &main_vsi->veb->head, list) {
			if (vsi_list->vsi->type == I40E_VSI_VMDQ2)
				ret = i40e_vsi_config_tc(vsi_list->vsi,
							 tc_map);
			else
				ret = i40e_vsi_config_tc(vsi_list->vsi,
							 I40E_DEFAULT_TCMAP);
			if (ret)
				PMD_INIT_LOG(WARNING,
					"Failed configuring TC for VSI seid=%d",
					vsi_list->vsi->seid);
		}
	}
	return I40E_SUCCESS;
}
static enum i40e_status_code i40e_dcb_hw_configure ( struct i40e_pf * pf , struct i40e_dcbx_config * new_cfg , uint8_t tc_map ) { struct i40e_hw * hw = I40E_PF_TO_HW ( pf ) ; struct i40e_dcbx_config * old_cfg = & hw -> local_dcbx_config ; struct i40e_vsi * main_vsi = pf -> main_vsi ; struct i40e_vsi_list * vsi_list ; enum i40e_status_code ret ; int i ; uint32_t val ; if ( ! ( ( ( hw -> aq . fw_maj_ver == 4 ) && ( hw -> aq . fw_min_ver >= 4 ) ) || ( hw -> aq . fw_maj_ver >= 5 ) ) ) { PMD_INIT_LOG ( ERR , " " ) ; return I40E_ERR_FIRMWARE_API_VERSION ; } if ( ! memcmp ( new_cfg , old_cfg , sizeof ( struct i40e_dcbx_config ) ) ) { PMD_INIT_LOG ( ERR , " " ) ; return I40E_SUCCESS ; } * old_cfg = * new_cfg ; old_cfg -> etsrec = old_cfg -> etscfg ; ret = i40e_set_dcb_config ( hw ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , i40e_stat_str ( hw , ret ) , i40e_aq_str ( hw , hw -> aq . asq_last_status ) ) ; return ret ; } for ( i = 0 ; i <= I40E_PRTDCB_RETSTCC_MAX_INDEX ; i ++ ) { val = I40E_READ_REG ( hw , I40E_PRTDCB_RETSTCC ( i ) ) ; val &= ~ ( I40E_PRTDCB_RETSTCC_BWSHARE_MASK | I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK | I40E_PRTDCB_RETSTCC_ETSTC_SHIFT ) ; val |= ( ( uint32_t ) old_cfg -> etscfg . tcbwtable [ i ] << I40E_PRTDCB_RETSTCC_BWSHARE_SHIFT ) & I40E_PRTDCB_RETSTCC_BWSHARE_MASK ; val |= ( ( uint32_t ) 1 << I40E_PRTDCB_RETSTCC_UPINTC_MODE_SHIFT ) & I40E_PRTDCB_RETSTCC_UPINTC_MODE_MASK ; val |= ( ( uint32_t ) 1 << I40E_PRTDCB_RETSTCC_ETSTC_SHIFT ) & I40E_PRTDCB_RETSTCC_ETSTC_MASK ; I40E_WRITE_REG ( hw , I40E_PRTDCB_RETSTCC ( i ) , val ) ; } hw -> local_dcbx_config . dcbx_mode = I40E_DCBX_MODE_IEEE ; i40e_aq_get_dcb_config ( hw , I40E_AQ_LLDP_MIB_LOCAL , 0 , & hw -> local_dcbx_config ) ; if ( main_vsi -> veb ) { ret = i40e_config_switch_comp_tc ( main_vsi -> veb , tc_map ) ; if ( ret ) PMD_INIT_LOG ( WARNING , " " , main_vsi -> veb -> seid ) ; } i40e_vsi_config_tc ( main_vsi , tc_map ) ; if ( main_vsi -> veb ) { TAILQ_FOREACH ( vsi_list , & main_vsi -> veb -> head , list ) { if ( vsi_list -> vsi -> type == I40E_VSI_VMDQ2 ) ret = i40e_vsi_config_tc ( vsi_list -> vsi , tc_map ) ; else ret = i40e_vsi_config_tc ( vsi_list -> vsi , I40E_DEFAULT_TCMAP ) ; if ( ret ) PMD_INIT_LOG ( WARNING , " " , vsi_list -> vsi -> seid ) ; } } return I40E_SUCCESS ; }
i40e_dcb_hw_configure - program the dcb setting to hw
 @pf: pf the configuration is taken on
 @new_cfg: new configuration
 @tc_map: enabled TC bitmap
i40e_dcb_hw_configure - program the dcb setting to hw @pf : pf the configuration is taken on @new_cfg : new configuration @tc_map : enabled TC bitmap
/* Use the FW API if FW > v4.4*/ /* Check if need reconfiguration */ /* Copy the new config to the current config */ /* set receive Arbiter to RR mode and ETS scheme by default */ /* get local mib to check whether it is configured correctly */ /* IEEE mode */ /* Get Local DCB Config */ /* if Veb is created, need to update TC of it at first */ /* Update each VSI */ /* Beside main VSI and VMDQ VSIs, only enable default
			 * TC for other VSIs
			 */ /* continue */