net: mtk_eth_soc: phylink validate implementation updates
Subsystems (4)
cover net: mtk_eth_soc: phylink validate implementation updates
Hi,
This series converts mtk_eth_soc 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/mediatek/mtk_eth_soc.c | 111 ++++++---------------------- 1 file changed, 24 insertions(+), 87 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: mtk_eth_soc: populate supported_interfaces member
Populate the phy interface mode bitmap for the Mediatek driver with interfaces modes supported by the MAC.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +20 -0
@@ -3009,6 +3009,26 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type =PHYLINK_NETDEV ; +__set_bit (PHY_INTERFACE_MODE_MII , + mac->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_GMII , + mac->phylink_config.supported_interfaces); + +if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_RGMII )) +phy_interface_set_rgmii (mac->phylink_config.supported_interfaces); + +if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_TRGMII ) && !mac->id) +__set_bit (PHY_INTERFACE_MODE_TRGMII , + mac->phylink_config.supported_interfaces); + +if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_SGMII )) { +__set_bit (PHY_INTERFACE_MODE_SGMII , + mac->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , + mac->phylink_config.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_2500BASEX , + mac->phylink_config.supported_interfaces); + } phylink = phylink_create(&mac->phylink_config, of_fwnode_handle(mac->of_node),
Signature · 1 line
2.30.2
PATCH 2/4 net: mtk_eth_soc: remove interface checks in mtk_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, nor handle PHY_INTERFACE_MODE_NA in the validation function. Remove these to simplify the implementation.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 34 --------------------- 1 file changed, 34 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +0 -34
@@ -467,24 +467,8 @@ static void mtk_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state) { - struct mtk_mac *mac = container_of(config, struct mtk_mac, - phylink_config);__ETHTOOL_DECLARE_LINK_MODE_MASK (mask ) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface !=PHY_INTERFACE_MODE_MII && - state->interface !=PHY_INTERFACE_MODE_GMII && - !(MTK_HAS_CAPS (mac->hw->soc->caps,MTK_RGMII ) && -phy_interface_mode_is_rgmii (state->interface)) && - !(MTK_HAS_CAPS (mac->hw->soc->caps,MTK_TRGMII ) && - !mac->id && state->interface ==PHY_INTERFACE_MODE_TRGMII ) && - !(MTK_HAS_CAPS (mac->hw->soc->caps,MTK_SGMII ) && - (state->interface ==PHY_INTERFACE_MODE_SGMII || -phy_interface_mode_is_8023z (state->interface)))) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);
@@ -511,7 +495,6 @@ static void mtk_validate(struct phylink_config *config,case PHY_INTERFACE_MODE_MII :case PHY_INTERFACE_MODE_RMII :case PHY_INTERFACE_MODE_REVMII : -case PHY_INTERFACE_MODE_NA :default : phylink_set(mask, 10baseT_Half); phylink_set(mask, 10baseT_Full);
@@ -520,23 +503,6 @@ static void mtk_validate(struct phylink_config *config,break ; } -if (state->interface ==PHY_INTERFACE_MODE_NA ) { -if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_SGMII )) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 2500baseX_Full); - } -if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_RGMII )) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseT_Half); - phylink_set(mask, 1000baseX_Full); - } -if (MTK_HAS_CAPS (mac->hw->soc->caps,MTK_GEPHY )) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseT_Half); - } - } -phylink_set (mask, Pause);phylink_set (mask, Asym_Pause);
Signature · 1 line
2.30.2
PATCH 3/4 net: mtk_eth_soc: 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/mediatek/mtk_eth_soc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +2 -6
@@ -477,8 +477,9 @@ static void mtk_validate(struct phylink_config *config, phylink_set(mask, 1000baseT_Full);break ;case PHY_INTERFACE_MODE_1000BASEX : -case PHY_INTERFACE_MODE_2500BASEX : phylink_set(mask, 1000baseX_Full); +break ; +case PHY_INTERFACE_MODE_2500BASEX : phylink_set(mask, 2500baseX_Full);break ;case PHY_INTERFACE_MODE_GMII :
@@ -508,11 +509,6 @@ static void mtk_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 const struct phylink_mac_ops mtk_phylink_ops = {
Signature · 1 line
2.30.2
PATCH 4/4 net: mtk_eth_soc: use phylink_generic_validate()
In reply to Russell King (Oracle)mtk_eth_soc has no special behaviour in its validation implementation, so can be switched to phylink_generic_validate().
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 53 ++------------------- 1 file changed, 4 insertions(+), 49 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4 -49
@@ -463,56 +463,8 @@ static void mtk_mac_link_up(struct phylink_config *config,mtk_w32 (mac->hw, mcr,MTK_MAC_MCR (mac->id)); } -static void mtk_validate (struct phylink_config *config, -unsigned long *supported, -struct phylink_link_state *state) -{ -__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; - -phylink_set_port_modes (mask); -phylink_set (mask, Autoneg); - -switch (state->interface) { -case PHY_INTERFACE_MODE_TRGMII : - phylink_set(mask, 1000baseT_Full); -break ; -case PHY_INTERFACE_MODE_1000BASEX : - phylink_set(mask, 1000baseX_Full); -break ; -case PHY_INTERFACE_MODE_2500BASEX : - phylink_set(mask, 2500baseX_Full); -break ; -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, 1000baseT_Half); - fallthrough; -case PHY_INTERFACE_MODE_SGMII : - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - fallthrough; -case PHY_INTERFACE_MODE_MII : -case PHY_INTERFACE_MODE_RMII : -case PHY_INTERFACE_MODE_REVMII : -default : - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); -break ; - } - -phylink_set (mask, Pause); -phylink_set (mask, Asym_Pause); - -linkmode_and (supported, supported, mask); -linkmode_and (state->advertising, state->advertising, mask); -} -static const struct phylink_mac_ops mtk_phylink_ops = { - .validate = mtk_validate, + .validate = phylink_generic_validate, .mac_pcs_get_state = mtk_mac_pcs_get_state, .mac_an_restart = mtk_mac_an_restart, .mac_config = mtk_mac_config,
@@ -2971,6 +2923,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type =PHYLINK_NETDEV ; + mac->phylink_config.mac_capabilities =MAC_ASYM_PAUSE |MAC_SYM_PAUSE | +MAC_10 |MAC_100 |MAC_1000 |MAC_2500FD ; +__set_bit (PHY_INTERFACE_MODE_MII , mac->phylink_config.supported_interfaces); __set_bit(PHY_INTERFACE_MODE_GMII,
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 8 lines · On Tue, 16 Nov 2021 10:06:23 +0000 you wrote:
Hi,
This series converts
mtk_eth_socto fill in thesupported_interfacesmember ofphylink_config, cleans up thevalidate()implementation, and then converts tophylink_generic_validate().drivers/net/ethernet/mediatek/mtk_eth_soc.c | 111 ++++++---------------------- 1 file changed, 24 insertions(+), 87 deletions(-)
Here is the summary with links:
- [net-next,1/4] net: mtk_eth_soc: populate supported_interfaces member
https://git.kernel.org/netdev/net-next/c/83800d29f0c5 - [net-next,2/4] net: mtk_eth_soc: remove interface checks in mtk_validate() https://git.kernel.org/netdev/net-next/c/db81ca153814 - [net-next,3/4] net: mtk_eth_soc: drop use of phylink_helper_basex_speed() https://git.kernel.org/netdev/net-next/c/71d927494463 - [net-next,4/4] net: mtk_eth_soc: use phylink_generic_validate() https://git.kernel.org/netdev/net-next/c/a4238f6ce151
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html