Skip to contentSkip to conversation

net: dsa: cleanup EEE (part 2)

RFC PATCH In review Russell King (Oracle) 3 participants 13 messages Dec 10, 2024 – Jan 2, 2025

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover net: dsa: cleanup EEE (part 2)

This is part 2 of the DSA EEE cleanups, and is being sent out becaues it is relevant for the review of part 1, but would make part 1 too large.

Patch 1 removes the useless setting of tx_lpi parameters in the ksz driver.

Patch 2 removes the DSA core code that calls the get_mac_eee() operation. This needs to be done before removing the implementations because doing otherwise would cause dsa_user_get_eee() to return -EOPNOTSUPP.

Patches 3..6 remove the trivial get_mac_eee() implementations from DSA drivers.

Patch 7 finally removes the get_mac_eee() method from struct dsa_switch_ops.

For part 2:

 drivers/net/dsa/b53/b53_common.c       |  7 -------
 drivers/net/dsa/b53/b53_priv.h         |  1 -
 drivers/net/dsa/bcm_sf2.c              |  1 -
 drivers/net/dsa/microchip/ksz_common.c | 15 ---------------
 drivers/net/dsa/mv88e6xxx/chip.c       |  8 --------
 drivers/net/dsa/qca/qca8k-8xxx.c       |  1 -
 drivers/net/dsa/qca/qca8k-common.c     |  7 -------
 drivers/net/dsa/qca/qca8k.h            |  1 -
 include/net/dsa.h                      |  2 --
 net/dsa/user.c                         | 12 ------------
 10 files changed, 55 deletions(-)

For part 1 and part 2 combined results in a net reduction of 33 LOC:

 drivers/net/dsa/b53/b53_common.c       | 14 ++++----------
 drivers/net/dsa/b53/b53_priv.h         |  2 +-
 drivers/net/dsa/bcm_sf2.c              |  2 +-
 drivers/net/dsa/microchip/ksz_common.c | 35 +++++-----------------------------
 drivers/net/dsa/mt7530.c               |  1 +
 drivers/net/dsa/mv88e6xxx/chip.c       |  9 +--------
 drivers/net/dsa/qca/qca8k-8xxx.c       |  2 +-
 drivers/net/dsa/qca/qca8k-common.c     |  7 -------
 drivers/net/dsa/qca/qca8k.h            |  1 -
 include/net/dsa.h                      |  4 ++--
 net/dsa/port.c                         | 16 ++++++++++++++++
 net/dsa/user.c                         | 18 +++++++----------
 12 files changed, 39 insertions(+), 72 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

RFC PATCH 1/7 net: dsa: ksz: remove setting of tx_lpi parameters

dsa_user_get_eee() calls the DSA switch get_mac_eee() method followed by phylink_ethtool_get_eee(), which goes on to call phy_ethtool_get_eee(). This overwrites all members of the passed ethtool_keee, which means anything written by the DSA switch get_mac_eee() method will discarded.

Remove setting any members in ksz_get_mac_eee().

---
 drivers/net/dsa/microchip/ksz_common.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +0 -8
index 94f9aa983ff6..9a48b4438a6d 100644
@@ -3480,14 +3480,6 @@ static bool ksz_support_eee(struct dsa_switch *ds, int port)
 static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
 			   struct ethtool_keee *e)
 {
-	/* There is no documented control of Tx LPI configuration. */
-	e->tx_lpi_enabled = true;
-
-	/* There is no documented control of Tx LPI timer. According to tests
-	 * Tx LPI timer seems to be set by default to minimal value.
-	 */
-	e->tx_lpi_timer = 0;
-
 	return 0;
 }
 
Signature · 1 line
2.30.2
#3 lore raw

RFC PATCH 2/7 net: dsa: no longer call ds->ops->get_mac_eee()

In reply to Russell King (Oracle)

All implementations of get_mac_eee() now just return zero without doing anything useful. Remove the call to this method in preparation to removing the method from each DSA driver.

---
 net/dsa/user.c | 12 ------------
 1 file changed, 12 deletions(-)
