Skip to contentSkip to conversation

net: ocelot_net: phylink validate implementation updates

PATCH Applied Russell King (Oracle) 3 participants 5 messages Nov 16, 2021 – Nov 17, 2021

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

cover net: ocelot_net: phylink validate implementation updates

Hi,

This series converts ocelot_net to fill in the supported_interfaces member of phylink_config, cleans up the validate() implementation, and then converts to phylink_generic_validate().

 drivers/net/ethernet/mscc/ocelot_net.c | 41 +++++-----------------------------
 1 file changed, 6 insertions(+), 35 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH 1/3 net: ocelot_net: populate supported_interfaces member

Populate the phy interface mode bitmap for the MSCC Ocelot driver with the interface modes supported by the MAC.

---
 drivers/net/ethernet/mscc/ocelot_net.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/mscc/ocelot_net.c +3 -0
index eaeba60b1bba..37c158df60ce 100644
@@ -1655,6 +1655,9 @@ static int ocelot_port_phylink_create(struct ocelot *ocelot, int port,
 	priv->phylink_config.dev = &priv->dev->dev;
 	priv->phylink_config.type = PHYLINK_NETDEV;
 
+	__set_bit(ocelot_port->phy_mode,
+		  priv->phylink_config.supported_interfaces);
+
 	phylink = phylink_create(&priv->phylink_config,
 				 of_fwnode_handle(portnp),
 				 phy_mode, &ocelot_phylink_ops);
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/3 net: ocelot_net: remove interface checks in macb_validate()

In reply to Russell King (Oracle)

As phylink checks the interface mode against the supported_interfaces bitmap, we no longer need to validate the interface mode in the validation function. Remove this to simplify it.

---
 drivers/net/ethernet/mscc/ocelot_net.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +0 -9
index 37c158df60ce..21df548dcf64 100644
@@ -1502,17 +1502,8 @@ static void vsc7514_phylink_validate(struct phylink_config *config,
 				     unsigned long *supported,
 				     struct phylink_link_state *state)
 {
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct ocelot_port_private *priv = netdev_priv(ndev);
-	struct ocelot_port *ocelot_port = &priv->port;
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
 
-	if (state->interface != PHY_INTERFACE_MODE_NA &&
-	    state->interface != ocelot_port->phy_mode) {
-		linkmode_zero(supported);
-		return;
-	}
-
 	phylink_set_port_modes(mask);
 
 	phylink_set(mask, Pause);
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/3 net: ocelot_net: use phylink_generic_validate()

In reply to Russell King (Oracle)

ocelot_net has no special behaviour in its validation implementation, so can be switched to phylink_generic_validate().

---
 drivers/net/ethernet/mscc/ocelot_net.c | 29 +++-----------------------
 1 file changed, 3 insertions(+), 26 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +3 -26
index 21df548dcf64..0fcf359a6975 100644
@@ -1498,31 +1498,6 @@ struct notifier_block ocelot_switchdev_blocking_nb __read_mostly = {
 	.notifier_call = ocelot_switchdev_blocking_event,
 };
 
-static void vsc7514_phylink_validate(struct phylink_config *config,
-				     unsigned long *supported,
-				     struct phylink_link_state *state)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = {};
-
-	phylink_set_port_modes(mask);
-
-	phylink_set(mask, Pause);
-	phylink_set(mask, Autoneg);
-	phylink_set(mask, Asym_Pause);
-	phylink_set(mask, 10baseT_Half);
-	phylink_set(mask, 10baseT_Full);
-	phylink_set(mask, 100baseT_Half);
-	phylink_set(mask, 100baseT_Full);
-	phylink_set(mask, 1000baseT_Half);
-	phylink_set(mask, 1000baseT_Full);
-	phylink_set(mask, 1000baseX_Full);
-	phylink_set(mask, 2500baseT_Full);
-	phylink_set(mask, 2500baseX_Full);
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
-}
-
 static void vsc7514_phylink_mac_config(struct phylink_config *config,
 				       unsigned int link_an_mode,
 				       const struct phylink_link_state *state)
@@ -1581,7 +1556,7 @@ static void vsc7514_phylink_mac_link_up(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops ocelot_phylink_ops = {
-	.validate		= vsc7514_phylink_validate,
+	.validate		= phylink_generic_validate,
 	.mac_config		= vsc7514_phylink_mac_config,
 	.mac_link_down		= vsc7514_phylink_mac_link_down,
 	.mac_link_up		= vsc7514_phylink_mac_link_up,
@@ -1645,6 +1620,8 @@ static int ocelot_port_phylink_create(struct ocelot *ocelot, int port,
 
 	priv->phylink_config.dev = &priv->dev->dev;
 	priv->phylink_config.type = PHYLINK_NETDEV;
+	priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+		MAC_10 | MAC_100 | MAC_1000FD | MAC_2500FD;
 
 	__set_bit(ocelot_port->phy_mode,
 		  priv->phylink_config.supported_interfaces);
Signature · 1 line
2.30.2
#4 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Tue, 16 Nov 2021 10:08:58 +0000 you wrote:

Hi,

This series converts ocelot_net to fill in the supported_interfaces member of phylink_config, cleans up the validate() implementation, and then converts to phylink_generic_validate().

 drivers/net/ethernet/mscc/ocelot_net.c | 41 +++++-----------------------------
 1 file changed, 6 insertions(+), 35 deletions(-)

Here is the summary with links:
- [net-next,1/3] net: ocelot_net: populate supported_interfaces member

    https://git.kernel.org/netdev/net-next/c/8ea8c5b492d4
  - [net-next,2/3] net: ocelot_net: remove interface checks in macb_validate()
    https://git.kernel.org/netdev/net-next/c/a6f5248bc0a3
  - [net-next,3/3] net: ocelot_net: use phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/7258aa5094db

You are awesome, thank you!

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