Skip to contentSkip to conversation

net: dsa: remove obsolete phylink dsa_switch operations

PATCH Applied Russell King (Oracle) 4 participants 5 messages Oct 3, 2024 – Oct 7, 2024

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

PATCH v2 1/1 net: dsa: remove obsolete phylink dsa_switch operations

No driver now uses the DSA switch phylink members, so we can now remove the method pointers, but we need to leave empty shim functions to allow those drivers that do not provide phylink MAC operations structure to continue functioning.

---
Changes since v1 (a while ago):
- don't remove the shim functions and ops structure which will break some DSA drivers that do not provide a phylink_mac_ops struct as pointed out by Vladimir (thanks.)

 include/net/dsa.h | 15 ---------------
 net/dsa/dsa.c     |  8 --------
 net/dsa/port.c    | 34 +---------------------------------
 3 files changed, 1 insertion(+), 56 deletions(-)
include/net/dsa.h +0 -15
index d7a6c2930277..72ae65e7246a 100644
@@ -885,21 +885,6 @@ struct dsa_switch_ops {
 	 */
 	void	(*phylink_get_caps)(struct dsa_switch *ds, int port,
 				    struct phylink_config *config);
-	struct phylink_pcs *(*phylink_mac_select_pcs)(struct dsa_switch *ds,
-						      int port,
-						      phy_interface_t iface);
-	void	(*phylink_mac_config)(struct dsa_switch *ds, int port,
-				      unsigned int mode,
-				      const struct phylink_link_state *state);
-	void	(*phylink_mac_link_down)(struct dsa_switch *ds, int port,
-					 unsigned int mode,
-					 phy_interface_t interface);
-	void	(*phylink_mac_link_up)(struct dsa_switch *ds, int port,
-				       unsigned int mode,
-				       phy_interface_t interface,
-				       struct phy_device *phydev,
-				       int speed, int duplex,
-				       bool tx_pause, bool rx_pause);
 	void	(*phylink_fixed_state)(struct dsa_switch *ds, int port,
 				       struct phylink_link_state *state);
 	/*
net/dsa/dsa.c +0 -8
index 668c729946ea..09d2f5d4b3dd 100644
@@ -1505,14 +1505,6 @@ static int dsa_switch_probe(struct dsa_switch *ds)
 	if (!ds->num_ports)
 		return -EINVAL;
 
-	if (ds->phylink_mac_ops) {
-		if (ds->ops->phylink_mac_select_pcs ||
-		    ds->ops->phylink_mac_config ||
-		    ds->ops->phylink_mac_link_down ||
-		    ds->ops->phylink_mac_link_up)
-			return -EINVAL;
-	}
-
 	if (np) {
 		err = dsa_switch_parse_of(ds, np);
 		if (err)
net/dsa/port.c +1 -33
index 25258b33e59e..f1e96706a701 100644
@@ -1579,40 +1579,19 @@ static struct phylink_pcs *
 dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
 				phy_interface_t interface)
 {
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
-	struct dsa_switch *ds = dp->ds;
-
-	if (ds->ops->phylink_mac_select_pcs)
-		pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);
-
-	return pcs;
+	return ERR_PTR(-EOPNOTSUPP);
 }
 
 static void dsa_port_phylink_mac_config(struct phylink_config *config,
 					unsigned int mode,
 					const struct phylink_link_state *state)
 {
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct dsa_switch *ds = dp->ds;
-
-	if (!ds->ops->phylink_mac_config)
-		return;
-
-	ds->ops->phylink_mac_config(ds, dp->index, mode, state);
 }
 
 static void dsa_port_phylink_mac_link_down(struct phylink_config *config,
 					   unsigned int mode,
 					   phy_interface_t interface)
 {
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct dsa_switch *ds = dp->ds;
-
-	if (!ds->ops->phylink_mac_link_down)
-		return;
-
-	ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
 }
 
 static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
@@ -1622,14 +1601,6 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
 					 int speed, int duplex,
 					 bool tx_pause, bool rx_pause)
 {
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct dsa_switch *ds = dp->ds;
-
-	if (!ds->ops->phylink_mac_link_up)
-		return;
-
-	ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
-				     speed, duplex, tx_pause, rx_pause);
 }
 
 static const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
@@ -1871,9 +1842,6 @@ static void dsa_shared_port_link_down(struct dsa_port *dp)
 	if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down)
 		ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED,
 						   PHY_INTERFACE_MODE_NA);
-	else if (ds->ops->phylink_mac_link_down)
-		ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED,
-					       PHY_INTERFACE_MODE_NA);
 }
 
 int dsa_shared_port_link_register_of(struct dsa_port *dp)
Signature · 1 line
2.30.2
maintainer Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 19 lines · Russell King (Oracle)

No driver now uses the DSA switch phylink members, so we can now remove the method pointers, but we need to leave empty shim functions to allow those drivers that do not provide phylink MAC operations structure to continue functioning.

---

net/dsa/dsa.c +0 -0
index 668c729946ea..09d2f5d4b3dd 100644
net/dsa/port.c +0 -0
index 25258b33e59e..f1e96706a701 100644
@@ -1579,40 +1579,19 @@ static struct phylink_pcs *
 dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
 				phy_interface_t interface)
 {

net/dsa/port.c static struct phylink_pcs * · line 1583

Quoted 10 lines
net/dsa/port.c +1 -8
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
-	struct dsa_switch *ds = dp->ds;
-
-	if (ds->ops->phylink_mac_select_pcs)
-		pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);
-
-	return pcs;
+	return ERR_PTR(-EOPNOTSUPP);
 }

dsa_port_phylink_mac_select_pcs() didn't have to stay, as phylink_mac_select_pcs() is entirely optional in phylink. Otherwise:

#2 lore raw
Quoted 25 lines · Vladimir Oltean
Quoted 24 lines · Russell King (Oracle)

No driver now uses the DSA switch phylink members, so we can now remove the method pointers, but we need to leave empty shim functions to allow those drivers that do not provide phylink MAC operations structure to continue functioning.

---

net/dsa/dsa.c +0 -0
index 668c729946ea..09d2f5d4b3dd 100644
net/dsa/port.c +0 -5
index 25258b33e59e..f1e96706a701 100644
@@ -1579,40 +1579,19 @@ static struct phylink_pcs *
 dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
 				phy_interface_t interface)
 {
-	struct dsa_port *dp = dsa_phylink_to_port(config);
-	struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
-	struct dsa_switch *ds = dp->ds;
-
-	if (ds->ops->phylink_mac_select_pcs)
Quoted 8 lines

net/dsa/port.c static struct phylink_pcs * · line 1583

Quoted 5 lines
net/dsa/port.c +1 -3
-		pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);
-
-	return pcs;
+	return ERR_PTR(-EOPNOTSUPP);
 }

dsa_port_phylink_mac_select_pcs() didn't have to stay, as phylink_mac_select_pcs() is entirely optional in phylink. Otherwise:

Yes, that's correct, but let's keep it to this for the moment.

There's more to do with mac_select_pcs(). When it was introdued, we needed a way to distinguish whether the method was actually implemented or whether the old phylink_set_pcs() function was being used. Those days are long gone, so returning ERR_PTR(-EOPNOTSUPP) no longer makes much sense.

DSA's core code returns this, as does mv88e6xxx when the chip doesn't have any pcs_ops (I'm not sure now why I did the latter now.)

So, I'd like to (a) make mv88e6xxx_mac_select_pcs() return NULL, then kill dsa_port_phylink_mac_select_pcs() and then eliminate:

        if (mac_ops->mac_select_pcs &&
            mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
              ERR_PTR(-EOPNOTSUPP))
                using_mac_select_pcs = true;

replacing all other cases of pl->using_mac_select_pcs with a test for pl->mac_ops->mac_select_pcs being non-NULL.

However, that's for later - I think for this patch, it makes sense to keep returning the ERR_PTR() value because that's what it was doing prior to this patch - we're then only removing the members on the dsa_switch_ops and their callsite in this patch.

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!
maintainer
#3 lore raw
Quoted 19 lines · Russell King (Oracle)

Yes, that's correct, but let's keep it to this for the moment.

There's more to do with mac_select_pcs(). When it was introdued, we needed a way to distinguish whether the method was actually implemented or whether the old phylink_set_pcs() function was being used. Those days are long gone, so returning ERR_PTR(-EOPNOTSUPP) no longer makes much sense.

DSA's core code returns this, as does mv88e6xxx when the chip doesn't have any pcs_ops (I'm not sure now why I did the latter now.)

So, I'd like to (a) make mv88e6xxx_mac_select_pcs() return NULL, then kill dsa_port_phylink_mac_select_pcs() and then eliminate:

        if (mac_ops->mac_select_pcs &&
            mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
              ERR_PTR(-EOPNOTSUPP))
                using_mac_select_pcs = true;
Quoted 7 lines

replacing all other cases of pl->using_mac_select_pcs with a test for pl->mac_ops->mac_select_pcs being non-NULL.

However, that's for later - I think for this patch, it makes sense to keep returning the ERR_PTR() value because that's what it was doing prior to this patch - we're then only removing the members on the dsa_switch_ops and their callsite in this patch.

I was about to write the same thing earlier, except I stopped when I realized I also had no idea why mv88e6xxx_mac_select_pcs() returns ERR_PTR(-EOPNOTSUPP).

The removal of using_mac_select_pcs is "further work", and deleting dsa_port_phylink_mac_select_pcs() altogether, although it can also be done now, can be grouped with that.

#4 lore raw
In reply to Russell King (Oracle)
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 03 Oct 2024 12:52:17 +0100 you wrote:

No driver now uses the DSA switch phylink members, so we can now remove the method pointers, but we need to leave empty shim functions to allow those drivers that do not provide phylink MAC operations structure to continue functioning.

[...]

Here is the summary with links:
- [net-next,v2] net: dsa: remove obsolete phylink dsa_switch operations

    https://git.kernel.org/netdev/net-next/c/539770616521

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html