linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command
@ 2017-11-03  4:18 Lipeng
  2017-11-03  4:18 ` [PATCH net-next 1/6] net: hns3: fix for getting autoneg in hns3_get_link_ksettings Lipeng
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

This patch-set adds support for set_link_ksettings && for nway_resets
ethtool command and fixes some related ethtool bugs.
1, patch[4/6] adds support for ethtool_ops.set_link_ksettings.
2, patch[5/6] adds support ethtool_ops.for nway_reset.
3, patch[1/6,2/6,3/6,6/6] fix some bugs for getting port information by
   ethtool command(ethtool ethx).

Fuyun Liang (6):
  net: hns3: fix for getting autoneg in hns3_get_link_ksettings
  net: hns3: fix for getting advertised_caps in hns3_get_link_ksettings
  net: hns3: fix a bug in hns3_driv_to_eth_caps
  net: hns3: add support for set_link_ksettings
  net: hns3: add support for nway_reset
  net: hns3: fix a bug for phy supported feature initialization

 .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c    | 10 +++
 .../ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c  | 71 +++++++++++++++-------
 2 files changed, 59 insertions(+), 22 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH net-next 1/6] net: hns3: fix for getting autoneg in hns3_get_link_ksettings
  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 ` Lipeng
  2017-11-03  4:18 ` [PATCH net-next 2/6] net: hns3: fix for getting advertised_caps " Lipeng
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

This patch fixes a bug for ethtool's get_link_ksettings().
When phy exists, we should get autoneg from phy rather than from mac.
Because the value of mac.autoneg is invalid when phy exists.

Fixes: 496d03e (net: hns3: Add Ethtool support to HNS3 driver)
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c  | 30 +++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 5cd163b..367b20c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -9,6 +9,7 @@
 
 #include <linux/etherdevice.h>
 #include <linux/string.h>
+#include <linux/phy.h>
 
 #include "hns3_enet.h"
 
@@ -571,26 +572,25 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 	u32 advertised_caps;
 	u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
 	u8 link_stat;
-	u8 auto_neg;
-	u8 duplex;
-	u32 speed;
 
 	if (!h->ae_algo || !h->ae_algo->ops)
 		return -EOPNOTSUPP;
 
 	/* 1.auto_neg & speed & duplex from cmd */
-	if (h->ae_algo->ops->get_ksettings_an_result) {
-		h->ae_algo->ops->get_ksettings_an_result(h, &auto_neg,
-							 &speed, &duplex);
-		cmd->base.autoneg = auto_neg;
-		cmd->base.speed = speed;
-		cmd->base.duplex = duplex;
-
-		link_stat = hns3_get_link(netdev);
-		if (!link_stat) {
-			cmd->base.speed = (u32)SPEED_UNKNOWN;
-			cmd->base.duplex = DUPLEX_UNKNOWN;
-		}
+	if (netdev->phydev)
+		phy_ethtool_ksettings_get(netdev->phydev, cmd);
+	else 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;
+
+	link_stat = hns3_get_link(netdev);
+	if (!link_stat) {
+		cmd->base.speed = SPEED_UNKNOWN;
+		cmd->base.duplex = DUPLEX_UNKNOWN;
 	}
 
 	/* 2.media_type get from bios parameter block */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 2/6] net: hns3: fix for getting advertised_caps in hns3_get_link_ksettings
  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 ` Lipeng
  2017-11-03  4:18 ` [PATCH net-next 3/6] net: hns3: fix a bug in hns3_driv_to_eth_caps Lipeng
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

This patch fixes a bug for ethtool's get_link_ksettings().
The advertising for autoneg is always added to advertised_caps
whether autoneg is enable or disable. This patch fixes it.

Fixes: 496d03e (net: hns3: Add Ethtool support to HNS3 driver)
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 367b20c..0e10a43 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -640,6 +640,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 			break;
 		}
 
+		if (!cmd->base.autoneg)
+			advertised_caps &= ~HNS3_LM_AUTONEG_BIT;
+
 		/* now, map driver link modes to ethtool link modes */
 		hns3_driv_to_eth_caps(supported_caps, cmd, false);
 		hns3_driv_to_eth_caps(advertised_caps, cmd, true);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 3/6] net: hns3: fix a bug in hns3_driv_to_eth_caps
  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 ` Lipeng
  2017-11-03  4:18 ` [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings Lipeng
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

The value of link_modes.advertising and the value of link_modes.supported
is initialized to zero every time in for loop in hns3_driv_to_eth_caps().
But we just want to set specified bit for them. Initialization is
unnecessary. This patch fixes it.

Fixes: 496d03e (net: hns3: Add Ethtool support to HNS3 driver)
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 0e10a43..c7b8ebd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -359,17 +359,12 @@ static void hns3_driv_to_eth_caps(u32 caps, struct ethtool_link_ksettings *cmd,
 		if (!(caps & hns3_lm_map[i].hns3_link_mode))
 			continue;
 
-		if (is_advertised) {
-			ethtool_link_ksettings_zero_link_mode(cmd,
-							      advertising);
+		if (is_advertised)
 			__set_bit(hns3_lm_map[i].ethtool_link_mode,
 				  cmd->link_modes.advertising);
-		} else {
-			ethtool_link_ksettings_zero_link_mode(cmd,
-							      supported);
+		else
 			__set_bit(hns3_lm_map[i].ethtool_link_mode,
 				  cmd->link_modes.supported);
-		}
 	}
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings
  2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
                   ` (2 preceding siblings ...)
  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 ` Lipeng
  2017-11-03 19:52   ` Florian Fainelli
  2017-11-03  4:18 ` [PATCH net-next 5/6] net: hns3: add support for nway_reset Lipeng
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

This patch adds set_link_ksettings support for ethtool cmd.

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

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index c7b8ebd..7fe193b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -653,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 	return 0;
 }
 
+static int hns3_set_link_ksettings(struct net_device *netdev,
+				   const struct ethtool_link_ksettings *cmd)
+{
+	/* Only support ksettings_set for netdev with phy attached for now */
+	if (netdev->phydev)
+		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
+
+	return -EOPNOTSUPP;
+}
+
 static u32 hns3_get_rss_key_size(struct net_device *netdev)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
@@ -839,6 +849,7 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 	.get_rxfh = hns3_get_rss,
 	.set_rxfh = hns3_set_rss,
 	.get_link_ksettings = hns3_get_link_ksettings,
+	.set_link_ksettings = hns3_set_link_ksettings,
 };
 
 void hns3_ethtool_set_ops(struct net_device *netdev)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 5/6] net: hns3: add support for nway_reset
  2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
                   ` (3 preceding siblings ...)
  2017-11-03  4:18 ` [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings Lipeng
@ 2017-11-03  4:18 ` Lipeng
  2017-11-03 19:53   ` Florian Fainelli
  2017-11-03  4:18 ` [PATCH net-next 6/6] net: hns3: fix a bug for phy supported feature initialization Lipeng
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 6/6] net: hns3: fix a bug for phy supported feature initialization
  2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
                   ` (4 preceding siblings ...)
  2017-11-03  4:18 ` [PATCH net-next 5/6] net: hns3: add support for nway_reset Lipeng