net/dsa/user.c +0 -12
index 4239083c18bf..fb38543b29db 100644
@@ -1250,23 +1250,11 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e)
 {
 	struct dsa_port *dp = dsa_user_to_port(dev);
 	struct dsa_switch *ds = dp->ds;
-	int ret;
 
 	/* Check whether the switch supports EEE */
 	if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
 		return -EOPNOTSUPP;
 
-	/* Port's PHY and MAC both need to be EEE capable */
-	if (!dev->phydev)
-		return -ENODEV;
-
-	if (!ds->ops->get_mac_eee)
-		return -EOPNOTSUPP;
-
-	ret = ds->ops->get_mac_eee(ds, dp->index, e);
-	if (ret)
-		return ret;
-
 	return phylink_ethtool_get_eee(dp->pl, e);
 }
 
Signature · 1 line
2.30.2
#6 lore raw

RFC PATCH 3/7 net: dsa: b53/bcm_sf2: remove b53_get_mac_eee()

In reply to Russell King (Oracle)

b53_get_mac_eee() is no longer called by the core DSA code. Remove it.

---
 drivers/net/dsa/b53/b53_common.c | 7 -------
 drivers/net/dsa/b53/b53_priv.h   | 1 -
 drivers/net/dsa/bcm_sf2.c        | 1 -
 3 files changed, 9 deletions(-)
drivers/net/dsa/b53/b53_common.c +0 -7
index 0561b60f668f..79dc77835681 100644
@@ -2232,12 +2232,6 @@ bool b53_support_eee(struct dsa_switch *ds, int port)
 }
 EXPORT_SYMBOL(b53_support_eee);
 
