From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lipeng Subject: [PATCH net-next 5/6] net: hns3: add support for nway_reset Date: Fri, 3 Nov 2017 12:18:29 +0800 Message-ID: <1509682710-94908-6-git-send-email-lipeng321@huawei.com> References: <1509682710-94908-1-git-send-email-lipeng321@huawei.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , To: Return-path: Received: from szxga04-in.huawei.com ([45.249.212.190]:9943 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752400AbdKCDvI (ORCPT ); Thu, 2 Nov 2017 23:51:08 -0400 In-Reply-To: <1509682710-94908-1-git-send-email-lipeng321@huawei.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Fuyun Liang This patch adds nway_reset support for ethtool cmd. Signed-off-by: Fuyun Liang Signed-off-by: Lipeng --- .../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