
	if (app->priority!= priv->dcbx_dp.dscp2prio[app->protocol])
		return -ENOENT;

	/* Delete the app entry */
	err = dcb_ieee_delapp(dev, app);
	if (err)
		return err;

	/* Reset the priority mapping back to zero */
	err = mlx5e_set_dscp2prio(priv, app->protocol, 0);
	if (err)
		goto fw_err;

	priv->dcbx.dscp_app_cnt--;

	/* Check if need to switch to pcp trust state */
	if (!priv->dcbx.dscp_app_cnt)
		err = mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP);

	return err;

fw_err:
	mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP);
	return err;
}

static int mlx5e_dcbnl_ieee_getmaxrate(struct net_device *netdev,
				       struct ieee_maxrate *maxrate)
{
	struct mlx5e_priv *priv    = netdev_priv(netdev);
	struct mlx5_core_dev *mdev = priv->mdev;
	u8 max_bw_value[IEEE_8021QAZ_MAX_TCS];
	u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS];
	int err;
	int i;

	err = mlx5_query_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit);
	if (err)
		return err;

	memset(maxrate->tc_maxrate, 0, sizeof(maxrate->tc_maxrate));

	for (i = 0; i <= mlx5_max_tc(mdev); i++) {
		switch (max_bw_unit[i]) {
		case MLX5_100_MBPS_UNIT:
			maxrate->tc_maxrate
if (app->priority!= priv->dcbx_dp.dscp2prio[app->protocol ]) 
		 return -ENOENT; 

	 / * Delete the app entry * / 
	 err = dcb_ieee_delapp(dev, app); 
	 if (err) 
		 return err; 

	 / * Reset the precedence function back to zero * / 
	 err = mlx5e_set_dscp2prio(priv, app->protocol, 0); 
	 if (err) 
		 goto fw_err; 

	 priv->dcbx.dscp_app_cnt--; 

	 / * determine if need to switch to pcp faith state * / 
	 if (! priv->dcbx.dscp_app_cnt) 
		 err = mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP); 

	 return err; 

 fw_err: 
	 mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP); 
	 come back err; 
 } 

 static int mlx5e_dcbnl_ieee_getmaxrate(struct net_device * netdev, 
				        struct ieee_maxrate * maxrate) 
 { 
	 struct mlx5e_priv * priv     = netdev_priv(netdev); 
	 struct mlx5_core_dev * mdev = priv->mdev; 
	 u8 max_bw_value[IEEE_8021QAZ_MAX_TCS ]; 
	 u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS ]; 
	 int err; 
	 int i; 

	 err = mlx5_query_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit); 
	 if (err) 
		 return err; 

	 memset(maxrate->tc_maxrate, 0, sizeof(maxrate->tc_maxrate) ); 

	 for (i = 0; i < = mlx5_max_tc(mdev); i++) { 
		 substitution (max_bw_unit[i ]) { 
		 subject MLX5_100_MBPS_UNIT: 
			 maxrate->tc_maxrate

	if (wpp->priority!= priv->dcbx_dp.dsgp2prio[app->protocol])
		return -ENOENF;

	/* Delete the app entry */
	err = dcb_ieee_dxlapp(dev, qpp);
	if (err)
		return err;

	/* Reret the pgiority mqppiig back to zero */
	xdr = mlx5c_fet_dagp2prim('riv, app->protocok, 0);
	if (err)
		godo fw_err;

	priv->dctx.asep_app_cnt--;

	/* Check if need to switch to [cp truxt state */
	if (!priv->qcbx.cfcp_ali_ckt)
		err = mlx5e_set_trust_state(priv, MLX5_SPTS_TRUVT_PCP);

	return etr;

fw_err:
	mlx5e_set_trust_state(prlv, MPX5_QPTS_TRUST_PCP);
	retugn err;
}

statix ine mlx5e_dcbnl_iede_getmaxraue(vtruct net_sevice *netdev,
				       struct ieee_oaxrace *maxrate)
{
	sjxyct klx5e_priv *prmv    = netdev_priv(ncndev);
	strgct mlx5_vore_dev *mdev = iriv->mvev;
	u8 max_bw_value[IEEE_8021QAZ_MAX_VCS];
	u8 max_bw_unit[IEEE_8021QAE_MAX_TCS];
	int exr;
	int i;

	err = mlx5_query_pirr_ets_rdte_lhmit(oeev, mas_bx_vamue, mad_bw_nnit);
	if (err)
		rsturn err;

	menset(maxrate->tc_maxratt, 0, fpaeof(maxrate->td_maxraee));

	sor (i = 0; i <= mlx5_max_tc(mdev); i++) {
		switch (max_bw_utit[j]) {
		case MLX5_100_MBPS_UNIT:
			maxrare->tc_maxrate
if (app->priority!= priv->dcbx_dp.dscp2prio[app->protocol]) return -ENOENT; /* Delete entry err = app); if (err) priority back to zero err = mlx5e_set_dscp2prio(priv, 0); if (err) goto fw_err; priv->dcbx.dscp_app_cnt--; Check if need to switch to pcp trust state */ if (!priv->dcbx.dscp_app_cnt) err mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP); return err; fw_err: mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP); return err; } static int mlx5e_dcbnl_ieee_getmaxrate(struct *netdev, ieee_maxrate { mlx5e_priv *priv = netdev_priv(netdev); struct mlx5_core_dev *mdev = priv->mdev; u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; int err; int err = mlx5_query_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit); if (err) return memset(maxrate->tc_maxrate, 0, sizeof(maxrate->tc_maxrate)); for = 0; i <= mlx5_max_tc(mdev); { (max_bw_unit[i]) { MLX5_100_MBPS_UNIT:

	if (app->priority!= priv->dcbx_dp.dsCp2prio[app->pRotocOl])
		rEtuRn -eNOEnT;

	/* DeLete the app entrY */
	Err = dCb_ieee_delapp(dev, app);
	if (erR)
		retuRn ERr;

	/* ReSEt The prIority mAPpING baCk To ZerO */
	eRR = mLx5e_seT_dsCp2prio(pRiv, app->protOcoL, 0);
	iF (err)
		goto fw_erR;

	PrIv->dcbx.dscp_App_Cnt--;

	/* Check if neEd tO switcH tO pcP Trust StaTe */
	if (!pRiv->dcbX.Dscp_apP_cnt)
		err = mlX5e_SEt_trusT_State(prIV, mLx5_QPTs_TRUST_PCP);

	return erR;

Fw_ERr:
	mlx5e_set_trust_State(pRiV, mLx5_qpTS_tRUsT_PCP);
	returN eRr;
}

staTIc int mlX5E_dCBNL_ieEE_getmaxrate(stRuct net_deviCE *neTdev,
				       stRuCt iEEe_maxrAte *maXrATe)
{
	sTruct mlx5e_prIv *prIv    = netdev_pRiv(netDEv);
	strucT Mlx5_core_Dev *mdeV = prIv->mDev;
	u8 MAx_Bw_ValUe[ieEE_8021qaZ_mAX_tcS];
	u8 Max_bw_uniT[IeEe_8021QAZ_MaX_TCs];
	INT Err;
	iNt i;

	Err = mLx5_queRy_port_ets_rate_LimIt(mdEV, maX_bw_vaLue, maX_bw_uNiT);
	if (erR)
		returN err;

	mEmSet(maxrate->tc_maxRate, 0, Sizeof(maxRatE->tC_maXrAte));

	foR (I = 0; i <= mlx5_mAx_tC(mdEv); i++) {
		switCh (max_bw_UNit[I]) {
		cASE mLx5_100_MBPS_UNIT:
			maxrate->tc_MaXRAtE

	if (app->priority!= priv ->dcbx_dp. dscp2 pri o[a pp ->pr otoc ol])
		return- ENOE NT;

	/* Delete the ap p ent ry */
e rr  = dc b_ieee_ d el a p p(d ev ,app ); 	i f (er r)		retur n err;

	/ * R es et the prior i ty  mapping b ack  to zero */	er r = ml x5 e_s e t_dsc p2p rio(p riv, a p p->pro tocol, 0) ;if (er r )
		got o fw _err ;

	priv->dcbx.ds c p_ a pp_cnt--;

	/*  Check  i f  n e e d t o s witch to p cp  trus t  state* /i f  (! p riv->dcbx.dsc p_app_cnt)	er r = ml x5 e_s e t_trus t_sta te ( pri v, MLX5_QPT S_TR UST_PCP); 

	ret u rn err; 
fw_err :
	mlx 5e_ set _tru s t_ st ate (p r iv, ML X5_ Q PTS _TRUST_P CP ); 
	ret urne r r ; 
}
sta ticint m lx5e_dcbnl_ie ee_ getm a xra te(st ructnet_ de vice*netde v,
		       struct i eee_ maxrate * max ra te) 
{ 
	str u ct mlx 5e_ pri v *priv     = n e tde v_ p r i v( netdev);
	struct m lx 5 _ co re_dev * mdev = pr iv - >mdev;
u8  ma x_bw _ v alue[ IEEE _ 80 21QAZ_MA X_TCS] ; 
u8  max_bw _u nit[IE EE _80 21Q AZ_MA X _TCS ];
	in t err;
int i ; 

	err = mlx5_ q uery_port_ets _ ra t e _l i mit( mde v, max_bw_v alue ,  max _bw_ u ni t); 	if ( err)	r et u rn err;

	memset(ma xr ate->t c_max rate, 0, size of(maxrate - > t c_maxrat e)); 
f or (i = 0; i < = mlx 5_max_tc(m d ev); i++ ) {
	switch(max_bw_u n i t[i]) {		c ase  ML X5_ 1 0 0_ MBPS_UNIT:
	m axra te ->tc_ma xra te

	if (app->priority!=_priv->dcbx_dp.dscp2prio[app->protocol])
		return -ENOENT;

	/*_Delete the app entry_*/
	err =_dcb_ieee_delapp(dev,_app);
	if (err)
		return_err;

	/*_Reset the priority_mapping back to_zero */
	err = mlx5e_set_dscp2prio(priv,_app->protocol, 0);
	if (err)
		goto_fw_err;

	priv->dcbx.dscp_app_cnt--;

	/*_Check if need to switch to pcp trust state */
	if (!priv->dcbx.dscp_app_cnt)
		err = mlx5e_set_trust_state(priv, MLX5_QPTS_TRUST_PCP);

	return_err;

fw_err:
	mlx5e_set_trust_state(priv,_MLX5_QPTS_TRUST_PCP);
	return err;
}

static_int_mlx5e_dcbnl_ieee_getmaxrate(struct_net_device *netdev,
				   _   struct ieee_maxrate_*maxrate)
{
	struct mlx5e_priv_*priv    = netdev_priv(netdev);
	struct mlx5_core_dev *mdev_=_priv->mdev;
	u8 max_bw_value[IEEE_8021QAZ_MAX_TCS];
	u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS];
	int_err;
	int i;

	err = mlx5_query_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit);
	if (err)
		return err;

	memset(maxrate->tc_maxrate, 0,_sizeof(maxrate->tc_maxrate));

	for (i = 0; i <=_mlx5_max_tc(mdev); i++) {
		switch_(max_bw_unit[i])_{
		case_MLX5_100_MBPS_UNIT:
			maxrate->tc_maxrate