@ 2017-11-03  4:18 ` 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
  7 siblings, 0 replies; 13+ messages in thread
From: Lipeng @ 2017-11-03  4:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

This patch fixes a bug for phy supported feature initialization.
Currently, the value of phydev->supported is initialized by kernel.
So it includes many features that we do not support, such as
SUPPORTED_FIBRE and SUPPORTED_BNC. This patch fixes it.

Fixes: 256727d (net: hns3: Add MDIO support to HNS3 Ethernet driver for hip08 SoC)
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index f32d719..7069e94 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -14,6 +14,13 @@
 #include "hclge_main.h"
 #include "hclge_mdio.h"
 
+#define HCLGE_PHY_SUPPORTED_FEATURES	(SUPPORTED_Autoneg | \
+					 SUPPORTED_TP | \
+					 SUPPORTED_Pause | \
+					 PHY_10BT_FEATURES | \
+					 PHY_100BT_FEATURES | \
+					 PHY_1000BT_FEATURES)
+
 enum hclge_mdio_c22_op_seq {
 	HCLGE_MDIO_C22_WRITE = 1,
 	HCLGE_MDIO_C22_READ = 2
@@ -195,6 +202,9 @@ int hclge_mac_start_phy(struct hclge_dev *hdev)
 		return ret;
 	}
 
+	phydev->supported &= HCLGE_PHY_SUPPORTED_FEATURES;
+	phydev->advertising = phydev->supported;
+
 	phy_start(phydev);
 
 	return 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command
  2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
                   ` (5 preceding siblings ...)
  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 ` David Miller
  2017-11-03 15:51 ` Andrew Lunn
  7 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2017-11-03 12:37 UTC (permalink / raw)
  To: lipeng321; +Cc: netdev, linux-kernel, linuxarm, salil.mehta

From: Lipeng <lipeng321@huawei.com>
Date: Fri, 3 Nov 2017 12:18:24 +0800

> This patch-set adds support for set_link_ksettings && for nway_resets
> ethtool command and fixes some related ethtool bugs.
> 1, patch[4/6] adds support for ethtool_ops.set_link_ksettings.
> 2, patch[5/6] adds support ethtool_ops.for nway_reset.
> 3, patch[1/6,2/6,3/6,6/6] fix some bugs for getting port information by
>    ethtool command(ethtool ethx).

