From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0113.outbound.protection.outlook.com ([104.47.41.113]:19232 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752937AbeBCSBf (ORCPT ); Sat, 3 Feb 2018 13:01:35 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Huy Nguyen , Moshe Shemesh , Saeed Mahameed , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 041/110] net/mlx5e: Fix ETS BW check Date: Sat, 3 Feb 2018 18:00:48 +0000 Message-ID: <20180203180015.29073-41-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Huy Nguyen [ Upstream commit ff0891915cd7b24ab27eee9b360c0452853bf9f6 ] Fix bug that allows ets bw sum to be 0% when ets tc type exists. Fixes: 08fb1dacdd76 ('net/mlx5e: Support DCBNL IEEE ETS') Signed-off-by: Moshe Shemesh Reviewed-by: Huy Nguyen Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/n= et/ethernet/mellanox/mlx5/core/en_dcbnl.c index 51c4cc00a186..9d64d0759ee9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c @@ -259,6 +259,7 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *pri= v, struct ieee_ets *ets) static int mlx5e_dbcnl_validate_ets(struct net_device *netdev, struct ieee_ets *ets) { + bool have_ets_tc =3D false; int bw_sum =3D 0; int i; =20 @@ -273,11 +274,14 @@ static int mlx5e_dbcnl_validate_ets(struct net_device= *netdev, } =20 /* Validate Bandwidth Sum */ - for (i =3D 0; i < IEEE_8021QAZ_MAX_TCS; i++) - if (ets->tc_tsa[i] =3D=3D IEEE_8021QAZ_TSA_ETS) + for (i =3D 0; i < IEEE_8021QAZ_MAX_TCS; i++) { + if (ets->tc_tsa[i] =3D=3D IEEE_8021QAZ_TSA_ETS) { + have_ets_tc =3D true; bw_sum +=3D ets->tc_tx_bw[i]; + } + } =20 - if (bw_sum !=3D 0 && bw_sum !=3D 100) { + if (have_ets_tc && bw_sum !=3D 100) { netdev_err(netdev, "Failed to validate ETS: BW sum is illegal\n"); return -EINVAL; --=20 2.11.0