Skip to contentSkip to conversation

net: gianfar: add ethtool eee support

PATCH In review Yangbo Lu 4 participants 5 messages Nov 28, 2017 – Dec 8, 2017

Subsystems (3)
lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

PATCH 1/1 net: gianfar: add ethtool eee support

From: Shaohui Xie <[email protected]>

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.

---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/net/ethernet/freescale/gianfar_ethtool.c +28 -0
index 56588f2e1d91..8953650b36f3 100644
@@ -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,
Signature · 1 line
2.14.1
#1 lore raw
Quoted 8 lines · Yangbo Lu

From: Shaohui Xie <[email protected]>

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

maintainer
#2 lore raw

PATCH 1/1 gianfar: Disable EEE autoneg by default

In reply to Yangbo Lu

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.

---
 drivers/net/ethernet/freescale/gianfar.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/freescale/gianfar.c +5 -0
index 81a73af..7f83700 100644
@@ -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;
 }
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH net] gianfar: Disable EEE autoneg by default

Quoted 10 lines · Claudiu Manoil

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.

Andrew

maintainer Applied
#4 lore raw

Re: [PATCH net] gianfar: Disable EEE autoneg by default

In reply to Claudiu Manoil

From: Claudiu Manoil <[email protected]>
Date: Thu, 7 Dec 2017 18:44:23 +0200

Quoted 10 lines

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.

Applied, thank you.