Skip to contentSkip to conversation

Add phylink helper for 10G modes

PATCH Applied Russell King (Oracle) 3 participants 4 messages Oct 4, 2021

Subsystems (7)
lore
Share & tools
lore

Russell King (Oracle)

author maintainer
#0 lore raw

cover Add phylink helper for 10G modes

Hi,

During the last cycle, there was discussion about adding a helper to set the 10G link modes for phylink, which resulted in these two patches introduce such a helper.

 drivers/net/ethernet/cadence/macb_main.c         |  7 +------
 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c |  7 +------
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c  |  7 +------
 drivers/net/phy/phylink.c                        | 11 +++++++++++
 include/linux/phylink.h                          |  1 +
 5 files changed, 15 insertions(+), 18 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/2 net: phylink: add phylink_set_10g_modes() helper

Add a helper for setting 10Gigabit modes, so we have one central place that sets all appropriate 10G modes for a driver.

---
 drivers/net/phy/phylink.c | 11 +++++++++++
 include/linux/phylink.h   |  1 +
 2 files changed, 12 insertions(+)
drivers/net/phy/phylink.c +11 -0
index 5a58c77d0002..b32774fd65f8 100644
@@ -132,6 +132,17 @@ void phylink_set_port_modes(unsigned long *mask)
 }
 EXPORT_SYMBOL_GPL(phylink_set_port_modes);
 
+void phylink_set_10g_modes(unsigned long *mask)
+{
+	phylink_set(mask, 10000baseT_Full);
+	phylink_set(mask, 10000baseCR_Full);
+	phylink_set(mask, 10000baseSR_Full);
+	phylink_set(mask, 10000baseLR_Full);
+	phylink_set(mask, 10000baseLRM_Full);
+	phylink_set(mask, 10000baseER_Full);
+}
+EXPORT_SYMBOL_GPL(phylink_set_10g_modes);
+
 static int phylink_is_empty_linkmode(const unsigned long *linkmode)
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp) = { 0, };
include/linux/phylink.h +1 -0
index 237291196ce2..f7b5ed06a815 100644
@@ -484,6 +484,7 @@ int phylink_speed_up(struct phylink *pl);
 #define phylink_test(bm, mode)	__phylink_do_bit(test_bit, bm, mode)
 
 void phylink_set_port_modes(unsigned long *bits);
+void phylink_set_10g_modes(unsigned long *mask);
 void phylink_helper_basex_speed(struct phylink_link_state *state);
 
 void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 net: ethernet: use phylink_set_10g_modes()

In reply to Russell King (Oracle)

Update three drivers to use the new phylink_set_10g_modes() helper:
Cadence macb, Freescale DPAA2 and Marvell PP2.

---
 drivers/net/ethernet/cadence/macb_main.c         | 7 +------
 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 7 +------
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c  | 7 +------
 3 files changed, 3 insertions(+), 18 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +1 -6
index e2730b3e1a57..b58297aeb793 100644
@@ -547,13 +547,8 @@ static void macb_validate(struct phylink_config *config,
 	if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE &&
 	    (state->interface == PHY_INTERFACE_MODE_NA ||
 	     state->interface == PHY_INTERFACE_MODE_10GBASER)) {
-		phylink_set(mask, 10000baseCR_Full);
-		phylink_set(mask, 10000baseER_Full);
+		phylink_set_10g_modes(mask);
 		phylink_set(mask, 10000baseKR_Full);
-		phylink_set(mask, 10000baseLR_Full);
-		phylink_set(mask, 10000baseLRM_Full);
-		phylink_set(mask, 10000baseSR_Full);
-		phylink_set(mask, 10000baseT_Full);
 		if (state->interface != PHY_INTERFACE_MODE_NA)
 			goto out;
 	}
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +1 -6
index 543c1f202420..ef8f0a055024 100644
@@ -139,12 +139,7 @@ static void dpaa2_mac_validate(struct phylink_config *config,
 	case PHY_INTERFACE_MODE_NA:
 	case PHY_INTERFACE_MODE_10GBASER:
 	case PHY_INTERFACE_MODE_USXGMII:
-		phylink_set(mask, 10000baseT_Full);
-		phylink_set(mask, 10000baseCR_Full);
-		phylink_set(mask, 10000baseSR_Full);
-		phylink_set(mask, 10000baseLR_Full);
-		phylink_set(mask, 10000baseLRM_Full);
-		phylink_set(mask, 10000baseER_Full);
+		phylink_set_10g_modes(mask);
 		if (state->interface == PHY_INTERFACE_MODE_10GBASER)
 			break;
 		phylink_set(mask, 5000baseT_Full);
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -6
index d5c92e43f89e..34b997aa6c66 100644
@@ -6301,12 +6301,7 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
 	case PHY_INTERFACE_MODE_XAUI:
 	case PHY_INTERFACE_MODE_NA:
 		if (mvpp2_port_supports_xlg(port)) {
-			phylink_set(mask, 10000baseT_Full);
-			phylink_set(mask, 10000baseCR_Full);
-			phylink_set(mask, 10000baseSR_Full);
-			phylink_set(mask, 10000baseLR_Full);
-			phylink_set(mask, 10000baseLRM_Full);
-			phylink_set(mask, 10000baseER_Full);
+			phylink_set_10g_modes(mask);
 			phylink_set(mask, 10000baseKR_Full);
 		}
 		if (state->interface != PHY_INTERFACE_MODE_NA)
Signature · 1 line
2.30.2
#3 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 6 lines · On Mon, 4 Oct 2021 12:02:36 +0100 you wrote:

Hi,

During the last cycle, there was discussion about adding a helper to set the 10G link modes for phylink, which resulted in these two patches introduce such a helper.

Quoted 6 lines
 drivers/net/ethernet/cadence/macb_main.c         |  7 +------
 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c |  7 +------
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c  |  7 +------
 drivers/net/phy/phylink.c                        | 11 +++++++++++
 include/linux/phylink.h                          |  1 +
 5 files changed, 15 insertions(+), 18 deletions(-)

Here is the summary with links:
- [net-next,1/2] net: phylink: add phylink_set_10g_modes() helper

    https://git.kernel.org/netdev/net-next/c/a2c27a61b433
  - [net-next,2/2] net: ethernet: use phylink_set_10g_modes()
    https://git.kernel.org/netdev/net-next/c/14ad41c74f6b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html