1 From 2ce30993831041b9dcd31eb12896be6611e8b7e2 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Mon, 12 Feb 2024 19:57:46 +0100
4 Subject: [PATCH] r8169: add generic rtl_set_eee_txidle_timer function
6 Add a generic setter for the EEE tx idle timer and use it with all
7 RTL8125/RTL8126 chip versions, in line with the vendor driver.
8 This prepares for adding EEE tx idle timer support for additional
11 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Link: https://lore.kernel.org/r/39beed72-0dc4-4c45-8899-b72c43ab62a7@gmail.com
14 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++++++++----------
17 1 file changed, 20 insertions(+), 14 deletions(-)
19 --- a/drivers/net/ethernet/realtek/r8169_main.c
20 +++ b/drivers/net/ethernet/realtek/r8169_main.c
21 @@ -619,6 +619,7 @@ struct rtl8169_private {
22 struct page *Rx_databuff[NUM_RX_DESC]; /* Rx data buffers */
23 struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */
29 @@ -2054,6 +2055,22 @@ static int rtl_set_coalesce(struct net_d
33 +static void rtl_set_eee_txidle_timer(struct rtl8169_private *tp)
35 + unsigned int timer_val = READ_ONCE(tp->dev->mtu) + ETH_HLEN + 0x20;
37 + switch (tp->mac_version) {
38 + case RTL_GIGA_MAC_VER_61:
39 + case RTL_GIGA_MAC_VER_63:
40 + case RTL_GIGA_MAC_VER_65:
41 + tp->tx_lpi_timer = timer_val;
42 + RTL_W16(tp, EEE_TXIDLE_TIMER_8125, timer_val);
49 static int rtl8169_get_eee(struct net_device *dev, struct ethtool_eee *data)
51 struct rtl8169_private *tp = netdev_priv(dev);
52 @@ -2312,14 +2329,8 @@ static void rtl8125a_config_eee_mac(stru
53 r8168_mac_ocp_modify(tp, 0xeb62, 0, BIT(2) | BIT(1));
56 -static void rtl8125_set_eee_txidle_timer(struct rtl8169_private *tp)
58 - RTL_W16(tp, EEE_TXIDLE_TIMER_8125, tp->dev->mtu + ETH_HLEN + 0x20);
61 static void rtl8125b_config_eee_mac(struct rtl8169_private *tp)
63 - rtl8125_set_eee_txidle_timer(tp);
64 r8168_mac_ocp_modify(tp, 0xe040, 0, BIT(1) | BIT(0));
67 @@ -3852,6 +3863,8 @@ static void rtl_hw_start(struct rtl8169
68 rtl_hw_aspm_clkreq_enable(tp, false);
69 RTL_W16(tp, CPlusCmd, tp->cp_cmd);
71 + rtl_set_eee_txidle_timer(tp);
73 if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
74 rtl_hw_start_8169(tp);
75 else if (rtl_is_8125(tp))
76 @@ -3885,14 +3898,7 @@ static int rtl8169_change_mtu(struct net
78 netdev_update_features(dev);
81 - switch (tp->mac_version) {
82 - case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_65:
83 - rtl8125_set_eee_txidle_timer(tp);
88 + rtl_set_eee_txidle_timer(tp);