From patchwork Sun Nov 18 03:19:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 151426 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1140984ljp; Sat, 17 Nov 2018 19:20:46 -0800 (PST) X-Google-Smtp-Source: AJdET5ckORPDzOmiXUqfcN6UgbtyP4RSnPmI78KsGu40qo182qHRvBYZ/9zLCNp/16Kk0MvrKXob X-Received: by 2002:a63:e84c:: with SMTP id a12mr15360332pgk.241.1542511246503; Sat, 17 Nov 2018 19:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542511246; cv=none; d=google.com; s=arc-20160816; b=ExDJFKf+O42VQc6QFQXDVmxJ4HZJOq99Ud8QtzmlizisXO3UHeZDJY+HC7RrfARLXq dbIERRMMqHZ3ojtpGlKcC7/YUsmzwK3ZGPrU4Dwsk1Xnkh6VQ4KA2ovngsCdmxPyPlea Ncs/I/3Yx1MkOcsuaGJPTqsViSpRVvw1e6I0riSkUFdqV14jPxGPTczg5cWekpMP9Tz6 vDjpmiiLiDLTLSHj33LZkI3XBwS6GqYMIF5sOnN2nK1aLZZ1MldEKpEga0ggyjdJz768 zQXjF8kDVp/4CQ5XKUoT+5lsLMa4EDZApVUCqxib4AgmiTf7WGuwMVrfjzIaL1fWnh1A wSjg== 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=EnyNUhGlf3JDfCInw6kJfEJhnsIaCWVUB7Gk50h/Yw8=; b=S0epdheBtLc5v9dR11tFMyU16pqjOy0yZK1gJUHSIUM+3qyVJRQbyMtURByCFlNIlb TaBI98O2Una5huUEUmZMYzd/1qhCowP9D8yB1Kw464Co7p4YY4xD6mlOBz6mKqL23xOv 3iUtMSE+NhhOROYh1gjD4Y9op3UmbL4BAzWAXI3d5avVIgVM1S+vSpVEEzmIdKFIGB/a Xi1bXi8Joj6S7b6J0jWM1/Oqd2allcCdQy5nNLCSQ36384QgaixGoq5Tk6MTJGFrgR2t sSU9X5dkrEqmYOYEQuhideDQDxyHewyUpTEEoJvulRMoJXGoDw7Wp4htfZIzaBhIIDsV R2Yw== 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 i72-v6si31358016pfj.276.2018.11.17.19.20.46; Sat, 17 Nov 2018 19:20:46 -0800 (PST) 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 S1726908AbeKRNj1 (ORCPT + 32 others); Sun, 18 Nov 2018 08:39:27 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:48617 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725831AbeKRNj1 (ORCPT ); Sun, 18 Nov 2018 08:39:27 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 694775BCD9977; Sun, 18 Nov 2018 11:20:33 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.88.178) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Sun, 18 Nov 2018 11:20:24 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin , Jian Shen Subject: [PATCH net-next 1/5] net: hns3: Support two vlan header when setting mtu Date: Sun, 18 Nov 2018 03:19:10 +0000 Message-ID: <20181118031914.23892-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181118031914.23892-1-salil.mehta@huawei.com> References: <20181118031914.23892-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.88.178] 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 This patch adds supports for two vlan header when setting mtu. Signed-off-by: Yunsheng Lin Signed-off-by: Jian Shen Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +++-- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 22220af92aa9..c944090d3adf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3609,8 +3609,9 @@ static int hns3_client_init(struct hnae3_handle *handle) hns3_dcbnl_setup(handle); - /* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */ - netdev->max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN); + /* MTU range: (ETH_MIN_MTU(kernel default) - 9702) */ + netdev->max_mtu = + HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN); set_bit(HNS3_NIC_STATE_INITED, &priv->state); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 33885a7529fc..019f747e486a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6364,7 +6364,7 @@ static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mtu) int max_frm_size; int ret; - max_frm_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; + max_frm_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN; if (max_frm_size < HCLGE_MAC_MIN_FRAME || max_frm_size > HCLGE_MAC_MAX_FRAME) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index ca90b662e33b..279661764910 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -120,7 +120,7 @@ enum HLCGE_PORT_TYPE { #define HCLGE_VECTOR0_IMP_RESET_INT_B 1 #define HCLGE_MAC_DEFAULT_FRAME \ - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN + ETH_DATA_LEN) + (ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN + ETH_DATA_LEN) #define HCLGE_MAC_MIN_FRAME 64 #define HCLGE_MAC_MAX_FRAME 9728 From patchwork Sun Nov 18 03:19:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 151427 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1140990ljp; Sat, 17 Nov 2018 19:20:47 -0800 (PST) X-Google-Smtp-Source: AJdET5d+HdUmVDfCOHeRXCsg3xFXM9ALV/lQUvTEEL2Enhj/jmwTzw976mvmCSxzIYUiepQDv3cg X-Received: by 2002:a62:1bd7:: with SMTP id b206mr17594440pfb.213.1542511247285; Sat, 17 Nov 2018 19:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542511247; cv=none; d=google.com; s=arc-20160816; b=txuYYTYxS7zHpFZ14cXtEd00HWd0ctBA3av4ea6nsv4NPpW26cWuuv1GmKUNHsvczF +Q9UkFRLH7fLTX8xok2mV63qIlj3nRr6giCJ+87vD2S3GDyoDnCuNK2RVZaiwZnV5MrJ W/DqDHebdsqFooy2tH+pKDsiemtcKB/cSbXf7E/XZHtYvjzLJA4BTCA0UNM1i/apkNdN 47gAYS6I4BJAL8L7MbSF/7b+QezK5nw6gYwt3fgwP4rFXU3qYmsRb08OpFm+Rasn46gg oQBg+JGXRhWrcCL/mRu/ChtX4rz+skiEmMTk2DkMA8+kppz4O3vsXiqyqEE2/6Q3y19o im+A== 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=r+Vb05ufh2eUrKIp806HldNxLfF6bhVvUlegSZ0W/j4=; b=cmd7+W/DVLT0UYh2t7ehmyEFSLFqv7yXj1ThmURUd/rdi0JRbjpRhcsGTftDmYW9kp c6mVnnnCOXvxXYoYjHswWJna/MiKGpwlow58ikPQyPVT92jGnBRQ39U1WtIh4cRPvbEa C+y2Q7JVuLb2meDgtdawvKeU2HR7tXNiIuYAE+XMKI5q3Q7ldCGzrFB29PUhYiRhoRMj twwonym4b1OTrgJoRc3xaMuliuUJZ5xVWQa6ab9/rZsiatk5n7QgRU+P+SbefT7HEHtO ee4WSkN6/qm0gzUDuQpmTf8WTO6JjU8BzFq/kkWbLVHb4/M2eoE1FujKpsFzNCiDlkEj YKww== 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 i72-v6si31358016pfj.276.2018.11.17.19.20.46; Sat, 17 Nov 2018 19:20:47 -0800 (PST) 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 S1726982AbeKRNjd (ORCPT + 32 others); Sun, 18 Nov 2018 08:39:33 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:44065 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725831AbeKRNjc (ORCPT ); Sun, 18 Nov 2018 08:39:32 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6D187285F323D; Sun, 18 Nov 2018 11:20:38 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.88.178) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Sun, 18 Nov 2018 11:20:30 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin , Jian Shen Subject: [PATCH net-next 2/5] net: hns3: Refactor mac mtu setting related functions Date: Sun, 18 Nov 2018 03:19:11 +0000 Message-ID: <20181118031914.23892-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181118031914.23892-1-salil.mehta@huawei.com> References: <20181118031914.23892-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.88.178] 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 This patch refactors mac mtu setting related functions, normalizes the use of mps and mtu. Signed-off-by: Yunsheng Lin Signed-off-by: Jian Shen Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +- .../net/ethernet/hisilicon/hns3/hns3_enet.h | 5 +- .../hisilicon/hns3/hns3pf/hclge_main.c | 52 ++++++++----------- 3 files changed, 27 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index c944090d3adf..d58d3c193ab7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3610,8 +3610,7 @@ static int hns3_client_init(struct hnae3_handle *handle) hns3_dcbnl_setup(handle); /* MTU range: (ETH_MIN_MTU(kernel default) - 9702) */ - netdev->max_mtu = - HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN); + netdev->max_mtu = HNS3_MAX_MTU; set_bit(HNS3_NIC_STATE_INITED, &priv->state); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 3365c9596983..bbf227ba30f8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -76,7 +76,10 @@ enum hns3_nic_state { #define HNS3_RING_MAX_PENDING 32768 #define HNS3_RING_MIN_PENDING 8 #define HNS3_RING_BD_MULTIPLE 8 -#define HNS3_MAX_MTU 9728 +/* max frame size of mac */ +#define HNS3_MAC_MAX_FRAME 9728 +#define HNS3_MAX_MTU \ + (HNS3_MAC_MAX_FRAME - (ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN)) #define HNS3_BD_SIZE_512_TYPE 0 #define HNS3_BD_SIZE_1024_TYPE 1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 019f747e486a..0a8297f67b06 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -26,7 +26,7 @@ #define HCLGE_STATS_READ(p, offset) (*((u64 *)((u8 *)(p) + (offset)))) #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) -static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu); +static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mps); static int hclge_init_vlan_config(struct hclge_dev *hdev); static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev); static int hclge_set_umv_space(struct hclge_dev *hdev, u16 space_size, @@ -1969,10 +1969,7 @@ static int hclge_get_autoneg(struct hnae3_handle *handle) static int hclge_mac_init(struct hclge_dev *hdev) { - struct hnae3_handle *handle = &hdev->vport[0].nic; - struct net_device *netdev = handle->kinfo.netdev; struct hclge_mac *mac = &hdev->hw.mac; - int mtu; int ret; hdev->hw.mac.duplex = HCLGE_MAC_FULL; @@ -1986,15 +1983,16 @@ static int hclge_mac_init(struct hclge_dev *hdev) mac->link = 0; - if (netdev) - mtu = netdev->mtu; - else - mtu = ETH_DATA_LEN; + ret = hclge_set_mac_mtu(hdev, hdev->mps); + if (ret) { + dev_err(&hdev->pdev->dev, "set mtu failed ret=%d\n", ret); + return ret; + } - ret = hclge_set_mtu(handle, mtu); + ret = hclge_buffer_alloc(hdev); if (ret) dev_err(&hdev->pdev->dev, - "set mtu failed ret=%d\n", ret); + "allocate buffer fail, ret=%d\n", ret); return ret; } @@ -6357,49 +6355,42 @@ int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) return hclge_set_vlan_rx_offload_cfg(vport); } -static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mtu) +static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mps) { struct hclge_config_max_frm_size_cmd *req; struct hclge_desc desc; - int max_frm_size; - int ret; - - max_frm_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN; - - if (max_frm_size < HCLGE_MAC_MIN_FRAME || - max_frm_size > HCLGE_MAC_MAX_FRAME) - return -EINVAL; - max_frm_size = max(max_frm_size, HCLGE_MAC_DEFAULT_FRAME); + new_mps = max(new_mps, HCLGE_MAC_DEFAULT_FRAME); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAX_FRM_SIZE, false); req = (struct hclge_config_max_frm_size_cmd *)desc.data; - req->max_frm_size = cpu_to_le16(max_frm_size); + req->max_frm_size = cpu_to_le16(new_mps); req->min_frm_size = HCLGE_MAC_MIN_FRAME; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) - dev_err(&hdev->pdev->dev, "set mtu fail, ret =%d.\n", ret); - else - hdev->mps = max_frm_size; - - return ret; + return hclge_cmd_send(&hdev->hw, &desc, 1); } static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu) { struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; - int ret; + int max_frm_size, ret; - ret = hclge_set_mac_mtu(hdev, new_mtu); + max_frm_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN; + if (max_frm_size < HCLGE_MAC_MIN_FRAME || + max_frm_size > HCLGE_MAC_MAX_FRAME) + return -EINVAL; + + ret = hclge_set_mac_mtu(hdev, max_frm_size); if (ret) { dev_err(&hdev->pdev->dev, "Change mtu fail, ret =%d\n", ret); return ret; } + hdev->mps = max_frm_size; + ret = hclge_buffer_alloc(hdev); if (ret) dev_err(&hdev->pdev->dev, @@ -7021,6 +7012,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hdev->reset_type = HNAE3_NONE_RESET; hdev->reset_level = HNAE3_FUNC_RESET; ae_dev->priv = hdev; + hdev->mps = ETH_FRAME_LEN + ETH_FCS_LEN + 2 * VLAN_HLEN; ret = hclge_pci_init(hdev); if (ret) { From patchwork Sun Nov 18 03:19:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 151429 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1141083ljp; Sat, 17 Nov 2018 19:20:56 -0800 (PST) X-Google-Smtp-Source: AJdET5claHuqLaDtIgBLJRb2Xhrz6yYSNL/mw4fUy3xaPxxms5YWK8xC4Z+X/Ag8HPhoaH0SjywG X-Received: by 2002:a62:f247:: with SMTP id y7mr8032814pfl.25.1542511256275; Sat, 17 Nov 2018 19:20:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542511256; cv=none; d=google.com; s=arc-20160816; b=gJ1R/kF9qgtoYVsHN+0eVH0QT0dzaAzdtKLE9WcGREAncyWTR8540DjSEfFgchHO+M YMdt1W7Zm+iCcxWstWC1MBc10MjJv4CNV9OPS5XiLWW9gfkpbLddbzYJefe4G0SbOIL2 GllBcasV1xrRwaxQqjymW1fkU5ZvahLku5qeHSQqZn9OhZYaYLhQZjAXpgHnRpnDEEPb 6NGJte/29M0/svaCLvjp5tCAsDvh5cjjwB87B0FYyinPYzkv3psPFzFgtUyFIdBJJld0 l+qqxsbiXX6Bjt+kIQ88kV9BSjSPruud9R4AZCYgGOcWEU6mj4EK8wATk4buJyCyl3RN yMcA== 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=nYJ03Y1q3qeR+wEVMKsmhUk5PiQl3aB7gJEQVoo8dns=; b=WGJn1TZfM1veyt1e7LCp2C3NZb2y7xUfyuihfI4wjkvDGMVm9TSKladyIUD2DKD63L aPqSP2mBoRgOt+XjWCS6JAzraB1XXfDpf8CEnqxlWllPPxcdI92DzYoeef8c/nfkXVyb u+KI/2AnOZabBZ3Re165opiyU0xKa+/qm8Q8j1eutyDd3fnrn4unsJPR7OSYRZZmFxSz sz5eMVhlRyhUjMCQHXXv+g29HDcZlF+AvjU8azMeajru4xgO3WcgROSHyccG0Ts2tKSi KOU7/ukeRi9TJDr69Rr1wAB7FyRfPxaDR8mO1BiRdhtnLRm0Tps5mkjUI9LMVQKSDIsP RMeg== 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 r34si15653114pga.242.2018.11.17.19.20.55; Sat, 17 Nov 2018 19:20:56 -0800 (PST) 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 S1727045AbeKRNjj (ORCPT + 32 others); Sun, 18 Nov 2018 08:39:39 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:15112 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725831AbeKRNji (ORCPT ); Sun, 18 Nov 2018 08:39:38 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 755C3D5542806; Sun, 18 Nov 2018 11:20:43 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.88.178) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Sun, 18 Nov 2018 11:20:35 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin , Jian Shen Subject: [PATCH net-next 3/5] net: hns3: Add vport alive state checking support Date: Sun, 18 Nov 2018 03:19:12 +0000 Message-ID: <20181118031914.23892-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181118031914.23892-1-salil.mehta@huawei.com> References: <20181118031914.23892-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.88.178] 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 Currently there is no way for pf to know if a vf device is alive or not, so PF does not know which vf to notify when reset happens, or which vf's mtu is invalid when vf and pf share the same hardware mtu setting. This patch adds vport alive state checking support, in order to support the above scenario. Signed-off-by: Yunsheng Lin Signed-off-by: Jian Shen Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hclge_mbx.h | 2 + drivers/net/ethernet/hisilicon/hns3/hnae3.h | 6 ++ .../net/ethernet/hisilicon/hns3/hns3_enet.c | 24 +++++++ .../hisilicon/hns3/hns3pf/hclge_main.c | 55 +++++++++++++++ .../hisilicon/hns3/hns3pf/hclge_main.h | 10 +++ .../hisilicon/hns3/hns3pf/hclge_mbx.c | 31 +++++++++ .../hisilicon/hns3/hns3vf/hclgevf_main.c | 67 ++++++++++++++++++- .../hisilicon/hns3/hns3vf/hclgevf_main.h | 2 + 8 files changed, 195 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index 3bb313cdbc9f..fd2338f0c34e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -36,6 +36,8 @@ enum HCLGE_MBX_OPCODE { HCLGE_MBX_BIND_FUNC_QUEUE, /* (VF -> PF) bind function and queue */ HCLGE_MBX_GET_LINK_STATUS, /* (VF -> PF) get link status */ HCLGE_MBX_QUEUE_RESET, /* (VF -> PF) reset queue */ + HCLGE_MBX_KEEP_ALIVE, /* (VF -> PF) send keep alive cmd */ + HCLGE_MBX_SET_ALIVE, /* (VF -> PF) set alive state */ }; /* below are per-VF mac-vlan subcodes */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 1746172ffbf7..4a39feaba8b2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -210,6 +210,10 @@ struct hnae3_ae_dev { * Enable the hardware * stop() * Disable the hardware + * start_client() + * Inform the hclge that client has been started + * stop_client() + * Inform the hclge that client has been stopped * get_status() * Get the carrier state of the back channel of the handle, 1 for ok, 0 for * non-ok @@ -319,6 +323,8 @@ struct hnae3_ae_ops { struct hnae3_ae_dev *ae_dev); int (*start)(struct hnae3_handle *handle); void (*stop)(struct hnae3_handle *handle); + int (*client_start)(struct hnae3_handle *handle); + void (*client_stop)(struct hnae3_handle *handle); int (*get_status)(struct hnae3_handle *handle); void (*get_ksettings_an_result)(struct hnae3_handle *handle, u8 *auto_neg, u32 *speed, u8 *duplex); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index d58d3c193ab7..5cae14c991ee 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3540,6 +3540,22 @@ static void hns3_nic_set_priv_ops(struct net_device *netdev) priv->ops.maybe_stop_tx = hns3_nic_maybe_stop_tx; } +static int hns3_client_start(struct hnae3_handle *handle) +{ + if (!handle->ae_algo->ops->client_start) + return 0; + + return handle->ae_algo->ops->client_start(handle); +} + +static void hns3_client_stop(struct hnae3_handle *handle) +{ + if (!handle->ae_algo->ops->client_stop) + return; + + handle->ae_algo->ops->client_stop(handle); +} + static int hns3_client_init(struct hnae3_handle *handle) { struct pci_dev *pdev = handle->pdev; @@ -3607,6 +3623,12 @@ static int hns3_client_init(struct hnae3_handle *handle) goto out_reg_netdev_fail; } + ret = hns3_client_start(handle); + if (ret) { + dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret); + goto out_reg_netdev_fail; + } + hns3_dcbnl_setup(handle); /* MTU range: (ETH_MIN_MTU(kernel default) - 9702) */ @@ -3635,6 +3657,8 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) struct hns3_nic_priv *priv = netdev_priv(netdev); int ret; + hns3_client_stop(handle); + hns3_remove_hw_addr(netdev); if (netdev->reg_state != NETREG_UNINITIALIZED) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 0a8297f67b06..9bb7a1c21e00 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2911,6 +2911,19 @@ static void hclge_mailbox_service_task(struct work_struct *work) clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state); } +static void hclge_update_vport_alive(struct hclge_dev *hdev) +{ + int i; + + /* start from vport 1 for PF is always alive */ + for (i = 1; i < hdev->num_alloc_vport; i++) { + struct hclge_vport *vport = &hdev->vport[i]; + + if (time_after(jiffies, vport->last_active_jiffies + 8 * HZ)) + clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); + } +} + static void hclge_service_task(struct work_struct *work) { struct hclge_dev *hdev = @@ -2923,6 +2936,7 @@ static void hclge_service_task(struct work_struct *work) hclge_update_speed_duplex(hdev); hclge_update_link_status(hdev); + hclge_update_vport_alive(hdev); hclge_service_complete(hdev); } @@ -5208,6 +5222,32 @@ static void hclge_ae_stop(struct hnae3_handle *handle) hclge_update_link_status(hdev); } +int hclge_vport_start(struct hclge_vport *vport) +{ + set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); + vport->last_active_jiffies = jiffies; + return 0; +} + +void hclge_vport_stop(struct hclge_vport *vport) +{ + clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); +} + +static int hclge_client_start(struct hnae3_handle *handle) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + + return hclge_vport_start(vport); +} + +static void hclge_client_stop(struct hnae3_handle *handle) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + + hclge_vport_stop(vport); +} + static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport, u16 cmdq_resp, u8 resp_code, enum hclge_mac_vlan_tbl_opcode op) @@ -7189,6 +7229,17 @@ static void hclge_stats_clear(struct hclge_dev *hdev) memset(&hdev->hw_stats, 0, sizeof(hdev->hw_stats)); } +static void hclge_reset_vport_state(struct hclge_dev *hdev) +{ + struct hclge_vport *vport = hdev->vport; + int i; + + for (i = 0; i < hdev->num_alloc_vport; i++) { + hclge_vport_start(vport); + vport++; + } +} + static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) { struct hclge_dev *hdev = ae_dev->priv; @@ -7274,6 +7325,8 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) if (hclge_enable_tm_hw_error(hdev, true)) dev_err(&pdev->dev, "failed to enable TM hw error interrupts\n"); + hclge_reset_vport_state(hdev); + dev_info(&pdev->dev, "Reset done, %s driver initialization finished.\n", HCLGE_DRIVER_NAME); @@ -7682,6 +7735,8 @@ static const struct hnae3_ae_ops hclge_ops = { .set_loopback = hclge_set_loopback, .start = hclge_ae_start, .stop = hclge_ae_stop, + .client_start = hclge_client_start, + .client_stop = hclge_client_stop, .get_status = hclge_get_status, .get_ksettings_an_result = hclge_get_ksettings_an_result, .update_speed_duplex_h = hclge_update_speed_duplex_h, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 279661764910..5617770c9eb8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -728,6 +728,11 @@ struct hclge_rss_tuple_cfg { u8 ipv6_fragment_en; }; +enum HCLGE_VPORT_STATE { + HCLGE_VPORT_STATE_ALIVE, + HCLGE_VPORT_STATE_MAX +}; + struct hclge_vport { u16 alloc_tqps; /* Allocated Tx/Rx queues */ @@ -753,6 +758,9 @@ struct hclge_vport { struct hclge_dev *back; /* Back reference to associated dev */ struct hnae3_handle nic; struct hnae3_handle roce; + + unsigned long state; + unsigned long last_active_jiffies; }; void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc, @@ -800,4 +808,6 @@ int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id); int hclge_cfg_flowctrl(struct hclge_dev *hdev); int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id); +int hclge_vport_start(struct hclge_vport *vport); +void hclge_vport_stop(struct hclge_vport *vport); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 4c7e7bd3c847..b64f4424837d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -301,6 +301,21 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport, return status; } +static int hclge_set_vf_alive(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *mbx_req, + bool gen_resp) +{ + bool alive = !!mbx_req->msg[2]; + int ret = 0; + + if (alive) + ret = hclge_vport_start(vport); + else + hclge_vport_stop(vport); + + return ret; +} + static int hclge_get_vf_tcinfo(struct hclge_vport *vport, struct hclge_mbx_vf_to_pf_cmd *mbx_req, bool gen_resp) @@ -380,6 +395,12 @@ static void hclge_reset_vf(struct hclge_vport *vport, hclge_gen_resp_to_vf(vport, mbx_req, ret, NULL, 0); } +static void hclge_vf_keep_alive(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *mbx_req) +{ + vport->last_active_jiffies = jiffies; +} + static bool hclge_cmd_crq_empty(struct hclge_hw *hw) { u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG); @@ -457,6 +478,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev) "PF failed(%d) to config VF's VLAN\n", ret); break; + case HCLGE_MBX_SET_ALIVE: + ret = hclge_set_vf_alive(vport, req, false); + if (ret) + dev_err(&hdev->pdev->dev, + "PF failed(%d) to set VF's ALIVE\n", + ret); + break; case HCLGE_MBX_GET_QINFO: ret = hclge_get_vf_queue_info(vport, req, true); if (ret) @@ -484,6 +512,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev) case HCLGE_MBX_RESET: hclge_reset_vf(vport, req); break; + case HCLGE_MBX_KEEP_ALIVE: + hclge_vf_keep_alive(vport, req); + break; default: dev_err(&hdev->pdev->dev, "un-supported mailbox message, code = %d\n", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index e27d6fa85a74..cdaa7e4207ea 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1515,6 +1515,28 @@ static void hclgevf_mailbox_service_task(struct work_struct *work) clear_bit(HCLGEVF_STATE_MBX_HANDLING, &hdev->state); } +static void hclgevf_keep_alive_timer(struct timer_list *t) +{ + struct hclgevf_dev *hdev = from_timer(hdev, t, keep_alive_timer); + + schedule_work(&hdev->keep_alive_task); + mod_timer(&hdev->keep_alive_timer, jiffies + 2 * HZ); +} + +static void hclgevf_keep_alive_task(struct work_struct *work) +{ + struct hclgevf_dev *hdev; + u8 respmsg; + int ret; + + hdev = container_of(work, struct hclgevf_dev, keep_alive_task); + ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_KEEP_ALIVE, 0, NULL, + 0, false, &respmsg, sizeof(u8)); + if (ret) + dev_err(&hdev->pdev->dev, + "VF sends keep alive cmd failed(=%d)\n", ret); +} + static void hclgevf_service_task(struct work_struct *work) { struct hclgevf_dev *hdev; @@ -1767,6 +1789,38 @@ static void hclgevf_ae_stop(struct hnae3_handle *handle) hclgevf_update_link_status(hdev, 0); } +static int hclgevf_set_alive(struct hnae3_handle *handle, bool alive) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + u8 msg_data; + + msg_data = alive ? 1 : 0; + return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_ALIVE, + 0, &msg_data, 1, false, NULL, 0); +} + +static int hclgevf_client_start(struct hnae3_handle *handle) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + + mod_timer(&hdev->keep_alive_timer, jiffies + 2 * HZ); + return hclgevf_set_alive(handle, true); +} + +static void hclgevf_client_stop(struct hnae3_handle *handle) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + int ret; + + ret = hclgevf_set_alive(handle, false); + if (ret) + dev_warn(&hdev->pdev->dev, + "%s failed %d\n", __func__, ret); + + del_timer_sync(&hdev->keep_alive_timer); + cancel_work_sync(&hdev->keep_alive_task); +} + static void hclgevf_state_init(struct hclgevf_dev *hdev) { /* setup tasks for the MBX */ @@ -2279,6 +2333,7 @@ static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev) static int hclgevf_init_ae_dev(struct hnae3_ae_dev *ae_dev) { struct pci_dev *pdev = ae_dev->pdev; + struct hclgevf_dev *hdev; int ret; ret = hclgevf_alloc_hdev(ae_dev); @@ -2288,10 +2343,16 @@ static int hclgevf_init_ae_dev(struct hnae3_ae_dev *ae_dev) } ret = hclgevf_init_hdev(ae_dev->priv); - if (ret) + if (ret) { dev_err(&pdev->dev, "hclge device initialization failed\n"); + return ret; + } - return ret; + hdev = ae_dev->priv; + timer_setup(&hdev->keep_alive_timer, hclgevf_keep_alive_timer, 0); + INIT_WORK(&hdev->keep_alive_task, hclgevf_keep_alive_task); + + return 0; } static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) @@ -2413,6 +2474,8 @@ static const struct hnae3_ae_ops hclgevf_ops = { .uninit_client_instance = hclgevf_uninit_client_instance, .start = hclgevf_ae_start, .stop = hclgevf_ae_stop, + .client_start = hclgevf_client_start, + .client_stop = hclgevf_client_stop, .map_ring_to_vector = hclgevf_map_ring_to_vector, .unmap_ring_from_vector = hclgevf_unmap_ring_from_vector, .get_vector = hclgevf_get_vector, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 4c5ea7edcbb1..4517b7ea5817 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -201,7 +201,9 @@ struct hclgevf_dev { struct hclgevf_mbx_arq_ring arq; /* mailbox async rx queue */ struct timer_list service_timer; + struct timer_list keep_alive_timer; struct work_struct service_task; + struct work_struct keep_alive_task; struct work_struct rst_service_task; struct work_struct mbx_service_task; From patchwork Sun Nov 18 03:19:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 151430 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1141133ljp; Sat, 17 Nov 2018 19:21:01 -0800 (PST) X-Google-Smtp-Source: AJdET5eZqzSu5QIQIFk1QISzodBnAYWUu9D+qfxWIcVktQlZfWxGCzCvbx5w7tRvQRgSeg5QuzI6 X-Received: by 2002:a17:902:64c1:: with SMTP id y1mr7739338pli.64.1542511260979; Sat, 17 Nov 2018 19:21:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542511260; cv=none; d=google.com; s=arc-20160816; b=q+N8irmMugUVc2oBkkqWTC9pszfN6TGVWxtQ1OIbaGnbmyukTFFIrZ/doBLXHgJYQa A+2rmAS/634k+8nQKtNDSCQOAMvZp8mSgGUvcs8Pzm5xScwSvTmmzaYYxmg8ohzexKt0 Xvh3goO/I9eky3r8ILINY+8v31Mz2KMTqwjZvvLkZicYAknM3wQdOYw1dsy4PhP+8VKO dF6wTq1QPlAoWqc2hL4WYpcyFoT7/tP9y4B7mZB9E1ji4j5LwgWANX7URrFl5mlQA5PJ Fxyrj/fhgnlFwYbVSPMPrSALeQrJXhOIS9cbdLiaTICrR0RLQqb9ckghb8qAevvUHgJt ZV9w== 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=aJXXKo9F5ZA9rLoSeQQ5M4xeCfzZGosEoJ3M7rNW4Pw=; b=K/QD0kbTkJhOK2u52MDizk9s8vx8T1XN38W84+nyIvMZ8cpPj4Rc99D1ZUfwam77EV t24WDKhicYCtAsGnzmZc8McupdQUo9qvKbCxfrRbc+TTduARXO8qbBcujmj6iicteiYq LYKZmdVPdrT6axlDhCJzW4sY7RIFAXMmo48MbSC+v6+qNePVVdkLyV3Lo9nZXlZgKjT/ kvcp5XL1KlTcxbRjvWwNRNQhB3b58UNXVS4yrrkMfLGvW+Of3pGNQoclpUHz1ZOx1Azn 3tNloFwEWGagTcOQyhQm5DxfG0qnp9a1h8q8ECEPz8M9Gm1HixJA5O5dPop+SXNS+sQf x91w== 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 h10si8791460pgi.562.2018.11.17.19.21.00; Sat, 17 Nov 2018 19:21:00 -0800 (PST) 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 S1727141AbeKRNjt (ORCPT + 32 others); Sun, 18 Nov 2018 08:39:49 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:15113 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725831AbeKRNjs (ORCPT ); Sun, 18 Nov 2018 08:39:48 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 95FD9FCA895C9; Sun, 18 Nov 2018 11:20:53 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.88.178) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Sun, 18 Nov 2018 11:20:47 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin , Jian Shen Subject: [PATCH net-next 5/5] net: hns3: up/down netdev in hclge module when setting mtu Date: Sun, 18 Nov 2018 03:19:14 +0000 Message-ID: <20181118031914.23892-6-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181118031914.23892-1-salil.mehta@huawei.com> References: <20181118031914.23892-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.88.178] 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 Currently netdev is down in enet module, and it is before mtu range checking in hclge module, which may be cause netdev being down unnecessarily. Signed-off-by: Yunsheng Lin Signed-off-by: Jian Shen Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 11 ----------- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +++ 2 files changed, 3 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 5cae14c991ee..7f81db3df041 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1573,18 +1573,11 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) { struct hnae3_handle *h = hns3_get_handle(netdev); - bool if_running = netif_running(netdev); int ret; if (!h->ae_algo->ops->set_mtu) return -EOPNOTSUPP; - /* if this was called with netdev up then bring netdevice down */ - if (if_running) { - (void)hns3_nic_net_stop(netdev); - msleep(100); - } - ret = h->ae_algo->ops->set_mtu(h, new_mtu); if (ret) netdev_err(netdev, "failed to change MTU in hardware %d\n", @@ -1592,10 +1585,6 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) else netdev->mtu = new_mtu; - /* if the netdev was running earlier, bring it up again */ - if (if_running && hns3_nic_net_open(netdev)) - ret = -EINVAL; - return ret; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 967cb83f32d6..f78b8e188443 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6450,6 +6450,8 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu) return -EINVAL; } + hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); + ret = hclge_set_mac_mtu(hdev, max_frm_size); if (ret) { dev_err(&hdev->pdev->dev, @@ -6466,6 +6468,7 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu) "Allocate buffer fail, ret =%d\n", ret); out: + hclge_notify_client(hdev, HNAE3_UP_CLIENT); mutex_unlock(&hdev->vport_lock); return ret; }