src/dpdk/drivers/net/i40e/i40e_ethdev.c
int
i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb)
{
	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	int i, ret = 0;

	if ((pf->flags & I40E_FLAG_DCB) == 0) {
		PMD_INIT_LOG(INFO, "HW doesn't support DCB");
		return -ENOTSUP;
	}

	/* DCB initialization:
	 * Update DCB configuration from the Firmware and configure
	 * LLDP MIB change event.
	 */
	if (sw_dcb == TRUE) {
		/* Stopping lldp is necessary for DPDK, but it will cause
		 * DCB init failed. For i40e_init_dcb(), the prerequisite
		 * for successful initialization of DCB is that LLDP is
		 * enabled. So it is needed to start lldp before DCB init
		 * and stop it after initialization.
		 */
		ret = i40e_aq_start_lldp(hw, true, NULL);
		if (ret != I40E_SUCCESS)
			PMD_INIT_LOG(DEBUG, "Failed to start lldp");

		ret = i40e_init_dcb(hw, true);
		/* If lldp agent is stopped, the return value from
		 * i40e_init_dcb we expect is failure with I40E_AQ_RC_EPERM
		 * adminq status. Otherwise, it should return success.
		 */
		if ((ret == I40E_SUCCESS) || (ret != I40E_SUCCESS &&
		    hw->aq.asq_last_status == I40E_AQ_RC_EPERM)) {
			memset(&hw->local_dcbx_config, 0,
				sizeof(struct i40e_dcbx_config));
			/* set dcb default configuration */
			hw->local_dcbx_config.etscfg.willing = 0;
			hw->local_dcbx_config.etscfg.maxtcs = 0;
			hw->local_dcbx_config.etscfg.tcbwtable[0] = 100;
			hw->local_dcbx_config.etscfg.tsatable[0] =
						I40E_IEEE_TSA_ETS;
#ifdef TREX_PATCH_LOW_LATENCY
			hw->local_dcbx_config.etscfg.tcbwtable[1] = 0;
			hw->local_dcbx_config.etscfg.tsatable[1] = I40E_IEEE_TSA_STRICT;
			hw->local_dcbx_config.etscfg.prioritytable[1] = 1;
#else
			/* all UPs mapping to TC0 */
			for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
				hw->local_dcbx_config.etscfg.prioritytable[i] = 0;
#endif

			hw->local_dcbx_config.etsrec =
				hw->local_dcbx_config.etscfg;
			hw->local_dcbx_config.pfc.willing = 0;
			hw->local_dcbx_config.pfc.pfccap =
						I40E_MAX_TRAFFIC_CLASS;
			/* FW needs one App to configure HW */
			hw->local_dcbx_config.numapps = 1;
			hw->local_dcbx_config.app[0].selector =
						I40E_APP_SEL_ETHTYPE;
			hw->local_dcbx_config.app[0].priority = 3;
			hw->local_dcbx_config.app[0].protocolid =
						I40E_APP_PROTOID_FCOE;
			ret = i40e_set_dcb_config(hw);
			if (ret) {
				PMD_INIT_LOG(ERR,
					"default dcb config fails. err = %d, aq_err = %d.",
					ret, hw->aq.asq_last_status);
				return -ENOSYS;
			}
#ifdef TREX_PATCH_LOW_LATENCY
            if (i40e_vsi_update_tc_bandwidth_ex(pf->main_vsi) !=
                I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to update TC bandwidth");
                return -ENOSYS;
            }
#endif

		} else {
			PMD_INIT_LOG(INFO,
				"DCB initialization in FW fails, err = %d, aq_err = %d.",
				ret, hw->aq.asq_last_status);
			return -ENOTSUP;
		}

		if (i40e_need_stop_lldp(dev)) {
			ret = i40e_aq_stop_lldp(hw, true, true, NULL);
			if (ret != I40E_SUCCESS)
				PMD_INIT_LOG(DEBUG, "Failed to stop lldp");
		}
	} else {
		ret = i40e_aq_start_lldp(hw, true, NULL);
		if (ret != I40E_SUCCESS)
			PMD_INIT_LOG(DEBUG, "Failed to start lldp");

		ret = i40e_init_dcb(hw, true);
		if (!ret) {
			if (hw->dcbx_status == I40E_DCBX_STATUS_DISABLED) {
				PMD_INIT_LOG(INFO,
					"HW doesn't support DCBX offload.");
				return -ENOTSUP;
			}
		} else {
			PMD_INIT_LOG(INFO,
				"DCBX configuration failed, err = %d, aq_err = %d.",
				ret, hw->aq.asq_last_status);
			return -ENOTSUP;
		}
	}
	return 0;
}
/*
 * i40e_dcb_init_configure - initial dcb config
 * @dev: device being configured
 * @sw_dcb: indicate whether dcb is sw configured or hw offload
 *
 * Returns 0 on success, negative value on failure
 */
