Skip to contentSkip to conversation

net: xilinx: phylink validate implementation updates

PATCH Applied Russell King (Oracle) 4 participants 6 messages Nov 16, 2021 – Nov 17, 2021

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

cover net: xilinx: phylink validate implementation updates

Hi,

This series converts axienet 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/xilinx/xilinx_axienet_main.c | 71 ++++-------------------
 1 file changed, 11 insertions(+), 60 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: axienet: populate supported_interfaces member

Populate the phy_interface_t bitmap for the Xilinx axienet driver with interfaces modes supported by the MAC.

---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8 -0
index 9b068b81ae09..8a0a43d71b51 100644
@@ -2105,6 +2105,14 @@ static int axienet_probe(struct platform_device *pdev)
 	lp->phylink_config.dev = &ndev->dev;
 	lp->phylink_config.type = PHYLINK_NETDEV;
 
+	__set_bit(lp->phy_mode, lp->phylink_config.supported_interfaces);
+	if (lp->switch_x_sgmii) {
+		__set_bit(PHY_INTERFACE_MODE_1000BASEX,
+			  lp->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  lp->phylink_config.supported_interfaces);
+	}
+
 	lp->phylink = phylink_create(&lp->phylink_config, pdev->dev.fwnode,
 				     lp->phy_mode,
 				     &axienet_phylink_ops);
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/3 net: axienet: remove interface checks in axienet_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.

---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 -------------------
 1 file changed, 22 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0 -22
index 8a0a43d71b51..a058019ad9a1 100644
@@ -1507,29 +1507,8 @@ static void axienet_validate(struct phylink_config *config,
 			     unsigned long *supported,
 			     struct phylink_link_state *state)
 {
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct axienet_local *lp = netdev_priv(ndev);
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
-	/* Only support the mode we are configured for */
-	switch (state->interface) {
-	case PHY_INTERFACE_MODE_NA:
-		break;
-	case PHY_INTERFACE_MODE_1000BASEX:
-	case PHY_INTERFACE_MODE_SGMII:
-		if (lp->switch_x_sgmii)
-			break;
-		fallthrough;
-	default:
-		if (state->interface != lp->phy_mode) {
-			netdev_warn(ndev, "Cannot use PHY mode %s, supported: %s\n",
-				    phy_modes(state->interface),
-				    phy_modes(lp->phy_mode));
-			linkmode_zero(supported);
-			return;
-		}
-	}
-
 	phylink_set(mask, Autoneg);
 	phylink_set_port_modes(mask);
 
@@ -1537,7 +1516,6 @@ static void axienet_validate(struct phylink_config *config,
 	phylink_set(mask, Pause);
 
 	switch (state->interface) {
-	case PHY_INTERFACE_MODE_NA:
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_GMII:
Signature · 1 line
2.30.2
#3 lore raw

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

In reply to Russell King (Oracle)

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

---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 41 ++-----------------
 1 file changed, 3 insertions(+), 38 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3 -38
index a058019ad9a1..3dabc1901416 100644
@@ -1503,43 +1503,6 @@ static const struct ethtool_ops axienet_ethtool_ops = {
 	.nway_reset	= axienet_ethtools_nway_reset,
 };
 
-static void axienet_validate(struct phylink_config *config,
-			     unsigned long *supported,
-			     struct phylink_link_state *state)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
-
-	phylink_set(mask, Autoneg);
-	phylink_set_port_modes(mask);
-
-	phylink_set(mask, Asym_Pause);
-	phylink_set(mask, Pause);
-
-	switch (state->interface) {
-	case PHY_INTERFACE_MODE_1000BASEX:
-	case PHY_INTERFACE_MODE_SGMII:
-	case PHY_INTERFACE_MODE_GMII:
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		phylink_set(mask, 1000baseX_Full);
-		phylink_set(mask, 1000baseT_Full);
-		if (state->interface == PHY_INTERFACE_MODE_1000BASEX)
-			break;
-		fallthrough;
-	case PHY_INTERFACE_MODE_MII:
-		phylink_set(mask, 100baseT_Full);
-		phylink_set(mask, 10baseT_Full);
-		fallthrough;
-	default:
-		break;
-	}
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
-}
-
 static void axienet_mac_pcs_get_state(struct phylink_config *config,
 				      struct phylink_link_state *state)
 {
@@ -1665,7 +1628,7 @@ static void axienet_mac_link_up(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops axienet_phylink_ops = {
-	.validate = axienet_validate,
+	.validate = phylink_generic_validate,
 	.mac_pcs_get_state = axienet_mac_pcs_get_state,
 	.mac_an_restart = axienet_mac_an_restart,
 	.mac_prepare = axienet_mac_prepare,
@@ -2082,6 +2045,8 @@ static int axienet_probe(struct platform_device *pdev)
 
 	lp->phylink_config.dev = &ndev->dev;
 	lp->phylink_config.type = PHYLINK_NETDEV;
+	lp->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE |
+		MAC_10FD | MAC_100FD | MAC_1000FD;
 
 	__set_bit(lp->phy_mode, lp->phylink_config.supported_interfaces);
 	if (lp->switch_x_sgmii) {
Signature · 1 line
2.30.2
#4 lore raw
In reply to Russell King (Oracle)

+Harini

Quoted 9 lines · Russell King (Oracle)

Hi,

This series converts axienet 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/xilinx/xilinx_axienet_main.c | 71 ++++-------------------
  1 file changed, 11 insertions(+), 60 deletions(-)

Harini: Please review this series.

Thanks,
Michal

#5 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 09:54:59 +0000 you wrote:

Hi,

This series converts axienet 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/xilinx/xilinx_axienet_main.c | 71 ++++-------------------
 1 file changed, 11 insertions(+), 60 deletions(-)

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

    https://git.kernel.org/netdev/net-next/c/136a3fa28a9f
  - [net-next,2/3] net: axienet: remove interface checks in axienet_validate()
    https://git.kernel.org/netdev/net-next/c/5703a4b66456
  - [net-next,3/3] net: axienet: use phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/72a47e1aaf2e

You are awesome, thank you!

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