r8169: add and use helper rtl_is_8168evl_up
Heiner Kallweit
maintainercover r8169: add and use helper rtl_is_8168evl_up
Few registers have been added or changed its purpose with version RTL8168e-vl, so create a helper for identifying chip versions from RTL8168e-vl.
Heiner Kallweit (2):
r8169: add helper rtl_is_8168evl_up
r8169: use helper rtl_is_8168evl_up for setting register
MaxTxPacketSize
drivers/net/ethernet/realtek/r8169_main.c | 53 +++++++---------------- 1 file changed, 16 insertions(+), 37 deletions(-)
Signature · 1 line
2.22.0
Heiner Kallweit
maintainerPATCH 1/2 r8169: add helper rtl_is_8168evl_up
Add helper rtl_is_8168evl_up to make the code better readable and to simplify it.
--- drivers/net/ethernet/realtek/r8169_main.c | 29 ++++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +12 -17
@@ -724,6 +724,12 @@ static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force) PCI_EXP_DEVCTL_READRQ, force); } +static bool rtl_is_8168evl_up (struct rtl8169_private *tp) +{ +return tp->mac_version >=RTL_GIGA_MAC_VER_34 && + tp->mac_version !=RTL_GIGA_MAC_VER_39 ; +} +struct rtl_cond {bool (*check)(struct rtl8169_private *);const char *msg;
@@ -1389,9 +1395,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)rtl_unlock_config_regs (tp); -switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: - case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51: +if (rtl_is_8168evl_up (tp)) { tmp =ARRAY_SIZE (cfg) -1 ;if (wolopts &WAKE_MAGIC ) rtl_eri_set_bits(tp, 0x0dc, ERIAR_MASK_0100,
@@ -1399,10 +1403,8 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)else rtl_eri_clear_bits (tp,0x0dc ,ERIAR_MASK_0100 , MagicPacket_v2); -break ; -default : + }else { tmp =ARRAY_SIZE (cfg); -break ; }for (i =0 ; i < tmp; i++) {
@@ -4101,8 +4103,7 @@ static void rtl_set_tx_config_registers(struct rtl8169_private *tp)u32 val =TX_DMA_BURST << TxDMAShift | InterFrameGap << TxInterFrameGapShift; -if (tp->mac_version >=RTL_GIGA_MAC_VER_34 && - tp->mac_version !=RTL_GIGA_MAC_VER_39 ) +if (rtl_is_8168evl_up (tp)) val |=TXCFG_AUTO_FIFO ;RTL_W32 (tp, TxConfig, val);
@@ -6483,13 +6484,10 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)static void rtl_read_mac_address (struct rtl8169_private *tp,u8 mac_addr[ETH_ALEN ]) { -u32 value; -/* Get MAC address */ -switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_35 ... RTL_GIGA_MAC_VER_38: - case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51: - value =rtl_eri_read (tp,0xe0 ); +if (rtl_is_8168evl_up (tp) && tp->mac_version !=RTL_GIGA_MAC_VER_34 ) { +u32 value =rtl_eri_read (tp,0xe0 ); + mac_addr[0 ] = (value >>0 ) &0xff ; mac_addr[1 ] = (value >>8 ) &0xff ; mac_addr[2 ] = (value >>16 ) &0xff ;
@@ -6498,9 +6496,6 @@ static void rtl_read_mac_address(struct rtl8169_private *tp, value =rtl_eri_read (tp,0xe4 ); mac_addr[4 ] = (value >>0 ) &0xff ; mac_addr[5 ] = (value >>8 ) &0xff ; -break ; -default : -break ; } }
Signature · 1 line
2.22.0
Heiner Kallweit
maintainerPATCH 2/2 r8169: use helper rtl_is_8168evl_up for setting register MaxTxPacketSize
In reply to Heiner KallweitQuoted 1 line
From RTL8168e-vl the value in register MaxTxPacketSize is interpreted
differently, therefore use new helper rtl_is_8168evl_up to set this register.
--- drivers/net/ethernet/realtek/r8169_main.c | 24 ++++------------------- 1 file changed, 4 insertions(+), 20 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +4 -20
@@ -4331,8 +4331,6 @@ static void rtl_hw_start_8168bef(struct rtl8169_private *tp) {rtl_hw_start_8168bb (tp); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -RTL_W8 (tp, Config4,RTL_R8 (tp, Config4) & ~(1 <<0 )); }
@@ -4384,8 +4382,6 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)/* Magic. */ RTL_W8 (tp,DBG_REG ,0x20 ); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -if (tp->dev->mtu <=ETH_DATA_LEN )rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); }
@@ -4439,8 +4435,6 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)rtl_disable_clock_request (tp); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -if (tp->dev->mtu <=ETH_DATA_LEN )rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); }
@@ -4452,8 +4446,6 @@ static void rtl_hw_start_8168dp(struct rtl8169_private *tp)if (tp->dev->mtu <=ETH_DATA_LEN )rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -rtl_disable_clock_request (tp); }
@@ -4469,8 +4461,6 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -rtl_ephy_init (tp, e_info_8168d_4);rtl_enable_clock_request (tp);
@@ -4501,8 +4491,6 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)if (tp->dev->mtu <=ETH_DATA_LEN )rtl_tx_performance_tweak (tp,PCI_EXP_DEVCTL_READRQ_4096B ); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); -rtl_disable_clock_request (tp);/* Reset tx FIFO pointer */
@@ -4534,8 +4522,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)rtl_eri_set_bits (tp,0x1b0 ,ERIAR_MASK_0001 ,BIT (4 ));rtl_w0w1_eri (tp,0x0d4 ,ERIAR_MASK_0011 ,0x0c00 ,0xff00 ); -RTL_W8 (tp, MaxTxPacketSize, EarlySize); -rtl_disable_clock_request (tp);RTL_W8 (tp,MCU ,RTL_R8 (tp,MCU ) & ~NOW_IS_OOB );
@@ -4564,8 +4550,6 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)rtl_eri_write (tp,0xcc ,ERIAR_MASK_1111 ,0x00000050 );rtl_eri_write (tp,0xd0 ,ERIAR_MASK_1111 ,0x00000060 ); -RTL_W8 (tp, MaxTxPacketSize, EarlySize); -rtl_disable_clock_request (tp);RTL_W8 (tp,MCU ,RTL_R8 (tp,MCU ) & ~NOW_IS_OOB );
@@ -4622,7 +4606,6 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)rtl_eri_write (tp,0x2f8 ,ERIAR_MASK_0011 ,0x1d8f );RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN ); -RTL_W8 (tp, MaxTxPacketSize, EarlySize);rtl_eri_write (tp,0xc0 ,ERIAR_MASK_0011 ,0x0000 );rtl_eri_write (tp,0xb8 ,ERIAR_MASK_0011 ,0x0000 );
@@ -4720,7 +4703,6 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)rtl_eri_write (tp,0x5f0 ,ERIAR_MASK_0011 ,0x4f87 );RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN ); -RTL_W8 (tp, MaxTxPacketSize, EarlySize);rtl_eri_write (tp,0xc0 ,ERIAR_MASK_0011 ,0x0000 );rtl_eri_write (tp,0xb8 ,ERIAR_MASK_0011 ,0x0000 );
@@ -4796,7 +4778,6 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp)rtl_eri_write (tp,0x5f0 ,ERIAR_MASK_0011 ,0x4f87 );RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN ); -RTL_W8 (tp, MaxTxPacketSize, EarlySize);rtl_eri_write (tp,0xc0 ,ERIAR_MASK_0011 ,0x0000 );rtl_eri_write (tp,0xb8 ,ERIAR_MASK_0011 ,0x0000 );
@@ -5068,7 +5049,10 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)pcie_capability_set_word (tp->pci_dev,PCI_EXP_DEVCTL ,PCI_EXP_DEVCTL_NOSNOOP_EN ); -RTL_W8 (tp, MaxTxPacketSize, TxPacketMax); +if (rtl_is_8168evl_up (tp)) +RTL_W8 (tp, MaxTxPacketSize, EarlySize); +else +RTL_W8 (tp, MaxTxPacketSize, TxPacketMax);rtl_hw_config (tp); }
Signature · 1 line
2.22.0
David Miller
maintainerFrom: Heiner Kallweit <[email protected]>
Date: Fri, 14 Jun 2019 07:51:33 +0200
Quoted 3 lines
Few registers have been added or changed its purpose with version RTL8168e-vl, so create a helper for identifying chip versions from RTL8168e-vl.
Series applied, thanks Heiner.