1 From 7a3bcd39ae1f0e3ab896d9df62339ab4297a0bfd Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Sat, 9 Nov 2024 23:12:12 +0100
4 Subject: [PATCH] r8169: use helper r8169_mod_reg8_cond to simplify
7 Use recently added helper r8169_mod_reg8_cond() to simplify jumbo
10 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
11 Reviewed-by: Simon Horman <horms@kernel.org>
12 Link: https://patch.msgid.link/3df1d484-a02e-46e7-8f75-db5b428e422e@gmail.com
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 drivers/net/ethernet/realtek/r8169_main.c | 77 ++++-------------------
16 1 file changed, 11 insertions(+), 66 deletions(-)
18 --- a/drivers/net/ethernet/realtek/r8169_main.c
19 +++ b/drivers/net/ethernet/realtek/r8169_main.c
20 @@ -2547,86 +2547,31 @@ static void rtl8169_init_ring_indexes(st
21 tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0;
24 -static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp)
26 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0);
27 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) | Jumbo_En1);
30 -static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp)
32 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0);
33 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~Jumbo_En1);
36 -static void r8168dp_hw_jumbo_enable(struct rtl8169_private *tp)
38 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0);
41 -static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp)
43 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0);
46 -static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
48 - RTL_W8(tp, MaxTxPacketSize, 0x24);
49 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0);
50 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) | 0x01);
53 -static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
55 - RTL_W8(tp, MaxTxPacketSize, 0x3f);
56 - RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0);
57 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~0x01);
60 -static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp)
62 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) | (1 << 0));
65 -static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
67 - RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0));
70 static void rtl_jumbo_config(struct rtl8169_private *tp)
72 bool jumbo = tp->dev->mtu > ETH_DATA_LEN;
75 + if (jumbo && tp->mac_version >= RTL_GIGA_MAC_VER_17 &&
76 + tp->mac_version <= RTL_GIGA_MAC_VER_26)
79 rtl_unlock_config_regs(tp);
80 switch (tp->mac_version) {
81 case RTL_GIGA_MAC_VER_17:
84 - r8168b_1_hw_jumbo_enable(tp);
86 - r8168b_1_hw_jumbo_disable(tp);
88 + r8169_mod_reg8_cond(tp, Config4, BIT(0), jumbo);
90 case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26:
93 - r8168c_hw_jumbo_enable(tp);
95 - r8168c_hw_jumbo_disable(tp);
97 + r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo);
98 + r8169_mod_reg8_cond(tp, Config4, Jumbo_En1, jumbo);
100 case RTL_GIGA_MAC_VER_28:
102 - r8168dp_hw_jumbo_enable(tp);
104 - r8168dp_hw_jumbo_disable(tp);
105 + r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo);
107 case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33:
109 - r8168e_hw_jumbo_enable(tp);
111 - r8168e_hw_jumbo_disable(tp);
112 + RTL_W8(tp, MaxTxPacketSize, jumbo ? 0x24 : 0x3f);
113 + r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo);
114 + r8169_mod_reg8_cond(tp, Config4, BIT(0), jumbo);