All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: gianfar: add ethtool eee support
@ 2017-11-28  6:29 Yangbo Lu
  2017-11-28 13:15 ` Andrew Lunn
  2017-12-07 16:44 ` [PATCH net] gianfar: Disable EEE autoneg by default Claudiu Manoil
  0 siblings, 2 replies; 9+ messages in thread
From: Yangbo Lu @ 2017-11-28  6:29 UTC (permalink / raw)
  To: netdev, linux-kernel, Claudiu Manoil; +Cc: Shaohui Xie, Yangbo Lu

From: Shaohui Xie <Shaohui.Xie@nxp.com>

Gianfar does not support EEE, but it can connect to a PHY which supports
EEE and the PHY advertises EEE by default, and its link partner also
advertises EEE, so the PHY enters low power mode when traffic rate is low,
which causes packet loss if an application's traffic rate is low. This
patch provides .get_eee and .set_eee so that to disable the EEE
advertisement via ethtool if needed, other EEE features are not supported.

Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
Signed-off-by: Yangbo Lu <Yangbo.lu@nxp.com>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 56588f2e1d91..8953650b36f3 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -184,6 +184,32 @@ static void gfar_gdrvinfo(struct net_device *dev,
 	strlcpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info));
 }
 
+static int gfar_get_eee(struct net_device *dev, struct ethtool_eee *et_eee)
+{
+	struct phy_device *phydev = dev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return phy_ethtool_get_eee(phydev, et_eee);
+}
+
+static int gfar_set_eee(struct net_device *dev, struct ethtool_eee *et_eee)
+{
+	struct phy_device *phydev = dev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	if (et_eee->eee_enabled ||
+	    et_eee->tx_lpi_enabled ||
+	    et_eee->tx_lpi_timer) {
+		return -EOPNOTSUPP;
+	}
+
+	return phy_ethtool_set_eee(phydev, et_eee);
+}
+
 /* Return the length of the register structure */
 static int gfar_reglen(struct net_device *dev)
 {
@@ -1535,6 +1561,8 @@ static int gfar_get_ts_info(struct net_device *dev,
 }
 
 const struct ethtool_ops gfar_ethtool_ops = {
+	.get_eee = gfar_get_eee,
+	.set_eee = gfar_set_eee,
 	.get_drvinfo = gfar_gdrvinfo,
 	.get_regs_len = gfar_reglen,
 	.get_regs = gfar_get_regs,
-- 
2.14.1

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

* Re: [PATCH] net: gianfar: add ethtool eee support
  2017-11-28  6:29 [PATCH] net: gianfar: add ethtool eee support Yangbo Lu
@ 2017-11-28 13:15 ` Andrew Lunn
  2017-12-07 16:44 ` [PATCH net] gianfar: Disable EEE autoneg by default Claudiu Manoil
  1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-11-28 13:15 UTC (permalink / raw)
  To: Yangbo Lu; +Cc: netdev, linux-kernel, Claudiu Manoil, Shaohui Xie

On Tue, Nov 28, 2017 at 02:29:01PM +0800, Yangbo Lu wrote:
> From: Shaohui Xie <Shaohui.Xie@nxp.com>
> 
> Gianfar does not support EEE, but it can connect to a PHY which supports
> EEE and the PHY advertises EEE by default, and its link partner also
> advertises EEE, so the PHY enters low power mode when traffic rate is low,
> which causes packet loss if an application's traffic rate is low. This
> patch provides .get_eee and .set_eee so that to disable the EEE
> advertisement via ethtool if needed, other EEE features are not supported.

Hi Yangbo

This patch is good, as far as it goes. However, as you said, some PHYs
advertise EEE by default. So i think it would be good to add a call to
phy_ethtool_set_eee() to disable advertisement, e.g. in init_phy().

Thanks
	      Andrew

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

* [PATCH net] gianfar: Disable EEE autoneg by default
  2017-11-28  6:29 [PATCH] net: gianfar: add ethtool eee support Yangbo Lu
  2017-11-28 13:15 ` Andrew Lunn
@ 2017-12-07 16:44 ` Claudiu Manoil
  2017-12-07 17:54   ` Andrew Lunn
  2017-12-08 18:23   ` David Miller
  1 sibling, 2 replies; 9+ messages in thread
From: Claudiu Manoil @ 2017-12-07 16:44 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, David S . Miller, Shaohui Xie

This controller does not support EEE, but it may connect to a PHY
which supports EEE and advertises EEE by default, while its link
partner also advertises EEE. If this happens, the PHY enters low
power mode when the traffic rate is low and causes packet loss.
This patch disables EEE advertisement by default for any PHY that
gianfar connects to, to prevent the above unwanted outcome.

Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
Tested-by: Yangbo Lu <Yangbo.lu@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 81a73af..7f83700 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1792,6 +1792,7 @@ static int init_phy(struct net_device *dev)
 		GFAR_SUPPORTED_GBIT : 0;
 	phy_interface_t interface;
 	struct phy_device *phydev;
+	struct ethtool_eee edata;
 
 	priv->oldlink = 0;
 	priv->oldspeed = 0;
@@ -1816,6 +1817,10 @@ static int init_phy(struct net_device *dev)
 	/* Add support for flow control, but don't advertise it by default */
 	phydev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
 
+	/* disable EEE autoneg, EEE not supported by eTSEC */
+	memset(&edata, 0, sizeof(struct ethtool_eee));
+	phy_ethtool_set_eee(phydev, &edata);
+
 	return 0;
 }
 
-- 
2.7.4

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

* Re: [PATCH net] gianfar: Disable EEE autoneg by default
  2017-12-07 16:44 ` [PATCH net] gianfar: Disable EEE autoneg by default Claudiu Manoil
@ 2017-12-07 17:54   ` Andrew Lunn
  2017-12-08 18:23   ` David Miller
  1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-12-07 17:54 UTC (permalink / raw)
  To: Claudiu Manoil; +Cc: netdev, David S . Miller, Shaohui Xie

On Thu, Dec 07, 2017 at 06:44:23PM +0200, Claudiu Manoil wrote:
> This controller does not support EEE, but it may connect to a PHY
> which supports EEE and advertises EEE by default, while its link
> partner also advertises EEE. If this happens, the PHY enters low
> power mode when the traffic rate is low and causes packet loss.
> This patch disables EEE advertisement by default for any PHY that
> gianfar connects to, to prevent the above unwanted outcome.
> 
> Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
> Tested-by: Yangbo Lu <Yangbo.lu@nxp.com>
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net] gianfar: Disable EEE autoneg by default
  2017-12-07 16:44 ` [PATCH net] gianfar: Disable EEE autoneg by default Claudiu Manoil
  2017-12-07 17:54   ` Andrew Lunn
@ 2017-12-08 18:23   ` David Miller
  1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2017-12-08 18:23 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, andrew, Shaohui.Xie

From: Claudiu Manoil <claudiu.manoil@nxp.com>
Date: Thu, 7 Dec 2017 18:44:23 +0200

> This controller does not support EEE, but it may connect to a PHY
> which supports EEE and advertises EEE by default, while its link
> partner also advertises EEE. If this happens, the PHY enters low
> power mode when the traffic rate is low and causes packet loss.
> This patch disables EEE advertisement by default for any PHY that
> gianfar connects to, to prevent the above unwanted outcome.
> 
> Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
> Tested-by: Yangbo Lu <Yangbo.lu@nxp.com>
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>

Applied, thank you.

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

* RE: [PATCH] net: gianfar: add ethtool eee support
  2016-12-08 23:22   ` Florian Fainelli
@ 2016-12-09  2:55     ` S.H. Xie
  0 siblings, 0 replies; 9+ messages in thread
From: S.H. Xie @ 2016-12-09  2:55 UTC (permalink / raw)
  To: Florian Fainelli, David Miller; +Cc: netdev

> -----Original Message-----
> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> Sent: Friday, December 09, 2016 7:22 AM
> To: David Miller <davem@davemloft.net>; S.H. Xie <shaohui.xie@nxp.com>
> Cc: netdev@vger.kernel.org
> Subject: Re: [PATCH] net: gianfar: add ethtool eee support
> 
> On 12/08/2016 03:19 PM, David Miller wrote:
> > From: Shaohui Xie <Shaohui.Xie@nxp.com>
> > Date: Thu, 8 Dec 2016 19:27:06 +0800
> >
> >> Gianfar does not support EEE, but it can connect to a PHY which
> >> supports EEE and the PHY advertises EEE by default, and its link
> >> partner also advertises EEE, so the PHY enters low power mode when
> >> traffic rate is low, which causes packet loss if an application's
> >> traffic rate is low. This patch provides .get_eee and .set_eee so
> >> that to disable the EEE advertisement via ethtool if needed, other EEE features
> are not supported.
> >>
> >> Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
> >
> > This is not the way to fix this.
> >
> > If the Gianfar MAC does not support EEE properly, then the gianfar
> > driver should not create a situation where the PHY advertises EEE in
> > the first place.
> 
> Agreed, you should have gianfar mask out the EEE advertisement from the PHY it
> connects to, in order to make sure that EEE is properly disabled.
> This should be no different from e.g: connecting a 10/100/1000 PHY to a
> 10/100 only controller for instance.
[S.H] The EEE advertisement does not belong to PHY device, gianfar cannot mask out the EEE
Advertisement like advertising, should use phy_write_mmd_indirect() to disable it?

And by disabling EEE advertisement always, the PHY cannot enter low power mode even if there 
is no traffic. Using ethtool could provide user options to handle this.

Thanks.
Shaohui



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

* Re: [PATCH] net: gianfar: add ethtool eee support
  2016-12-08 23:19 ` David Miller
@ 2016-12-08 23:22   ` Florian Fainelli
  2016-12-09  2:55     ` S.H. Xie
  0 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2016-12-08 23:22 UTC (permalink / raw)
  To: David Miller, Shaohui.Xie; +Cc: netdev

On 12/08/2016 03:19 PM, David Miller wrote:
> From: Shaohui Xie <Shaohui.Xie@nxp.com>
> Date: Thu, 8 Dec 2016 19:27:06 +0800
> 
>> Gianfar does not support EEE, but it can connect to a PHY which supports
>> EEE and the PHY advertises EEE by default, and its link partner also
>> advertises EEE, so the PHY enters low power mode when traffic rate is low,
>> which causes packet loss if an application's traffic rate is low. This
>> patch provides .get_eee and .set_eee so that to disable the EEE
>> advertisement via ethtool if needed, other EEE features are not supported.
>>
>> Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
> 
> This is not the way to fix this.
> 
> If the Gianfar MAC does not support EEE properly, then the gianfar
> driver should not create a situation where the PHY advertises EEE
> in the first place.

Agreed, you should have gianfar mask out the EEE advertisement from the
PHY it connects to, in order to make sure that EEE is properly disabled.
This should be no different from e.g: connecting a 10/100/1000 PHY to a
10/100 only controller for instance.
-- 
Florian

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

* Re: [PATCH] net: gianfar: add ethtool eee support
  2016-12-08 11:27 [PATCH] net: gianfar: add ethtool eee support Shaohui Xie
@ 2016-12-08 23:19 ` David Miller
  2016-12-08 23:22   ` Florian Fainelli
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2016-12-08 23:19 UTC (permalink / raw)
  To: Shaohui.Xie; +Cc: netdev

From: Shaohui Xie <Shaohui.Xie@nxp.com>
Date: Thu, 8 Dec 2016 19:27:06 +0800

> Gianfar does not support EEE, but it can connect to a PHY which supports
> EEE and the PHY advertises EEE by default, and its link partner also
> advertises EEE, so the PHY enters low power mode when traffic rate is low,
> which causes packet loss if an application's traffic rate is low. This
> patch provides .get_eee and .set_eee so that to disable the EEE
> advertisement via ethtool if needed, other EEE features are not supported.
> 
> Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>

This is not the way to fix this.

If the Gianfar MAC does not support EEE properly, then the gianfar
driver should not create a situation where the PHY advertises EEE
in the first place.

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

* [PATCH] net: gianfar: add ethtool eee support
@ 2016-12-08 11:27 Shaohui Xie
  2016-12-08 23:19 ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Shaohui Xie @ 2016-12-08 11:27 UTC (permalink / raw)
  To: netdev, davem; +Cc: Shaohui Xie

Gianfar does not support EEE, but it can connect to a PHY which supports
EEE and the PHY advertises EEE by default, and its link partner also
advertises EEE, so the PHY enters low power mode when traffic rate is low,
which causes packet loss if an application's traffic rate is low. This
patch provides .get_eee and .set_eee so that to disable the EEE
advertisement via ethtool if needed, other EEE features are not supported.

Signed-off-by: Shaohui Xie <Shaohui.Xie@nxp.com>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 56588f2..9375078 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -184,6 +184,32 @@ static void gfar_gdrvinfo(struct net_device *dev,
 	strlcpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info));
 }
 
+static int gfar_get_eee(struct net_device *dev, struct ethtool_eee *et_eee)
+{
+	struct phy_device *phydev = dev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return phy_ethtool_get_eee(phydev, et_eee);
+}
+
+static int gfar_set_eee(struct net_device *dev, struct ethtool_eee *et_eee)
+{
+	struct phy_device *phydev = dev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	if (et_eee->eee_enabled ||
+	    et_eee->tx_lpi_enabled ||
+	    et_eee->tx_lpi_timer) {
+		return -EOPNOTSUPP;
+	}
+
+	return phy_ethtool_set_eee(phydev, et_eee);
+}
+
 /* Return the length of the register structure */
 static int gfar_reglen(struct net_device *dev)
 {
@@ -1548,6 +1574,8 @@ const struct ethtool_ops gfar_ethtool_ops = {
 	.get_strings = gfar_gstrings,
 	.get_sset_count = gfar_sset_count,
 	.get_ethtool_stats = gfar_fill_stats,
+	.get_eee = gfar_get_eee,
+	.set_eee = gfar_set_eee,
 	.get_msglevel = gfar_get_msglevel,
 	.set_msglevel = gfar_set_msglevel,
 #ifdef CONFIG_PM
-- 
2.1.0.27.g96db324

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

end of thread, other threads:[~2017-12-08 18:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28  6:29 [PATCH] net: gianfar: add ethtool eee support Yangbo Lu
2017-11-28 13:15 ` Andrew Lunn
2017-12-07 16:44 ` [PATCH net] gianfar: Disable EEE autoneg by default Claudiu Manoil
2017-12-07 17:54   ` Andrew Lunn
2017-12-08 18:23   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2016-12-08 11:27 [PATCH] net: gianfar: add ethtool eee support Shaohui Xie
2016-12-08 23:19 ` David Miller
2016-12-08 23:22   ` Florian Fainelli
2016-12-09  2:55     ` S.H. Xie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.