From patchwork Mon Sep 3 10:21:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 145775 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2313245ljw; Mon, 3 Sep 2018 03:23:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbSzfcXtu01LVEqQEL5502cyCEm6tAlxotVkbcVNyw4kMzLJynosTNfql4UNTDBTAvePu2t X-Received: by 2002:a17:902:9302:: with SMTP id bc2-v6mr28165441plb.280.1535970195424; Mon, 03 Sep 2018 03:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970195; cv=none; d=google.com; s=arc-20160816; b=utUS5co7iAMBxdYtoyU4+WI8hz8xRfa26m4YOVT5W6XxUX7TkEYBzXIXyty08ZlfN0 1MVPW70NHbk4W56enrSnGrT3uEvtUxFeRCI3by7KH/F/gjHMPhgyXdKF02kVzlOT+3V4 LdyP3qqpx09qvU/W/Yk0IHzZOdk4SmsuA01j/iWzfItcihVWnRZaV8jNCqwBii/EnAHR WQ3gsmVy3jvGy9cztl7qKYqlwPOpC0aFYVy1OsYfiOyXpJHJaKOiU4pxJ9Lp7nLinPf6 5WjJ8RJ/sLGLvE/ZEE5HHD+7EbaAzCjdqgRsNzTI0F6rYbQf8QGhf27Uud4LQvId/q1m E2/g== 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=gTyCvuocfaK/YpeNYTmQhxrfnavVUY0AtD9av/1pXJ4=; b=hy526ofsFrIjT+/Jz2UHc2mTGXupEfhU5LXJOZio2h9uV/uPvT4OoICSKGe325bxIu 2TdZE+dLOM9G8QCiKsTz9H0fkTyDtrogf09PuOTk8nmK+pxSnMcyI4TgVHicLNCriPxL O/qzax508nsh8Q/KtyvypN8CQIb7kFfzQ8u3RW8YWowTCChmnKl/vb0PM0DuUOdh/+He Q/yegWPKSFhiFxzqCmsAfB/pVqHRRfNxmx7pelCsv5lf5KKyATZ4XJOYHApOFRjy8bDX YV65CNbwAUaS8hhWqU43GQoMvcALdCb5lN80meYJD/D+PW9YLhO7G1Zm/JDsa9nBMWiZ 5zqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 d36-v6si17165097pgl.148.2018.09.03.03.23.15; Mon, 03 Sep 2018 03:23:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727284AbeICOmn (ORCPT + 10 others); Mon, 3 Sep 2018 10:42:43 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:51554 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726039AbeICOmn (ORCPT ); Mon, 3 Sep 2018 10:42:43 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BF822107FDD95; Mon, 3 Sep 2018 18:23:09 +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; Mon, 3 Sep 2018 18:23:00 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 04/11] net: hns3: Implement shutdown ops in hns3 pci driver Date: Mon, 3 Sep 2018 11:21:49 +0100 Message-ID: <20180903102156.18676-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180903102156.18676-1-salil.mehta@huawei.com> References: <20180903102156.18676-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yunsheng Lin This patch implements shutdown ops in hns3 pci driver, which unloads the hns3 driver and set the power state to D3hot. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 955c4ab..75e8ee9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1662,11 +1662,24 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) return 0; } +static void hns3_shutdown(struct pci_dev *pdev) +{ + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); + + hnae3_unregister_ae_dev(ae_dev); + devm_kfree(&pdev->dev, ae_dev); + pci_set_drvdata(pdev, NULL); + + if (system_state == SYSTEM_POWER_OFF) + pci_set_power_state(pdev, PCI_D3hot); +} + static struct pci_driver hns3_driver = { .name = hns3_driver_name, .id_table = hns3_pci_tbl, .probe = hns3_probe, .remove = hns3_remove, + .shutdown = hns3_shutdown, .sriov_configure = hns3_pci_sriov_configure, }; From patchwork Mon Sep 3 10:21:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 145779 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2313371ljw; Mon, 3 Sep 2018 03:23:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYWhZyTMjSXAHetQWFVoWGLGEJm7wr+0QlRmgrjEW2BVpeGMwHkTP6l96N3flSTH1DBi8Uw X-Received: by 2002:a17:902:8e81:: with SMTP id bg1-v6mr28025601plb.129.1535970206681; Mon, 03 Sep 2018 03:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970206; cv=none; d=google.com; s=arc-20160816; b=aDjZUpehbBckgiPlowI+Vgsq2qFBc6mr8pOFmFkl15H3/u4RLgCtjLnKUBk059OSSt 4YV6fC16wLzymFtVB56xUrskbDQKsK0hNzBsXSRVl2GEaiRTwiAIvrD4d7Q0tHg7bvic PrVHISILNP88TV6qpNRdpnikQAIqKqzUlUJIAUUz28XiBc0RVO+yb5kjRUeWTQJYdUQY oJ+6ya2kAruELld3SlyxAg+kTHHe53TQma5KoX/L2y41pq+MilpnNPnjoWVaf0AAYGv/ U2I3rn+kaOzsxFOwLEzty1xrTfKsALzXFNsMJpEgl+m4gKOvH1/+tGGfzSFvAMq+hE7T uWvQ== 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=Y+TKIh0c6Lx7k+3KIvCOlW4KVZahA+NYWjvgLgQeVEc=; b=Zhy7e9BKc1r5wnu1pW3Fh3lEG3OMsXtg2yC3lOhjcN5JuLPwT3w4ch0XNk6W/N3ZuI 3gmkZUp/gRp462RGRLcRzuzhW7SDodtkmfdwJ6a/0xwFhtV6AI4nSzSh3Xzm/qCw3xHs EVrE71s4OiL3fO78yGfZ09YQVjmBcQ39w/7ztReFdK/T6tBfMWiMp3Ike+W58N18HGW9 qgWybFAzNvZXgW05gZQ+HEVuWjgCizXXXReA5XLhnm3QTVBeA3rjs1pMwJxuVZQo1oNh EzNzgAJr+Qd7B7eRwjZwv/8dW+CWD1fYaJ2dgho1JpCgxMWeBpUuj1YnLCHmV6kdGmde Gvdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 s68-v6si18298436pgc.16.2018.09.03.03.23.26; Mon, 03 Sep 2018 03:23:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728040AbeICOmz (ORCPT + 10 others); Mon, 3 Sep 2018 10:42:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11222 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726047AbeICOmx (ORCPT ); Mon, 3 Sep 2018 10:42:53 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6EA42BC01338E; Mon, 3 Sep 2018 18:23:19 +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; Mon, 3 Sep 2018 18:23:12 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 08/11] net: hns3: Only update mac configuation when necessary Date: Mon, 3 Sep 2018 11:21:53 +0100 Message-ID: <20180903102156.18676-9-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180903102156.18676-1-salil.mehta@huawei.com> References: <20180903102156.18676-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yunsheng Lin Currently only fiber port checks if it is necessay to set the mac through firmware when link is changed, this patch unify the checking to allow the copper port do the checking too. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 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 004bfc1..25d4fd9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2066,19 +2066,17 @@ static int hclge_init_msi(struct hclge_dev *hdev) return 0; } -static void hclge_check_speed_dup(struct hclge_dev *hdev, int duplex, int speed) +static u8 hclge_check_speed_dup(u8 duplex, int speed) { - struct hclge_mac *mac = &hdev->hw.mac; - if ((speed == HCLGE_MAC_SPEED_10M) || (speed == HCLGE_MAC_SPEED_100M)) - mac->duplex = (u8)duplex; - else - mac->duplex = HCLGE_MAC_FULL; + if (!(speed == HCLGE_MAC_SPEED_10M || speed == HCLGE_MAC_SPEED_100M)) + duplex = HCLGE_MAC_FULL; - mac->speed = speed; + return duplex; } -int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex) +static int hclge_cfg_mac_speed_dup_hw(struct hclge_dev *hdev, int speed, + u8 duplex) { struct hclge_config_mac_speed_dup_cmd *req; struct hclge_desc desc; @@ -2138,7 +2136,23 @@ int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex) return ret; } - hclge_check_speed_dup(hdev, duplex, speed); + return 0; +} + +int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex) +{ + int ret; + + duplex = hclge_check_speed_dup(duplex, speed); + if (hdev->hw.mac.speed == speed && hdev->hw.mac.duplex == duplex) + return 0; + + ret = hclge_cfg_mac_speed_dup_hw(hdev, speed, duplex); + if (ret) + return ret; + + hdev->hw.mac.speed = speed; + hdev->hw.mac.duplex = duplex; return 0; } @@ -2259,7 +2273,9 @@ static int hclge_mac_init(struct hclge_dev *hdev) int ret; int i; - ret = hclge_cfg_mac_speed_dup(hdev, hdev->hw.mac.speed, HCLGE_MAC_FULL); + hdev->hw.mac.duplex = HCLGE_MAC_FULL; + ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.speed, + hdev->hw.mac.duplex); if (ret) { dev_err(&hdev->pdev->dev, "Config mac speed dup fail ret=%d\n", ret); @@ -2415,13 +2431,11 @@ static int hclge_update_speed_duplex(struct hclge_dev *hdev) return ret; } - if ((mac.speed != speed) || (mac.duplex != duplex)) { - ret = hclge_cfg_mac_speed_dup(hdev, speed, duplex); - if (ret) { - dev_err(&hdev->pdev->dev, - "mac speed/duplex config failed %d\n", ret); - return ret; - } + ret = hclge_cfg_mac_speed_dup(hdev, speed, duplex); + if (ret) { + dev_err(&hdev->pdev->dev, + "mac speed/duplex config failed %d\n", ret); + return ret; } return 0; From patchwork Mon Sep 3 10:21:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 145780 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2313479ljw; Mon, 3 Sep 2018 03:23:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZfqOf6ZRbdX4M5wA20sU3vOkheRsUYGQ2Vkn9Efui7CcgwNQS/+SbCqeLQMjumOGiaZ5Vh X-Received: by 2002:a62:b0b:: with SMTP id t11-v6mr24668191pfi.36.1535970213793; Mon, 03 Sep 2018 03:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970213; cv=none; d=google.com; s=arc-20160816; b=RqTQyzXLeAdSIjIJalKmCgzz4UBU9wkBpX5DVkGsAO/qmMbXnynv5dDWXNDSQEpmTP F7e1WvYMLCvVqgmrlHYkwak8vKAwTtAiHbt215gczYy1ZZEqJtnu4j0tj3aqFlPNbw1D up0v/9lladkg7nDZPGdA3/QW7zNmcB+X9L95KyoF4tt3dzRXm6AAkDVwhvmetUAHqZeI 3nVgQpptWIa+Bjj1ECYhRVobYUX5iTvbpJMg08++F1IaYhTJsBlzdoSWVkuCAwZsKKev w+IwHpI7H+x7k/s01wQRL6TNCJSBLoqq7cGvDUeGWzu0feRgjZt5yNrEsT7/7OxTGlYW WJug== 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=4ShoJO4s3Jf0BPHE055PjsLZdQUd9M4Mh+ATKvCr3aA=; b=h7p340IffySAYUt/RXShoXR+QD8bgYJnCYmcbepQThU2okNo7ra4wjs5jCIQKPPo+z dobLrj02a7HEt7grdfy/RzhakY/DqtqtcRMUTs8ZAwN4GvD1QsylhJGP1lzifn58vPvk /ZLVMsY3rQotxaR7fcte5ieyikz8FQa6Q9fH4C1ljaEf5kJFdi6BLGmNu4AhDGKiaGE/ WfgWdawZHRYQsA73nF0gE0OyALL6KzkjhB8B+ElQyrc9yVOhBA8R7SBa7LCAeu2eMPnG L628xHh+b7AH9RSw4XmhyksSs3XZFoGnhdAGM9MEegkYNpCd7/xb3nNqp9s24LWW1NRj SRzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 z21-v6si14235403pgu.163.2018.09.03.03.23.33; Mon, 03 Sep 2018 03:23:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728020AbeICOmz (ORCPT + 10 others); Mon, 3 Sep 2018 10:42:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11221 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727991AbeICOmx (ORCPT ); Mon, 3 Sep 2018 10:42:53 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 69E09E97681F4; Mon, 3 Sep 2018 18:23:19 +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; Mon, 3 Sep 2018 18:23:15 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 09/11] net: hns3: Change the dst mac addr of loopback packet Date: Mon, 3 Sep 2018 11:21:54 +0100 Message-ID: <20180903102156.18676-10-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180903102156.18676-1-salil.mehta@huawei.com> References: <20180903102156.18676-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yunsheng Lin Currently, the dst mac addr of loopback packet is the same as the host' mac addr, the SSU component may loop back the packet to host before the packet reaches mac or serdes, which will defect the purpose of mac or serdes selftest. This patch changes it by adding 0x1f to the last byte of dst mac addr. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 7143e39..dfce76e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -137,6 +137,7 @@ static void hns3_lp_setup_skb(struct sk_buff *skb) packet = skb_put(skb, HNS3_NIC_LB_TEST_PACKET_SIZE); memcpy(ethh->h_dest, ndev->dev_addr, ETH_ALEN); + ethh->h_dest[5] += 0x1f; eth_zero_addr(ethh->h_source); ethh->h_proto = htons(ETH_P_ARP); skb_reset_mac_header(skb);