-int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
-{
-	return 0;
-}
-EXPORT_SYMBOL(b53_get_mac_eee);
-
 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
 {
 	struct b53_device *dev = ds->priv;
@@ -2299,7 +2293,6 @@ static const struct dsa_switch_ops b53_switch_ops = {
 	.port_enable		= b53_enable_port,
 	.port_disable		= b53_disable_port,
 	.support_eee		= b53_support_eee,
-	.get_mac_eee		= b53_get_mac_eee,
 	.set_mac_eee		= b53_set_mac_eee,
 	.port_bridge_join	= b53_br_join,
 	.port_bridge_leave	= b53_br_leave,
drivers/net/dsa/b53/b53_priv.h +0 -1
index 99e5cfc98ae8..9e9b5bc0c5d6 100644
@@ -385,7 +385,6 @@ void b53_disable_port(struct dsa_switch *ds, int port);
 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
 bool b53_support_eee(struct dsa_switch *ds, int port);
-int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
 
 #endif
drivers/net/dsa/bcm_sf2.c +0 -1
index a53fb6191e6b..fa2bf3fa9019 100644
@@ -1233,7 +1233,6 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
 	.port_enable		= bcm_sf2_port_setup,
 	.port_disable		= bcm_sf2_port_disable,
 	.support_eee		= b53_support_eee,
-	.get_mac_eee		= b53_get_mac_eee,
 	.set_mac_eee		= b53_set_mac_eee,
 	.port_bridge_join	= b53_br_join,
 	.port_bridge_leave	= b53_br_leave,
Signature · 1 line
2.30.2
#7 lore raw

RFC PATCH 4/7 net: dsa: ksz: remove ksz_get_mac_eee()

In reply to Russell King (Oracle)

ksz_get_mac_eee() is no longer called by the core DSA code. Remove it.

---
 drivers/net/dsa/microchip/ksz_common.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +0 -7
index 9a48b4438a6d..807a37112a00 100644
@@ -3477,12 +3477,6 @@ static bool ksz_support_eee(struct dsa_switch *ds, int port)
 	return false;
 }
 
-static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
-			   struct ethtool_keee *e)
-{
-	return 0;
-}
-
 static int ksz_set_mac_eee(struct dsa_switch *ds, int port,
 			   struct ethtool_keee *e)
 {
@@ -4633,7 +4627,6 @@ static const struct dsa_switch_ops ksz_switch_ops = {
 	.cls_flower_del		= ksz_cls_flower_del,
 	.port_setup_tc		= ksz_setup_tc,
 	.support_eee		= ksz_support_eee,
-	.get_mac_eee		= ksz_get_mac_eee,
 	.set_mac_eee		= ksz_set_mac_eee,
 	.port_get_default_prio	= ksz_port_get_default_prio,
 	.port_set_default_prio	= ksz_port_set_default_prio,
Signature · 1 line
2.30.2
#8 lore raw

RFC PATCH 5/7 net: dsa: mv88e6xxx: remove mv88e6xxx_get_mac_eee()

In reply to Russell King (Oracle)

mv88e6xxx_get_mac_eee() is no longer called by the core DSA code. Remove it.

---
 drivers/net/dsa/mv88e6xxx/chip.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +0 -8
index 1d78974ea2a3..ddb70047098f 100644
@@ -1522,13 +1522,6 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
 	mv88e6xxx_reg_unlock(chip);
 }
 
-static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
-				 struct ethtool_keee *e)
-{
-	/* Nothing to do on the port's MAC */
-	return 0;
-}
-
 static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
 				 struct ethtool_keee *e)
 {
@@ -7075,7 +7068,6 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.port_max_mtu		= mv88e6xxx_get_max_mtu,
 	.port_change_mtu	= mv88e6xxx_change_mtu,
 	.support_eee		= dsa_supports_eee,
-	.get_mac_eee		= mv88e6xxx_get_mac_eee,
 	.set_mac_eee		= mv88e6xxx_set_mac_eee,
 	.get_eeprom_len		= mv88e6xxx_get_eeprom_len,
 	.get_eeprom		= mv88e6xxx_get_eeprom,
Signature · 1 line
2.30.2
#9 lore raw

RFC PATCH 6/7 net: dsa: qca: remove qca8k_get_mac_eee()

In reply to Russell King (Oracle)

qca8k_get_mac_eee() is no longer called by the core DSA code. Remove it.

---
 drivers/net/dsa/qca/qca8k-8xxx.c   | 1 -
 drivers/net/dsa/qca/qca8k-common.c | 7 -------
 drivers/net/dsa/qca/qca8k.h        | 1 -
 3 files changed, 9 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +0 -1
index ec74e3c2b0e9..4c68524ad8af 100644
@@ -2017,7 +2017,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = {
 	.get_sset_count		= qca8k_get_sset_count,
 	.set_ageing_time	= qca8k_set_ageing_time,
 	.support_eee		= dsa_supports_eee,
-	.get_mac_eee		= qca8k_get_mac_eee,
 	.set_mac_eee		= qca8k_set_mac_eee,
 	.port_enable		= qca8k_port_enable,
 	.port_disable		= qca8k_port_disable,
drivers/net/dsa/qca/qca8k-common.c +0 -7
index 560c74c4ac3d..13005f10edb7 100644
@@ -557,13 +557,6 @@ int qca8k_set_mac_eee(struct dsa_switch *ds, int port,
 	return ret;
 }
 
-int qca8k_get_mac_eee(struct dsa_switch *ds, int port,
-		      struct ethtool_keee *e)
-{
-	/* Nothing to do on the port's MAC */
-	return 0;
-}
-
 static int qca8k_port_configure_learning(struct dsa_switch *ds, int port,
 					 bool learning)
 {
drivers/net/dsa/qca/qca8k.h +0 -1
index 3664a2e2f1f6..961d14f0336d 100644
@@ -520,7 +520,6 @@ int qca8k_get_sset_count(struct dsa_switch *ds, int port, int sset);
 
 /* Common eee function */
 int qca8k_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *eee);
-int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
 
 /* Common bridge function */
 void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
Signature · 1 line
2.30.2
#10 lore raw

RFC PATCH 7/7 net: dsa: remove get_mac_eee() method

In reply to Russell King (Oracle)

The get_mac_eee() is no longer called by the core DSA code, nor are there any implementations of this method. Remove it.

---
 include/net/dsa.h | 2 --
 1 file changed, 2 deletions(-)
include/net/dsa.h +0 -2
index 4aeedb296d67..9640d5c67f56 100644
@@ -991,8 +991,6 @@ struct dsa_switch_ops {
 	bool	(*support_eee)(struct dsa_switch *ds, int port);
 	int	(*set_mac_eee)(struct dsa_switch *ds, int port,
 			       struct ethtool_keee *e);
-	int	(*get_mac_eee)(struct dsa_switch *ds, int port,
-			       struct ethtool_keee *e);
 
 	/* EEPROM access */
 	int	(*get_eeprom_len)(struct dsa_switch *ds);
Signature · 1 line
2.30.2
maintainer
#2 lore raw

Re: [PATCH RFC net-next 1/7] net: dsa: ksz: remove setting of tx_lpi parameters

In reply to Russell King (Oracle)
Quoted 5 lines · Russell King (Oracle)

dsa_user_get_eee() calls the DSA switch get_mac_eee() method followed by phylink_ethtool_get_eee(), which goes on to call phy_ethtool_get_eee(). This overwrites all members of the passed ethtool_keee, which means anything written by the DSA switch get_mac_eee() method will discarded.

nitpick: will _be_ discarded.

maintainer
#4 lore raw

Re: [PATCH RFC net-next 2/7] net: dsa: no longer call ds->ops->get_mac_eee()

In reply to Russell King (Oracle)
Quoted 16 lines · Russell King (Oracle)

All implementations of get_mac_eee() now just return zero without doing anything useful. Remove the call to this method in preparation to removing the method from each DSA driver.

---
 net/dsa/user.c | 12 ------------
 1 file changed, 12 deletions(-)
net/dsa/user.c +0 -0
index 4239083c18bf..fb38543b29db 100644
@@ -1250,23 +1250,11 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e)
 {
 	struct dsa_port *dp = dsa_user_to_port(dev);

net/dsa/user.c static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e) · line 1261

Quoted 10 lines
net/dsa/user.c +0 -4
 	struct dsa_switch *ds = dp->ds;
-	int ret;
 
 	/* Check whether the switch supports EEE */
 	if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
 		return -EOPNOTSUPP;
 
-	/* Port's PHY and MAC both need to be EEE capable */
-	if (!dev->phydev)
-		return -ENODEV;

It may well be that removing this test is ok given the later call to phylink_ethtool_get_eee() which will fail with the same return code, but this change does not logically pertain to a patch titled "no longer call ds->ops->get_mac_eee()", and no justification is brought for it in the commit message (my previous sentence should be sufficient). Please move this to a separate patch, for traceability purposes.

Quoted 14 lines
net/dsa/user.c +0 -8
-
-	if (!ds->ops->get_mac_eee)
-		return -EOPNOTSUPP;
-
-	ret = ds->ops->get_mac_eee(ds, dp->index, e);
-	if (ret)
-		return ret;
-
 	return phylink_ethtool_get_eee(dp->pl, e);
 }
 
Signature · 1 line
2.30.2
maintainer
#11 lore raw
In reply to Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)

