r8169: remove fiddling with the PCIe max read request size
Heiner Kallweit
maintainercover r8169: remove fiddling with the PCIe max read request size
The attempt to improve performance by changing the PCIe max read request size was added in the vendor driver more than 10 years back and copied to r8169 driver. In the vendor driver this has been removed long ago. Obviously it had no effect, also in my tests I didn't see any difference. Typically the max payload size is less than 512 bytes anyway, and the PCI core takes care that the maximum supported value is set. So let's remove fiddling with PCIe max read request size from r8169 too. This change allows to simplify the driver in the subsequent three patches of this series.
Heiner Kallweit (4):
r8169: remove fiddling with the PCIe max read request size
r8169: simplify setting PCI_EXP_DEVCTL_NOSNOOP_EN
r8169: remove rtl_hw_start_8168dp
r8169: remove rtl_hw_start_8168bef
drivers/net/ethernet/realtek/r8169_main.c | 90 ++++------------------- 1 file changed, 15 insertions(+), 75 deletions(-)
Signature · 1 line
2.23.0
Heiner Kallweit
maintainerPATCH 1/4 r8169: remove fiddling with the PCIe max read request size
The attempt to improve performance by changing the PCIe max read request size was added in the vendor driver more than 10 years back and copied to r8169 driver. In the vendor driver this has been removed long ago. Obviously it had no effect, also in my tests I didn't see any difference. Typically the max payload size is less than 512 bytes anyway, and the PCI core takes care that the maximum supported value is set. So let's remove fiddling with PCIe max read request size from r8169 too.
--- drivers/net/ethernet/realtek/r8169_main.c | 40 +++-------------------- 1 file changed, 4 insertions(+), 36 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +4 -36
@@ -741,12 +741,6 @@ static void rtl_unlock_config_regs(struct rtl8169_private *tp)RTL_W8 (tp, Cfg9346, Cfg9346_Unlock); } -static void rtl_tx_performance_tweak (struct rtl8169_private *tp,u16 force) -{ -pcie_capability_clear_and_set_word (tp->pci_dev,PCI_EXP_DEVCTL , -PCI_EXP_DEVCTL_READRQ , force); -} -static bool rtl_is_8125 (struct rtl8169_private *tp) {return tp->mac_version >=RTL_GIGA_MAC_VER_60 ;
@@ -4032,14 +4026,12 @@ static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp) {RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) | Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) | Jumbo_En1); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_512B ); }static void r8168c_hw_jumbo_disable (struct rtl8169_private *tp) {RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~Jumbo_En1); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); }static void r8168dp_hw_jumbo_enable (struct rtl8169_private *tp)
@@ -4057,7 +4049,6 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)RTL_W8 (tp, MaxTxPacketSize,0x3f );RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) | Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) |0x01 ); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_512B ); }static void r8168e_hw_jumbo_disable (struct rtl8169_private *tp)
@@ -4065,19 +4056,18 @@ static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)RTL_W8 (tp, MaxTxPacketSize,0x0c );RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Jumbo_En0);RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~0x01 ); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); }static void r8168b_0_hw_jumbo_enable (struct rtl8169_private *tp) { -rtl_tx_performance_tweak (tp, -PCI_EXP_DEVCTL_READRQ_512B |PCI_EXP_DEVCTL_NOSNOOP_EN ); +pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL , +PCI_EXP_DEVCTL_NOSNOOP_EN ); }static void r8168b_0_hw_jumbo_disable (struct rtl8169_private *tp) { -rtl_tx_performance_tweak (tp, -PCI_EXP_DEVCTL_READRQ_4096B |PCI_EXP_DEVCTL_NOSNOOP_EN ); +pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL , +PCI_EXP_DEVCTL_NOSNOOP_EN ); }static void r8168b_1_hw_jumbo_enable (struct rtl8169_private *tp)
@@ -4550,18 +4540,12 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)rtl_set_def_aspm_entry_latency (tp);rtl_disable_clock_request (tp); - -if (tp->dev->mtu <=ETH_DATA_LEN ) -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); }static void rtl_hw_start_8168dp (struct rtl8169_private *tp) {rtl_set_def_aspm_entry_latency (tp); -if (tp->dev->mtu <=ETH_DATA_LEN ) -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_disable_clock_request (tp); }
@@ -4576,8 +4560,6 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_ephy_init (tp, e_info_8168d_4);rtl_enable_clock_request (tp);
@@ -4652,8 +4634,6 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp) {rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_eri_write (tp,0xc0 ,ERIAR_MASK_0011 ,0x0000 );rtl_eri_write (tp,0xb8 ,ERIAR_MASK_0011 ,0x0000 );rtl_set_fifo_size (tp,0x10 ,0x10 ,0x02 ,0x06 );
@@ -4716,8 +4696,6 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_reset_packet_filter (tp);rtl_eri_write (tp,0x2f8 ,ERIAR_MASK_0011 ,0x1d8f );
@@ -4954,8 +4932,6 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_reset_packet_filter (tp);rtl_eri_set_bits (tp,0xdc ,ERIAR_MASK_1111 ,BIT (4 ));
@@ -5013,8 +4989,6 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp)rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_reset_packet_filter (tp);rtl_eri_set_bits (tp,0xd4 ,ERIAR_MASK_1111 ,0x1f80 );
@@ -5117,8 +5091,6 @@ static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)RTL_W8 (tp,DBG_REG ,FIX_NAK_1 ); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -RTL_W8 (tp, Config1,LEDS1 |LEDS0 | Speed_down |MEMMAP |IOMAP |VPD | PMEnable);RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Beacon_en);
@@ -5134,8 +5106,6 @@ static void rtl_hw_start_8102e_2(struct rtl8169_private *tp) {rtl_set_def_aspm_entry_latency (tp); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -RTL_W8 (tp, Config1,MEMMAP |IOMAP |VPD | PMEnable);RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Beacon_en); }
@@ -5196,8 +5166,6 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)rtl_ephy_init (tp, e_info_8402); -rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -rtl_set_fifo_size (tp,0x00 ,0x00 ,0x02 ,0x06 );rtl_reset_packet_filter (tp);rtl_eri_write (tp,0xc0 ,ERIAR_MASK_0011 ,0x0000 );
Signature · 1 line
2.23.0
Heiner Kallweit
maintainerPATCH 2/4 r8169: simplify setting PCI_EXP_DEVCTL_NOSNOOP_EN
In reply to Heiner Kallweitr8168b_0_hw_jumbo_enable() and r8168b_0_hw_jumbo_disable() both do the same and just set PCI_EXP_DEVCTL_NOSNOOP_EN. We can simplify the code by moving this setting for RTL8168B to rtl_hw_start_8168().
--- drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++---------------- 1 file changed, 10 insertions(+), 24 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +10 -24
@@ -4058,29 +4058,13 @@ static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~0x01 ); } -static void r8168b_0_hw_jumbo_enable (struct rtl8169_private *tp) -{ -pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL , -PCI_EXP_DEVCTL_NOSNOOP_EN ); -} - -static void r8168b_0_hw_jumbo_disable (struct rtl8169_private *tp) -{ -pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL , -PCI_EXP_DEVCTL_NOSNOOP_EN ); -} -static void r8168b_1_hw_jumbo_enable (struct rtl8169_private *tp) { -r8168b_0_hw_jumbo_enable (tp); -RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) | (1 <<0 )); }static void r8168b_1_hw_jumbo_disable (struct rtl8169_private *tp) { -r8168b_0_hw_jumbo_disable (tp); -RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~(1 <<0 )); }
@@ -4088,9 +4072,6 @@ static void rtl_hw_jumbo_enable(struct rtl8169_private *tp) {rtl_unlock_config_regs (tp);switch (tp->mac_version) { -case RTL_GIGA_MAC_VER_11 : -r8168b_0_hw_jumbo_enable (tp); -break ;case RTL_GIGA_MAC_VER_12 :case RTL_GIGA_MAC_VER_17 :r8168b_1_hw_jumbo_enable (tp);
@@ -4114,9 +4095,6 @@ static void rtl_hw_jumbo_disable(struct rtl8169_private *tp) {rtl_unlock_config_regs (tp);switch (tp->mac_version) { -case RTL_GIGA_MAC_VER_11 : -r8168b_0_hw_jumbo_disable (tp); -break ;case RTL_GIGA_MAC_VER_12 :case RTL_GIGA_MAC_VER_17 :r8168b_1_hw_jumbo_disable (tp);
@@ -5381,10 +5359,18 @@ static void rtl_hw_start_8125(struct rtl8169_private *tp)static void rtl_hw_start_8168 (struct rtl8169_private *tp) { -if (tp->mac_version ==RTL_GIGA_MAC_VER_13 || - tp->mac_version ==RTL_GIGA_MAC_VER_16 ) +switch (tp->mac_version) { +case RTL_GIGA_MAC_VER_11 : +case RTL_GIGA_MAC_VER_12 : +case RTL_GIGA_MAC_VER_13 : +case RTL_GIGA_MAC_VER_16 : +case RTL_GIGA_MAC_VER_17 :pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL ,PCI_EXP_DEVCTL_NOSNOOP_EN ); +break ; +default : +break ; + }if (rtl_is_8168evl_up (tp))RTL_W8 (tp, MaxTxPacketSize, EarlySize);
Signature · 1 line
2.23.0
Heiner Kallweit
maintainerPATCH 3/4 r8169: remove rtl_hw_start_8168dp
In reply to Heiner KallweitWe can remove rtl_hw_start_8168dp() because it's the same as rtl_hw_start_8168dp() now.
--- drivers/net/ethernet/realtek/r8169_main.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -8
@@ -4520,13 +4520,6 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)rtl_disable_clock_request (tp); } -static void rtl_hw_start_8168dp (struct rtl8169_private *tp) -{ -rtl_set_def_aspm_entry_latency (tp); - -rtl_disable_clock_request (tp); -} -static void rtl_hw_start_8168d_4 (struct rtl8169_private *tp) {static const struct ephy_info e_info_8168d_4[] = {
@@ -5317,7 +5310,7 @@ static void rtl_hw_config(struct rtl8169_private *tp) [RTL_GIGA_MAC_VER_28] = rtl_hw_start_8168d_4, [RTL_GIGA_MAC_VER_29] = rtl_hw_start_8105e_1, [RTL_GIGA_MAC_VER_30] = rtl_hw_start_8105e_2, - [RTL_GIGA_MAC_VER_31] = rtl_hw_start_8168dp, + [RTL_GIGA_MAC_VER_31] = rtl_hw_start_8168d, [RTL_GIGA_MAC_VER_32] = rtl_hw_start_8168e_1, [RTL_GIGA_MAC_VER_33] = rtl_hw_start_8168e_1, [RTL_GIGA_MAC_VER_34] = rtl_hw_start_8168e_2,
Signature · 1 line
2.23.0
Heiner Kallweit
maintainerPATCH 4/4 r8169: remove rtl_hw_start_8168bef
In reply to Heiner KallweitWe can remove rtl_hw_start_8168bef() and use rtl_hw_start_8168b() instead because setting register Config4 is done in rtl_jumbo_config(), being called from rtl_hw_start().
--- drivers/net/ethernet/realtek/r8169_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +4 -11
@@ -4415,18 +4415,11 @@ static void rtl8168g_set_pause_thresholds(struct rtl8169_private *tp,rtl_eri_write (tp,0xd0 ,ERIAR_MASK_0001 , high); } -static void rtl_hw_start_8168bb (struct rtl8169_private *tp) +static void rtl_hw_start_8168b (struct rtl8169_private *tp) {RTL_W8 (tp, Config3,RTL_R8 (tp, Config3) & ~Beacon_en); } -static void rtl_hw_start_8168bef (struct rtl8169_private *tp) -{ -rtl_hw_start_8168bb (tp); - -RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~(1 <<0 )); -} -static void __rtl_hw_start_8168cp (struct rtl8169_private *tp) {RTL_W8 (tp, Config1,RTL_R8 (tp, Config1) | Speed_down);
@@ -5290,13 +5283,13 @@ static void rtl_hw_config(struct rtl8169_private *tp) [RTL_GIGA_MAC_VER_08] = rtl_hw_start_8102e_3, [RTL_GIGA_MAC_VER_09] = rtl_hw_start_8102e_2, [RTL_GIGA_MAC_VER_10] = NULL, - [RTL_GIGA_MAC_VER_11] = rtl_hw_start_8168bb, - [RTL_GIGA_MAC_VER_12] = rtl_hw_start_8168bef, + [RTL_GIGA_MAC_VER_11] = rtl_hw_start_8168b, + [RTL_GIGA_MAC_VER_12] = rtl_hw_start_8168b, [RTL_GIGA_MAC_VER_13] = NULL, [RTL_GIGA_MAC_VER_14] = NULL, [RTL_GIGA_MAC_VER_15] = NULL, [RTL_GIGA_MAC_VER_16] = NULL, - [RTL_GIGA_MAC_VER_17] = rtl_hw_start_8168bef, + [RTL_GIGA_MAC_VER_17] = rtl_hw_start_8168b, [RTL_GIGA_MAC_VER_18] = rtl_hw_start_8168cp_1, [RTL_GIGA_MAC_VER_19] = rtl_hw_start_8168c_1, [RTL_GIGA_MAC_VER_20] = rtl_hw_start_8168c_2,
Signature · 1 line
2.23.0
Jakub Kicinski
AppliedQuoted 9 lines · Heiner Kallweit
The attempt to improve performance by changing the PCIe max read request size was added in the vendor driver more than 10 years back and copied to r8169 driver. In the vendor driver this has been removed long ago. Obviously it had no effect, also in my tests I didn't see any difference. Typically the max payload size is less than 512 bytes anyway, and the PCI core takes care that the maximum supported value is set. So let's remove fiddling with PCIe max read request size from r8169 too. This change allows to simplify the driver in the subsequent three patches of this series.
Applied, thanks!