Introducing support for DWC xpcs Energy Efficient Ethernet
Subsystems (6)
cover Introducing support for DWC xpcs Energy Efficient Ethernet
The goal of this patch set is to enable EEE in the xpcs so that when EEE is enabled, the MAC-->xpcs-->PHY have all the EEE related configurations enabled.
Patch 1 adds the functions to enable EEE in the xpcs and sets it to transparent mode.
Patch 2 adds the callbacks to configure the xpcs EEE mode.
The results are tested by checking the lpi counters of the tx and rx path of the interface. When EEE is enabled, the lpi counters should increament as it enters and exits lpi states.
host@EHL$ ethtool --show-eee enp0s30f4
EEE Settings for enp0s30f4:
EEE status: disabled
Tx LPI: disabled
Supported EEE link modes: 100baseT/Full
1000baseT/Full
Advertised EEE link modes: Not reported
Link partner advertised EEE link modes: 100baseT/Full
1000baseT/Full
host@EHL$ ethtool -S enp0s30f4 | grep lpi
irq_tx_path_in_lpi_mode_n: 0
irq_tx_path_exit_lpi_mode_n: 0
irq_rx_path_in_lpi_mode_n: 0
irq_rx_path_exit_lpi_mode_n: 0
host@EHL$ ethtool --set-eee enp0s30f4 eee on
host@EHL$ [ 110.265154] intel-eth-pci 0000:00:1e.4 enp0s30f4: Link is Down
[ 112.315155] intel-eth-pci 0000:00:1e.4 enp0s30f4: Link is Up - 1Gbps/Full - flow control off
[ 112.324612] IPv6: ADDRCONF(NETDEV_CHANGE): enp0s30f4: link becomes ready
host@EHL$ ethtool --show-eee enp0s30f4
EEE Settings for enp0s30f4:
EEE status: enabled - active
Tx LPI: 1000000 (us)
Supported EEE link modes: 100baseT/Full
1000baseT/Full
Advertised EEE link modes: 100baseT/Full
1000baseT/Full
Link partner advertised EEE link modes: 100baseT/Full
1000baseT/Full
host@EHL$ ethtool -S enp0s30f4 | grep lpi
irq_tx_path_in_lpi_mode_n: 6
irq_tx_path_exit_lpi_mode_n: 5
irq_rx_path_in_lpi_mode_n: 7
irq_rx_path_exit_lpi_mode_n: 6
host@EHL$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.02 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.510 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.489 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.484 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.504 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=0.466 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=0.529 ms
64 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=0.519 ms
64 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=0.518 ms
64 bytes from 192.168.1.1: icmp_seq=10 ttl=64 time=0.501 ms--- 192.168.1.1 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9216ms rtt min/avg/max/mdev = 0.466/0.553/1.018/0.155 ms
host@EHL$ ethtool -S enp0s30f4 | grep lpi
irq_tx_path_in_lpi_mode_n: 22
irq_tx_path_exit_lpi_mode_n: 21
irq_rx_path_in_lpi_mode_n: 21
irq_rx_path_exit_lpi_mode_n: 20Michael Sit Wei Hong (2):
net: pcs: Introducing support for DWC xpcs Energy Efficient Ethernet
net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 11 ++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 + .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 +++ drivers/net/pcs/pcs-xpcs.c | 51 +++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 2 + include/linux/stmmac.h | 1 + 6 files changed, 73 insertions(+)
Signature · 1 line
2.17.1
PATCH 1/2 net: pcs: Introducing support for DWC xpcs Energy Efficient Ethernet
Add DWC xpcs EEE support callbacks.The callback function is used to set EEE registers on xpcs.
xpcs transparent mode is enabled to allow PHY to detect MAC EEE status.
--- drivers/net/pcs/pcs-xpcs.c | 51 ++++++++++++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 2 ++ 2 files changed, 53 insertions(+)
drivers/net/pcs/pcs-xpcs.c +51 -0
@@ -63,6 +63,9 @@#define DW_VR_MII_DIG_CTRL1 0x8000#define DW_VR_MII_AN_CTRL 0x8001#define DW_VR_MII_AN_INTR_STS 0x8002 +/* EEE Mode Control Register */ +#define DW_VR_MII_EEE_MCTRL0 0x8006 +#define DW_VR_MII_EEE_MCTRL1 0x800b/* VR_MII_DIG_CTRL1 */ #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9)
@@ -86,6 +89,20 @@#define DW_VR_MII_C37_ANSGM_SP_1000 0x2#define DW_VR_MII_C37_ANSGM_SP_LNKSTS BIT(4) +/* VR MII EEE Control 0 defines */ +#define DW_VR_MII_EEE_LTX_EN BIT(0)/* LPI Tx Enable */ +#define DW_VR_MII_EEE_LRX_EN BIT(1)/* LPI Rx Enable */ +#define DW_VR_MII_EEE_TX_QUIET_EN BIT(2)/* Tx Quiet Enable */ +#define DW_VR_MII_EEE_RX_QUIET_EN BIT(3)/* Rx Quiet Enable */ +#define DW_VR_MII_EEE_TX_EN_CTRL BIT(4)/* Tx Control Enable */ +#define DW_VR_MII_EEE_RX_EN_CTRL BIT(7)/* Rx Control Enable */ + +#define DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT 8 +#define DW_VR_MII_EEE_MULT_FACT_100NS GENMASK(11, 8) + +/* VR MII EEE Control 1 defines */ +#define DW_VR_MII_EEE_TRN_LPI BIT(0)/* Transparent Mode Enable */ +static const int xpcs_usxgmii_features[] = { ETHTOOL_LINK_MODE_Pause_BIT, ETHTOOL_LINK_MODE_Asym_Pause_BIT,
@@ -650,6 +667,39 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs,return 0 ; } +static int xpcs_config_eee (struct mdio_xpcs_args *xpcs,int mult_fact_100ns, +int enable) +{ +int ret; + +if (enable) { +/* Enable EEE */ + ret =DW_VR_MII_EEE_LTX_EN |DW_VR_MII_EEE_LRX_EN | +DW_VR_MII_EEE_TX_QUIET_EN |DW_VR_MII_EEE_RX_QUIET_EN | +DW_VR_MII_EEE_TX_EN_CTRL |DW_VR_MII_EEE_RX_EN_CTRL | + mult_fact_100ns <<DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT ; + }else { + ret =xpcs_read (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL0 ); +if (ret <0 ) +return ret; + ret &= ~(DW_VR_MII_EEE_LTX_EN |DW_VR_MII_EEE_LRX_EN | +DW_VR_MII_EEE_TX_QUIET_EN |DW_VR_MII_EEE_RX_QUIET_EN | +DW_VR_MII_EEE_TX_EN_CTRL |DW_VR_MII_EEE_RX_EN_CTRL | +DW_VR_MII_EEE_MULT_FACT_100NS ); + } + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL0 , ret); +if (ret <0 ) +return ret; + + ret =xpcs_read (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL1 ); +if (ret <0 ) +return ret; + + ret |=DW_VR_MII_EEE_TRN_LPI ; +return xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL1 , ret); +} +static int xpcs_config_aneg_c37_sgmii (struct mdio_xpcs_args *xpcs) {int ret;
@@ -908,6 +958,7 @@ static struct mdio_xpcs_ops xpcs_ops = { .get_state = xpcs_get_state, .link_up = xpcs_link_up, .probe = xpcs_probe, + .config_eee = xpcs_config_eee, };struct mdio_xpcs_ops *mdio_xpcs_get_ops (void )
include/linux/pcs/pcs-xpcs.h +2 -0
@@ -32,6 +32,8 @@ struct mdio_xpcs_ops {int (*link_up)(struct mdio_xpcs_args *xpcs,int speed,phy_interface_t interface);int (*probe)(struct mdio_xpcs_args *xpcs,phy_interface_t interface); +int (*config_eee)(struct mdio_xpcs_args *xpcs,int mult_fact_100ns, +int enable); };#if IS_ENABLED (CONFIG_PCS_XPCS )
Signature · 1 line
2.17.1
PATCH 2/2 net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
In reply to Michael Sit Wei HongLink xpcs callback functions for MAC to configure the xpcs EEE feature.
The clk_eee frequency is used to calculate the MULT_FACT_100NS. This is to adjust the clock tic closer to 100ns.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 11 +++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++++ include/linux/stmmac.h | 1 + 4 files changed, 20 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +11 -0
@@ -429,6 +429,17 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->force_sf_dma_mode =0 ; plat->tso_en =1 ; +/* Multiplying factor to the clk_eee_i clock time +* period to make it closer to 100 ns. This value +* should be programmed such that the clk_eee_time_period * +* (MULT_FACT_100NS + 1) should be within 80 ns to 120 ns +* clk_eee frequency is 19.2Mhz +* clk_eee_time_period is 52ns +* 52ns * (1 + 1) = 104ns +* MULT_FACT_100NS = 1 +*/ + plat->mult_fact_100ns =1 ; + plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ;for (i =0 ; i < plat->rx_queues_to_use; i++) {
drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -0
@@ -624,6 +624,8 @@ struct stmmac_mmc_ops { stmmac_do_callback(__priv, xpcs, link_up, __args) #define stmmac_xpcs_probe(__priv, __args...) \ stmmac_do_callback(__priv, xpcs, probe, __args) +#define stmmac_xpcs_config_eee(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, config_eee, __args)struct stmmac_regs_off {u32 ptp_off;
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +6 -0
@@ -720,6 +720,12 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev,netdev_warn (priv->dev,"Setting EEE tx-lpi is not supported\n" ); + ret =stmmac_xpcs_config_eee (priv, &priv->hw->xpcs_args, + priv->plat->mult_fact_100ns, + edata->eee_enabled); +if (ret) +return ret; +if (!edata->eee_enabled)stmmac_disable_eee_mode (priv);
include/linux/stmmac.h +1 -0
@@ -223,6 +223,7 @@ struct plat_stmmacenet_data {struct clk *clk_ptp_ref;unsigned int clk_ptp_rate;unsigned int clk_ref_rate; +unsigned int mult_fact_100ns;s32 ptp_max_adj;struct reset_control *stmmac_rst;struct stmmac_axi *axi;
Signature · 1 line
2.17.1
Russell King (Oracle)
reviewerRe: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
Quoted 6 lines · Michael Sit Wei Hong
Link xpcs callback functions for MAC to configure the xpcs EEE feature.
The
clk_eeefrequency is used to calculate theMULT_FACT_100NS. This is to adjust the clock tic closer to 100ns.Signed-off-by Michael Sit Wei Hong <[email protected]>
What is the initial state of the EEE configuration before the first call to stmmac_ethtool_op_set_eee()? Does it reflect the default EEE settings?
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
RE: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
Quoted 27 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, 17 May, 2021 6:54 PM
To: Sit, Michael Wei Hong <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Voon, Weifeng <[email protected]>; Ong, Boon Leong <[email protected]>; Tan, Tee Min <[email protected]>; [email protected]; Wong, Vee Khee <[email protected]>; linux-stm32@st- md-mailman.stormreply.com; linux-arm- [email protected]; [email protected]
Subject: Re: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient EthernetQuoted 1 line · Michael Sit Wei Hong
Link xpcs callback functions for MAC to configure the xpcs EEE
feature.
Quoted 2 lines
The
clk_eeefrequency is used to calculate the
MULT_FACT_100NS. This
Quoted 8 lines
Quoted 3 lines
is to adjust the clock tic closer to 100ns.
Signed-off-by Michael Sit Wei HongWhat is the initial state of the EEE configuration before the first call to
stmmac_ethtool_op_set_eee()? Does it reflect the default EEE settings?
The register values before the first call are the default reset values in the registers. The reset values assumes the clk_eee_i time period is 10ns, Hence, the reset value is set to 9.
According to the register description,
This value should be programmed such that the clk_eee_i_time_period * (MULT_FACT_100NS + 1) should be
within 80 ns to 120 ns.
Since we are using a fixed 19.2MHz clk_eee, which is 52ns, we are setting the value to 1.
Quoted 6 lines
--
RMK's Patch system:
https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Russell King (Oracle)
reviewerRe: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
Quoted 26 lines · Michael Wei Hong
Quoted 9 lines
From: Russell King <[email protected]>
Quoted 1 line · Michael Sit Wei Hong
Link xpcs callback functions for MAC to configure the xpcs EEE
feature.
Quoted 2 lines
The
clk_eeefrequency is used to calculate the
MULT_FACT_100NS. ThisQuoted 8 lines
Quoted 3 lines
is to adjust the clock tic closer to 100ns.
Signed-off-by Michael Sit Wei HongWhat is the initial state of the EEE configuration before the first call to
stmmac_ethtool_op_set_eee()? Does it reflect the default EEE settings?The register values before the first call are the default reset values in the registers. The reset values assumes the
clk_eee_itime period is 10ns, Hence, the reset value is set to 9.
According to the register description,
This value should be programmed such that theclk_eee_i_time_period* (MULT_FACT_100NS+ 1) should be
within 80 ns to 120 ns.
Quoted 2 lines
Since we are using a fixed 19.2MHz
clk_eee, which is 52ns, we are setting the value to 1.
Does that hardware default configuration match what is returned by ethtool --show-eee ?
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
RE: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet
Quoted 53 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Tuesday, 18 May, 2021 6:06 PM
To: Sit, Michael Wei Hong <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Voon, Weifeng <[email protected]>; Ong, Boon Leong <[email protected]>; Tan, Tee Min <[email protected]>; [email protected]; Wong, Vee Khee <[email protected]>; linux-stm32@st- md-mailman.stormreply.com; linux-arm- [email protected]; [email protected]
Subject: Re: [PATCH net-next 2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient EthernetQuoted 3 lines · Michael Wei Hong
Quoted 3 lines
From: Russell King <[email protected]>
On Mon, May 17, 2021 at 05:43:32PM +0800, Michael Sit Wei
Hong
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Link xpcs callback functions for MAC to configure the xpcs
EEE
Quoted 10 lines
Quoted 10 lines
feature.
Quoted 2 lines
The
clk_eeefrequency is used to calculate the
MULT_FACT_100NS. ThisQuoted 3 lines
is to adjust the clock tic closer to 100ns.
Signed-off-by Michael Sit Wei HongWhat is the initial state of the EEE configuration before the
first
Quoted 1 line
Quoted 1 line
call to
stmmac_ethtool_op_set_eee()? Does it reflect thedefault EEE
Quoted 3 lines
Quoted 1 line
settings?
The register values before the first call are the default reset
values
Quoted 1 line
in the registers. The reset values assumes the
clk_eee_itimeperiod
Quoted 2 lines
is 10ns, Hence, the reset value is set to 9. According to the register description, This value should be
programmed
Quoted 1 line
such that the
clk_eee_i_time_period* (MULT_FACT_100NS+ 1)should be
Quoted 8 lines
Quoted 3 lines
within 80 ns to 120 ns.
Since we are using a fixed 19.2MHz
clk_eee, which is 52ns, weare
Quoted 1 line
setting the value to 1.
Does that hardware default configuration match what is returned by ethtool --show-eee ?
May I know what is the hardware default configuration that is expected to be returned by ethtool --show-eee?
The MULT_FACT_100NS value is an internal register setting not meant to be exposed to userspace, and only relevant when EEE is enabled.
Quoted 6 lines
--
RMK's Patch system:
https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Mon, 17 May 2021 17:43:30 +0800 you wrote:
The goal of this patch set is to enable EEE in the xpcs so that when EEE is enabled, the MAC-->xpcs-->PHY have all the EEE related configurations enabled.
Patch 1 adds the functions to enable EEE in the xpcs and sets it to transparent mode.
Patch 2 adds the callbacks to configure the xpcs EEE mode.[...]
Here is the summary with links:
- [net-next,1/2] net: pcs: Introducing support for DWC xpcs Energy Efficient Ethernet
https://git.kernel.org/netdev/net-next/c/7617af3d1a5e - [net-next,2/2] net: stmmac: Add callbacks for DWC xpcs Energy Efficient Ethernet https://git.kernel.org/netdev/net-next/c/e80fe71b3ffe
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html