initial dcb config
@dev: device being configured
@sw_dcb: indicate whether dcb is sw configured or hw offload

Returns 0 on success, negative value on failure
initial dcb config @dev : device being configured @sw_dcb : indicate whether dcb is sw configured or hw offload Returns 0 on success negative value on failure
int
i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb)
{
	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	int i, ret = 0;
	if ((pf->flags & I40E_FLAG_DCB) == 0) {
		PMD_INIT_LOG(INFO, "HW doesn't support DCB");
		return -ENOTSUP;
	}
	if (sw_dcb == TRUE) {
		ret = i40e_aq_start_lldp(hw, true, NULL);
		if (ret != I40E_SUCCESS)
			PMD_INIT_LOG(DEBUG, "Failed to start lldp");
		ret = i40e_init_dcb(hw, true);
		if ((ret == I40E_SUCCESS) || (ret != I40E_SUCCESS &&
		    hw->aq.asq_last_status == I40E_AQ_RC_EPERM)) {
			memset(&hw->local_dcbx_config, 0,
				sizeof(struct i40e_dcbx_config));
			hw->local_dcbx_config.etscfg.willing = 0;
			hw->local_dcbx_config.etscfg.maxtcs = 0;
			hw->local_dcbx_config.etscfg.tcbwtable[0] = 100;
			hw->local_dcbx_config.etscfg.tsatable[0] =
						I40E_IEEE_TSA_ETS;
#ifdef TREX_PATCH_LOW_LATENCY
			hw->local_dcbx_config.etscfg.tcbwtable[1] = 0;
			hw->local_dcbx_config.etscfg.tsatable[1] = I40E_IEEE_TSA_STRICT;
			hw->local_dcbx_config.etscfg.prioritytable[1] = 1;
#else
			for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
				hw->local_dcbx_config.etscfg.prioritytable[i] = 0;
#endif
			hw->local_dcbx_config.etsrec =
				hw->local_dcbx_config.etscfg;
			hw->local_dcbx_config.pfc.willing = 0;
			hw->local_dcbx_config.pfc.pfccap =
						I40E_MAX_TRAFFIC_CLASS;
			hw->local_dcbx_config.numapps = 1;
			hw->local_dcbx_config.app[0].selector =
						I40E_APP_SEL_ETHTYPE;
			hw->local_dcbx_config.app[0].priority = 3;
			hw->local_dcbx_config.app[0].protocolid =
						I40E_APP_PROTOID_FCOE;
			ret = i40e_set_dcb_config(hw);
			if (ret) {
				PMD_INIT_LOG(ERR,
					"default dcb config fails. err = %d, aq_err = %d.",
					ret, hw->aq.asq_last_status);
				return -ENOSYS;
			}
#ifdef TREX_PATCH_LOW_LATENCY
            if (i40e_vsi_update_tc_bandwidth_ex(pf->main_vsi) !=
                I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to update TC bandwidth");
                return -ENOSYS;
            }
#endif
		} else {
			PMD_INIT_LOG(INFO,
				"DCB initialization in FW fails, err = %d, aq_err = %d.",
				ret, hw->aq.asq_last_status);
			return -ENOTSUP;
		}
		if (i40e_need_stop_lldp(dev)) {
			ret = i40e_aq_stop_lldp(hw, true, true, NULL);
			if (ret != I40E_SUCCESS)
				PMD_INIT_LOG(DEBUG, "Failed to stop lldp");
		}
	} else {
		ret = i40e_aq_start_lldp(hw, true, NULL);
		if (ret != I40E_SUCCESS)
			PMD_INIT_LOG(DEBUG, "Failed to start lldp");
		ret = i40e_init_dcb(hw, true);
		if (!ret) {
			if (hw->dcbx_status == I40E_DCBX_STATUS_DISABLED) {
				PMD_INIT_LOG(INFO,
					"HW doesn't support DCBX offload.");
				return -ENOTSUP;
			}
		} else {
			PMD_INIT_LOG(INFO,
				"DCBX configuration failed, err = %d, aq_err = %d.",
				ret, hw->aq.asq_last_status);
			return -ENOTSUP;
		}
	}
	return 0;
}
int i40e_dcb_init_configure ( struct rte_eth_dev * dev , bool sw_dcb ) { struct i40e_pf * pf = I40E_DEV_PRIVATE_TO_PF ( dev -> data -> dev_private ) ; struct i40e_hw * hw = I40E_DEV_PRIVATE_TO_HW ( dev -> data -> dev_private ) ; int i , ret = 0 ; if ( ( pf -> flags & I40E_FLAG_DCB ) == 0 ) { PMD_INIT_LOG ( INFO , " " ) ; return - ENOTSUP ; } if ( sw_dcb == TRUE ) { ret = i40e_aq_start_lldp ( hw , true , NULL ) ; if ( ret != I40E_SUCCESS ) PMD_INIT_LOG ( DEBUG , " " ) ; ret = i40e_init_dcb ( hw , true ) ; if ( ( ret == I40E_SUCCESS ) || ( ret != I40E_SUCCESS && hw -> aq . asq_last_status == I40E_AQ_RC_EPERM ) ) { memset ( & hw -> local_dcbx_config , 0 , sizeof ( struct i40e_dcbx_config ) ) ; hw -> local_dcbx_config . etscfg . willing = 0 ; hw -> local_dcbx_config . etscfg . maxtcs = 0 ; hw -> local_dcbx_config . etscfg . tcbwtable [ 0 ] = 100 ; hw -> local_dcbx_config . etscfg . tsatable [ 0 ] = I40E_IEEE_TSA_ETS ; #ifdef TREX_PATCH_LOW_LATENCY hw -> local_dcbx_config . etscfg . tcbwtable [ 1 ] = 0 ; hw -> local_dcbx_config . etscfg . tsatable [ 1 ] = I40E_IEEE_TSA_STRICT ; hw -> local_dcbx_config . etscfg . prioritytable [ 1 ] = 1 ; #else for ( i = 0 ; i < I40E_MAX_USER_PRIORITY ; i ++ ) hw -> local_dcbx_config . etscfg . prioritytable [ i ] = 0 ; #endif hw -> local_dcbx_config . etsrec = hw -> local_dcbx_config . etscfg ; hw -> local_dcbx_config . pfc . willing = 0 ; hw -> local_dcbx_config . pfc . pfccap = I40E_MAX_TRAFFIC_CLASS ; hw -> local_dcbx_config . numapps = 1 ; hw -> local_dcbx_config . app [ 0 ] . selector = I40E_APP_SEL_ETHTYPE ; hw -> local_dcbx_config . app [ 0 ] . priority = 3 ; hw -> local_dcbx_config . app [ 0 ] . protocolid = I40E_APP_PROTOID_FCOE ; ret = i40e_set_dcb_config ( hw ) ; if ( ret ) { PMD_INIT_LOG ( ERR , " " , ret , hw -> aq . asq_last_status ) ; return - ENOSYS ; } #ifdef TREX_PATCH_LOW_LATENCY if ( i40e_vsi_update_tc_bandwidth_ex ( pf -> main_vsi ) != I40E_SUCCESS ) { PMD_DRV_LOG ( ERR , " " ) ; return - ENOSYS ; } #endif } else { PMD_INIT_LOG ( INFO , " " , ret , hw -> aq . asq_last_status ) ; return - ENOTSUP ; } if ( i40e_need_stop_lldp ( dev ) ) { ret = i40e_aq_stop_lldp ( hw , true , true , NULL ) ; if ( ret != I40E_SUCCESS ) PMD_INIT_LOG ( DEBUG , " " ) ; } } else { ret = i40e_aq_start_lldp ( hw , true , NULL ) ; if ( ret != I40E_SUCCESS ) PMD_INIT_LOG ( DEBUG , " " ) ; ret = i40e_init_dcb ( hw , true ) ; if ( ! ret ) { if ( hw -> dcbx_status == I40E_DCBX_STATUS_DISABLED ) { PMD_INIT_LOG ( INFO , " " ) ; return - ENOTSUP ; } } else { PMD_INIT_LOG ( INFO , " " , ret , hw -> aq . asq_last_status ) ; return - ENOTSUP ; } } return 0 ; }
i40e_dcb_init_configure - initial dcb config
 @dev: device being configured
 @sw_dcb: indicate whether dcb is sw configured or hw offload
i40e_dcb_init_configure - initial dcb config @dev : device being configured @sw_dcb : indicate whether dcb is sw configured or hw offload
/* DCB initialization:
	 * Update DCB configuration from the Firmware and configure
	 * LLDP MIB change event.
	 */ /* Stopping lldp is necessary for DPDK, but it will cause
		 * DCB init failed. For i40e_init_dcb(), the prerequisite
		 * for successful initialization of DCB is that LLDP is
		 * enabled. So it is needed to start lldp before DCB init
		 * and stop it after initialization.
		 */ /* If lldp agent is stopped, the return value from
		 * i40e_init_dcb we expect is failure with I40E_AQ_RC_EPERM
		 * adminq status. Otherwise, it should return success.
		 */ /* set dcb default configuration */ /* all UPs mapping to TC0 */ /* FW needs one App to configure HW */