Series applied, thank you.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command
  2017-11-03  4:18 [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command Lipeng
                   ` (6 preceding siblings ...)
  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
  7 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2017-11-03 15:51 UTC (permalink / raw)
  To: Lipeng; +Cc: davem, netdev, linux-kernel, linuxarm, salil.mehta

On Fri, Nov 03, 2017 at 12:18:24PM +0800, Lipeng wrote:
> This patch-set adds support for set_link_ksettings && for nway_resets
> ethtool command and fixes some related ethtool bugs.
> 1, patch[4/6] adds support for ethtool_ops.set_link_ksettings.
> 2, patch[5/6] adds support ethtool_ops.for nway_reset.
> 3, patch[1/6,2/6,3/6,6/6] fix some bugs for getting port information by
>    ethtool command(ethtool ethx).

Hi Lipeng

Do you want the fixes applied to net, and back ported to stable?

If so, you need to submit them separately, and against the correct
tree.

	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH net-next 0/6] net: hns3: support set_link_ksettings and for nway_reset ethtool command
  2017-11-03 15:51 ` Andrew Lunn
@ 2017-11-03 16:01   ` Salil Mehta
  0 siblings, 0 replies; 13+ messages in thread
From: Salil Mehta @ 2017-11-03 16:01 UTC (permalink / raw)
  To: Andrew Lunn, lipeng (Y); +Cc: davem, netdev, linux-kernel, Linuxarm

Hi Andrew,

> -----Original Message-----
> From: Andrew Lunn [mailto:andrew@lunn.ch]
> Sent: Friday, November 03, 2017 3:52 PM
> To: lipeng (Y)
> Cc: davem@davemloft.net; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; Linuxarm; Salil Mehta
> Subject: Re: [PATCH net-next 0/6] net: hns3: support set_link_ksettings
> and for nway_reset ethtool command
> 
> On Fri, Nov 03, 2017 at 12:18:24PM +0800, Lipeng wrote:
> > This patch-set adds support for set_link_ksettings && for nway_resets
> > ethtool command and fixes some related ethtool bugs.
> > 1, patch[4/6] adds support for ethtool_ops.set_link_ksettings.
> > 2, patch[5/6] adds support ethtool_ops.for nway_reset.
> > 3, patch[1/6,2/6,3/6,6/6] fix some bugs for getting port information
> by
> >    ethtool command(ethtool ethx).
> 
> Hi Lipeng
> 
> Do you want the fixes applied to net, and back ported to stable?
> 
> If so, you need to submit them separately, and against the correct
> tree.
Yes, you are correct. This should have been submitted against net repo.
But now this patch-set has been accepted by Dave for net-next do you
think we can still submit it again against Dave's net repo?

Thanks
Salil

> 
> 	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings
  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)
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Fainelli @ 2017-11-03 19:52 UTC (permalink / raw)
  To: Lipeng, davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta

On 11/02/2017 09:18 PM, Lipeng wrote:
> From: Fuyun Liang <liangfuyun1@huawei.com>
> 
> This patch adds set_link_ksettings support for ethtool cmd.
> 
> Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
> Signed-off-by: Lipeng <lipeng321@huawei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> index c7b8ebd..7fe193b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> @@ -653,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
>  	return 0;
>  }
>  
> +static int hns3_set_link_ksettings(struct net_device *netdev,
> +				   const struct ethtool_link_ksettings *cmd)
> +{
> +	/* Only support ksettings_set for netdev with phy attached for now */
> +	if (netdev->phydev)
> +		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
> +
> +	return -EOPNOTSUPP;

Consider using phy_ethtool_get_link_ksettings() which already checks for
netdev->phydev.
-- 
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 5/6] net: hns3: add support for nway_reset
  2017-11-03  4:18 ` [PATCH net-next 5/6] net: hns3: add support for nway_reset Lipeng
@ 2017-11-03 19:53   ` Florian Fainelli
  0 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2017-11-03 19:53 UTC (permalink / raw)
  To: Lipeng, davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta

On 11/02/2017 09:18 PM, Lipeng wrote:
> 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);

Consider using phy_ethtool_nway_reset() which properly checks for
phydev->drv (you don't). phy_restart_aneg() already checks for
phydev->autoneg.
-- 
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 4/6] net: hns3: add support for set_link_ksettings
  2017-11-03 19:52   ` Florian Fainelli
@ 2017-11-06  2:28     ` lipeng (Y)
  0 siblings, 0 replies; 13+ messages in thread
From: lipeng (Y) @ 2017-11-06  2:28 UTC (permalink / raw)
  To: Florian Fainelli, davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta



On 2017/11/4 3:52, Florian Fainelli wrote:
> On 11/02/2017 09:18 PM, Lipeng wrote:
>> From: Fuyun Liang <liangfuyun1@huawei.com>
>>
>> This patch adds set_link_ksettings support for ethtool cmd.
>>
>> Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
>> Signed-off-by: Lipeng <lipeng321@huawei.com>
>> ---
>>   drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> index c7b8ebd..7fe193b 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> @@ -653,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
>>   	return 0;
>>   }
>>   
>> +static int hns3_set_link_ksettings(struct net_device *netdev,
>> +				   const struct ethtool_link_ksettings *cmd)
>> +{
>> +	/* Only support ksettings_set for netdev with phy attached for now */
>> +	if (netdev->phydev)
>> +		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
>> +
>> +	return -EOPNOTSUPP;
> Consider using phy_ethtool_get_link_ksettings() which already checks for
> netdev->phydev.
agree, Thanks for your comment.

as this patch has been applied to  net-next, we will push another 
cleanup patch.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-11-06  2:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH net-next 5/6] net: hns3: add support for nway_reset Lipeng
2017-11-03 19:53   ` 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

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).