From patchwork Fri Sep 21 15:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147296 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp971268ljw; Fri, 21 Sep 2018 08:43:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZZu36HkGeQsow3dnk/KzTG3I17ThfKMPjNME9TUNPiZKo9BpZDd7IuaHQ4M3eLdTFkRzoV X-Received: by 2002:a65:6455:: with SMTP id s21-v6mr42816824pgv.25.1537544608970; Fri, 21 Sep 2018 08:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537544608; cv=none; d=google.com; s=arc-20160816; b=zulhpZvrBylUtX6uW3ZH85H2F9kAGqeeNswouVzsKfwkHF/I8DhEuN8kpglYTuZoOC r9xzQZPbgaJDoDzmn2bQUSMsiS9aVKc2vHBcfbVfZOA3GFdeMVh/ZBPh84XNtMdSN7vO ZD2GxrgtrrTQibNai7TZsjy9jZPqJO83cOCuNulk1/xs7IFyIdkmPb7R9+jzUA6lir0y zP8dwCIt2XXYOYSqPXarTAaG39v+5hOscUCGLQS4loCoruh4rHlzB7vUqerQJ5dCr0fk FA5sB6UI7S1Hpw+iaMFff/ypI7qJ61j0lIHJJo/zFo9nl65qLB0ihqZUrrnGBOPEf5pC N1vQ== 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=RaImxzNma4Ch4joJWe6PanJpPq7GaQ4PIK0Ys8UIxgA=; b=hj/uDEuy98nB2GL71Ior9HCNmv6ICg1an+1HH93rKfs5E4qU3FE9aT9reD18cvE5MM lHlAsiA8+2zEW7h1jWcaVsW22c8b2/DeYrQfXrdAEPSH5CJtbYXgL/pULoyhvWl5ufRd aa68oAhmQnJLuTynK96OLjbReTyEY/QOTJ6IyzGGGH4s9G0k+CTSNyHtQBUE8cu/3Qle COY+hzQOHohC1lpGMp8y2ETrtnSV0G5qemZtd3sMU8iu//pfSRwyD6vIEdAiERogQitr AgPf+6wP4m/SmiTvCicimXtjjwVfL9OA92xCHP147EDI6rvsYdsrTU8DEYxg7D5dL4A/ pwzg== 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 a75-v6si27696644pfc.106.2018.09.21.08.43.27; Fri, 21 Sep 2018 08:43:28 -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 S2390781AbeIUVcw (ORCPT + 32 others); Fri, 21 Sep 2018 17:32:52 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13100 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390678AbeIUVcv (ORCPT ); Fri, 21 Sep 2018 17:32:51 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 41ED74BC6DED3; Fri, 21 Sep 2018 23:43:18 +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; Fri, 21 Sep 2018 23:43:12 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 11/12] net: hns3: Fix speed/duplex information loss problem when executing ethtool ethx cmd of VF Date: Fri, 21 Sep 2018 16:41:47 +0100 Message-ID: <20180921154148.26756-12-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180921154148.26756-1-salil.mehta@huawei.com> References: <20180921154148.26756-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: Fuyun Liang Our VF has not implemented the ops for get_port_type. So when we executing ethtool ethx cmd of VF, hns3_get_link_ksettings will return directly. And we can not query anything. To support get_link_ksettings for VF, this patch replaces get_port_type with get_media_type. If the media type is HNAE3_MEDIA_TYPE_NONE, hns3_get_link_ksettings will return link information of VF. Fixes: 12f46bc1d447 ("net: hns3: Refine hns3_get_link_ksettings()") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 66 +++++++++++++--------- 1 file changed, 39 insertions(+), 27 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 46701cf..8803a87 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -545,55 +545,67 @@ static int hns3_set_pauseparam(struct net_device *netdev, return -EOPNOTSUPP; } +static void hns3_get_ksettings(struct hnae3_handle *h, + struct ethtool_link_ksettings *cmd) +{ + const struct hnae3_ae_ops *ops = h->ae_algo->ops; + + /* 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); + + /* 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); +} + static int hns3_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd) { struct hnae3_handle *h = hns3_get_handle(netdev); const struct hnae3_ae_ops *ops; + u8 media_type; u8 link_stat; if (!h->ae_algo || !h->ae_algo->ops) return -EOPNOTSUPP; ops = h->ae_algo->ops; - if (ops->get_port_type) - ops->get_port_type(h, &cmd->base.port); + if (ops->get_media_type) + ops->get_media_type(h, &media_type); 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); - + switch (media_type) { + case HNAE3_MEDIA_TYPE_NONE: + cmd->base.port = PORT_NONE; + hns3_get_ksettings(h, cmd); + break; + case HNAE3_MEDIA_TYPE_FIBER: + cmd->base.port = PORT_FIBRE; + hns3_get_ksettings(h, cmd); break; - case PORT_TP: + case HNAE3_MEDIA_TYPE_COPPER: if (!netdev->phydev) return -EOPNOTSUPP; + cmd->base.port = PORT_TP; phy_ethtool_ksettings_get(netdev->phydev, cmd); break; default: - netdev_warn(netdev, - "Unknown port type, neither Fibre/Copper detected"); + + netdev_warn(netdev, "Unknown media type"); return 0; }