r8169: extend EEE tx idle timer support
Heiner Kallweit
maintainercover r8169: extend EEE tx idle timer support
This series extends EEE tx idle timer support, and exposes the timer value to userspace.
Heiner Kallweit (3):
r8169: add generic rtl_set_eee_txidle_timer function
r8169: support setting the EEE tx idle timer on RTL8168h
r8169: add support for returning tx_lpi_timer in ethtool get_eee
drivers/net/ethernet/realtek/r8169_main.c | 61 +++++++++++++++++------ 1 file changed, 46 insertions(+), 15 deletions(-)
Signature · 1 line
2.43.1
Heiner Kallweit
maintainerPATCH 1/3 r8169: add generic rtl_set_eee_txidle_timer function
Add a generic setter for the EEE tx idle timer and use it with all RTL8125/RTL8126 chip versions, in line with the vendor driver. This prepares for adding EEE tx idle timer support for additional chip versions.
--- drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++++++++---------- 1 file changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +20 -14
@@ -619,6 +619,7 @@ struct rtl8169_private {struct page *Rx_databuff[NUM_RX_DESC ];/* Rx data buffers */ struct ring_info tx_skb[NUM_TX_DESC ];/* Tx data buffers */ u16 cp_cmd; +u16 tx_lpi_timer;u32 irq_mask;int irq;struct clk *clk;
@@ -2031,6 +2032,22 @@ static int rtl_set_coalesce(struct net_device *dev,return 0 ; } +static void rtl_set_eee_txidle_timer (struct rtl8169_private *tp) +{ +unsigned int timer_val =READ_ONCE (tp->dev->mtu) +ETH_HLEN +0x20 ; + +switch (tp->mac_version) { +case RTL_GIGA_MAC_VER_61 : +case RTL_GIGA_MAC_VER_63 : +case RTL_GIGA_MAC_VER_65 : + tp->tx_lpi_timer = timer_val; +RTL_W16 (tp,EEE_TXIDLE_TIMER_8125 , timer_val); +break ; +default : +break ; + } +} +static int rtl8169_get_eee (struct net_device *dev,struct ethtool_keee *data) {struct rtl8169_private *tp =netdev_priv (dev);
@@ -2289,14 +2306,8 @@ static void rtl8125a_config_eee_mac(struct rtl8169_private *tp)r8168_mac_ocp_modify (tp,0xeb62 ,0 ,BIT (2 ) |BIT (1 )); } -static void rtl8125_set_eee_txidle_timer (struct rtl8169_private *tp) -{ -RTL_W16 (tp,EEE_TXIDLE_TIMER_8125 , tp->dev->mtu +ETH_HLEN +0x20 ); -} -static void rtl8125b_config_eee_mac (struct rtl8169_private *tp) { -rtl8125_set_eee_txidle_timer (tp);r8168_mac_ocp_modify (tp,0xe040 ,0 ,BIT (1 ) |BIT (0 )); }
@@ -3829,6 +3840,8 @@ static void rtl_hw_start(struct rtl8169_private *tp)rtl_hw_aspm_clkreq_enable (tp, false);RTL_W16 (tp, CPlusCmd, tp->cp_cmd); +rtl_set_eee_txidle_timer (tp); +if (tp->mac_version <=RTL_GIGA_MAC_VER_06 )rtl_hw_start_8169 (tp);else if (rtl_is_8125 (tp))
@@ -3862,14 +3875,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) dev->mtu = new_mtu;netdev_update_features (dev);rtl_jumbo_config (tp); - -switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_65: -rtl8125_set_eee_txidle_timer (tp); -break ; -default : -break ; - } +rtl_set_eee_txidle_timer (tp);return 0 ; }
Signature · 1 line
2.43.1
Re: [PATCH net-next 1/3] r8169: add generic rtl_set_eee_txidle_timer function
Quoted 6 lines · Heiner Kallweit
Add a generic setter for the EEE tx idle timer and use it with all RTL8125/RTL8126 chip versions, in line with the vendor driver. This prepares for adding EEE tx idle timer support for additional chip versions.
Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 2/3 r8169: support setting the EEE tx idle timer on RTL8168h
In reply to Heiner KallweitSupport setting the EEE tx idle timer also on RTL8168h.
--- drivers/net/ethernet/realtek/r8169_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +5 -0
@@ -2037,6 +2037,11 @@ static void rtl_set_eee_txidle_timer(struct rtl8169_private *tp)unsigned int timer_val =READ_ONCE (tp->dev->mtu) +ETH_HLEN +0x20 ;switch (tp->mac_version) { +case RTL_GIGA_MAC_VER_46 : +case RTL_GIGA_MAC_VER_48 : + tp->tx_lpi_timer = timer_val; +r8168_mac_ocp_write (tp,0xe048 , timer_val); +break ;case RTL_GIGA_MAC_VER_61 :case RTL_GIGA_MAC_VER_63 :case RTL_GIGA_MAC_VER_65 :
Signature · 1 line
2.43.1
Re: [PATCH net-next 2/3] r8169: support setting the EEE tx idle timer on RTL8168h
Quoted 3 lines · Heiner Kallweit
Support setting the EEE tx idle timer also on RTL8168h.
Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 3/3 r8169: add support for returning tx_lpi_timer in ethtool get_eee
In reply to Heiner KallweitAdd support for returning the tx_lpi_timer value to userspace. This is supported by few chip versions only: RTL8168h/RTL8125/RTL8126
--- drivers/net/ethernet/realtek/r8169_main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +21 -1
@@ -2053,14 +2053,34 @@ static void rtl_set_eee_txidle_timer(struct rtl8169_private *tp) } } +static unsigned int r8169_get_tx_lpi_timer_us (struct rtl8169_private *tp) +{ +unsigned int speed = tp->phydev->speed; +unsigned int timer = tp->tx_lpi_timer; + +if (!timer || speed ==SPEED_UNKNOWN ) +return 0 ; + +/* tx_lpi_timer value is in bytes */ +return DIV_ROUND_CLOSEST (timer *BITS_PER_BYTE , speed); +} +static int rtl8169_get_eee (struct net_device *dev,struct ethtool_keee *data) {struct rtl8169_private *tp =netdev_priv (dev); +int ret;if (!rtl_supports_eee (tp))return -EOPNOTSUPP ; -return phy_ethtool_get_eee (tp->phydev, data); + ret =phy_ethtool_get_eee (tp->phydev, data); +if (ret) +return ret; + + data->tx_lpi_timer =r8169_get_tx_lpi_timer_us (tp); + data->tx_lpi_enabled = data->tx_lpi_timer ? data->eee_enabled : false; + +return 0 ; }static int rtl8169_set_eee (struct net_device *dev,struct ethtool_keee *data)
Signature · 1 line
2.43.1
Re: [PATCH net-next 3/3] r8169: add support for returning tx_lpi_timer in ethtool get_eee
Quoted 4 lines · Heiner Kallweit
Add support for returning the
tx_lpi_timervalue to userspace. This is supported by few chip versions only: RTL8168h/RTL8125/RTL8126Signed-off-by Heiner Kallweit <[email protected]>
Andrew
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 9 lines · On Mon, 12 Feb 2024 19:57:09 +0100 you wrote:
This series extends EEE tx idle timer support, and exposes the timer value to userspace.
Heiner Kallweit (3):
r8169: add genericrtl_set_eee_txidle_timerfunction
r8169: support setting the EEE tx idle timer on RTL8168h
r8169: add support for returningtx_lpi_timerin ethtoolget_eee[...]
Here is the summary with links:
- [net-next,1/3] r8169: add generic rtl_set_eee_txidle_timer function
https://git.kernel.org/netdev/net-next/c/2ce309938310 - [net-next,2/3] r8169: support setting the EEE tx idle timer on RTL8168h https://git.kernel.org/netdev/net-next/c/57d2d2c8f132 - [net-next,3/3] r8169: add support for returning tx_lpi_timer in ethtool get_eee https://git.kernel.org/netdev/net-next/c/9c5013972726
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html