Convert mvpp2 to phylink supported_interfaces
Subsystems (3)
Russell King (Oracle)
maintainercover Convert mvpp2 to phylink supported_interfaces
Hi,
This patch series converts mvpp2 to use phylinks supported_interfaces bitmap to simplify the validate() implementation. The patches:
1) Add the supported interface modes the supported_interfaces bitmap.
2) Removes the checks for the interface type being supported from the validate callback
3) Removes the now unnecessary checks and call to phylink_helper_basex_speed() to support switching between 1000base-X and 2500base-X for SFPs
4) Cleans up the resulting validate() code.
(3) becomes possible because when asking the MAC for its complete support, we walk all supported interfaces which will include 1000base-X and 2500base-X only if the comphy is present.
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 95 +++++++++++++------------ 1 file changed, 50 insertions(+), 45 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!
PATCH 1/4 net: mvpp2: populate supported_interfaces member
Populate the phy interface mode bitmap for the Marvell mvpp2 driver with interfaces modes supported by the MAC.
--- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +34 -0
@@ -6937,6 +6937,40 @@ static int mvpp2_port_probe(struct platform_device *pdev, port->phylink_config.dev = &dev->dev; port->phylink_config.type =PHYLINK_NETDEV ; +if (mvpp2_port_supports_xlg (port)) { +__set_bit (PHY_INTERFACE_MODE_10GBASER , + port->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_XAUI , + port->phylink_config.supported_interfaces); + } + +if (mvpp2_port_supports_rgmii (port)) +phy_interface_set_rgmii (port->phylink_config.supported_interfaces); + +if (comphy) { +/* If a COMPHY is present, we can support any of the +* serdes modes and switch between them. +*/ +__set_bit (PHY_INTERFACE_MODE_SGMII , + port->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , + port->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_2500BASEX , + port->phylink_config.supported_interfaces); + }else if (phy_mode ==PHY_INTERFACE_MODE_2500BASEX ) { +/* No COMPHY, with only 2500BASE-X mode supported */ +__set_bit (PHY_INTERFACE_MODE_2500BASEX , + port->phylink_config.supported_interfaces); + }else if (phy_mode ==PHY_INTERFACE_MODE_1000BASEX || + phy_mode ==PHY_INTERFACE_MODE_SGMII ) { +/* No COMPHY, we can switch between 1000BASE-X and SGMII +*/ +__set_bit (PHY_INTERFACE_MODE_1000BASEX , + port->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_SGMII , + port->phylink_config.supported_interfaces); + } + phylink =phylink_create (&port->phylink_config, port_fwnode, phy_mode, &mvpp2_phylink_ops);if (IS_ERR (phylink)) {
Signature · 1 line
2.30.2
PATCH 2/4 net: mvpp2: remove interface checks in mvpp2_phylink_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/marvell/mvpp2/mvpp2_main.c | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +7 -26
@@ -6261,32 +6261,13 @@ static void mvpp2_phylink_validate(struct phylink_config *config,struct mvpp2_port *port =mvpp2_phylink_to_port (config);__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -/* Invalid combinations */ -switch (state->interface) { -case PHY_INTERFACE_MODE_10GBASER : -case PHY_INTERFACE_MODE_XAUI : -if (!mvpp2_port_supports_xlg (port)) - goto empty_set; -break ; -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_RGMII_ID : -case PHY_INTERFACE_MODE_RGMII_RXID : -case PHY_INTERFACE_MODE_RGMII_TXID : -if (!mvpp2_port_supports_rgmii (port)) - goto empty_set; -break ; -case PHY_INTERFACE_MODE_1000BASEX : -case PHY_INTERFACE_MODE_2500BASEX : -/* When in 802.3z mode, we must have AN enabled: -* Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... -* When <PortType> = 1 (1000BASE-X) this field must be set to 1. -*/ -if (!phylink_test (state->advertising, Autoneg)) - goto empty_set; -break ; -default : -break ; - } +/* When in 802.3z mode, we must have AN enabled: +* Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... +* When <PortType> = 1 (1000BASE-X) this field must be set to 1. +*/ +if (phy_interface_mode_is_8023z (state->interface) && + !phylink_test (state->advertising, Autoneg)) + goto empty_set;phylink_set (mask, Autoneg);phylink_set_port_modes (mask);
Signature · 1 line
2.30.2
PATCH 3/4 net: mvpp2: drop use of phylink_helper_basex_speed()
In reply to Russell King (Oracle)Now that we have a better method to select SFP interface modes, we no longer need to use phylink_helper_basex_speed() in a driver's validation function, and we can also get rid of our hack to indicate both 1000base-X and 2500base-X if the comphy is present to make that work. Remove this hack and use of phylink_helper_basex_speed().
--- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +7 -12
@@ -6303,17 +6303,14 @@ static void mvpp2_phylink_validate(struct phylink_config *config,break ; fallthrough;case PHY_INTERFACE_MODE_1000BASEX : + phylink_set(mask, 1000baseT_Full); + phylink_set(mask, 1000baseX_Full); +if (state->interface !=PHY_INTERFACE_MODE_NA ) +break ; + fallthrough;case PHY_INTERFACE_MODE_2500BASEX : -if (port->comphy || - state->interface !=PHY_INTERFACE_MODE_2500BASEX ) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - } -if (port->comphy || - state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { - phylink_set(mask, 2500baseT_Full); - phylink_set(mask, 2500baseX_Full); - } + phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full);break ;default : goto empty_set;
@@ -6321,8 +6318,6 @@ static void mvpp2_phylink_validate(struct phylink_config *config,linkmode_and (supported, supported, mask);linkmode_and (state->advertising, state->advertising, mask); - -phylink_helper_basex_speed (state);return ; empty_set:
Signature · 1 line
2.30.2
PATCH 4/4 net: mvpp2: clean up mvpp2_phylink_validate()
In reply to Russell King (Oracle)mvpp2_phylink_validate() no longer needs to check for PHY_INTERFACE_MODE_NA as phylink will walk the supported interface types to discover the link mode capabilities. Remove these checks.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +7 -10
@@ -6280,14 +6280,12 @@ static void mvpp2_phylink_validate(struct phylink_config *config,switch (state->interface) {case PHY_INTERFACE_MODE_10GBASER :case PHY_INTERFACE_MODE_XAUI : -case PHY_INTERFACE_MODE_NA :if (mvpp2_port_supports_xlg (port)) {phylink_set_10g_modes (mask); phylink_set(mask, 10000baseKR_Full); } -if (state->interface !=PHY_INTERFACE_MODE_NA ) -break ; - fallthrough; +break ; +case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_RXID :
@@ -6299,19 +6297,18 @@ static void mvpp2_phylink_validate(struct phylink_config *config, phylink_set(mask, 100baseT_Full); phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); -if (state->interface !=PHY_INTERFACE_MODE_NA ) -break ; - fallthrough; +break ; +case PHY_INTERFACE_MODE_1000BASEX : phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); -if (state->interface !=PHY_INTERFACE_MODE_NA ) -break ; - fallthrough; +break ; +case PHY_INTERFACE_MODE_2500BASEX : phylink_set(mask, 2500baseT_Full); phylink_set(mask, 2500baseX_Full);break ; +default : goto empty_set; }
Signature · 1 line
2.30.2
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 13 lines · On Wed, 27 Oct 2021 10:48:38 +0100 you wrote:
Hi,
This patch series converts mvpp2 to use phylinks
supported_interfacesbitmap to simplify thevalidate()implementation. The patches:1) Add the supported interface modes the
supported_interfacesbitmap.
2) Removes the checks for the interface type being supported from the validate callback
3) Removes the now unnecessary checks and call tophylink_helper_basex_speed()to support switching between 1000base-X and 2500base-X for SFPs
4) Cleans up the resultingvalidate()code.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/4] net: mvpp2: populate supported_interfaces member
https://git.kernel.org/netdev/net-next/c/8498e17ed4c5 - [net-next,2/4] net: mvpp2: remove interface checks in mvpp2_phylink_validate() https://git.kernel.org/netdev/net-next/c/6c0c4b7ac06f - [net-next,3/4] net: mvpp2: drop use of phylink_helper_basex_speed() https://git.kernel.org/netdev/net-next/c/76947a635874 - [net-next,4/4] net: mvpp2: clean up mvpp2_phylink_validate() https://git.kernel.org/netdev/net-next/c/b63f1117aefc
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html