Convert mvneta to phylink supported_interfaces
Subsystems (3)
cover Convert mvneta to phylink supported_interfaces
Hi,
This patch series converts mvneta 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
(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/mvneta.c | 48 ++++++++++++++++++++++------------- 1 file changed, 30 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!
PATCH 1/3 net: mvneta: populate supported_interfaces member
Populate the phy_interface_t bitmap for the Marvell mvneta driver with interfaces modes supported by the MAC.
--- drivers/net/ethernet/marvell/mvneta.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +25 -0
@@ -5179,6 +5179,31 @@ static int mvneta_probe(struct platform_device *pdev) pp->phylink_config.dev = &dev->dev; pp->phylink_config.type =PHYLINK_NETDEV ; +phy_interface_set_rgmii (pp->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_QSGMII , + pp->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 , + pp->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , + pp->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_2500BASEX , + pp->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 , + pp->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 , + pp->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_SGMII , + pp->phylink_config.supported_interfaces); + } phylink =phylink_create (&pp->phylink_config, pdev->dev.fwnode, phy_mode, &mvneta_phylink_ops);
Signature · 1 line
2.30.2
PATCH 2/3 net: mvneta: remove interface checks in mvneta_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/marvell/mvneta.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/marvell/mvneta.c +2 -9
@@ -3832,15 +3832,8 @@ static void mvneta_validate(struct phylink_config *config,* "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)) { -if (!phylink_test (state->advertising, Autoneg)) { -linkmode_zero (supported); -return ; - } - }else if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface !=PHY_INTERFACE_MODE_QSGMII && - state->interface !=PHY_INTERFACE_MODE_SGMII && - !phy_interface_mode_is_rgmii (state->interface)) { +if (phy_interface_mode_is_8023z (state->interface) && + !phylink_test (state->advertising, Autoneg)) {linkmode_zero (supported);return ; }
Signature · 1 line
2.30.2
PATCH 3/3 net: mvneta: 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().
--- drivers/net/ethernet/marvell/mvneta.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/net/ethernet/marvell/mvneta.c +3 -9
@@ -3823,8 +3823,6 @@ static void mvneta_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state) { - struct net_device *ndev = to_net_dev(config->dev); -struct mvneta_port *pp =netdev_priv (ndev);__ETHTOOL_DECLARE_LINK_MODE_MASK (mask ) = {0 , };/* We only support QSGMII, SGMII, 802.3z and RGMII modes.
@@ -3846,11 +3844,12 @@ static void mvneta_validate(struct phylink_config *config,phylink_set (mask, Pause);/* Half-duplex at speeds higher than 100Mbit is unsupported */ -if (pp->comphy || state->interface !=PHY_INTERFACE_MODE_2500BASEX ) { +if (state->interface !=PHY_INTERFACE_MODE_2500BASEX ) { phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); } -if (pp->comphy || state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { + +if (state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { phylink_set(mask, 2500baseT_Full); phylink_set(mask, 2500baseX_Full); }
@@ -3865,11 +3864,6 @@ static void mvneta_validate(struct phylink_config *config,linkmode_and (supported, supported, mask);linkmode_and (state->advertising, state->advertising, mask); - -/* We can only operate at 2500BaseX or 1000BaseX. If requested -* to advertise both, only report advertising at 2500BaseX. -*/ -phylink_helper_basex_speed (state); } static void mvneta_mac_pcs_get_state(struct phylink_config *config,
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 5 lines · On Wed, 27 Oct 2021 10:03:11 +0100 you wrote:
Hi,
This patch series converts mvneta to use phylinks
supported_interfacesbitmap to simplify thevalidate()implementation. The patches:
Quoted 8 lines
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[...]
Here is the summary with links:
- [net-next,1/3] net: mvneta: populate supported_interfaces member
https://git.kernel.org/netdev/net-next/c/fdedb695e6a8 - [net-next,2/3] net: mvneta: remove interface checks in mvneta_validate() https://git.kernel.org/netdev/net-next/c/d9ca72807ecb - [net-next,3/3] net: mvneta: drop use of phylink_helper_basex_speed() https://git.kernel.org/netdev/net-next/c/099cbfa286ab
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html