Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1547624imm; Mon, 3 Sep 2018 03:24:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY3KD1O5dHxddhbEcAYA53Akl7IYdkJCseEKJCGHasDAk8mQM2K1g2KPdpcFmf2QQAVi6UH X-Received: by 2002:a63:f902:: with SMTP id h2-v6mr25839272pgi.154.1535970295374; Mon, 03 Sep 2018 03:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970295; cv=none; d=google.com; s=arc-20160816; b=Nw3dV2SulQVwOAM7AfxLLMP9GMZPF1NHk7huFfQ6B/ED6pM1rOA2Aqfa+byzrGmNMG wQQ9eWlWHSQRoATrottnomFON1jk9eyGO908VLvLgVPD82yMeq/OuqmEJW1qFj6elqyW KCNGM8BtzB5vKKj0AlRN3N2Nh9eDf2+ZeW9e82cr8Sqwz3ADYYy/r57mztSykEaBlna2 awKE1JPjSgTfqsD0iSAeFqW7mdzlIsQHQpyMnRqyBnKifdPtUSTT4tDM/zmDYMvEF+56 ovN2OTeH6GEBxGovOmwxBod8HW01Fkh/ZsorFf7XL7NLHB3d/hRMAPQUlrpuM7YVVPzP N8Dg== 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=CkYSNT3UZr2Er2gufoKP1k12Vga5y6tkRO3CTEgCrh++lch1OOj/WSe4gPdmUtXDRg m59APD00cOemZBEQi9h+myF2bCLDI+36US8/W0qb4AE/2GSfBODuRG2mn9SdbhEvhkmG yoihJOu/bXDPuM8lbZ6BwWcUi174dou7phDK9+wMvYAJgImECzTPFTxunM+umeHNGRr4 q1ATYLbJ39bxCM9EwO8HOysIqSJpidu3gu+4PsWnMG+gzjlzofsv/X8MtL1naCBhPYiM BhKafCX2mTttwmZyDxzSKHbPZoEPhc2lVAloNv7/avdJFIH2R/25pB+3utL7QUlva23J PGRQ== 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 i3-v6si2342145pgm.288.2018.09.03.03.24.40; Mon, 03 Sep 2018 03:24:55 -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 S1728030AbeICOmz (ORCPT + 99 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 Content-Type: text/plain X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: 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(-) 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; -- 2.7.4