From patchwork Tue May 1 18:55:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134799 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5283156lji; Tue, 1 May 2018 12:01:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphJLbOJljJfmtUjVtLz04ia6XL+BYYsZOEUwVG+d59WJVAwt7h/WHHCt3FwXevylaqHCYi X-Received: by 2002:a17:902:b497:: with SMTP id y23-v6mr9856416plr.309.1525201285029; Tue, 01 May 2018 12:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201285; cv=none; d=google.com; s=arc-20160816; b=KrdoaqLGG/5nyzhmnMslZ0DcnHw5Q3zzvOaEm9uxZtK+XQQsweIFKyhnavlx9fox4q wfB/7KlskodNZBI7otsR0YjF6ByZRVmoXP+2E1ZnSMl19UBgx8nWPnPrfZr20mUzdPNL BAdUe5WsL2F+5sg+VneCufe22PXwP/hL3CpZ64KxtqPQthTGxcQ89ScFAecf/DGXND/a /HOLG8wbKbutdLivlIjTx+ZC6io63QX2KbBtwx+dOY+aHkAd0wnxAvCWdj+darp/8z/L dCSmWkXAvsthqPiKfh1HzU/VUKkJeT9WIAfhdOxhKUNmgRfFqo6tFYcSqIzTKmZfDctv aqdA== 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:arc-authentication-results; bh=VhbI9b6lNCxtc/5qOrX8wIsJRULVrHSr/GBF+M42h/c=; b=TGQ5cNjjAe9uHWFXvWdb7eBSvj+jxhJ4CMif486xSojSYK8TBFlgPWHDK2l0EEvI9e p0n5AEgKQ2yk21ew47F/JE+xj9xmKGN/a5Mg0bUXQjWCr9xRegGq1UBwve50caKfALEG slDiaqhahig9uVHDWpE19gxGHX4i76/h0/cF/QBxmnS6d6RsBO9Fqy3h/FO/OKQiv7g2 yv/RPnqn/MP0nUMJnvXQp/KKof5O3480SYTm6QfcxxFSImwgRfNloKbbbtTaJnDb025y pokJkgc1d5E86Q7kG7BzlhadPKKFMz5zs1Pj5/hK8Vj/Qpx/ENwCu07oxSjbi8YCQsOy cF0g== 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 w71-v6si1179897pgd.1.2018.05.01.12.01.24; Tue, 01 May 2018 12:01:25 -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 S1756134AbeEAS55 (ORCPT + 29 others); Tue, 1 May 2018 14:57:57 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7638 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753505AbeEAS5z (ORCPT ); Tue, 1 May 2018 14:57:55 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 361DAAA760EA0; Wed, 2 May 2018 02:57:42 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:35 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 1/9] net: hns3: Remove error log when getting pfc stats fails Date: Tue, 1 May 2018 19:55:57 +0100 Message-ID: <20180501185605.9584-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin When mac supports DCB, but is in GE mode, it does not support querying pfc stats, firmware returns error when trying to query the pfc stats. this creates a lot of noise in the kernel log when it prints the error log. This patch fixes it by removing the error log, because it already return the error to the user space, so the user should be aware of the error. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index 885f25c..c69ecab 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -134,11 +134,8 @@ static int hclge_pfc_stats_get(struct hclge_dev *hdev, } ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM); - if (ret) { - dev_err(&hdev->pdev->dev, - "Get pfc pause stats fail, ret = %d.\n", ret); + if (ret) return ret; - } for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) { struct hclge_pfc_stats_cmd *pfc_stats = From patchwork Tue May 1 18:55:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134791 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5279785lji; Tue, 1 May 2018 11:58:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZog+7CHrLgl5JcU9ac5v93bqvsxl+f22h1Q4HijpW4YDFyLjBnPR6GnZIlhURP5BY+uZQv2 X-Received: by 10.98.150.92 with SMTP id c89mr16748495pfe.37.1525201087977; Tue, 01 May 2018 11:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201087; cv=none; d=google.com; s=arc-20160816; b=JQfgoXpYrjuTQiZA2eJdmRoF6slsLOA12SK/aL9yU8wQMvc65nj6WTKRuBo4+bp8+Y xLRz5D4gmtJA2K8eSVbChppM2IP560b9CuPiC0R0ADGbikUQHcGXmF+T5a2vxMwkSRxb vXm+Kv+a2q1c4/QzWEBxBHsMN1bYOhTFvHFa4Or9PpKxQ1zH104JuFCZIrowCypk3Psl h3aBRT5u7qaMRBPvyeYm4+ZFMNnu2oLxNKpUPq/BLuFh/iJ/EkDxwp2rO0srIZQTrSu9 9+Kvtz8VeHt6Kkqvm6oGAFYyYvOLiL4/y3RyrDr47Dw/0DDGg++10W6Q/MeNJEseeCFB YdvA== 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:arc-authentication-results; bh=yaBWJlR00DBEIAMQYodqivgwcr09dyIfUP+W3n3g+Po=; b=pXLenZIajAH4t5ND8na5uQb0cAsWtc81qSwSLv2aZEbiXlcGP5pE5Psv4CSD0Htfvm SKDpgSr84OSv3DzoMwrrfyrv7qwXkh1JEnTgxhYcZZEgdBZerJG6laHzJbvk1AZu2xUz v95JFQxrp8UN67JxnAO8rP8S/RaiC3LUKuHAfKFgBc/4s1cGU8qz8BJeZ1s0d+3islzj WIwKkxWPkC0mx0iHE5oBPvQf1hJgZn0nNZxx9kdxRLKMc2hys4+fQGvbn4vx/viffj87 C8KUo7LzVi2opCja9X5aQ6diOc1Fw1lCBI8JzdWzj+qlcRAYVi67z2wkyNF2aXDiSnTm T/eQ== 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 n81si10036460pfj.152.2018.05.01.11.58.07; Tue, 01 May 2018 11:58:07 -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 S1756601AbeEAS6E (ORCPT + 29 others); Tue, 1 May 2018 14:58:04 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7641 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756247AbeEAS6A (ORCPT ); Tue, 1 May 2018 14:58:00 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 54CC876B7DFD; Wed, 2 May 2018 02:57:47 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:38 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 2/9] net: hns3: fix to correctly fetch l4 protocol outer header Date: Tue, 1 May 2018 19:55:58 +0100 Message-ID: <20180501185605.9584-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan This patch fixes the function being used to fetch L4 protocol outer header. Mistakenly skb_inner_transport_header API was being used earlier. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 8c55965..c4e2950 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -502,7 +502,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, /* find outer header point */ l3.hdr = skb_network_header(skb); - l4_hdr = skb_inner_transport_header(skb); + l4_hdr = skb_transport_header(skb); if (skb->protocol == htons(ETH_P_IPV6)) { exthdr = l3.hdr + sizeof(*l3.v6); From patchwork Tue May 1 18:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134798 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5282410lji; Tue, 1 May 2018 12:00:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqjC+tf8GG+juBwNHj1P0JvZXxpkn8W9Uf1Any9pyUf+/JS46bUSHCgwDHmkdSYCWTE51rp X-Received: by 2002:a17:902:a612:: with SMTP id u18-v6mr16728764plq.192.1525201256154; Tue, 01 May 2018 12:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201256; cv=none; d=google.com; s=arc-20160816; b=e2kUSt6aEUdQtZcsZXzoTc68zhcVkt+uZM9Hs08JHebu/UnJ9cDjI8QhWqv8e3Fs/e 2+zt9kkx3l4Kj0+3cN/EWs/zKyH4i72jr4ZgA0Ste3p+j+92lpvSUFrW0AWeTKOJ37Jh 6qjU0+DY091Zz7jHWlcY1jyt++k+L4QRL78XMfLG6VfLGydxdtWHTe/2JXu5FWSK83K+ 2zEx3QhODN9ZJOGXwdKabG8o5w6lHHWvc/gKOvHRTvmutyMteaiXd1Vew5J9NDMaUWf8 jjOVXFXFcw2yk3jS9MCj2x+PBlOyESP5cAJVgHNE98s8NZr1FH8nCfol8/etiEAgrOgk aAqQ== 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:arc-authentication-results; bh=mNRr40qhrJkA/zO5Ycc4HhzTUzhy9OiiMGFXc2b9jM8=; b=BfzcsSvisRO2dQXtW8Yyo1AeslcVT6r75Dip00rLDqhUmohQPHBEtlpW1GiM5xijHv m3y6ufvHkqrAZo9HX2TkEqQ+0x6xhkvP7B5g9jyiLJYmXJJIywCecZ0MAVIesWENYXZH d4W7Ng5rZDFHAwQWfZbiu7A4fyVDQpkOzYc5B3qnXXaVJnHN+kYCG96Nwc/kYIhOBvVZ Zp0hLlzWrVlXBkC22NYYoqw/K9jT3v7j12aKhq80X4WdWbM6RCj0f0ZnlSUfMJrdWMxF 2OWWtSdDoWhxSThP+QQfxPZIeGErQYBTKcfHVsWKFuA03Gww5opK4bCNlTZoZaXobFtH 59+w== 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 k6-v6si2130814pla.509.2018.05.01.12.00.55; Tue, 01 May 2018 12:00:56 -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 S1756521AbeEAS6D (ORCPT + 29 others); Tue, 1 May 2018 14:58:03 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7640 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754790AbeEAS6A (ORCPT ); Tue, 1 May 2018 14:58:00 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 46FD65074A8F3; Wed, 2 May 2018 02:57:47 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:41 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 3/9] net: hns3: Fixes the out of bounds access in hclge_map_tqp Date: Tue, 1 May 2018 19:55:59 +0100 Message-ID: <20180501185605.9584-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan This patch fixes the handling of the check when number of vports are detected to be more than available TPQs. Current handling causes an out of bounds access in hclge_map_tqp(). Fixes: 7df7dad633e2 ("net: hns3: Refactor the mapping of tqp to vport") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2066dd7..c9e80ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1459,8 +1459,11 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) /* We need to alloc a vport for main NIC of PF */ num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; - if (hdev->num_tqps < num_vport) - num_vport = hdev->num_tqps; + if (hdev->num_tqps < num_vport) { + dev_err(&hdev->pdev->dev, "tqps(%d) is less than vports(%d)", + hdev->num_tqps, num_vport); + return -EINVAL; + } /* Alloc the same number of TQPs for every vport */ tqp_per_vport = hdev->num_tqps / num_vport; From patchwork Tue May 1 18:56:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134796 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5281346lji; Tue, 1 May 2018 12:00:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpKd9xY+b+4qlSYhEkbRb6k6QLJvSEQVNr9Gn6/dC0HKyeIehBRKknlicEfbKr2DZ/nkTCg X-Received: by 2002:a63:7150:: with SMTP id b16-v6mr13870840pgn.326.1525201206600; Tue, 01 May 2018 12:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201206; cv=none; d=google.com; s=arc-20160816; b=fb9oS6/UiXba4NaMHU0NbCtHMAyWc6ggT3HtH7D/BkkisPB0vhupASWAPnUTzwl1m7 VTq05dfrzuM8rbjdQNwArt3eT4HThKraHAyBhNtz0CoMt3EwaidZ/xSYOXV2rgluRVt1 q5rn6qRUD4mlU9kYn2tbmkvdlXhJVzS5OGjsVcmjQOTFSEIZwhaY1emgjHiHqbVIWMfA QlrWu5htD8xx43cr1UIaV16w13V6HSmRB28A6zVOOsCPVl0x60cWbPVvDxGcsMxeDHU3 XIKtc67C+H7msjWSweYYG4m7cDXIjYnbu+4hqjejk9URBAjLXfNR5jG5ZpdTokQROpSN 32Yg== 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:arc-authentication-results; bh=qhs+JMcD8oWM7HgZWW6fkqH4Aj6Vfa8zcr/6hpTAJik=; b=gauP3lzeAhZ7Dliv7Rk0EjSqA46gYKcaOCn8HZzlH0lhuiuKq/xda+APs5MNEhmvJL mD+7GLEcCMPSMj8tie6srwx0NIbdNzF8leXR4VG8W10hNAagd0fxPgtzAckGsA8bGjAH kvpOQjArg7DPDXAyPWHRihZwflswYRJvvJk9s0N/QnsO2HF0wXw0PqiJj5XJro0Msz5e dbRXOg/hPjPnyWJrpmoChyC4/cqiud0SCsZqmbSi6bvwoKLO9H6gHv0aszD4Z1BH/DrX tR9mFO+vwuwxyahTrmcunoodVJ5w0ksGP5Gz1oaCJERsmAl40H96N0NMX94Vs3ZvYKUc i5gg== 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 c8si10177233pfj.138.2018.05.01.12.00.06; Tue, 01 May 2018 12:00:06 -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 S1756672AbeEAS6K (ORCPT + 29 others); Tue, 1 May 2018 14:58:10 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7642 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756593AbeEAS6F (ORCPT ); Tue, 1 May 2018 14:58:05 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 55E554EDE1D95; Wed, 2 May 2018 02:57:52 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:44 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 4/9] net: hns3: Fixes the error legs in hclge_init_ae_dev function Date: Tue, 1 May 2018 19:56:00 +0100 Message-ID: <20180501185605.9584-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan This patch fixes some of the missed error legs in the initialization function of the ae device. This might cause leaks in case of failure. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 55 +++++++++++++--------- 1 file changed, 34 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index c9e80ca..b5e0c58 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5430,7 +5430,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL); if (!hdev) { ret = -ENOMEM; - goto err_hclge_dev; + goto out; } hdev->pdev = pdev; @@ -5443,38 +5443,38 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ret = hclge_pci_init(hdev); if (ret) { dev_err(&pdev->dev, "PCI init failed\n"); - goto err_pci_init; + goto out; } /* Firmware command queue initialize */ ret = hclge_cmd_queue_init(hdev); if (ret) { dev_err(&pdev->dev, "Cmd queue init failed, ret = %d.\n", ret); - return ret; + goto err_pci_uninit; } /* Firmware command initialize */ ret = hclge_cmd_init(hdev); if (ret) - goto err_cmd_init; + goto err_cmd_uninit; ret = hclge_get_cap(hdev); if (ret) { dev_err(&pdev->dev, "get hw capability error, ret = %d.\n", ret); - return ret; + goto err_cmd_uninit; } ret = hclge_configure(hdev); if (ret) { dev_err(&pdev->dev, "Configure dev error, ret = %d.\n", ret); - return ret; + goto err_cmd_uninit; } ret = hclge_init_msi(hdev); if (ret) { dev_err(&pdev->dev, "Init MSI/MSI-X error, ret = %d.\n", ret); - return ret; + goto err_cmd_uninit; } ret = hclge_misc_irq_init(hdev); @@ -5482,69 +5482,69 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) dev_err(&pdev->dev, "Misc IRQ(vector0) init error, ret = %d.\n", ret); - return ret; + goto err_msi_uninit; } ret = hclge_alloc_tqps(hdev); if (ret) { dev_err(&pdev->dev, "Allocate TQPs error, ret = %d.\n", ret); - return ret; + goto err_msi_irq_uninit; } ret = hclge_alloc_vport(hdev); if (ret) { dev_err(&pdev->dev, "Allocate vport error, ret = %d.\n", ret); - return ret; + goto err_msi_irq_uninit; } ret = hclge_map_tqp(hdev); if (ret) { dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); - return ret; + goto err_sriov_disable; } ret = hclge_mac_mdio_config(hdev); if (ret) { dev_warn(&hdev->pdev->dev, "mdio config fail ret=%d\n", ret); - return ret; + goto err_sriov_disable; } ret = hclge_mac_init(hdev); if (ret) { dev_err(&pdev->dev, "Mac init error, ret = %d\n", ret); - return ret; + goto err_mdiobus_unreg; } ret = hclge_config_tso(hdev, HCLGE_TSO_MSS_MIN, HCLGE_TSO_MSS_MAX); if (ret) { dev_err(&pdev->dev, "Enable tso fail, ret =%d\n", ret); - return ret; + goto err_mdiobus_unreg; } ret = hclge_init_vlan_config(hdev); if (ret) { dev_err(&pdev->dev, "VLAN init fail, ret =%d\n", ret); - return ret; + goto err_mdiobus_unreg; } ret = hclge_tm_schd_init(hdev); if (ret) { dev_err(&pdev->dev, "tm schd init fail, ret =%d\n", ret); - return ret; + goto err_mdiobus_unreg; } hclge_rss_init_cfg(hdev); ret = hclge_rss_init_hw(hdev); if (ret) { dev_err(&pdev->dev, "Rss init fail, ret =%d\n", ret); - return ret; + goto err_mdiobus_unreg; } ret = init_mgr_tbl(hdev); if (ret) { dev_err(&pdev->dev, "manager table init fail, ret =%d\n", ret); - return ret; + goto err_mdiobus_unreg; } hclge_dcb_ops_set(hdev); @@ -5567,11 +5567,24 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME); return 0; -err_cmd_init: +err_mdiobus_unreg: + if (hdev->hw.mac.phydev) + mdiobus_unregister(hdev->hw.mac.mdio_bus); +err_sriov_disable: + if (IS_ENABLED(CONFIG_PCI_IOV)) + hclge_disable_sriov(hdev); +err_msi_irq_uninit: + hclge_misc_irq_uninit(hdev); +err_msi_uninit: + pci_free_irq_vectors(pdev); +err_cmd_uninit: + hclge_destroy_cmd_queue(&hdev->hw); +err_pci_uninit: + pci_clear_master(pdev); pci_release_regions(pdev); -err_pci_init: + pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); -err_hclge_dev: +out: return ret; } From patchwork Tue May 1 18:56:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134794 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5280331lji; Tue, 1 May 2018 11:58:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZPK+ROQTa+iODvPDXWB6tHZxTEY87N6bjXOyU/bvUL4BB3iAHUzAxh2IVIpvn4nPnESiH X-Received: by 10.98.217.217 with SMTP id b86mr16826561pfl.41.1525201130915; Tue, 01 May 2018 11:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201130; cv=none; d=google.com; s=arc-20160816; b=mby/OpW+S5M6eViX00KYcS2SBXXSf14R3tu5FqPt18C2bVx/LLM0w7uaVEt3tPWMPm vdDlmpYLa8GG7ZbqIEBEcQwkKKBaZXFunbQtFYU9i65hiLm03nVuF9qfRMoQ3sTBai64 LC3vmVRw+lvymXiFfYI+YLyY5v3/3gcUB7BZjkg3nsQo/ArGTxDxhsAsDhFW8MB9X3UP WqGyNcbrpTeDE5wiPhcStJMl1tnO6wDqr3OdNC0m9dyzElzKugXrXhlwi3xv2y7IK4a5 ALvL4Mh1JyMzTBdwFh479vh1k75/g8dzI1ZP8ogf1QfiylSnuYmU1dd+CvaywCu7Q4mf HxsA== 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:arc-authentication-results; bh=bLB0g2Uks9n5lV74CbD2OUkNO1VHyegC2b9hYdz1ZVo=; b=VmnYiVBaQi6KNjqFgcfuYiTc6K46LnDKLvCDGL79F/lf4+1K78nRJHGFqTT6woatfd QRhWO72xW92vO0gZHKsyC6tue0ihKhFWH30aeYnqxVbgBNGEkmRoiMLoqShW969k9+ze F1L7hhECCxIds1hOivNzBskMbNgTF/LIh5oyf30MAUX3OXKeEw8grNmOYdlewANTiY7R gUti3fWI16LOUc2yoxm0vnNzrB1fQyhsUmlmHF5zAdELepsR/knfgKX/M1jAVXxNPWu1 LmMRBnn1RlZIx8DJX+Ld6m4qRM2vzbNaVGlm81Jr6gXRBoclBOxy2AptJuqVt1mQP/5y zNXQ== 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 s1-v6si8220928pgq.282.2018.05.01.11.58.50; Tue, 01 May 2018 11:58:50 -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 S1756737AbeEAS6s (ORCPT + 29 others); Tue, 1 May 2018 14:58:48 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7644 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756654AbeEAS6K (ORCPT ); Tue, 1 May 2018 14:58:10 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 76A46B93EA053; Wed, 2 May 2018 02:57:57 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:50 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 6/9] net: hns3: Fix to support autoneg only for port attached with phy Date: Tue, 1 May 2018 19:56:02 +0100 Message-ID: <20180501185605.9584-7-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang This patch adds a check to support autoneg(ethtool -A) only when PHY is attached with the port. Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index cc09713..a4e9991 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5169,12 +5169,6 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg, struct phy_device *phydev = hdev->hw.mac.phydev; u32 fc_autoneg; - /* Only support flow control negotiation for netdev with - * phy attached for now. - */ - if (!phydev) - return -EOPNOTSUPP; - fc_autoneg = hclge_get_autoneg(handle); if (auto_neg != fc_autoneg) { dev_info(&hdev->pdev->dev, @@ -5193,6 +5187,12 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg, if (!fc_autoneg) return hclge_cfg_pauseparam(hdev, rx_en, tx_en); + /* Only support flow control negotiation for netdev with + * phy attached for now. + */ + if (!phydev) + return -EOPNOTSUPP; + return phy_start_aneg(phydev); } From patchwork Tue May 1 18:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134797 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5281693lji; Tue, 1 May 2018 12:00:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQTaWKOdUs6Py3alKN06+csMN4gZd+aF3A0AzmLTMHEozdRTRVXFcVPeaRT7SRbW4fkm16 X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr2149566plo.278.1525201224096; Tue, 01 May 2018 12:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201224; cv=none; d=google.com; s=arc-20160816; b=cEMN/CDHdEtCYZvXsrxdWLq9ye/MFsw0SKI4gubkZsmIc6aMWkHbaRSOdRcU3eBzCF iucQ+6/P6PlWZWW0d2twss2dwBS2sSoYyY+vLB/jBG5OQRGSPvBwQrhQT9KMPSiPsTEQ a7Lesn9D9X9HK0re7g3l71ltW9sGYjo6MhOaaBKsrFtwWtI7Kgb0opIPmNDsCMeTI1sV PgMyUDFoA5CieTf+EsoCpcHYHI8CZBXFv4GyC0Azq57WpB3qhcT5SLoeVEbwQ5ucUNXQ uyxWr1zlqY85DD45tz9dBwvhdPRg/ulKR3lpTgBSx+IkiNL2TDHZIcNZ7k2gpeoHYhYP eHZw== 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:arc-authentication-results; bh=FJNP2jW7vJBPKVjmS1xl6bnPWM3PRVprqjq2XmC9JzU=; b=SE/+rbg42VJthlVFEC1Yj1h5Ic0eCGGj/ghnMK/NkzVQNqpSMQJ8yAAb2xqPHv+iYD jSyB5RQ13IyP03zGaw8CXTl/WEKsBpL+04aA5Fz1lHeucK9083ceFhpuy1oh+k/zoP1b SRZASRFgck2ltoxyR0nRS3xxrjG2/3LuvNzBI+HMDITwi2zLyJi/g0mcf/w/QWd5oPGL rQHIOV0Vn7DPVxuYFJmmqFiWO+A11RI/8k2UJpJkkAvvq3FxxHP4jbkJGS1o3zOsKuf5 gcWzQBCTKBPgTNoppO/xrmUlvkpLo/Ai9G6J8pnN8TCXljocaVMiNZC3bxggFMLfVMiS 5i3Q== 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 c8si10177233pfj.138.2018.05.01.12.00.23; Tue, 01 May 2018 12:00:24 -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 S1756646AbeEAS6I (ORCPT + 29 others); Tue, 1 May 2018 14:58:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54948 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756398AbeEAS6F (ORCPT ); Tue, 1 May 2018 14:58:05 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C93FCE11240; Wed, 2 May 2018 02:58:02 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:53 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 7/9] net: hns3: fix a dead loop in hclge_cmd_csq_clean Date: Tue, 1 May 2018 19:56:03 +0100 Message-ID: <20180501185605.9584-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan If head has invlid value then a dead loop can be triggered in hclge_cmd_csq_clean. This patch adds sanity check for this case. Fixes: 68c0a5c70614 ("net: hns3: Add HNS3 IMP(Integrated Mgmt Proc) Cmd Interface Support") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c index ff13d18..fab7068 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -31,6 +31,17 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring) return ring->desc_num - used - 1; } +static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int h) +{ + int u = ring->next_to_use; + int c = ring->next_to_clean; + + if (unlikely(h >= ring->desc_num)) + return 0; + + return u > c ? (h > c && h <= u) : (h > c || h <= u); +} + static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring) { int size = ring->desc_num * sizeof(struct hclge_desc); @@ -141,6 +152,7 @@ static void hclge_cmd_init_regs(struct hclge_hw *hw) static int hclge_cmd_csq_clean(struct hclge_hw *hw) { + struct hclge_dev *hdev = (struct hclge_dev *)hw->back; struct hclge_cmq_ring *csq = &hw->cmq.csq; u16 ntc = csq->next_to_clean; struct hclge_desc *desc; @@ -149,6 +161,13 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw) desc = &csq->desc[ntc]; head = hclge_read_dev(hw, HCLGE_NIC_CSQ_HEAD_REG); + rmb(); /* Make sure head is ready before touch any data */ + + if (!is_valid_csq_clean_head(csq, head)) { + dev_warn(&hdev->pdev->dev, "wrong head (%d, %d-%d)\n", head, + csq->next_to_use, csq->next_to_clean); + return 0; + } while (head != ntc) { memset(desc, 0, sizeof(*desc)); From patchwork Tue May 1 18:56:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134792 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5279898lji; Tue, 1 May 2018 11:58:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZple67FZrxVvVbaVtKjCuZhUqUMHOfKGYlhIRlDehNRuNyOo/bLUhhk74boP2cbzPq6DxKi X-Received: by 10.98.160.68 with SMTP id r65mr16292279pfe.235.1525201095499; Tue, 01 May 2018 11:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201095; cv=none; d=google.com; s=arc-20160816; b=d5h5S9IPbppOAe+rEeMdI/AT35ZTAbSmy/06kUlfmmxGHT13c/05uWt7oBitAiUF6X vlJBX+adRBKPAX23BX/FNfIQ1FQS1lMqyXumQbeISKPs1UZrtLZHYusasBZk0qELzkVJ nex0Guz7OxIxSXlvm8ZZFulo+ZHQD2hXktY3XVWRiaoUsMXC0aR92yCcT5cgvTTRpBHU uMwzNChrZJBMas4FY4K56y5Xno+itN76wRZconwCSRNjCxyCHmE5S8SLrsCDfZcr9jK/ SOKgp9KqnQU4qSGV6dEMwSiD5tj1HYwzg8A8WEpvfl0FPL2+E1R85plJNACCsGptgSZc rcPQ== 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:arc-authentication-results; bh=hbDA6+V4z0uan0G0PmS+uPv27YvXtOsCFAXWBBlbH+U=; b=YBgX3ZiFcDpm6Ct2VXmxFPwZOKSrZ0EW2iMIFqRUlcyGw4jY7/oDSdQKmkBhmBsgDu QPLeTxxYnpveqhIm8qmGIxvlVr3um7troogYXN2Ti+wsSY5J9qKs6sUjnTeMbOvPqXmC Z66qaXQh54kiHRowmr6iVR74MrxfOkYUKRMeJsBQmbkd+JfXqPB0X5mMRWm1HQ13jMld j/+0XZk8O79pT9tQX/gORZ/8opjyMzTsHbhc9yGuyWkPYZRUhzR2TA5AEphz5tazd+Dy f/LzxKHDjni5vcAiAbNwv7m/ElEylt4OLUGUW2/MiKmQaQx3LhdbjcePuG2sY9V1hSAa IT7g== 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 v2-v6si8143437pgf.354.2018.05.01.11.58.15; Tue, 01 May 2018 11:58:15 -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 S1756692AbeEAS6M (ORCPT + 29 others); Tue, 1 May 2018 14:58:12 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54953 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756247AbeEAS6G (ORCPT ); Tue, 1 May 2018 14:58:06 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D6E441975B265; Wed, 2 May 2018 02:58:02 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:56 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 8/9] net: hns3: Fix for packet loss due wrong filter config in VLAN tbls Date: Tue, 1 May 2018 19:56:04 +0100 Message-ID: <20180501185605.9584-9-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin There are two level of vlan tables in hardware, one is port vlan which is shared by all functions, the other one is function vlan table, each function has it's own function vlan table. Currently, PF sets the port vlan table, and vf sets the function vlan table, which will cause packet lost problem. This patch fixes this problem by setting both vlan table, and use hdev->vlan_table to manage thet port vlan table. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 79 +++++++++++++++++----- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 8 ++- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 +- 3 files changed, 70 insertions(+), 24 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a4e9991..77d9e4c0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4543,8 +4543,9 @@ static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable) hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, enable); } -int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid, - bool is_kill, u16 vlan, u8 qos, __be16 proto) +static int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid, + bool is_kill, u16 vlan, u8 qos, + __be16 proto) { #define HCLGE_MAX_VF_BYTES 16 struct hclge_vlan_filter_vf_cfg_cmd *req0; @@ -4602,12 +4603,9 @@ int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid, return -EIO; } -static int hclge_set_port_vlan_filter(struct hnae3_handle *handle, - __be16 proto, u16 vlan_id, - bool is_kill) +static int hclge_set_port_vlan_filter(struct hclge_dev *hdev, __be16 proto, + u16 vlan_id, bool is_kill) { - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; struct hclge_vlan_filter_pf_cfg_cmd *req; struct hclge_desc desc; u8 vlan_offset_byte_val; @@ -4627,22 +4625,66 @@ static int hclge_set_port_vlan_filter(struct hnae3_handle *handle, req->vlan_offset_bitmap[vlan_offset_byte] = vlan_offset_byte_val; ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) + dev_err(&hdev->pdev->dev, + "port vlan command, send fail, ret =%d.\n", ret); + return ret; +} + +static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto, + u16 vport_id, u16 vlan_id, u8 qos, + bool is_kill) +{ + u16 vport_idx, vport_num = 0; + int ret; + + ret = hclge_set_vf_vlan_common(hdev, vport_id, is_kill, vlan_id, + 0, proto); if (ret) { dev_err(&hdev->pdev->dev, - "port vlan command, send fail, ret =%d.\n", - ret); + "Set %d vport vlan filter config fail, ret =%d.\n", + vport_id, ret); return ret; } - ret = hclge_set_vf_vlan_common(hdev, 0, is_kill, vlan_id, 0, proto); - if (ret) { + /* vlan 0 may be added twice when 8021q module is enabled */ + if (!is_kill && !vlan_id && + test_bit(vport_id, hdev->vlan_table[vlan_id])) + return 0; + + if (!is_kill && test_and_set_bit(vport_id, hdev->vlan_table[vlan_id])) { dev_err(&hdev->pdev->dev, - "Set pf vlan filter config fail, ret =%d.\n", - ret); - return -EIO; + "Add port vlan failed, vport %d is already in vlan %d\n", + vport_id, vlan_id); + return -EINVAL; } - return 0; + if (is_kill && + !test_and_clear_bit(vport_id, hdev->vlan_table[vlan_id])) { + dev_err(&hdev->pdev->dev, + "Delete port vlan failed, vport %d is not in vlan %d\n", + vport_id, vlan_id); + return -EINVAL; + } + + for_each_set_bit(vport_idx, hdev->vlan_table[vlan_id], VLAN_N_VID) + vport_num++; + + if ((is_kill && vport_num == 0) || (!is_kill && vport_num == 1)) + ret = hclge_set_port_vlan_filter(hdev, proto, vlan_id, + is_kill); + + return ret; +} + +int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, + u16 vlan_id, bool is_kill) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + + return hclge_set_vlan_filter_hw(hdev, proto, vport->vport_id, vlan_id, + 0, is_kill); } static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid, @@ -4656,7 +4698,7 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid, if (proto != htons(ETH_P_8021Q)) return -EPROTONOSUPPORT; - return hclge_set_vf_vlan_common(hdev, vfid, false, vlan, qos, proto); + return hclge_set_vlan_filter_hw(hdev, proto, vfid, vlan, qos, false); } static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport) @@ -4821,7 +4863,7 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev) } handle = &hdev->vport[0].nic; - return hclge_set_port_vlan_filter(handle, htons(ETH_P_8021Q), 0, false); + return hclge_set_vlan_filter(handle, htons(ETH_P_8021Q), 0, false); } static int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) @@ -5604,6 +5646,7 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) set_bit(HCLGE_STATE_DOWN, &hdev->state); hclge_stats_clear(hdev); + memset(hdev->vlan_table, 0, sizeof(hdev->vlan_table)); ret = hclge_cmd_init(hdev); if (ret) { @@ -6221,7 +6264,7 @@ static const struct hnae3_ae_ops hclge_ops = { .get_fw_version = hclge_get_fw_version, .get_mdix_mode = hclge_get_mdix_mode, .enable_vlan_filter = hclge_enable_vlan_filter, - .set_vlan_filter = hclge_set_port_vlan_filter, + .set_vlan_filter = hclge_set_vlan_filter, .set_vf_vlan_filter = hclge_set_vf_vlan_filter, .enable_hw_strip_rxvtag = hclge_en_hw_strip_rxvtag, .reset_event = hclge_reset_event, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 0f4157e..6432f754 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,6 +12,8 @@ #include #include #include +#include + #include "hclge_cmd.h" #include "hnae3.h" @@ -471,6 +473,7 @@ struct hclge_vlan_type_cfg { u16 tx_in_vlan_type; }; +#define HCLGE_VPORT_NUM 256 struct hclge_dev { struct pci_dev *pdev; struct hnae3_ae_dev *ae_dev; @@ -562,6 +565,7 @@ struct hclge_dev { u64 rx_pkts_for_led; u64 tx_pkts_for_led; + unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)]; }; /* VPort level vlan tag configuration for TX direction */ @@ -646,8 +650,8 @@ static inline int hclge_get_queue_id(struct hnae3_queue *queue) } int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex); -int hclge_set_vf_vlan_common(struct hclge_dev *vport, int vfid, - bool is_kill, u16 vlan, u8 qos, __be16 proto); +int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, + u16 vlan_id, bool is_kill); int hclge_buffer_alloc(struct hclge_dev *hdev); int hclge_rss_init_hw(struct hclge_dev *hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index a6f7ffa..7563335 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -264,19 +264,18 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport, struct hclge_mbx_vf_to_pf_cmd *mbx_req, bool gen_resp) { - struct hclge_dev *hdev = vport->back; int status = 0; if (mbx_req->msg[1] == HCLGE_MBX_VLAN_FILTER) { + struct hnae3_handle *handle = &vport->nic; u16 vlan, proto; bool is_kill; is_kill = !!mbx_req->msg[2]; memcpy(&vlan, &mbx_req->msg[3], sizeof(vlan)); memcpy(&proto, &mbx_req->msg[5], sizeof(proto)); - status = hclge_set_vf_vlan_common(hdev, vport->vport_id, - is_kill, vlan, 0, - cpu_to_be16(proto)); + status = hclge_set_vlan_filter(handle, cpu_to_be16(proto), + vlan, is_kill); } if (gen_resp) From patchwork Tue May 1 18:56:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134793 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5280117lji; Tue, 1 May 2018 11:58:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrON6T1TDBUdwqR6HK/g3+fwmCNrDS+U29LHOhH8vYMN7CGnvB0UTxsDErfu9n7gs4iqYi7 X-Received: by 10.98.17.82 with SMTP id z79mr16534191pfi.135.1525201111300; Tue, 01 May 2018 11:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201111; cv=none; d=google.com; s=arc-20160816; b=OOFg/5QB/GL40lXkAufzS4G4dtPuNa1wp/tQxvGenZKxerMRFxNSsOiU0vshz5DnnA DwR5UK9OwCppRTskIBroMbkTctRSdbOgmrJpNiYoCWYzsXV05Y96EPSPSPgArr71gm0/ dlxEfAftN34Wdy46S51iqc49PnoY+piekDvBzInMVcGjW9V/LswUFnsbN29FEhQ6uDQ/ JI8ofEjPpjHnh83pNV6MNhwsTsbbW5d1s3Gz5oWWvuq9eBlEIgtUFU/L2ycgqUdzg76a AsK0QPhJWIWgmvm391AvDbEvvM4ZWKedTZkvY0wNjQAg0QuBtkZR82JK8k3IHDd+hWwz wrpA== 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:arc-authentication-results; bh=KeWJSNFJw1Zr4WwMReLZu2151LaGTYA0+W98xWMxvZw=; b=yndClBfIjh+xxn3zEPF0LGuPTBDSGiJbqbFtgc82ihWpInK1HNmg7asobBKXxiXPM+ 6xSdRoCn3ScAYPSco6khhpFRH6BkCGuG3lE0CorBQeWjnJbW0z5vKKHsew9/eY7yGa2z GlVtXixo6QYEXYX8jS0yd0jR2M6IJ+vGYFhGVaVBr3pGg+1+a9kB/RGTpUj0SQq+vKmA KP2j4uW+F6BenD8LaAvltdTP1H7VF53gAaA//S6yC1IEdhsXcUzPSbAuG9fQ8aN2kcmc SmxNugCBnxOpVDAFMdm90Fkx05wembRNrqMWYKGarHR8lmqyukB0n0SH4ArgeGHXLJRT ENYA== 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 bg3-v6si9615123plb.118.2018.05.01.11.58.31; Tue, 01 May 2018 11:58:31 -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 S1756714AbeEAS62 (ORCPT + 29 others); Tue, 1 May 2018 14:58:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7645 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756247AbeEAS6U (ORCPT ); Tue, 1 May 2018 14:58:20 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 87F09E0C26278; Wed, 2 May 2018 02:58:07 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:59 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net-next 9/9] net: hns3: Remove packet statistics in the range of 8192~12287 Date: Tue, 1 May 2018 19:56:05 +0100 Message-ID: <20180501185605.9584-10-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang Because the current statistics for size 8192~12287 are only valid for GE, the ranges of 8192~9216 and 9217~12287 are valid only for LGE/CGE, and are always 0 for GE interfaces. it is easy to cause confusion when viewing the packet statistics using the command ethtool -S. This patch removes the 8192~12287 range of packet statistics and uses the 8192~9216 and 9217~12287 ranges for statistics. This change depends on the firmware upgrade. Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ---- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 77d9e4c0..dd5d65c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -304,8 +304,6 @@ static const struct hclge_comm_stats_str g_mac_stats_string[] = { HCLGE_MAC_STATS_FIELD_OFF(mac_tx_2048_4095_oct_pkt_num)}, {"mac_tx_4096_8191_oct_pkt_num", HCLGE_MAC_STATS_FIELD_OFF(mac_tx_4096_8191_oct_pkt_num)}, - {"mac_tx_8192_12287_oct_pkt_num", - HCLGE_MAC_STATS_FIELD_OFF(mac_tx_8192_12287_oct_pkt_num)}, {"mac_tx_8192_9216_oct_pkt_num", HCLGE_MAC_STATS_FIELD_OFF(mac_tx_8192_9216_oct_pkt_num)}, {"mac_tx_9217_12287_oct_pkt_num", @@ -356,8 +354,6 @@ static const struct hclge_comm_stats_str g_mac_stats_string[] = { HCLGE_MAC_STATS_FIELD_OFF(mac_rx_2048_4095_oct_pkt_num)}, {"mac_rx_4096_8191_oct_pkt_num", HCLGE_MAC_STATS_FIELD_OFF(mac_rx_4096_8191_oct_pkt_num)}, - {"mac_rx_8192_12287_oct_pkt_num", - HCLGE_MAC_STATS_FIELD_OFF(mac_rx_8192_12287_oct_pkt_num)}, {"mac_rx_8192_9216_oct_pkt_num", HCLGE_MAC_STATS_FIELD_OFF(mac_rx_8192_9216_oct_pkt_num)}, {"mac_rx_9217_12287_oct_pkt_num", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 6432f754..b7ee91d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -408,9 +408,9 @@ struct hclge_mac_stats { u64 mac_tx_1519_2047_oct_pkt_num; u64 mac_tx_2048_4095_oct_pkt_num; u64 mac_tx_4096_8191_oct_pkt_num; - u64 mac_tx_8192_12287_oct_pkt_num; /* valid for GE MAC only */ - u64 mac_tx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */ - u64 mac_tx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC */ + u64 rsv0; + u64 mac_tx_8192_9216_oct_pkt_num; + u64 mac_tx_9217_12287_oct_pkt_num; u64 mac_tx_12288_16383_oct_pkt_num; u64 mac_tx_1519_max_good_oct_pkt_num; u64 mac_tx_1519_max_bad_oct_pkt_num; @@ -435,9 +435,9 @@ struct hclge_mac_stats { u64 mac_rx_1519_2047_oct_pkt_num; u64 mac_rx_2048_4095_oct_pkt_num; u64 mac_rx_4096_8191_oct_pkt_num; - u64 mac_rx_8192_12287_oct_pkt_num;/* valid for GE MAC only */ - u64 mac_rx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */ - u64 mac_rx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC only */ + u64 rsv1; + u64 mac_rx_8192_9216_oct_pkt_num; + u64 mac_rx_9217_12287_oct_pkt_num; u64 mac_rx_12288_16383_oct_pkt_num; u64 mac_rx_1519_max_good_oct_pkt_num; u64 mac_rx_1519_max_bad_oct_pkt_num;