From: "Russell King (Oracle)" <linux@armlinux.org.uk> Date: 2021-10-27 09:48:43
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(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
From: Russell King <hidden> Date: 2021-10-27 09:49:25
Populate the phy interface mode bitmap for the Marvell mvpp2 driver
with interfaces modes supported by the MAC.
Signed-off-by: Russell King <redacted>
---
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
@@ -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+*serdesmodesandswitchbetweenthem.+*/+__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);+}elseif(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);+}elseif(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)){
From: Russell King (Oracle) <hidden> Date: 2021-10-27 09:49:26
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.
Signed-off-by: Russell King (Oracle) <redacted>
---
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 33 ++++---------------
1 file changed, 7 insertions(+), 26 deletions(-)
@@ -6261,32 +6261,13 @@ static void mvpp2_phylink_validate(struct phylink_config *config,structmvpp2_port*port=mvpp2_phylink_to_port(config);__ETHTOOL_DECLARE_LINK_MODE_MASK(mask)={0,};-/* Invalid combinations */-switch(state->interface){-casePHY_INTERFACE_MODE_10GBASER:-casePHY_INTERFACE_MODE_XAUI:-if(!mvpp2_port_supports_xlg(port))-gotoempty_set;-break;-casePHY_INTERFACE_MODE_RGMII:-casePHY_INTERFACE_MODE_RGMII_ID:-casePHY_INTERFACE_MODE_RGMII_RXID:-casePHY_INTERFACE_MODE_RGMII_TXID:-if(!mvpp2_port_supports_rgmii(port))-gotoempty_set;-break;-casePHY_INTERFACE_MODE_1000BASEX:-casePHY_INTERFACE_MODE_2500BASEX:-/* When in 802.3z mode, we must have AN enabled:-*Bit2FieldInBandAnEnIn-bandAuto-Negotiationenable....-*When<PortType>=1(1000BASE-X)thisfieldmustbesetto1.-*/-if(!phylink_test(state->advertising,Autoneg))-gotoempty_set;-break;-default:-break;-}+/* When in 802.3z mode, we must have AN enabled:+*Bit2FieldInBandAnEnIn-bandAuto-Negotiationenable....+*When<PortType>=1(1000BASE-X)thisfieldmustbesetto1.+*/+if(phy_interface_mode_is_8023z(state->interface)&&+!phylink_test(state->advertising,Autoneg))+gotoempty_set;phylink_set(mask,Autoneg);phylink_set_port_modes(mask);
From: Russell King (Oracle) <hidden> Date: 2021-10-27 09:49:31
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().
Signed-off-by: Russell King (Oracle) <redacted>
---
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
From: Russell King (Oracle) <hidden> Date: 2021-10-27 09:49:35
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.
Signed-off-by: Russell King (Oracle) <redacted>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller [off-list ref]:
On Wed, 27 Oct 2021 10:48:38 +0100 you wrote:
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.
[...]