This is part 2 of the DSA EEE cleanups, and is being sent out becaues it is relevant for the review of part 1, but would make part 1 too large.

Patch 1 removes the useless setting of tx_lpi parameters in the ksz driver.

Patch 2 removes the DSA core code that calls the get_mac_eee() operation. This needs to be done before removing the implementations because doing otherwise would cause dsa_user_get_eee() to return -EOPNOTSUPP.

Quoted 5 lines

Patches 3..6 remove the trivial get_mac_eee() implementations from DSA drivers.

Patch 7 finally removes the get_mac_eee() method from struct dsa_switch_ops.

I appreciate the splitting of the get_mac_eee() removal into multiple patches per driver and 2 for the DSA framework. It should help BSP backporters which target only a subset of DSA drivers. Monolithic patches are harder to digest, and may have trivial context conflicts due to unrelated changes.

The set looks good, please don't forget to also update the documentation.

#5 lore raw

Re: [PATCH RFC net-next 2/7] net: dsa: no longer call ds->ops->get_mac_eee()

In reply to Vladimir Oltean
Quoted 5 lines · Vladimir Oltean
Quoted 4 lines · Russell King (Oracle)
net/dsa/user.c +0 -0
 	/* Check whether the switch supports EEE */
 	if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
 		return -EOPNOTSUPP;
