net: phy: switch eee_broken_modes to linkmode bitmap and add accessor
Heiner Kallweit
maintainercover net: phy: switch eee_broken_modes to linkmode bitmap and add accessor
eee_broken_modes has a eee_cap1 register layout currently. This doen't allow to flag e.g. 2.5Gbps or 5Gbps BaseT EEE as broken. To overcome this limitation switch eee_broken_modes to a linkmode bitmap. Add an accessor for the bitmap and use it in r8169.
Heiner Kallweit (3):
net: phy: convert eee_broken_modes to a linkmode bitmap
net: phy: add phy_set_eee_broken
r8169: copy vendor driver 2.5G/5G EEE advertisement constraints
drivers/net/ethernet/realtek/r8169_main.c | 6 ++++ .../net/ethernet/realtek/r8169_phy_config.c | 16 +++------ drivers/net/phy/micrel.c | 2 +- drivers/net/phy/phy-c45.c | 12 +++---- drivers/net/phy/phy-core.c | 34 +++++++++++++------ include/linux/phy.h | 10 +++--- 6 files changed, 44 insertions(+), 36 deletions(-)
Signature · 1 line
2.47.0
Heiner Kallweit
maintainerPATCH 1/3 net: phy: convert eee_broken_modes to a linkmode bitmap
eee_broken_modes has a eee_cap1 register layout currently. This doen't allow to flag e.g. 2.5Gbps or 5Gbps BaseT EEE as broken. To overcome this limitation switch eee_broken_modes to a linkmode bitmap.
--- drivers/net/phy/micrel.c | 2 +- drivers/net/phy/phy-c45.c | 12 +++++------- drivers/net/phy/phy-core.c | 21 +++++++++------------ include/linux/phy.h | 9 ++++----- 4 files changed, 19 insertions(+), 25 deletions(-)
drivers/net/phy/micrel.c +1 -1
@@ -2004,7 +2004,7 @@ static int ksz9477_config_init(struct phy_device *phydev)* in this switch shall be regarded as broken. */ if (phydev->dev_flags &MICREL_NO_EEE ) - phydev->eee_broken_modes =-1 ; +linkmode_fill (phydev->eee_broken_modes);return kszphy_config_init (phydev); }
drivers/net/phy/phy-c45.c +5 -7
@@ -683,15 +683,13 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_mdix);static int genphy_c45_write_eee_adv (struct phy_device *phydev,unsigned long *adv) { +__ETHTOOL_DECLARE_LINK_MODE_MASK (tmp);int val, changed =0 ; -if (linkmode_intersects (phydev->supported_eee,PHY_EEE_CAP1_FEATURES )) { - val =linkmode_to_mii_eee_cap1_t (adv); +linkmode_andnot (tmp, adv, phydev->eee_broken_modes); -/* In eee_broken_modes are stored MDIO_AN_EEE_ADV specific raw -* register values. -*/ - val &= ~phydev->eee_broken_modes; +if (linkmode_intersects (phydev->supported_eee,PHY_EEE_CAP1_FEATURES )) { + val =linkmode_to_mii_eee_cap1_t (tmp);/* IEEE 802.3-2018 45.2.7.13 EEE advertisement 1 * (Register 7.60)
@@ -709,7 +707,7 @@ static int genphy_c45_write_eee_adv(struct phy_device *phydev, }if (linkmode_intersects (phydev->supported_eee,PHY_EEE_CAP2_FEATURES )) { - val =linkmode_to_mii_eee_cap2_t (adv); + val =linkmode_to_mii_eee_cap2_t (tmp);/* IEEE 802.3-2022 45.2.7.16 EEE advertisement 2 * (Register 7.62)
drivers/net/phy/phy-core.c +9 -12
@@ -388,28 +388,25 @@ void of_set_phy_supported(struct phy_device *phydev)void of_set_phy_eee_broken (struct phy_device *phydev) {struct device_node *node = phydev->mdio.dev.of_node; -u32 broken =0 ; +unsigned long *modes = phydev->eee_broken_modes; -if (!IS_ENABLED (CONFIG_OF_MDIO )) +if (!IS_ENABLED (CONFIG_OF_MDIO ) || !node)return ; -if (!node) -return ; +linkmode_zero (modes);if (of_property_read_bool (node,"eee-broken-100tx" )) - broken |=MDIO_EEE_100TX ; +linkmode_set_bit (ETHTOOL_LINK_MODE_100baseT_Full_BIT, modes);if (of_property_read_bool (node,"eee-broken-1000t" )) - broken |=MDIO_EEE_1000T ; +linkmode_set_bit (ETHTOOL_LINK_MODE_1000baseT_Full_BIT, modes);if (of_property_read_bool (node,"eee-broken-10gt" )) - broken |=MDIO_EEE_10GT ; +linkmode_set_bit (ETHTOOL_LINK_MODE_10000baseT_Full_BIT, modes);if (of_property_read_bool (node,"eee-broken-1000kx" )) - broken |=MDIO_EEE_1000KX ; +linkmode_set_bit (ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, modes);if (of_property_read_bool (node,"eee-broken-10gkx4" )) - broken |=MDIO_EEE_10GKX4 ; +linkmode_set_bit (ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, modes);if (of_property_read_bool (node,"eee-broken-10gkr" )) - broken |=MDIO_EEE_10GKR ; - - phydev->eee_broken_modes = broken; +linkmode_set_bit (ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, modes); }/**
include/linux/phy.h +4 -5
@@ -721,16 +721,15 @@ struct phy_device {/* used for eee validation and configuration*/ __ETHTOOL_DECLARE_LINK_MODE_MASK (supported_eee);__ETHTOOL_DECLARE_LINK_MODE_MASK (advertising_eee); +/* Energy efficient ethernet modes which should be prohibited */ +__ETHTOOL_DECLARE_LINK_MODE_MASK (eee_broken_modes);bool eee_enabled; +bool enable_tx_lpi; +struct eee_config eee_cfg;/* Host supported PHY interface types. Should be ignored if empty. */ DECLARE_PHY_INTERFACE_MASK (host_interfaces); -/* Energy efficient ethernet modes which should be prohibited */ -u32 eee_broken_modes; -bool enable_tx_lpi; -struct eee_config eee_cfg; -#ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers;unsigned int phy_num_led_triggers;
Signature · 1 line
2.47.0
Heiner Kallweit
maintainerPATCH 2/3 net: phy: add phy_set_eee_broken
In reply to Heiner KallweitAdd an accessor for eee_broken_modes, so that drivers don't have to deal with phylib internals.
--- include/linux/phy.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/phy.h +10 -0
@@ -1263,6 +1263,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev);void of_set_phy_timing_role (struct phy_device *phydev);int phy_speed_down_core (struct phy_device *phydev); +/** +* phy_set_eee_broken - Mark an EEE mode as broken so that it isn't advertised. +* @phydev: The phy_device struct +* @link_mode: The broken EEE mode +*/ +static inline void phy_set_eee_broken (struct phy_device *phydev,u32 link_mode) +{ +linkmode_set_bit (link_mode, phydev->eee_broken_modes); +} +/** * phy_is_started - Convenience function to check whether PHY is started * @phydev: The phy_device struct
Signature · 1 line
2.47.0
Heiner Kallweit
maintainerPATCH 3/3 r8169: copy vendor driver 2.5G/5G EEE advertisement constraints
In reply to Heiner KallweitVendor driver r8125 doesn't advertise 2.5G EEE on RTL8125A, and r8126 doesn't advertise 5G EEE. Likely there are compatibility issues, therefore do the same in r8169.
With this change we don't have to disable 2.5G EEE advertisement in rtl8125a_config_eee_phy() any longer.
We use new phylib accessor phy_set_eee_broken() to mark the respective EEE modes as broken.
--- drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ drivers/net/ethernet/realtek/r8169_phy_config.c | 16 ++++------------ 2 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +6 -0
@@ -5295,6 +5295,12 @@ static int r8169_mdio_register(struct rtl8169_private *tp)phy_support_eee (tp->phydev);phy_support_asym_pause (tp->phydev); +/* mimic behavior of r8125/r8126 vendor drivers */ +if (tp->mac_version ==RTL_GIGA_MAC_VER_61 ) +phy_set_eee_broken (tp->phydev, + ETHTOOL_LINK_MODE_2500baseT_Full_BIT); +phy_set_eee_broken (tp->phydev, ETHTOOL_LINK_MODE_5000baseT_Full_BIT); +/* PHY will be woken up in rtl_open() */ phy_suspend (tp->phydev);
drivers/net/ethernet/realtek/r8169_phy_config.c +4 -12
@@ -96,15 +96,7 @@ static void rtl8125_common_config_eee_phy(struct phy_device *phydev)phy_modify_paged (phydev,0xa4a ,0x11 ,0x0200 ,0x0000 ); } -static void rtl8125a_config_eee_phy (struct phy_device *phydev) -{ -rtl8168g_config_eee_phy (phydev); -/* disable EEE at 2.5Gbps */ -phy_modify_paged (phydev,0xa6d ,0x12 ,0x0001 ,0x0000 ); -rtl8125_common_config_eee_phy (phydev); -} - -static void rtl8125b_config_eee_phy (struct phy_device *phydev) +static void rtl8125_config_eee_phy (struct phy_device *phydev) {rtl8168g_config_eee_phy (phydev);rtl8125_common_config_eee_phy (phydev);
@@ -1066,7 +1058,7 @@ static void rtl8125a_2_hw_phy_config(struct rtl8169_private *tp,rtl8168g_enable_gphy_10m (phydev);rtl8168g_disable_aldps (phydev); -rtl8125a_config_eee_phy (phydev); +rtl8125_config_eee_phy (phydev); } static void rtl8125b_hw_phy_config(struct rtl8169_private *tp,
@@ -1106,7 +1098,7 @@ static void rtl8125b_hw_phy_config(struct rtl8169_private *tp,rtl8125_legacy_force_mode (phydev);rtl8168g_disable_aldps (phydev); -rtl8125b_config_eee_phy (phydev); +rtl8125_config_eee_phy (phydev); } static void rtl8125d_hw_phy_config(struct rtl8169_private *tp,
@@ -1116,7 +1108,7 @@ static void rtl8125d_hw_phy_config(struct rtl8169_private *tp,rtl8168g_enable_gphy_10m (phydev);rtl8125_legacy_force_mode (phydev);rtl8168g_disable_aldps (phydev); -rtl8125b_config_eee_phy (phydev); +rtl8125_config_eee_phy (phydev); } static void rtl8126a_hw_phy_config(struct rtl8169_private *tp,
Signature · 1 line
2.47.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Fri, 8 Nov 2024 07:53:17 +0100 you wrote:
eee_broken_modeshas aeee_cap1register layout currently. This doen't allow to flag e.g. 2.5Gbps or 5Gbps BaseT EEE as broken. To overcome this limitation switcheee_broken_modesto a linkmode bitmap. Add an accessor for the bitmap and use it in r8169.Heiner Kallweit (3):
net: phy: converteee_broken_modesto a linkmode bitmap
net: phy: addphy_set_eee_broken
r8169: copy vendor driver 2.5G/5G EEE advertisement constraints[...]
Here is the summary with links:
- [net-next,1/3] net: phy: convert eee_broken_modes to a linkmode bitmap
https://git.kernel.org/netdev/net-next/c/721aa69e708b - [net-next,2/3] net: phy: add phy_set_eee_broken https://git.kernel.org/netdev/net-next/c/ed623fb8e38e - [net-next,3/3] r8169: copy vendor driver 2.5G/5G EEE advertisement constraints https://git.kernel.org/netdev/net-next/c/e340bff27e63
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html