Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1548299imm; Mon, 3 Sep 2018 03:26:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZFozB+GHwPWx4OYKjdomtIRZGchtdtyUz869cxGQjalH5xXu9tfBaY6Z316U0JN1CIiXLI X-Received: by 2002:a17:902:904c:: with SMTP id w12-v6mr27762954plz.95.1535970375907; Mon, 03 Sep 2018 03:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535970375; cv=none; d=google.com; s=arc-20160816; b=boqrgfnI429P+dfsAgWh1T5GMG4GRqoJeXSjMBfYxQ82A+h7L2gX/Ykcotdur68iim POIvaEGjoqW5K7ruuTz3+Kch3QfkPXICYnrog87JwBfSiLJJxgnB0G2YL4u/dYa/cVbP +IK76vUEGGGOvyORo6e7BGTln6qf31JGhm64ZITJ4yNpRd4Pr9YfUQns/yall+Y36//J al8on5UUBag4UaoMqgBFI9DZWjok3eesBLB50Seb0zQHzpD11LMntYOBvV/1XppBjzVY nu7krVf/QB1AQn9Ly+Pe058mGVFE4h8zS7D1RKh2qz83fw22pVccITXAq2ClbHgciapH xACw== 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 p7-v6si17064698plo.159.2018.09.03.03.26.01; Mon, 03 Sep 2018 03:26: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 S1728086AbeICOnF (ORCPT + 99 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 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: 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(-) 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; } -- 2.7.4