1 From 9c50139727265c088f936e496777bf588850e9f1 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Mon, 12 Feb 2024 19:59:26 +0100
4 Subject: [PATCH] r8169: add support for returning tx_lpi_timer in
7 Add support for returning the tx_lpi_timer value to userspace.
8 This is supported by few chip versions only: RTL8168h/RTL8125/RTL8126
10 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
11 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
12 Link: https://lore.kernel.org/r/4eee9c34-c5d6-4c96-9b05-455896dea59a@gmail.com
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 drivers/net/ethernet/realtek/r8169_main.c | 22 +++++++++++++++++++++-
16 1 file changed, 21 insertions(+), 1 deletion(-)
18 --- a/drivers/net/ethernet/realtek/r8169_main.c
19 +++ b/drivers/net/ethernet/realtek/r8169_main.c
20 @@ -2103,14 +2103,34 @@ static void rtl_set_eee_txidle_timer(str
24 +static unsigned int r8169_get_tx_lpi_timer_us(struct rtl8169_private *tp)
26 + unsigned int speed = tp->phydev->speed;
27 + unsigned int timer = tp->tx_lpi_timer;
29 + if (!timer || speed == SPEED_UNKNOWN)
32 + /* tx_lpi_timer value is in bytes */
33 + return DIV_ROUND_CLOSEST(timer * BITS_PER_BYTE, speed);
36 static int rtl8169_get_eee(struct net_device *dev, struct ethtool_eee *data)
38 struct rtl8169_private *tp = netdev_priv(dev);
41 if (!rtl_supports_eee(tp))
44 - return phy_ethtool_get_eee(tp->phydev, data);
45 + ret = phy_ethtool_get_eee(tp->phydev, data);
49 + data->tx_lpi_timer = r8169_get_tx_lpi_timer_us(tp);
50 + data->tx_lpi_enabled = data->tx_lpi_timer ? data->eee_enabled : false;
55 static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data)