r8169: improve wol/suspend-related code
Heiner Kallweit
maintainercover r8169: improve wol/suspend-related code
This series improves wol/suspend-related code parts.
Heiner Kallweit (3):
r8169: improve __rtl8169_set_wol
r8169: improve rtl_set_d3_pll_down
r8169: align WAKE_PHY handling with r8125/r8126 vendor drivers
drivers/net/ethernet/realtek/r8169_main.c | 76 ++++++++++------------- 1 file changed, 32 insertions(+), 44 deletions(-)
Signature · 1 line
2.47.0
Heiner Kallweit
maintainerPATCH 1/3 r8169: improve __rtl8169_set_wol
Add helper r8169_mod_reg8_cond() what allows to significantly simplify __rtl8169_set_wol().
--- drivers/net/ethernet/realtek/r8169_main.c | 55 ++++++++++------------- 1 file changed, 24 insertions(+), 31 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +24 -31
@@ -748,6 +748,20 @@ static void rtl_mod_config5(struct rtl8169_private *tp, u8 clear, u8 set)RTL_W8 (tp, Config5, (val & ~clear) | set); } +static void r8169_mod_reg8_cond (struct rtl8169_private *tp,int reg, +u8 bits,bool cond) +{ +u8 val, old_val; + + old_val =RTL_R8 (tp, reg); +if (cond) + val = old_val | bits; +else + val = old_val & ~bits; +if (val != old_val) +RTL_W8 (tp, reg, val); +} +static bool rtl_is_8125 (struct rtl8169_private *tp) {return tp->mac_version >=RTL_GIGA_MAC_VER_61 ;
@@ -1538,58 +1552,37 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)static void __rtl8169_set_wol (struct rtl8169_private *tp,u32 wolopts) { -static const struct { -u32 opt; -u16 reg; -u8 mask; - } cfg[] = { - {WAKE_PHY , Config3, LinkUp }, - {WAKE_UCAST , Config5,UWF }, - {WAKE_BCAST , Config5,BWF }, - {WAKE_MCAST , Config5,MWF }, - {WAKE_ANY , Config5, LanWake }, - {WAKE_MAGIC , Config3, MagicPacket } - }; -unsigned int i, tmp =ARRAY_SIZE (cfg); -u8 options; -rtl_unlock_config_regs (tp);if (rtl_is_8168evl_up (tp)) { - tmp--;if (wolopts &WAKE_MAGIC )rtl_eri_set_bits (tp,0x0dc , MagicPacket_v2);else rtl_eri_clear_bits (tp,0x0dc , MagicPacket_v2); }else if (rtl_is_8125 (tp)) { - tmp--;if (wolopts &WAKE_MAGIC )r8168_mac_ocp_modify (tp,0xc0b6 ,0 ,BIT (0 ));else r8168_mac_ocp_modify (tp,0xc0b6 ,BIT (0 ),0 ); + }else { +r8169_mod_reg8_cond (tp, Config3, MagicPacket, + wolopts &WAKE_MAGIC ); } -for (i =0 ; i < tmp; i++) { - options =RTL_R8 (tp, cfg[i].reg) & ~cfg[i].mask; -if (wolopts & cfg[i].opt) - options |= cfg[i].mask; -RTL_W8 (tp, cfg[i].reg, options); - } +r8169_mod_reg8_cond (tp, Config3, LinkUp, wolopts &WAKE_PHY ); +r8169_mod_reg8_cond (tp, Config5,UWF , wolopts &WAKE_UCAST ); +r8169_mod_reg8_cond (tp, Config5,BWF , wolopts &WAKE_BCAST ); +r8169_mod_reg8_cond (tp, Config5,MWF , wolopts &WAKE_MCAST ); +r8169_mod_reg8_cond (tp, Config5, LanWake, wolopts);switch (tp->mac_version) { case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: - options =RTL_R8 (tp, Config1) & ~PMEnable; -if (wolopts) - options |= PMEnable; -RTL_W8 (tp, Config1, options); +r8169_mod_reg8_cond (tp, Config1, PMEnable, wolopts);break ;case RTL_GIGA_MAC_VER_34 :case RTL_GIGA_MAC_VER_37 : case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_66: -if (wolopts) -rtl_mod_config2 (tp,0 ,PME_SIGNAL ); -else -rtl_mod_config2 (tp,PME_SIGNAL ,0 ); +r8169_mod_reg8_cond (tp, Config2,PME_SIGNAL , wolopts);break ;default :break ;
Signature · 1 line
2.47.0
Re: [PATCH net-next 1/3] r8169: improve __rtl8169_set_wol
Quoted 4 lines · Heiner Kallweit
Add helper
r8169_mod_reg8_cond()what allows to significantly simplify__rtl8169_set_wol().Signed-off-by Heiner Kallweit <[email protected]>
__rtl8169_set_wol() certainly is much nicer now.
Heiner Kallweit
maintainerPATCH 2/3 r8169: improve rtl_set_d3_pll_down
In reply to Heiner KallweitMake use of new helper r8169_mod_reg8_cond() and move from a switch() to an if() clause. Benefit is that we don't have to touch this piece of code each time support for a new chip version is added.
--- drivers/net/ethernet/realtek/r8169_main.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +5 -13
@@ -1431,19 +1431,11 @@ static enum rtl_dash_type rtl_get_dash_type(struct rtl8169_private *tp)static void rtl_set_d3_pll_down (struct rtl8169_private *tp,bool enable) { -switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26: - case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30: - case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_37: - case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_66: -if (enable) -RTL_W8 (tp,PMCH ,RTL_R8 (tp,PMCH ) & ~D3_NO_PLL_DOWN ); -else -RTL_W8 (tp,PMCH ,RTL_R8 (tp,PMCH ) |D3_NO_PLL_DOWN ); -break ; -default : -break ; - } +if (tp->mac_version >=RTL_GIGA_MAC_VER_25 && + tp->mac_version !=RTL_GIGA_MAC_VER_28 && + tp->mac_version !=RTL_GIGA_MAC_VER_31 && + tp->mac_version !=RTL_GIGA_MAC_VER_38 ) +r8169_mod_reg8_cond (tp,PMCH ,D3_NO_PLL_DOWN , !enable); }static void rtl_reset_packet_filter (struct rtl8169_private *tp)
Signature · 1 line
2.47.0
Re: [PATCH net-next 2/3] r8169: improve rtl_set_d3_pll_down
Quoted 5 lines · Heiner Kallweit
Make use of new helper
r8169_mod_reg8_cond()and move from aswitch()to anif()clause. Benefit is that we don't have to touch this piece of code each time support for a new chip version is added.Signed-off-by Heiner Kallweit <[email protected]>
Heiner Kallweit
maintainerPATCH 3/3 r8169: align WAKE_PHY handling with r8125/r8126 vendor drivers
In reply to Heiner KallweitVendor drivers r8125/r8126 apply this additional magic setting when enabling WAKE_PHY, so do the same here.
--- drivers/net/ethernet/realtek/r8169_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +3 -0
@@ -1562,6 +1562,9 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) }r8169_mod_reg8_cond (tp, Config3, LinkUp, wolopts &WAKE_PHY ); +if (rtl_is_8125 (tp)) +r8168_mac_ocp_modify (tp,0xe0c6 ,0x3f , + wolopts &WAKE_PHY ?0x13 :0 );r8169_mod_reg8_cond (tp, Config5,UWF , wolopts &WAKE_UCAST );r8169_mod_reg8_cond (tp, Config5,BWF , wolopts &WAKE_BCAST );r8169_mod_reg8_cond (tp, Config5,MWF , wolopts &WAKE_MCAST );
Signature · 1 line
2.47.0
Re: [PATCH net-next 3/3] r8169: align WAKE_PHY handling with r8125/r8126 vendor drivers
Quoted 4 lines · Heiner Kallweit
Vendor drivers r8125/r8126 apply this additional magic setting when enabling
WAKE_PHY, so do the same here.Signed-off-by Heiner Kallweit <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 6 Nov 2024 17:54:27 +0100 you wrote:
This series improves wol/suspend-related code parts.
Heiner Kallweit (3):
r8169: improve__rtl8169_set_wol
r8169: improvertl_set_d3_pll_down
r8169: alignWAKE_PHYhandling with r8125/r8126 vendor drivers[...]
Here is the summary with links:
- [net-next,1/3] r8169: improve __rtl8169_set_wol
https://git.kernel.org/netdev/net-next/c/c507e96b5763 - [net-next,2/3] r8169: improve rtl_set_d3_pll_down https://git.kernel.org/netdev/net-next/c/330dc2297c82 - [net-next,3/3] r8169: align WAKE_PHY handling with r8125/r8126 vendor drivers https://git.kernel.org/netdev/net-next/c/e3e9e9039fa6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html