Skip to contentSkip to conversation

net: enetc: 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: enetc: phylink validate implementation updates

This series converts enetc 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/freescale/enetc/enetc_pf.c | 53 ++++++-------------------
 1 file changed, 13 insertions(+), 40 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: enetc: populate supported_interfaces member

Populate the phy_interface_t bitmap for the Freescale enetc driver with interfaces modes supported by the MAC.

---
 drivers/net/ethernet/freescale/enetc/enetc_pf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc_pf.c +10 -0
index 0e87c7043b77..536454205590 100644
@@ -1112,6 +1112,16 @@ static int enetc_phylink_create(struct enetc_ndev_priv *priv,
 	pf->phylink_config.dev = &priv->ndev->dev;
 	pf->phylink_config.type = PHYLINK_NETDEV;
 
+	__set_bit(PHY_INTERFACE_MODE_INTERNAL,
+		  pf->phylink_config.supported_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_SGMII,
+		  pf->phylink_config.supported_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+		  pf->phylink_config.supported_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_USXGMII,
+		  pf->phylink_config.supported_interfaces);
+	phy_interface_set_rgmii(pf->phylink_config.supported_interfaces);
+
 	phylink = phylink_create(&pf->phylink_config, of_fwnode_handle(node),
 				 pf->if_mode, &enetc_mac_phylink_ops);
 	if (IS_ERR(phylink)) {
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/3 net: enetc: remove interface checks in enetc_pl_mac_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/freescale/enetc/enetc_pf.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc_pf.c +0 -10
index 536454205590..61f05a021779 100644
@@ -936,16 +936,6 @@ static void enetc_pl_mac_validate(struct phylink_config *config,
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
-	if (state->interface != PHY_INTERFACE_MODE_NA &&
-	    state->interface != PHY_INTERFACE_MODE_INTERNAL &&
-	    state->interface != PHY_INTERFACE_MODE_SGMII &&
-	    state->interface != PHY_INTERFACE_MODE_2500BASEX &&
-	    state->interface != PHY_INTERFACE_MODE_USXGMII &&
-	    !phy_interface_mode_is_rgmii(state->interface)) {
-		linkmode_zero(supported);
-		return;
-	}
-
 	phylink_set_port_modes(mask);
 	phylink_set(mask, Autoneg);
 	phylink_set(mask, Pause);
Signature · 1 line
2.30.2
#3 lore raw

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

In reply to Russell King (Oracle)

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

---
 .../net/ethernet/freescale/enetc/enetc_pf.c   | 33 ++-----------------
 1 file changed, 3 insertions(+), 30 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc_pf.c +3 -30
index 61f05a021779..fe6a544f37f0 100644
@@ -930,35 +930,6 @@ static void enetc_mdiobus_destroy(struct enetc_pf *pf)
 	enetc_imdio_remove(pf);
 }
 
-static void enetc_pl_mac_validate(struct phylink_config *config,
-				  unsigned long *supported,
-				  struct phylink_link_state *state)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
-
-	phylink_set_port_modes(mask);
-	phylink_set(mask, Autoneg);
-	phylink_set(mask, Pause);
-	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, 100baseT_Half);
-	phylink_set(mask, 1000baseT_Half);
-	phylink_set(mask, 1000baseT_Full);
-
-	if (state->interface == PHY_INTERFACE_MODE_INTERNAL ||
-	    state->interface == PHY_INTERFACE_MODE_2500BASEX ||
-	    state->interface == PHY_INTERFACE_MODE_USXGMII) {
-		phylink_set(mask, 2500baseT_Full);
-		phylink_set(mask, 2500baseX_Full);
-	}
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
-}
-
 static void enetc_pl_mac_config(struct phylink_config *config,
 				unsigned int mode,
 				const struct phylink_link_state *state)
@@ -1086,7 +1057,7 @@ static void enetc_pl_mac_link_down(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops enetc_mac_phylink_ops = {
-	.validate = enetc_pl_mac_validate,
+	.validate = phylink_generic_validate,
 	.mac_config = enetc_pl_mac_config,
 	.mac_link_up = enetc_pl_mac_link_up,
 	.mac_link_down = enetc_pl_mac_link_down,
@@ -1101,6 +1072,8 @@ static int enetc_phylink_create(struct enetc_ndev_priv *priv,
 
 	pf->phylink_config.dev = &priv->ndev->dev;
 	pf->phylink_config.type = PHYLINK_NETDEV;
+	pf->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+		MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
 
 	__set_bit(PHY_INTERFACE_MODE_INTERNAL,
 		  pf->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 6 lines · On Tue, 16 Nov 2021 09:58:29 +0000 you wrote:

This series converts enetc 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/freescale/enetc/enetc_pf.c | 53 ++++++-------------------
 1 file changed, 13 insertions(+), 40 deletions(-)

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

    https://git.kernel.org/netdev/net-next/c/4e5015df5211
  - [net-next,2/3] net: enetc: remove interface checks in enetc_pl_mac_validate()
    https://git.kernel.org/netdev/net-next/c/5a94c1ba8e33
  - [net-next,3/3] net: enetc: use phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/75021cf02ff8

You are awesome, thank you!

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