Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3011imm; Fri, 21 Sep 2018 08:45:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV625rl3WPPMi0P5VSRy4TLLFK7zJWX+plYACEmHBj2ZaNVp+BzuNFtwk+I7ONGxJ3CWc/+q4 X-Received: by 2002:a17:902:d808:: with SMTP id a8-v6mr1420893plz.306.1537544741743; Fri, 21 Sep 2018 08:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537544741; cv=none; d=google.com; s=arc-20160816; b=qBEbDGecsX/mo924AfzRQFcvOrTnI7bn/JGhuNG6iGWEr0G6nG6ZVPoZLj/9XeNQ2q m6o2ztuEb1AS7iFxDl7oxRYVV8drbwahaQg/N0ipHuEYRm78xvl8Kqdr0CMEnSBwkS2f FkhHv8vKbuFdO9GLpsY01Io8adO3P7aoPaCX3rFn18UNEnUN1hNdQDNAwPmUXQA3QfUU bQg3pKr5AZowR+/RBRlwyVZjPOOI8+hNYEj2z5u7NSftejupiDvHV0yIFyyiKzNuMEdG 3H/3rgBG6V8fTS/qHsUuMtfMQ9WC0rHxLWG0wDIkjNXpsA9QcN97xAUj2QcMd57SMeT2 KYNA== 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 w20-v6si25304030pgf.434.2018.09.21.08.45.19; Fri, 21 Sep 2018 08:45:41 -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 S2390454AbeIUVcY (ORCPT + 99 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 Content-Type: text/plain 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(-) 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; -- 2.7.4