Quoted 10 lines

net/dsa/user.c static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e) · line 1261

Quoted 3 lines
net/dsa/user.c +0 -3
-	/* Port's PHY and MAC both need to be EEE capable */
-	if (!dev->phydev)
-		return -ENODEV;

It may well be that removing this test is ok given the later call to phylink_ethtool_get_eee() which will fail with the same return code, but this change does not logically pertain to a patch titled "no longer call ds->ops->get_mac_eee()", and no justification is brought for it in the commit message (my previous sentence should be sufficient). Please move this to a separate patch, for traceability purposes.

Let's say we split this from the patch, and leave the check in place for this patch.

We then end up with:

	/* Port's PHY and MAC both need to be EEE capable */
	if (!dev->phydev)
		return -ENODEV;

	return phylink_ethtool_get_eee(dp->pl, e);

here.

At this point, we end up with this code:

	if (!dev->phydev)
		return -ENODEV;
followed by:
	ret = -EOPNOTSUPP;

	if (pl->phydev)
		ret = phy_ethtool_get_eee(pl->phydev, eee);

	return ret;

You seem to want that, so I'll drop the removal of this from the patch series, especially as it changes the error that userspace sees - even though it's different from what other ethernet drivers do. If we want to address the !phydev return code issue, that can be done some other time.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#12 lore raw
In reply to Vladimir Oltean
Quoted 17 lines · Vladimir Oltean
Quoted 10 lines · Russell King (Oracle)

This is part 2 of the DSA EEE cleanups, and is being sent out becaues it is relevant for the review of part 1, but would make part 1 too large.

Patch 1 removes the useless setting of tx_lpi parameters in the ksz driver.

Patch 2 removes the DSA core code that calls the get_mac_eee() operation. This needs to be done before removing the implementations because doing otherwise would cause dsa_user_get_eee() to return -EOPNOTSUPP.

Quoted 5 lines

Patches 3..6 remove the trivial get_mac_eee() implementations from DSA drivers.

Patch 7 finally removes the get_mac_eee() method from struct dsa_switch_ops.

Quoted 7 lines

I appreciate the splitting of the get_mac_eee() removal into multiple patches per driver and 2 for the DSA framework. It should help BSP backporters which target only a subset of DSA drivers. Monolithic patches are harder to digest, and may have trivial context conflicts due to unrelated changes.

The set looks good, please don't forget to also update the documentation.

Sorry, but which documentation are you referring to?

$ grep get_mac_eee Documentation/networking/ drivers/net include/ net/ -r
$ 

No references to get_mac_eee() anywhere (except in the mt7530 driver which I've missed - patches now included, will be in v2.)

Even looking for "et_mac_eee" in case of Documentation using [sg]et_mac_eee() reveals nothing.

So, I don't think there's any documentation that these patches change.

There is this in Documentation/networking/dsa/dsa.rst:

- ``get_eee``: ethtool function which is used to query a switch port EEE settings, this function should return the EEE state of the switch port MAC controller and data-processing logic as well as query the PHY for its currently configured EEE settings

First, realise that my patch set actually changes nothing - all these implementations were entirely useless because everything they have been doing has been overwritten by phylib since phylib's EEE support was changed. Therefore, the above as wrong both before and after this patch set.

Second, when phylink managed EEE gets merged, the above becomes true again.

Think of the current phylib behaviour as a user visible regression (because that's exactly what it is), and this patch set is part of a move towards resolving that regression.

IMHO, phylib managed EEE support should never have been merged - not in the way it was. There should have been either a way to transition drivers to it without causing all this breakage, or there should have been a commitment to getting this fixed in a timely manner (in the same cycle that it was merged.)

What we have right now is a total trainwreck.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!