Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1722b969 authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by David S. Miller
Browse files

net/mlx5: Add error prints when validate ETS failed



Upon set ETS failure due to user invalid input, add error prints to
specify the exact error to the user.

Fixes: cdcf1121 ('net/mlx5e: Validate BW weight values of ETS')
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf50082c
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -127,29 +127,40 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets)
	return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw);
	return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw);
}
}


static int mlx5e_dbcnl_validate_ets(struct ieee_ets *ets)
static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
				    struct ieee_ets *ets)
{
{
	int bw_sum = 0;
	int bw_sum = 0;
	int i;
	int i;


	/* Validate Priority */
	/* Validate Priority */
	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
		if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY)
		if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY) {
			netdev_err(netdev,
				   "Failed to validate ETS: priority value greater than max(%d)\n",
				    MLX5E_MAX_PRIORITY);
			return -EINVAL;
			return -EINVAL;
		}
		}
	}


	/* Validate Bandwidth Sum */
	/* Validate Bandwidth Sum */
	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
		if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) {
		if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) {
			if (!ets->tc_tx_bw[i])
			if (!ets->tc_tx_bw[i]) {
				netdev_err(netdev,
					   "Failed to validate ETS: BW 0 is illegal\n");
				return -EINVAL;
				return -EINVAL;
			}


			bw_sum += ets->tc_tx_bw[i];
			bw_sum += ets->tc_tx_bw[i];
		}
		}
	}
	}


	if (bw_sum != 0 && bw_sum != 100)
	if (bw_sum != 0 && bw_sum != 100) {
		netdev_err(netdev,
			   "Failed to validate ETS: BW sum is illegal\n");
		return -EINVAL;
		return -EINVAL;
	}
	return 0;
	return 0;
}
}


@@ -159,7 +170,7 @@ static int mlx5e_dcbnl_ieee_setets(struct net_device *netdev,
	struct mlx5e_priv *priv = netdev_priv(netdev);
	struct mlx5e_priv *priv = netdev_priv(netdev);
	int err;
	int err;


	err = mlx5e_dbcnl_validate_ets(ets);
	err = mlx5e_dbcnl_validate_ets(netdev, ets);
	if (err)
	if (err)
		return err;
		return err;