From patchwork Mon Sep 3 10:21:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 145782 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2313536ljw; Mon, 3 Sep 2018 03:23:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZGWT9KBv9pKXzbNvGIeEo5so1wca+q2XlrBP4DaTKDD9xaq/LktTDOleuNCNeuH1suJQy9 X-Received: by 2002:a63:3105:: with SMTP id x5-v6mr5338815pgx.323.1535970217250; Mon, 03 Sep 2018 03:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970217; cv=none; d=google.com; s=arc-20160816; b=naNX7LGh1uhwKHUBY5FZOxGFRECV72EA4omfg1zM5lFDszMI2DPNtC/n6TYesrMYmM kvd8QXGc6+RWC9fxW78MJ9ljn8+BZKvzqlhqRFhPM9bJpXCNxSgMLRuzXFf7qglti5Gp Fxg/SE5PAs1bcUyr3lPuxz5F/3HJN+xDlKvXt/T1rSWA8mWvB50vOZ3lIIYsjFMZfSuU LVWvhgKTWtbn+rS0lVuW36efW8HrWz/EWpxy/Dhu99BUB2SC5MumgqWUrvatEIqXFRuP Flhw7x2Op1V0MMx9nibTCJJoegHvwUn1D0RPcjHgDzu52NmdNSQKnsb3mc7zpHloiNml nZ7A== 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=P6O1pLqmqt95bdWjehsDyLmk7E1kCQAU5V/Kt45vHz0=; b=ozBSTIzLcUa3KjFZ4+J2/pCXZ/LEwJpC5I4fhf2BOvkmbNw4H/uq8tLW7d2tfYEZQD iuuIGqBfgZA91SIz/1t8p0xK9ko5EVQRJY5p6Mui3At8uHyak87WlGbKs9dQSeD5pVAF St+7023pzHNBELri3T5Ksq+TekCM2mAOEMEvRxdu4DURpfnbMlUKYmOd4yyPXWtJQBTo Mm/cP6kulFcm6/deaMh2nd7bwCNUsMQZKSraeiJMjZZ1j+EkJsNivbkCqK0koFNn0tzk n1CZ88BF7n2FZ5hLWwVkCGTkmWE0/zooxvF9wuxef41JtBFdvVRigepawKjxv/ULyPPj J1PA== 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 p14-v6si16713862pgg.67.2018.09.03.03.23.36; Mon, 03 Sep 2018 03:23:37 -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 S1728089AbeICOnF (ORCPT + 32 others); Mon, 3 Sep 2018 10:43:05 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59189 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725949AbeICOnD (ORCPT ); Mon, 3 Sep 2018 10:43:03 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 648176D79E4E2; Mon, 3 Sep 2018 18:23:30 +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:21 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 11/11] net: hns3: Refine hns3_get_link_ksettings() Date: Mon, 3 Sep 2018 11:21:56 +0100 Message-ID: <20180903102156.18676-12-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen In the previous implement, the query operation for fibre port and copper port are mixed. This patch refines it by seperating them based on the port type. Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 68 +++++++++++++--------- 1 file changed, 40 insertions(+), 28 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 41d817d..3019007 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -546,26 +546,56 @@ static int hns3_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd) { struct hnae3_handle *h = hns3_get_handle(netdev); - u32 flowctrl_adv = 0; + const struct hnae3_ae_ops *ops; u8 link_stat; if (!h->ae_algo || !h->ae_algo->ops) return -EOPNOTSUPP; - /* 1.auto_neg & speed & duplex from cmd */ - if (netdev->phydev) { + ops = h->ae_algo->ops; + if (ops->get_port_type) + ops->get_port_type(h, &cmd->base.port); + else + return -EOPNOTSUPP; + + switch (cmd->base.port) { + case PORT_FIBRE: + /* 1.auto_neg & speed & duplex from cmd */ + if (ops->get_ksettings_an_result) + ops->get_ksettings_an_result(h, + &cmd->base.autoneg, + &cmd->base.speed, + &cmd->base.duplex); + else + return -EOPNOTSUPP; + + /* 2.get link mode*/ + if (ops->get_link_mode) + ops->get_link_mode(h, + cmd->link_modes.supported, + cmd->link_modes.advertising); + + /* 3.mdix_ctrl&mdix get from phy reg */ + if (ops->get_mdix_mode) + ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl, + &cmd->base.eth_tp_mdix); + + break; + case PORT_TP: + if (!netdev->phydev) + return -EOPNOTSUPP; + phy_ethtool_ksettings_get(netdev->phydev, cmd); + break; + default: + netdev_warn(netdev, + "Unknown port type, neither Fibre/Copper detected"); return 0; } - if (h->ae_algo->ops->get_ksettings_an_result) - h->ae_algo->ops->get_ksettings_an_result(h, - &cmd->base.autoneg, - &cmd->base.speed, - &cmd->base.duplex); - else - return -EOPNOTSUPP; + /* mdio_support */ + cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22; link_stat = hns3_get_link(netdev); if (!link_stat) { @@ -573,24 +603,6 @@ static int hns3_get_link_ksettings(struct net_device *netdev, cmd->base.duplex = DUPLEX_UNKNOWN; } - /* 2.get link mode and port type*/ - if (h->ae_algo->ops->get_link_mode) - h->ae_algo->ops->get_link_mode(h, - cmd->link_modes.supported, - cmd->link_modes.advertising); - - cmd->base.port = PORT_NONE; - if (h->ae_algo->ops->get_port_type) - h->ae_algo->ops->get_port_type(h, - &cmd->base.port); - - /* 3.mdix_ctrl&mdix get from phy reg */ - if (h->ae_algo->ops->get_mdix_mode) - h->ae_algo->ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl, - &cmd->base.eth_tp_mdix); - /* 4.mdio_support */ - cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22; - return 0; }