linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lipeng <lipeng321@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linuxarm@huawei.com>, <salil.mehta@huawei.com>,
	<lipeng321@huawei.com>
Subject: [PATCH net-next 5/6] net: hns3: add support for nway_reset
Date: Fri, 3 Nov 2017 12:18:29 +0800	[thread overview]
Message-ID: <1509682710-94908-6-git-send-email-lipeng321@huawei.com> (raw)
In-Reply-To: <1509682710-94908-1-git-send-email-lipeng321@huawei.com>

From: Fuyun Liang <liangfuyun1@huawei.com>

This patch adds nway_reset support for ethtool cmd.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 .../net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 7fe193b..a21470c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -832,6 +832,23 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 	}
 }
 
+static int hns3_nway_reset(struct net_device *netdev)
+{
+	struct phy_device *phy = netdev->phydev;
+
+	if (!netif_running(netdev))
+		return 0;
+
+	/* Only support nway_reset for netdev with phy attached for now */
+	if (!phy)
+		return -EOPNOTSUPP;
+
+	if (phy->autoneg != AUTONEG_ENABLE)
+		return -EINVAL;
+
+	return genphy_restart_aneg(phy);
+}
+
 static const struct ethtool_ops hns3_ethtool_ops = {
 	.self_test = hns3_self_test,
 	.get_drvinfo = hns3_get_drvinfo,
@@ -850,6 +867,7 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 	.set_rxfh = hns3_set_rss,
 	.get_link_ksettings = hns3_get_link_ksettings,
 	.set_link_ksettings = hns3_set_link_ksettings,
+	.nway_reset = hns3_nway_reset,
 };
 
 void hns3_ethtool_set_ops(struct net_device *netdev)
-- 
1.9.1

  parent reply	other threads:[~2017-11-03  3:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
2017-11-03  4:18 ` [PATCH net-next 1/6] net: hns3: fix for getting autoneg in hns3_get_link_ksettings Lipeng
2017-11-03  4:18 ` [PATCH net-next 2/6] net: hns3: fix for getting advertised_caps " Lipeng
2017-11-03  4:18 ` [PATCH net-next 3/6] net: hns3: fix a bug in hns3_driv_to_eth_caps Lipeng
2017-11-03  4:18 ` [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings Lipeng
2017-11-03 19:52   ` Florian Fainelli
2017-11-06  2:28     ` lipeng (Y)
2017-11-03  4:18 ` Lipeng [this message]
2017-11-03 19:53   ` [PATCH net-next 5/6] net: hns3: add support for nway_reset Florian Fainelli
2017-11-03  4:18 ` [PATCH net-next 6/6] net: hns3: fix a bug for phy supported feature initialization Lipeng
2017-11-03 12:37 ` [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command David Miller
2017-11-03 15:51 ` Andrew Lunn
2017-11-03 16:01   ` Salil Mehta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509682710-94908-6-git-send-email-lipeng321@huawei.com \
    --to=lipeng321@huawei.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).