From patchwork Fri Sep 21 15:41:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147288 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp970767ljw; Fri, 21 Sep 2018 08:43:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZZFWdms54sG7aiAMliTNeSTKGusPA7xyQqihZK6doo7PFCdjVc/4Y642clI1ZMYK8x8MrE X-Received: by 2002:a62:ba0b:: with SMTP id k11-v6mr47408970pff.171.1537544581705; Fri, 21 Sep 2018 08:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537544581; cv=none; d=google.com; s=arc-20160816; b=QxU6OTUDcaQWDPZ/aBR9bdS8mMQlqVtAunYFQv80Fa1zDx1Ypp3rF7KLEqgFy9B6WY 8fSGgOgZkRGYXwvPf6+JD34bahNbBk9KcFkCPeNEWeZac9oN+kdkwyg8dA2hVT1KDTrp fN33FiRRTV5lp6+qyInqKN3WNqUiWWjP1K3YNuaHHzC7DAypB+794iTclg07l3IQzHyq OouOMTt99z8EQttrEfVMN7aR4zcGwmBRGFouPHBJeoOQuI7XGpIHwHWG1Ekbn3oz9qId jnubT9T/ebheXkQ2tErqAHNwJj5YA7OAzRNv4Kq+6/xj1eCNLrO+bGauRxHxBgoSdMdO kocQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=QiV0JvhaRq6jolQbl9ZrhCK5w0bD/pveLYvLefoziQw=; b=krCU5XaDiMWFSdkklxgWRRiVBEXjw9t3JwYIg9C+CLzlw5g36u+O4LsKw1XBU8ZbuX QP5oGHmIrMPlQaHfwlAv4OaXAZjS4tB3dCdmHHKZ9dAX2x34HjB6Hd4g3AqNWZ3YRLbO 7Ps2iTbEWYmm+GosIrWg6rNDISks5+yB8sUtuUMylHFqFzvJD4J9+6YmBCPrc5Y6KGxt bL4dzqUc2LwSsgvrY/xXLnuiptc42R6w98mMleIlTsGHvB6ZjrW09oqyEisCf3su0SUQ sxpOzkWJ3QL1u51uFc5HA5M0Y/SpcRrOHdPhFczE1KKcOMTSfplf2tgS03ItzEB6ufyR l1FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g38-v6si2393882pgm.193.2018.09.21.08.42.59; Fri, 21 Sep 2018 08:43:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390480AbeIUVcY (ORCPT + 32 others); Fri, 21 Sep 2018 17:32:24 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:47103 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389657AbeIUVcX (ORCPT ); Fri, 21 Sep 2018 17:32:23 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 16261455E789C; Fri, 21 Sep 2018 23:42:48 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.399.0; Fri, 21 Sep 2018 23:42:41 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 01/12] net: hns3: Fix ets validate issue Date: Fri, 21 Sep 2018 16:41:37 +0100 Message-ID: <20180921154148.26756-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180921154148.26756-1-salil.mehta@huawei.com> References: <20180921154148.26756-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen There is a defect in hclge_ets_validate(). If each member of tc_tsa is not IEEE_8021QAZ_TSA_ETS, the variable total_ets_bw won't be updated. In this case, the check for value of total_ets_bw will fail. This patch fixes it by checking total_ets_bw only after it has been updated. Fixes: cacde272dd00 ("net: hns3: Add hclge_dcb module for the support of DCB feature") Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c index f08ebb7..92f1938 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c @@ -73,6 +73,7 @@ static int hclge_ieee_getets(struct hnae3_handle *h, struct ieee_ets *ets) static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets, u8 *tc, bool *changed) { + bool has_ets_tc = false; u32 total_ets_bw = 0; u8 max_tc = 0; u8 i; @@ -100,13 +101,14 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets, *changed = true; total_ets_bw += ets->tc_tx_bw[i]; - break; + has_ets_tc = true; + break; default: return -EINVAL; } } - if (total_ets_bw != BW_PERCENT) + if (has_ets_tc && total_ets_bw != BW_PERCENT) return -EINVAL; *tc = max_tc + 1;