net: stmmac/xpcs: further EEE work
Subsystems (7)
Russell King (Oracle)
maintainercover net: stmmac/xpcs: further EEE work
Hi,
This series is a preview of the further work I wish to merge during the next cycle for EEE in stmmac and XPCS drivers.
The first 14 patches target stmmac's EEE implementation, which I believe to be buggy such that it does not disable LPI signalling immediately when ethtool settings change, but instead in effect waits until the next packet is sent. This is a relatively minor bug, so isn't high priority.
However, what the first set of patches are doing is continuing the cleanup of the stmmac implementation and making things consistent and readable.
The following patches are aimed at eliminating the xpcs_config_eee() direct call between stmmac's EEE code and XPCS, and present a way to do this. Sadly, it doesn't reduce the number of direct calls between these two drivers as we need to implement a new call to configure the "mult_fract" parameter in the XPCS EEE control registers, which is supposed to be derived from the speed of an EEE-specific clock.
However, I remain unconvinced whether it is necessary to enable and disable the EEE controls at the XPCS with LPI being enabled/disabled at the MAC. Could many or all of these settings be configured as part of the creation of the driver instance instead?
Without knowing that, the only real way to clean this up is the one I've taken - which is the principle of preserving the existing behaviour.
Sadly, the entire series doesn't lead to a great reduction in LOC, however, the initial 14 stmmac patches leads to a reduction of 71 LOC.
My plan is to send the first 14 patches shortly after net-next opens.
drivers/net/ethernet/stmicro/stmmac/common.h | 14 +++ drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +-- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 30 ++--- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 12 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 96 +++++++--------- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 9 +- .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 49 ++++---- drivers/net/ethernet/stmicro/stmmac/hwif.h | 21 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 126 +++++++-------------- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 + drivers/net/pcs/pcs-xpcs.c | 89 ++++++++++----- drivers/net/pcs/pcs-xpcs.h | 1 + drivers/net/phy/phylink.c | 25 +++- include/linux/pcs/pcs-xpcs.h | 3 +- include/linux/phylink.h | 22 ++++ 15 files changed, 253 insertions(+), 259 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 1/22 net: stmmac: delete software timer before disabling LPI
Delete the software timer to ensure that the timer doesn't fire while we are modifying the LPI register state, potentially re-enabling LPI.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -447,8 +447,8 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)*/ static void stmmac_stop_sw_lpi (struct stmmac_priv *priv) { -stmmac_reset_eee_mode (priv, priv->hw);del_timer_sync (&priv->eee_ctrl_timer); +stmmac_reset_eee_mode (priv, priv->hw); priv->tx_path_in_lpi_mode = false; }
@@ -492,8 +492,8 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active)if (priv->eee_enabled) {netdev_dbg (priv->dev,"disable EEE\n" ); priv->eee_sw_timer_en = false; -stmmac_disable_hw_lpi_timer (priv);del_timer_sync (&priv->eee_ctrl_timer); +stmmac_disable_hw_lpi_timer (priv);stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS );if (priv->hw->xpcs)
Signature · 1 line
2.30.2
RFC PATCH 2/22 net: stmmac: ensure LPI is disabled when disabling EEE
In reply to Russell King (Oracle)When EEE is disabled, we call stmmac_set_eee_lpi_timer(..., 0).
For dwmac4, this will result in LPIATE being cleared, but LPIEN and LPITXA being set, causing LPI mode to be signalled (if it wasn't before).
For others MACs, stmmac_set_eee_lpi_timer() does nothing, which means that LPI mode will continue to be signalled despite the expectation for it to be disabled.
In both cases, LPI mode will be terminated when the transmitter has a packet to send, and LPIEN will be cleared by hardware.
Call stmmac_reset_eee_mode() to ensure that LPI mode is disabled when EEE mode is requested to be disabled.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -494,6 +494,7 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active) priv->eee_sw_timer_en = false;del_timer_sync (&priv->eee_ctrl_timer);stmmac_disable_hw_lpi_timer (priv); +stmmac_reset_eee_mode (priv, priv->hw);stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS );if (priv->hw->xpcs)
Signature · 1 line
2.30.2
RFC PATCH 3/22 net: stmmac: dwmac4: ensure LPIATE is cleared
In reply to Russell King (Oracle)LPIATE enables the hardware timer for entering LPI mode. To sure that the correct mode is used, clear LPIATE when using manual/software-timed mode to prevent the hardware using the timer.
stmmac_main.c avoids this being a problem at the moment by calling stmmac_set_eee_lpi_timer(..., 0) before switching to software mode.
We no longer need to call stmmac_set_eee_lpi_timer(..., 0) when disabling EEE as stmmac_reset_eee_mode() will now clear all LPI settings.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 +++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +3 -1
@@ -387,6 +387,7 @@ static void dwmac4_set_eee_mode(struct mac_device_info *hw,* state. */ value =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); + value &= ~GMAC4_LPI_CTRL_STATUS_LPIATE ; value |=GMAC4_LPI_CTRL_STATUS_LPIEN |GMAC4_LPI_CTRL_STATUS_LPITXA ;if (en_tx_lpi_clockgating)
@@ -401,7 +402,8 @@ static void dwmac4_reset_eee_mode(struct mac_device_info *hw)u32 value; value =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); - value &= ~(GMAC4_LPI_CTRL_STATUS_LPIEN |GMAC4_LPI_CTRL_STATUS_LPITXA ); + value &= ~(GMAC4_LPI_CTRL_STATUS_LPIATE |GMAC4_LPI_CTRL_STATUS_LPIEN | +GMAC4_LPI_CTRL_STATUS_LPITXA );writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS ); }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -1
@@ -493,7 +493,6 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active)netdev_dbg (priv->dev,"disable EEE\n" ); priv->eee_sw_timer_en = false;del_timer_sync (&priv->eee_ctrl_timer); -stmmac_disable_hw_lpi_timer (priv);stmmac_reset_eee_mode (priv, priv->hw);stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS );
Signature · 1 line
2.30.2
RFC PATCH 4/22 net: stmmac: split stmmac_init_eee() and move to phylink methods
In reply to Russell King (Oracle)Move the appropriate parts of stmmac_init_eee() into the phylink mac_enable_tx_lpi() and mac_disable_tx_lpi() methods.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 133 +++++++++--------- 1 file changed, 63 insertions(+), 70 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +63 -70
@@ -466,74 +466,6 @@ static void stmmac_eee_ctrl_timer(struct timer_list *t)stmmac_try_to_start_sw_lpi (priv); } -/** -* stmmac_eee_init - init EEE -* @priv: driver private structure -* @active: indicates whether EEE should be enabled. -* Description: -* if the GMAC supports the EEE (from the HW cap reg) and the phy device -* can also manage EEE, this function enable the LPI state and start related -* timer. -*/ -static void stmmac_eee_init (struct stmmac_priv *priv,bool active) -{ - priv->eee_active = active; - -/* Check if MAC core supports the EEE feature. */ -if (!priv->dma_cap.eee) { - priv->eee_enabled = false; -return ; - } - -mutex_lock (&priv->lock); - -/* Check if it needs to be deactivated */ -if (!priv->eee_active) { -if (priv->eee_enabled) { -netdev_dbg (priv->dev,"disable EEE\n" ); - priv->eee_sw_timer_en = false; -del_timer_sync (&priv->eee_ctrl_timer); -stmmac_reset_eee_mode (priv, priv->hw); -stmmac_set_eee_timer (priv, priv->hw,0 , -STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, - false); - } - priv->eee_enabled = false; -mutex_unlock (&priv->lock); -return ; - } - -if (priv->eee_active && !priv->eee_enabled) { -stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS , -STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, - true); - } - -if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) { -/* Use hardware LPI mode */ -del_timer_sync (&priv->eee_ctrl_timer); - priv->tx_path_in_lpi_mode = false; - priv->eee_sw_timer_en = false; -stmmac_enable_hw_lpi_timer (priv); - }else { -/* Use software LPI mode */ - priv->eee_sw_timer_en = true; -stmmac_disable_hw_lpi_timer (priv); -stmmac_restart_sw_lpi_timer (priv); - } - - priv->eee_enabled = true; - -mutex_unlock (&priv->lock); -netdev_dbg (priv->dev,"Energy-Efficient Ethernet initialized\n" ); -} -/* stmmac_get_tx_hwtstamp - get HW TX timestamps * @priv: driver private structure * @p : descriptor pointer
@@ -1110,7 +1042,33 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) {struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); -stmmac_eee_init (priv, false); + priv->eee_active = false; + +/* Check if MAC core supports the EEE feature. */ +if (!priv->dma_cap.eee) { + priv->eee_enabled = false; +return ; + } + +mutex_lock (&priv->lock); + +/* Check if it needs to be deactivated */ +if (!priv->eee_active) { +if (priv->eee_enabled) { +netdev_dbg (priv->dev,"disable EEE\n" ); + priv->eee_sw_timer_en = false; +del_timer_sync (&priv->eee_ctrl_timer); +stmmac_reset_eee_mode (priv, priv->hw); +stmmac_set_eee_timer (priv, priv->hw,0 , +STMMAC_DEFAULT_TWT_LS ); +if (priv->hw->xpcs) +xpcs_config_eee (priv->hw->xpcs, + priv->plat->mult_fact_100ns, + false); + } + priv->eee_enabled = false; + } +mutex_unlock (&priv->lock); } static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
@@ -1119,7 +1077,42 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); priv->tx_lpi_timer = timer; -stmmac_eee_init (priv, true); + priv->eee_active = true; + +/* Check if MAC core supports the EEE feature. */ +if (!priv->dma_cap.eee) { + priv->eee_enabled = false; +return 0 ; + } + +mutex_lock (&priv->lock); + +if (priv->eee_active && !priv->eee_enabled) { +stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS , +STMMAC_DEFAULT_TWT_LS ); +if (priv->hw->xpcs) +xpcs_config_eee (priv->hw->xpcs, + priv->plat->mult_fact_100ns, + true); + } + +if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) { +/* Use hardware LPI mode */ +del_timer_sync (&priv->eee_ctrl_timer); + priv->tx_path_in_lpi_mode = false; + priv->eee_sw_timer_en = false; +stmmac_enable_hw_lpi_timer (priv); + }else { +/* Use software LPI mode */ + priv->eee_sw_timer_en = true; +stmmac_disable_hw_lpi_timer (priv); +stmmac_restart_sw_lpi_timer (priv); + } + + priv->eee_enabled = true; + +mutex_unlock (&priv->lock); +netdev_dbg (priv->dev,"Energy-Efficient Ethernet initialized\n" );return 0 ; }
Signature · 1 line
2.30.2
RFC PATCH 5/22 net: stmmac: remove priv->dma_cap.eee test in tx_lpi methods
In reply to Russell King (Oracle)The tests for priv->dma_cap.eee in stmmac_mac_{en,dis}able_tx_lpi() is useless as these methods will only be called when using phylink managed EEE, and that will only be enabled if the LPI capabilities in phylink_config have been populated during initialisation. This only occurs when priv->dma_cap.eee was true.
As priv->dma_cap.eee remains constant during the lifetime of the driver instance, there is no need to re-check it in these methods.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -12
@@ -1044,12 +1044,6 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->eee_active = false; -/* Check if MAC core supports the EEE feature. */ -if (!priv->dma_cap.eee) { - priv->eee_enabled = false; -return ; - } -mutex_lock (&priv->lock);/* Check if it needs to be deactivated */
@@ -1079,12 +1073,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, priv->tx_lpi_timer = timer; priv->eee_active = true; -/* Check if MAC core supports the EEE feature. */ -if (!priv->dma_cap.eee) { - priv->eee_enabled = false; -return 0 ; - } -mutex_lock (&priv->lock);if (priv->eee_active && !priv->eee_enabled) {
Signature · 1 line
2.30.2
RFC PATCH 6/22 net: stmmac: remove unnecessary priv->eee_active tests
In reply to Russell King (Oracle)Since priv->eee_active is assigned with a constant value in each of these methods, there is no need to test its value later. Remove these unnecessary tests.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +12 -17
@@ -1047,21 +1047,17 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config)mutex_lock (&priv->lock);/* Check if it needs to be deactivated */ -if (!priv->eee_active) { -if (priv->eee_enabled) { -netdev_dbg (priv->dev,"disable EEE\n" ); - priv->eee_sw_timer_en = false; -del_timer_sync (&priv->eee_ctrl_timer); -stmmac_reset_eee_mode (priv, priv->hw); -stmmac_set_eee_timer (priv, priv->hw,0 , -STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, - false); - } - priv->eee_enabled = false; +if (priv->eee_enabled) { +netdev_dbg (priv->dev,"disable EEE\n" ); + priv->eee_sw_timer_en = false; +del_timer_sync (&priv->eee_ctrl_timer); +stmmac_reset_eee_mode (priv, priv->hw); +stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS ); +if (priv->hw->xpcs) +xpcs_config_eee (priv->hw->xpcs, + priv->plat->mult_fact_100ns, false); } + priv->eee_enabled = false;mutex_unlock (&priv->lock); }
@@ -1075,13 +1071,12 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,mutex_lock (&priv->lock); -if (priv->eee_active && !priv->eee_enabled) { +if (!priv->eee_enabled) {stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS ,STMMAC_DEFAULT_TWT_LS );if (priv->hw->xpcs)xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, - true); + priv->plat->mult_fact_100ns, true); }if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) {
Signature · 1 line
2.30.2
RFC PATCH 7/22 net: stmmac: remove unnecessary priv->eee_enabled tests
In reply to Russell King (Oracle)Phylink will not call the mac_disable_tx_lpi() and mac_enable_tx_lpi() methods randomly - the first method to be called will be the enable method, and then after, the disable method will be called once between subsequent enable calls. Thus there is a guaranteed ordering.
Therefore, we know the previous state of priv->eee_enabled, and can remove it from both methods.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +17 -20
@@ -1046,18 +1046,17 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config)mutex_lock (&priv->lock); -/* Check if it needs to be deactivated */ -if (priv->eee_enabled) { -netdev_dbg (priv->dev,"disable EEE\n" ); - priv->eee_sw_timer_en = false; -del_timer_sync (&priv->eee_ctrl_timer); -stmmac_reset_eee_mode (priv, priv->hw); -stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, false); - } priv->eee_enabled = false; + +netdev_dbg (priv->dev,"disable EEE\n" ); + priv->eee_sw_timer_en = false; +del_timer_sync (&priv->eee_ctrl_timer); +stmmac_reset_eee_mode (priv, priv->hw); +stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS ); +if (priv->hw->xpcs) +xpcs_config_eee (priv->hw->xpcs, priv->plat->mult_fact_100ns, + false); +mutex_unlock (&priv->lock); }
@@ -1071,13 +1070,13 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,mutex_lock (&priv->lock); -if (!priv->eee_enabled) { -stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS , -STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, - priv->plat->mult_fact_100ns, true); - } + priv->eee_enabled = true; + +stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS , +STMMAC_DEFAULT_TWT_LS ); +if (priv->hw->xpcs) +xpcs_config_eee (priv->hw->xpcs, priv->plat->mult_fact_100ns, + true);if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) {/* Use hardware LPI mode */
@@ -1092,8 +1091,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,stmmac_restart_sw_lpi_timer (priv); } - priv->eee_enabled = true; -mutex_unlock (&priv->lock);netdev_dbg (priv->dev,"Energy-Efficient Ethernet initialized\n" );
Signature · 1 line
2.30.2
RFC PATCH 8/22 net: stmmac: clear priv->tx_path_in_lpi_mode when disabling LPI
In reply to Russell King (Oracle)As other code paths do, clear priv->tx_path_in_lpi_mode when disabling LPI. This is done after the software timer has been deleted and hardware LPI has been disabled.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -1052,6 +1052,8 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->eee_sw_timer_en = false;del_timer_sync (&priv->eee_ctrl_timer);stmmac_reset_eee_mode (priv, priv->hw); + priv->tx_path_in_lpi_mode = false; +stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS );if (priv->hw->xpcs) xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns,
Signature · 1 line
2.30.2
RFC PATCH 9/22 net: stmmac: remove unnecessary LPI disable when enabling LPI
In reply to Russell King (Oracle)Remove the unnecessary LPI disable when enabling LPI - as noted in previous commits, there will never be two consecutive calls to stmmac_mac_enable_tx_lpi() without an intervening stmmac_mac_disable_tx_lpi.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -9
@@ -390,11 +390,6 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue)return dirty; } -static void stmmac_disable_hw_lpi_timer (struct stmmac_priv *priv) -{ -stmmac_set_eee_lpi_timer (priv, priv->hw,0 ); -} -static void stmmac_enable_hw_lpi_timer (struct stmmac_priv *priv) {stmmac_set_eee_lpi_timer (priv, priv->hw, priv->tx_lpi_timer);
@@ -1082,14 +1077,10 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) {/* Use hardware LPI mode */ -del_timer_sync (&priv->eee_ctrl_timer); - priv->tx_path_in_lpi_mode = false; - priv->eee_sw_timer_en = false;stmmac_enable_hw_lpi_timer (priv); }else {/* Use software LPI mode */ priv->eee_sw_timer_en = true; -stmmac_disable_hw_lpi_timer (priv);stmmac_restart_sw_lpi_timer (priv); }
Signature · 1 line
2.30.2
RFC PATCH 10/22 net: stmmac: use common LPI_CTRL_STATUS bit definitions
In reply to Russell King (Oracle)The bit definitions for the LPI control/status register are identical across all MAC versions, with the exception that some bits may not be implemented. Provide definitions for bits in this register in common.h, convert to use them, and remove the core- specific definitions.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 14 ++++++++++ .../net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +-------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 12 +------- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 28 +++++++++---------- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 9 +----- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 18 ++++++------ 6 files changed, 40 insertions(+), 54 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +14 -0
@@ -530,6 +530,20 @@ struct dma_features {#define STMMAC_DEFAULT_TWT_LS 0x1E#define STMMAC_ET_MAX 0xFFFFF +/* Common LPI register bits */ +#define LPI_CTRL_STATUS_LPITCSE BIT(21)/* LPI Tx Clock Stop Enable, gmac4, xgmac2 only */ +#define LPI_CTRL_STATUS_LPIATE BIT(20)/* LPI Timer Enable, gmac4 only */ +#define LPI_CTRL_STATUS_LPITXA BIT(19)/* Enable LPI TX Automate */ +#define LPI_CTRL_STATUS_PLSEN BIT(18)/* Enable PHY Link Status */ +#define LPI_CTRL_STATUS_PLS BIT(17)/* PHY Link Status */ +#define LPI_CTRL_STATUS_LPIEN BIT(16)/* LPI Enable */ +#define LPI_CTRL_STATUS_RLPIST BIT(9)/* Receive LPI state, gmac1000 only? */ +#define LPI_CTRL_STATUS_TLPIST BIT(8)/* Transmit LPI state, gmac1000 only? */ +#define LPI_CTRL_STATUS_RLPIEX BIT(3)/* Receive LPI Exit */ +#define LPI_CTRL_STATUS_RLPIEN BIT(2)/* Receive LPI Entry */ +#define LPI_CTRL_STATUS_TLPIEX BIT(1)/* Transmit LPI Exit */ +#define LPI_CTRL_STATUS_TLPIEN BIT(0)/* Transmit LPI Entry */ +#define STMMAC_CHAIN_MODE 0x1#define STMMAC_RING_MODE 0x2
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +1 -12
@@ -59,22 +59,11 @@ enum power_event {/* Energy Efficient Ethernet (EEE) * * LPI status, timer and control register offset +* For LPI control and status bit definitions, see common.h. */ #define LPI_CTRL_STATUS 0x0030#define LPI_TIMER_CTRL 0x0034 -/* LPI control and status defines */ -#define LPI_CTRL_STATUS_LPITXA 0x00080000/* Enable LPI TX Automate */ -#define LPI_CTRL_STATUS_PLSEN 0x00040000/* Enable PHY Link Status */ -#define LPI_CTRL_STATUS_PLS 0x00020000/* PHY Link Status */ -#define LPI_CTRL_STATUS_LPIEN 0x00010000/* LPI Enable */ -#define LPI_CTRL_STATUS_RLPIST 0x00000200/* Receive LPI state */ -#define LPI_CTRL_STATUS_TLPIST 0x00000100/* Transmit LPI state */ -#define LPI_CTRL_STATUS_RLPIEX 0x00000008/* Receive LPI Exit */ -#define LPI_CTRL_STATUS_RLPIEN 0x00000004/* Receive LPI Entry */ -#define LPI_CTRL_STATUS_TLPIEX 0x00000002/* Transmit LPI Exit */ -#define LPI_CTRL_STATUS_TLPIEN 0x00000001/* Transmit LPI Entry */ -/* GMAC HW ADDR regs */ #define GMAC_ADDR_HIGH (reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \ 0x00000040 + (reg * 8))
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +1 -11
@@ -177,23 +177,13 @@ enum power_event {/* Energy Efficient Ethernet (EEE) for GMAC4 * * LPI status, timer and control register offset +* For LPI control and status bit definitions, see common.h. */ #define GMAC4_LPI_CTRL_STATUS 0xd0#define GMAC4_LPI_TIMER_CTRL 0xd4#define GMAC4_LPI_ENTRY_TIMER 0xd8#define GMAC4_MAC_ONEUS_TIC_COUNTER 0xdc -/* LPI control and status defines */ -#define GMAC4_LPI_CTRL_STATUS_LPITCSE BIT(21)/* LPI Tx Clock Stop Enable */ -#define GMAC4_LPI_CTRL_STATUS_LPIATE BIT(20)/* LPI Timer Enable */ -#define GMAC4_LPI_CTRL_STATUS_LPITXA BIT(19)/* Enable LPI TX Automate */ -#define GMAC4_LPI_CTRL_STATUS_PLS BIT(17)/* PHY Link Status */ -#define GMAC4_LPI_CTRL_STATUS_LPIEN BIT(16)/* LPI Enable */ -#define GMAC4_LPI_CTRL_STATUS_RLPIEX BIT(3)/* Receive LPI Exit */ -#define GMAC4_LPI_CTRL_STATUS_RLPIEN BIT(2)/* Receive LPI Entry */ -#define GMAC4_LPI_CTRL_STATUS_TLPIEX BIT(1)/* Transmit LPI Exit */ -#define GMAC4_LPI_CTRL_STATUS_TLPIEN BIT(0)/* Transmit LPI Entry */ -/* MAC Debug bitmap */ #define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17)#define GMAC_DEBUG_TFCSTS_SHIFT 17
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +14 -14
@@ -387,11 +387,11 @@ static void dwmac4_set_eee_mode(struct mac_device_info *hw,* state. */ value =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); - value &= ~GMAC4_LPI_CTRL_STATUS_LPIATE ; - value |=GMAC4_LPI_CTRL_STATUS_LPIEN |GMAC4_LPI_CTRL_STATUS_LPITXA ; + value &= ~LPI_CTRL_STATUS_LPIATE ; + value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ;if (en_tx_lpi_clockgating) - value |=GMAC4_LPI_CTRL_STATUS_LPITCSE ; + value |=LPI_CTRL_STATUS_LPITCSE ;writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS ); }
@@ -402,8 +402,8 @@ static void dwmac4_reset_eee_mode(struct mac_device_info *hw)u32 value; value =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); - value &= ~(GMAC4_LPI_CTRL_STATUS_LPIATE |GMAC4_LPI_CTRL_STATUS_LPIEN | -GMAC4_LPI_CTRL_STATUS_LPITXA ); + value &= ~(LPI_CTRL_STATUS_LPIATE |LPI_CTRL_STATUS_LPIEN | +LPI_CTRL_STATUS_LPITXA );writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS ); }
@@ -415,9 +415,9 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link) value =readl (ioaddr +GMAC4_LPI_CTRL_STATUS );if (link) - value |=GMAC4_LPI_CTRL_STATUS_PLS ; + value |=LPI_CTRL_STATUS_PLS ;else - value &= ~GMAC4_LPI_CTRL_STATUS_PLS ; + value &= ~LPI_CTRL_STATUS_PLS ;writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS ); }
@@ -433,12 +433,12 @@ static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, u32 et)/* Enable/disable LPI entry timer */ regval =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); - regval |=GMAC4_LPI_CTRL_STATUS_LPIEN |GMAC4_LPI_CTRL_STATUS_LPITXA ; + regval |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ;if (et) - regval |=GMAC4_LPI_CTRL_STATUS_LPIATE ; + regval |=LPI_CTRL_STATUS_LPIATE ;else - regval &= ~GMAC4_LPI_CTRL_STATUS_LPIATE ; + regval &= ~LPI_CTRL_STATUS_LPIATE ;writel (regval, ioaddr +GMAC4_LPI_CTRL_STATUS ); }
@@ -851,17 +851,17 @@ static int dwmac4_irq_status(struct mac_device_info *hw,/* Clear LPI interrupt by reading MAC_LPI_Control_Status */ u32 status =readl (ioaddr +GMAC4_LPI_CTRL_STATUS ); -if (status &GMAC4_LPI_CTRL_STATUS_TLPIEN ) { +if (status &LPI_CTRL_STATUS_TLPIEN ) { ret |=CORE_IRQ_TX_PATH_IN_LPI_MODE ; x->irq_tx_path_in_lpi_mode_n++; } -if (status &GMAC4_LPI_CTRL_STATUS_TLPIEX ) { +if (status &LPI_CTRL_STATUS_TLPIEX ) { ret |=CORE_IRQ_TX_PATH_EXIT_LPI_MODE ; x->irq_tx_path_exit_lpi_mode_n++; } -if (status &GMAC4_LPI_CTRL_STATUS_RLPIEN ) +if (status &LPI_CTRL_STATUS_RLPIEN ) x->irq_rx_path_in_lpi_mode_n++; -if (status &GMAC4_LPI_CTRL_STATUS_RLPIEX ) +if (status &LPI_CTRL_STATUS_RLPIEX ) x->irq_rx_path_exit_lpi_mode_n++; }
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +1 -8
@@ -112,14 +112,7 @@#define XGMAC_MGKPKTEN BIT(1)#define XGMAC_PWRDWN BIT(0)#define XGMAC_LPI_CTRL 0x000000d0 -#define XGMAC_TXCGE BIT(21) -#define XGMAC_LPITXA BIT(19) -#define XGMAC_PLS BIT(17) -#define XGMAC_LPITXEN BIT(16) -#define XGMAC_RLPIEX BIT(3) -#define XGMAC_RLPIEN BIT(2) -#define XGMAC_TLPIEX BIT(1) -#define XGMAC_TLPIEN BIT(0) +/* For definitions, see LPI_CTRL_STATUS_xxx in common.h */ #define XGMAC_LPI_TIMER_CTRL 0x000000d4#define XGMAC_HW_FEATURE0 0x0000011c#define XGMAC_HWFEAT_EDMA BIT(31)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +9 -9
@@ -316,17 +316,17 @@ static int dwxgmac2_host_irq_status(struct mac_device_info *hw,if (stat &XGMAC_LPIIS ) {u32 lpi =readl (ioaddr +XGMAC_LPI_CTRL ); -if (lpi &XGMAC_TLPIEN ) { +if (lpi &LPI_CTRL_STATUS_TLPIEN ) { ret |=CORE_IRQ_TX_PATH_IN_LPI_MODE ; x->irq_tx_path_in_lpi_mode_n++; } -if (lpi &XGMAC_TLPIEX ) { +if (lpi &LPI_CTRL_STATUS_TLPIEX ) { ret |=CORE_IRQ_TX_PATH_EXIT_LPI_MODE ; x->irq_tx_path_exit_lpi_mode_n++; } -if (lpi &XGMAC_RLPIEN ) +if (lpi &LPI_CTRL_STATUS_RLPIEN ) x->irq_rx_path_in_lpi_mode_n++; -if (lpi &XGMAC_RLPIEX ) +if (lpi &LPI_CTRL_STATUS_RLPIEX ) x->irq_rx_path_exit_lpi_mode_n++; }
@@ -433,9 +433,9 @@ static void dwxgmac2_set_eee_mode(struct mac_device_info *hw, value =readl (ioaddr +XGMAC_LPI_CTRL ); - value |=XGMAC_LPITXEN |XGMAC_LPITXA ; + value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ;if (en_tx_lpi_clockgating) - value |=XGMAC_TXCGE ; + value |=LPI_CTRL_STATUS_LPITCSE ;writel (value, ioaddr +XGMAC_LPI_CTRL ); }
@@ -446,7 +446,7 @@ static void dwxgmac2_reset_eee_mode(struct mac_device_info *hw)u32 value; value =readl (ioaddr +XGMAC_LPI_CTRL ); - value &= ~(XGMAC_LPITXEN |XGMAC_LPITXA |XGMAC_TXCGE ); + value &= ~(LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA |LPI_CTRL_STATUS_LPITCSE );writel (value, ioaddr +XGMAC_LPI_CTRL ); }
@@ -457,9 +457,9 @@ static void dwxgmac2_set_eee_pls(struct mac_device_info *hw, int link) value =readl (ioaddr +XGMAC_LPI_CTRL );if (link) - value |=XGMAC_PLS ; + value |=LPI_CTRL_STATUS_PLS ;else - value &= ~XGMAC_PLS ; + value &= ~LPI_CTRL_STATUS_PLS ;writel (value, ioaddr +XGMAC_LPI_CTRL ); }
Signature · 1 line
2.30.2
RFC PATCH 11/22 net: stmmac: add new MAC method set_lpi_mode()
In reply to Russell King (Oracle)Add a new method to control LPI mode configuration. This is architected to have three configuration states: LPI disabled, LPI forced (active), or LPI under hardware timer control. This reflects the three modes which the main body of the driver wishes to deal with.
We pass in whether transmit clock gating should be used, and the hardware timer value in microseconds to be set when using hardware timer control.
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 33 ++++---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 83 +++++++++++-------- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 36 +++++--- drivers/net/ethernet/stmicro/stmmac/hwif.h | 11 +++ 4 files changed, 102 insertions(+), 61 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +19 -14
@@ -342,31 +342,35 @@ static int dwmac1000_irq_status(struct mac_device_info *hw,return ret; } -static void dwmac1000_set_eee_mode (struct mac_device_info *hw, -bool en_tx_lpi_clockgating) +static int dwmac1000_set_lpi_mode (struct mac_device_info *hw, +enum stmmac_lpi_mode mode, +bool en_tx_lpi_clockgating,u32 et) {void __iomem *ioaddr = hw->pcsr;u32 value; -/*TODO - en_tx_lpi_clockgating treatment */ +if (mode ==STMMAC_LPI_TIMER ) +return -EOPNOTSUPP ; -/* Enable the link status receive on RGMII, SGMII ore SMII -* receive path and instruct the transmit to enter in LPI -* state. -*/ value =readl (ioaddr +LPI_CTRL_STATUS ); - value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ; +if (mode ==STMMAC_LPI_FORCED ) + value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ; +else + value &= ~(LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA );writel (value, ioaddr +LPI_CTRL_STATUS ); + +return 0 ; } -static void dwmac1000_reset_eee_mode (struct mac_device_info *hw) +static void dwmac1000_set_eee_mode (struct mac_device_info *hw, +bool en_tx_lpi_clockgating) { -void __iomem *ioaddr = hw->pcsr; -u32 value; +dwmac1000_set_lpi_mode (hw,STMMAC_LPI_FORCED , en_tx_lpi_clockgating,0 ); +} - value =readl (ioaddr +LPI_CTRL_STATUS ); - value &= ~(LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ); -writel (value, ioaddr +LPI_CTRL_STATUS ); +static void dwmac1000_reset_eee_mode (struct mac_device_info *hw) +{ +dwmac1000_set_lpi_mode (hw,STMMAC_LPI_DISABLE , false,0 ); }static void dwmac1000_set_eee_pls (struct mac_device_info *hw,int link)
@@ -509,6 +513,7 @@ const struct stmmac_ops dwmac1000_ops = { .pmt = dwmac1000_pmt, .set_umac_addr = dwmac1000_set_umac_addr, .get_umac_addr = dwmac1000_get_umac_addr, + .set_lpi_mode = dwmac1000_set_lpi_mode, .set_eee_mode = dwmac1000_set_eee_mode, .reset_eee_mode = dwmac1000_reset_eee_mode, .set_eee_timer = dwmac1000_set_eee_timer,
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +48 -35
124 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +24 -12
@@ -425,29 +425,39 @@ static void dwxgmac2_get_umac_addr(struct mac_device_info *hw, addr[5 ] = (hi_addr >>8 ) &0xff ; } -static void dwxgmac2_set_eee_mode (struct mac_device_info *hw, -bool en_tx_lpi_clockgating) +static int dwxgmac2_set_lpi_mode (struct mac_device_info *hw, +enum stmmac_lpi_mode mode, +bool en_tx_lpi_clockgating,u32 et) {void __iomem *ioaddr = hw->pcsr;u32 value; +if (mode ==STMMAC_LPI_TIMER ) +return -EOPNOTSUPP ; + value =readl (ioaddr +XGMAC_LPI_CTRL ); +if (mode ==STMMAC_LPI_FORCED ) { + value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ; +if (en_tx_lpi_clockgating) + value |=LPI_CTRL_STATUS_LPITCSE ; + }else { + value &= ~(LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA | +LPI_CTRL_STATUS_LPITCSE ); + } +writel (value, ioaddr +XGMAC_LPI_CTRL ); - value |=LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA ; -if (en_tx_lpi_clockgating) - value |=LPI_CTRL_STATUS_LPITCSE ; +return 0 ; +} -writel (value, ioaddr +XGMAC_LPI_CTRL ); +static void dwxgmac2_set_eee_mode (struct mac_device_info *hw, +bool en_tx_lpi_clockgating) +{ +dwxgmac2_set_lpi_mode (hw,STMMAC_LPI_FORCED , en_tx_lpi_clockgating,0 ); }static void dwxgmac2_reset_eee_mode (struct mac_device_info *hw) { -void __iomem *ioaddr = hw->pcsr; -u32 value; - - value =readl (ioaddr +XGMAC_LPI_CTRL ); - value &= ~(LPI_CTRL_STATUS_LPIEN |LPI_CTRL_STATUS_LPITXA |LPI_CTRL_STATUS_LPITCSE ); -writel (value, ioaddr +XGMAC_LPI_CTRL ); +dwxgmac2_set_lpi_mode (hw,STMMAC_LPI_DISABLE , false,0 ); }static void dwxgmac2_set_eee_pls (struct mac_device_info *hw,int link)
@@ -1525,6 +1535,7 @@ const struct stmmac_ops dwxgmac210_ops = { .pmt = dwxgmac2_pmt, .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, + .set_lpi_mode = dwxgmac2_set_lpi_mode, .set_eee_mode = dwxgmac2_set_eee_mode, .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer,
@@ -1582,6 +1593,7 @@ const struct stmmac_ops dwxlgmac2_ops = { .pmt = dwxgmac2_pmt, .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, + .set_lpi_mode = dwxgmac2_set_lpi_mode, .set_eee_mode = dwxgmac2_set_eee_mode, .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer,
drivers/net/ethernet/stmicro/stmmac/hwif.h +11 -0
@@ -306,6 +306,12 @@ struct stmmac_pps_cfg;struct stmmac_rss ;struct stmmac_est ; +enum stmmac_lpi_mode { +STMMAC_LPI_DISABLE , +STMMAC_LPI_FORCED , +STMMAC_LPI_TIMER , +}; +/* Helpers to program the MAC core */ struct stmmac_ops {/* MAC core initialization */
@@ -360,6 +366,9 @@ struct stmmac_ops { unsigned int reg_n);void (*get_umac_addr)(struct mac_device_info *hw,unsigned char *addr,unsigned int reg_n); +int (*set_lpi_mode)(struct mac_device_info *hw, +enum stmmac_lpi_mode mode, +bool en_tx_lpi_clockgating,u32 et);void (*set_eee_mode)(struct mac_device_info *hw,bool en_tx_lpi_clockgating);void (*reset_eee_mode)(struct mac_device_info *hw);
@@ -467,6 +476,8 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_umac_addr, __args) #define stmmac_get_umac_addr(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) +#define stmmac_set_lpi_mode(__priv, __args...) \ + stmmac_do_callback(__priv, mac, set_lpi_mode, __args) #define stmmac_set_eee_mode(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_eee_mode, __args) #define stmmac_reset_eee_mode(__priv, __args...) \
Signature · 1 line
2.30.2
RFC PATCH 12/22 net: stmmac: dwmac4: clear LPI_CTRL_STATUS_LPITCSE too
In reply to Russell King (Oracle)Ensure that LPI_CTRL_STATUS_LPITCSE is also appropriately cleared when disabling LPI or enabling LPI without TX clock gating.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +1 -1
@@ -410,7 +410,7 @@ static int dwmac4_set_lpi_mode(struct mac_device_info *hw, } mask =LPI_CTRL_STATUS_LPIATE |LPI_CTRL_STATUS_LPIEN | -LPI_CTRL_STATUS_LPITXA ; +LPI_CTRL_STATUS_LPITXA |LPI_CTRL_STATUS_LPITCSE ; value |=readl (ioaddr +GMAC4_LPI_CTRL_STATUS ) & ~mask;writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS );
Signature · 1 line
2.30.2
RFC PATCH 13/22 net: stmmac: use stmmac_set_lpi_mode()
In reply to Russell King (Oracle)Use the new stmmac_set_lpi_mode() API to configure the parameters of the desired LPI mode rather than the older methods.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +15 -14
@@ -390,11 +390,6 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue)return dirty; } -static void stmmac_enable_hw_lpi_timer (struct stmmac_priv *priv) -{ -stmmac_set_eee_lpi_timer (priv, priv->hw, priv->tx_lpi_timer); -} -static bool stmmac_eee_tx_busy (struct stmmac_priv *priv) {u32 tx_cnt = priv->plat->tx_queues_to_use;
@@ -431,8 +426,9 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)/* Check and enter in LPI mode */ if (!priv->tx_path_in_lpi_mode) -stmmac_set_eee_mode (priv, priv->hw, - priv->plat->flags &STMMAC_FLAG_EN_TX_LPI_CLOCKGATING ); +stmmac_set_lpi_mode (priv, priv->hw,STMMAC_LPI_FORCED , + priv->plat->flags &STMMAC_FLAG_EN_TX_LPI_CLOCKGATING , +0 ); }/**
@@ -443,7 +439,7 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)static void stmmac_stop_sw_lpi (struct stmmac_priv *priv) {del_timer_sync (&priv->eee_ctrl_timer); -stmmac_reset_eee_mode (priv, priv->hw); +stmmac_set_lpi_mode (priv, priv->hw,STMMAC_LPI_DISABLE , false,0 ); priv->tx_path_in_lpi_mode = false; }
@@ -1046,7 +1042,7 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config)netdev_dbg (priv->dev,"disable EEE\n" ); priv->eee_sw_timer_en = false;del_timer_sync (&priv->eee_ctrl_timer); -stmmac_reset_eee_mode (priv, priv->hw); +stmmac_set_lpi_mode (priv, priv->hw,STMMAC_LPI_DISABLE , false,0 ); priv->tx_path_in_lpi_mode = false;stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS );
@@ -1061,6 +1057,7 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop) {struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); +int ret; priv->tx_lpi_timer = timer; priv->eee_active = true;
@@ -1075,11 +1072,15 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,xpcs_config_eee (priv->hw->xpcs, priv->plat->mult_fact_100ns, true); -if (priv->plat->has_gmac4 && priv->tx_lpi_timer <=STMMAC_ET_MAX ) { -/* Use hardware LPI mode */ -stmmac_enable_hw_lpi_timer (priv); - }else { -/* Use software LPI mode */ +/* Try to cnfigure the hardware timer. */ + ret =stmmac_set_lpi_mode (priv, priv->hw,STMMAC_LPI_TIMER , + priv->plat->flags &STMMAC_FLAG_EN_TX_LPI_CLOCKGATING , + priv->tx_lpi_timer); + +if (ret) { +/* Hardware timer mode not supported, or value out of range. +* Fall back to using software LPI mode +*/ priv->eee_sw_timer_en = true;stmmac_restart_sw_lpi_timer (priv); }
Signature · 1 line
2.30.2
RFC PATCH 14/22 net: stmmac: remove old EEE methods
In reply to Russell King (Oracle)As we no longer call the set_eee_mode(), reset_eee_mode() and set_eee_lpi_entry_timer() methods, remove these and their glue in common.h
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 13 --------- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 29 ------------------- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 15 ---------- drivers/net/ethernet/stmicro/stmmac/hwif.h | 10 ------- 4 files changed, 67 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +0 -13
@@ -362,17 +362,6 @@ static int dwmac1000_set_lpi_mode(struct mac_device_info *hw,return 0 ; } -static void dwmac1000_set_eee_mode (struct mac_device_info *hw, -bool en_tx_lpi_clockgating) -{ -dwmac1000_set_lpi_mode (hw,STMMAC_LPI_FORCED , en_tx_lpi_clockgating,0 ); -} - -static void dwmac1000_reset_eee_mode (struct mac_device_info *hw) -{ -dwmac1000_set_lpi_mode (hw,STMMAC_LPI_DISABLE , false,0 ); -} -static void dwmac1000_set_eee_pls (struct mac_device_info *hw,int link) {void __iomem *ioaddr = hw->pcsr;
@@ -514,8 +503,6 @@ const struct stmmac_ops dwmac1000_ops = { .set_umac_addr = dwmac1000_set_umac_addr, .get_umac_addr = dwmac1000_get_umac_addr, .set_lpi_mode = dwmac1000_set_lpi_mode, - .set_eee_mode = dwmac1000_set_eee_mode, - .reset_eee_mode = dwmac1000_reset_eee_mode, .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug,
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +0 -29
@@ -418,21 +418,6 @@ static int dwmac4_set_lpi_mode(struct mac_device_info *hw,return 0 ; } -static void dwmac4_set_eee_mode (struct mac_device_info *hw, -bool en_tx_lpi_clockgating) -{ -/* Enable the link status receive on RGMII, SGMII ore SMII -* receive path and instruct the transmit to enter in LPI -* state. -*/ -dwmac4_set_lpi_mode (hw,STMMAC_LPI_FORCED , en_tx_lpi_clockgating,0 ); -} - -static void dwmac4_reset_eee_mode (struct mac_device_info *hw) -{ -dwmac4_set_lpi_mode (hw,STMMAC_LPI_DISABLE , false,0 ); -} -static void dwmac4_set_eee_pls (struct mac_device_info *hw,int link) {void __iomem *ioaddr = hw->pcsr;
@@ -448,11 +433,6 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link)writel (value, ioaddr +GMAC4_LPI_CTRL_STATUS ); } -static void dwmac4_set_eee_lpi_entry_timer (struct mac_device_info *hw,u32 et) -{ -dwmac4_set_lpi_mode (hw,STMMAC_LPI_TIMER , false, et &STMMAC_ET_MAX ); -} -static void dwmac4_set_eee_timer (struct mac_device_info *hw,int ls,int tw) {void __iomem *ioaddr = hw->pcsr;
@@ -1214,9 +1194,6 @@ const struct stmmac_ops dwmac4_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane,
@@ -1259,9 +1236,6 @@ const struct stmmac_ops dwmac410_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane,
@@ -1306,9 +1280,6 @@ const struct stmmac_ops dwmac510_ops = { .set_umac_addr = dwmac4_set_umac_addr, .get_umac_addr = dwmac4_get_umac_addr, .set_lpi_mode = dwmac4_set_lpi_mode, - .set_eee_mode = dwmac4_set_eee_mode, - .reset_eee_mode = dwmac4_reset_eee_mode, - .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane,
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +0 -15
@@ -449,17 +449,6 @@ static int dwxgmac2_set_lpi_mode(struct mac_device_info *hw,return 0 ; } -static void dwxgmac2_set_eee_mode (struct mac_device_info *hw, -bool en_tx_lpi_clockgating) -{ -dwxgmac2_set_lpi_mode (hw,STMMAC_LPI_FORCED , en_tx_lpi_clockgating,0 ); -} - -static void dwxgmac2_reset_eee_mode (struct mac_device_info *hw) -{ -dwxgmac2_set_lpi_mode (hw,STMMAC_LPI_DISABLE , false,0 ); -} -static void dwxgmac2_set_eee_pls (struct mac_device_info *hw,int link) {void __iomem *ioaddr = hw->pcsr;
@@ -1536,8 +1525,6 @@ const struct stmmac_ops dwxgmac210_ops = { .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, .set_lpi_mode = dwxgmac2_set_lpi_mode, - .set_eee_mode = dwxgmac2_set_eee_mode, - .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, .debug = NULL,
@@ -1594,8 +1581,6 @@ const struct stmmac_ops dwxlgmac2_ops = { .set_umac_addr = dwxgmac2_set_umac_addr, .get_umac_addr = dwxgmac2_get_umac_addr, .set_lpi_mode = dwxgmac2_set_lpi_mode, - .set_eee_mode = dwxgmac2_set_eee_mode, - .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, .debug = NULL,
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -10
@@ -369,10 +369,6 @@ struct stmmac_ops {int (*set_lpi_mode)(struct mac_device_info *hw,enum stmmac_lpi_mode mode,bool en_tx_lpi_clockgating,u32 et); -void (*set_eee_mode)(struct mac_device_info *hw, -bool en_tx_lpi_clockgating); -void (*reset_eee_mode)(struct mac_device_info *hw); -void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw,u32 et);void (*set_eee_timer)(struct mac_device_info *hw,int ls,int tw);void (*set_eee_pls)(struct mac_device_info *hw,int link); void (*debug)(struct stmmac_priv *priv, void __iomem *ioaddr,
@@ -478,12 +474,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) #define stmmac_set_lpi_mode(__priv, __args...) \ stmmac_do_callback(__priv, mac, set_lpi_mode, __args) -#define stmmac_set_eee_mode(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, set_eee_mode, __args) -#define stmmac_reset_eee_mode(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args) -#define stmmac_set_eee_lpi_timer(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, set_eee_lpi_entry_timer, __args) #define stmmac_set_eee_timer(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_eee_timer, __args) #define stmmac_set_eee_pls(__priv, __args...) \
Signature · 1 line
2.30.2
RFC PATCH 15/22 net: phylink: add support for notifying PCS about EEE
In reply to Russell King (Oracle)There are hooks in the stmmac driver into XPCS to control the EEE settings when LPI is configured at the MAC. This bypasses the layering. To allow this to be removed from the stmmac driver, add two new methods for PCS to inform them when the LPI/EEE enablement state changes at the MAC.
--- drivers/net/phy/phylink.c | 25 ++++++++++++++++++++++--- include/linux/phylink.h | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/net/phy/phylink.c +22 -3
@@ -1073,6 +1073,18 @@ static void phylink_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, pcs->ops->pcs_link_up (pcs, neg_mode, interface, speed, duplex); } +static void phylink_pcs_disable_eee (struct phylink_pcs *pcs) +{ +if (pcs && pcs->ops->pcs_disable_eee) + pcs->ops->pcs_disable_eee (pcs); +} + +static void phylink_pcs_enable_eee (struct phylink_pcs *pcs) +{ +if (pcs && pcs->ops->pcs_enable_eee) + pcs->ops->pcs_enable_eee (pcs); +} +/* Query inband for a specific interface mode, asking the MAC for the * PCS which will be used to handle the interface mode. */
@@ -1601,6 +1613,8 @@ static void phylink_deactivate_lpi(struct phylink *pl)phylink_dbg (pl,"disabling LPI\n" ); pl->mac_ops->mac_disable_tx_lpi (pl->config); + +phylink_pcs_disable_eee (pl->pcs); } }
@@ -1617,13 +1631,18 @@ static void phylink_activate_lpi(struct phylink *pl)phylink_dbg (pl,"LPI timer %uus, tx clock stop %u\n" , pl->mac_tx_lpi_timer, pl->mac_tx_clk_stop); +phylink_pcs_enable_eee (pl->pcs); + err = pl->mac_ops->mac_enable_tx_lpi (pl->config, pl->mac_tx_lpi_timer, pl->mac_tx_clk_stop); -if (!err) - pl->mac_enable_tx_lpi = true; -else +if (err) { +phylink_pcs_disable_eee (pl->pcs);phylink_err (pl,"%ps() failed: %pe\n" , pl->mac_ops->mac_enable_tx_lpi,ERR_PTR (err)); +return ; + } + + pl->mac_enable_tx_lpi = true; } static void phylink_link_up(struct phylink *pl,
include/linux/phylink.h +22 -0
@@ -477,6 +477,10 @@ struct phylink_pcs {* @pcs_an_restart: restart 802.3z BaseX autonegotiation. * @pcs_link_up: program the PCS for the resolved link configuration * (where necessary). +* @pcs_disable_eee: optional notification to PCS that EEE has been disabled +* at the MAC. +* @pcs_enable_eee: optional notification to PCS that EEE will be enabled at +* the MAC. * @pcs_pre_init: configure PCS components necessary for MAC hardware * initialization e.g. RX clock for stmmac. */
@@ -500,6 +504,8 @@ struct phylink_pcs_ops {void (*pcs_an_restart)(struct phylink_pcs *pcs);void (*pcs_link_up)(struct phylink_pcs *pcs,unsigned int neg_mode,phy_interface_t interface,int speed,int duplex); +void (*pcs_disable_eee)(struct phylink_pcs *pcs); +void (*pcs_enable_eee)(struct phylink_pcs *pcs);int (*pcs_pre_init)(struct phylink_pcs *pcs); };
@@ -625,6 +631,22 @@ void pcs_an_restart(struct phylink_pcs *pcs);void pcs_link_up (struct phylink_pcs *pcs,unsigned int neg_mode,phy_interface_t interface,int speed,int duplex); +/** +* pcs_disable_eee() - Disable EEE at the PCS +* @pcs: a pointer to a &struct phylink_pcs +* +* Optional method informing the PCS that EEE has been disabled at the MAC. +*/ +void pcs_disable_eee (struct phylink_pcs *pcs); + +/** +* pcs_enable_eee() - Enable EEE at the PCS +* @pcs: a pointer to a &struct phylink_pcs +* +* Optional method informing the PCS that EEE is about to be enabled at the MAC. +*/ +void pcs_enable_eee (struct phylink_pcs *pcs); +/** * pcs_pre_init() - Configure PCS components necessary for MAC initialization * @pcs: a pointer to a &struct phylink_pcs.
Signature · 1 line
2.30.2
RFC PATCH 16/22 net: xpcs: add function to configure EEE clock multiplying factor
In reply to Russell King (Oracle)Add a function to separate out the EEE clock multiplying factor. This will be called by the stmmac driver to configure this value.
It would have been better had the driver used the CLK API to retrieve this clock, get its rate and calculate the appropriate multiplier, but that door has closed.
Question: Is there any other solution to this so we can avoid keeping this XPCS-specific function that MAC drivers have to know about if they are going to use EEE with XPCS?
--- drivers/net/pcs/pcs-xpcs.c | 14 ++++++++++++++ drivers/net/pcs/pcs-xpcs.h | 1 + include/linux/pcs/pcs-xpcs.h | 1 + 3 files changed, 16 insertions(+)
drivers/net/pcs/pcs-xpcs.c +14 -0
@@ -1193,6 +1193,20 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +/** +* xpcs_config_eee_mult_fact() - set the EEE clock multiplying factor +* @xpcs: pointer to a &struct dw_xpcs instance +* @mult_fact: the multiplying factor +* +* Configure the EEE clock multiplying factor. This value should be such that +* clk_eee_time_period * (mult_fact + 1) is within the range 80 to 120ns. +*/ +void xpcs_config_eee_mult_fact (struct dw_xpcs *xpcs,u8 mult_fact) +{ + xpcs->eee_mult_fact = mult_fact; +} +EXPORT_SYMBOL_GPL (xpcs_config_eee_mult_fact); +static int xpcs_read_ids (struct dw_xpcs *xpcs) {int ret;
drivers/net/pcs/pcs-xpcs.h +1 -0
@@ -122,6 +122,7 @@ struct dw_xpcs {struct phylink_pcs pcs;phy_interface_t interface;bool need_reset; +u8 eee_mult_fact; };int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg);
include/linux/pcs/pcs-xpcs.h +1 -0
@@ -52,6 +52,7 @@ struct phylink_pcs *xpcs_to_phylink_pcs(struct dw_xpcs *xpcs);int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface);int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable); +void xpcs_config_eee_mult_fact (struct dw_xpcs *xpcs,u8 mult_fact);struct dw_xpcs *xpcs_create_mdiodev (struct mii_bus *bus,int addr);struct dw_xpcs *xpcs_create_fwnode (struct fwnode_handle *fwnode);void xpcs_destroy (struct dw_xpcs *xpcs);
Signature · 1 line
2.30.2
RFC PATCH 17/22 net: stmmac: call xpcs_config_eee_mult_fact()
In reply to Russell King (Oracle)Arrange for stmmac to call the new xpcs_config_eee_mult_fact() function to configure the EEE clock multiplying factor. This will allow the removal of the xpcs_config_eee() calls in the next patch.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +2 -0
@@ -524,6 +524,8 @@ int stmmac_pcs_setup(struct net_device *ndev)if (ret)return dev_err_probe (priv->device, ret,"No xPCS found\n" ); +xpcs_config_eee_mult_fact (xpcs, priv->plat->mult_fact_100ns); + priv->hw->xpcs = xpcs;return 0 ;
Signature · 1 line
2.30.2
RFC PATCH 18/22 net: xpcs: convert to phylink managed EEE
In reply to Russell King (Oracle)Convert XPCS to use the new pcs_disable_eee() and pcs_enable_eee() methods. Since stmmac is the only user of xpcs_config_eee(), we can make this a no-op along with this change.
Questions:
1. Do we actually need this level of control at the PCS - or would it be sufficient to configure it once during initialisation?
2. Do we need to clear the mult_fact field when disabling EEE?
--- drivers/net/pcs/pcs-xpcs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/net/pcs/pcs-xpcs.c +23 -1
@@ -602,7 +602,8 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)__set_bit (compat->interface, interfaces); } -int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable) +static int __xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns, +int enable) {u16 mask, val;int ret;
@@ -630,6 +631,11 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable)DW_VR_MII_EEE_TRN_LPI , enable ? DW_VR_MII_EEE_TRN_LPI : 0); } + +int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable) +{ +return 0 ; +}EXPORT_SYMBOL_GPL (xpcs_config_eee);static void xpcs_pre_config (struct phylink_pcs *pcs,phy_interface_t interface)
@@ -1193,6 +1199,20 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +static void xpcs_disable_eee (struct phylink_pcs *pcs) +{ +struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); + +__xpcs_config_eee (xpcs,0 , false); +} + +static void xpcs_enable_eee (struct phylink_pcs *pcs) +{ +struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); + +__xpcs_config_eee (xpcs, xpcs->eee_mult_fact, true); +} +/** * xpcs_config_eee_mult_fact() - set the EEE clock multiplying factor * @xpcs: pointer to a &struct dw_xpcs instance
@@ -1355,6 +1375,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_get_state = xpcs_get_state, .pcs_an_restart = xpcs_an_restart, .pcs_link_up = xpcs_link_up, + .pcs_disable_eee = xpcs_disable_eee, + .pcs_enable_eee = xpcs_enable_eee, };static int xpcs_identify (struct dw_xpcs *xpcs)
Signature · 1 line
2.30.2
RFC PATCH 19/22 net: stmmac: remove calls to xpcs_config_eee()
In reply to Russell King (Oracle)Remove the explicit calls to xpcs_config_eee() from the stmmac driver, preferring instead for phylink to manage the EEE configuration at the PCS.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -7
@@ -1046,10 +1046,6 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config) priv->tx_path_in_lpi_mode = false;stmmac_set_eee_timer (priv, priv->hw,0 ,STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, priv->plat->mult_fact_100ns, - false); -mutex_unlock (&priv->lock); }
@@ -1068,9 +1064,6 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,stmmac_set_eee_timer (priv, priv->hw,STMMAC_DEFAULT_LIT_LS ,STMMAC_DEFAULT_TWT_LS ); -if (priv->hw->xpcs) -xpcs_config_eee (priv->hw->xpcs, priv->plat->mult_fact_100ns, - true);/* Try to cnfigure the hardware timer. */ ret = stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_TIMER,
Signature · 1 line
2.30.2
RFC PATCH 20/22 net: xpcs: remove xpcs_config_eee() from global scope
In reply to Russell King (Oracle)Make xpcs_config_eee() private to the XPCS driver, called only from the phylink pcs_disable_eee() and pcs_enable_eee() methods.
--- drivers/net/pcs/pcs-xpcs.c | 14 ++++---------- include/linux/pcs/pcs-xpcs.h | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-)
drivers/net/pcs/pcs-xpcs.c +4 -10
@@ -602,8 +602,8 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)__set_bit (compat->interface, interfaces); } -static int __xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns, -int enable) +static int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns, +int enable) {u16 mask, val;int ret;
@@ -632,12 +632,6 @@ static int __xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, enable ? DW_VR_MII_EEE_TRN_LPI : 0); } -int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable) -{ -return 0 ; -} -EXPORT_SYMBOL_GPL (xpcs_config_eee); -static void xpcs_pre_config (struct phylink_pcs *pcs,phy_interface_t interface) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);
@@ -1203,14 +1197,14 @@ static void xpcs_disable_eee(struct phylink_pcs *pcs) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); -__xpcs_config_eee (xpcs,0 , false); +xpcs_config_eee (xpcs,0 , false); }static void xpcs_enable_eee (struct phylink_pcs *pcs) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); -__xpcs_config_eee (xpcs, xpcs->eee_mult_fact, true); +xpcs_config_eee (xpcs, xpcs->eee_mult_fact, true); }/**
include/linux/pcs/pcs-xpcs.h +0 -2
@@ -50,8 +50,6 @@ struct dw_xpcs;struct phylink_pcs *xpcs_to_phylink_pcs (struct dw_xpcs *xpcs);int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface); -int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns, -int enable);void xpcs_config_eee_mult_fact (struct dw_xpcs *xpcs,u8 mult_fact);struct dw_xpcs *xpcs_create_mdiodev (struct mii_bus *bus,int addr);struct dw_xpcs *xpcs_create_fwnode (struct fwnode_handle *fwnode);
Signature · 1 line
2.30.2
RFC PATCH 21/22 net: xpcs: clean up xpcs_config_eee()
In reply to Russell King (Oracle)There is now no need to pass the mult_fact into xpcs_config_eee(), so let's remove that argument and use xpcs->eee_mult_fact directly. While changing the function signature, as we pass true/false for enable, use "bool" instead of "int" for this.
--- drivers/net/pcs/pcs-xpcs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/pcs/pcs-xpcs.c +4 -5
@@ -602,8 +602,7 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)__set_bit (compat->interface, interfaces); } -static int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns, -int enable) +static int xpcs_config_eee (struct dw_xpcs *xpcs,bool enable) {u16 mask, val;int ret;
@@ -618,7 +617,7 @@ static int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns,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 |FIELD_PREP (DW_VR_MII_EEE_MULT_FACT_100NS , - mult_fact_100ns); + xpcs->eee_mult_fact); else val =0 ;
@@ -1197,14 +1196,14 @@ static void xpcs_disable_eee(struct phylink_pcs *pcs) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); -xpcs_config_eee (xpcs,0 , false); +xpcs_config_eee (xpcs, false); }static void xpcs_enable_eee (struct phylink_pcs *pcs) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs); -xpcs_config_eee (xpcs, xpcs->eee_mult_fact, true); +xpcs_config_eee (xpcs, true); }/**
Signature · 1 line
2.30.2
RFC PATCH 22/22 net: xpcs: group EEE code together
In reply to Russell King (Oracle)Move xpcs_config_eee() with the other EEE-related functions.
--- drivers/net/pcs/pcs-xpcs.c | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/net/pcs/pcs-xpcs.c +29 -29
@@ -602,35 +602,6 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)__set_bit (compat->interface, interfaces); } -static int xpcs_config_eee (struct dw_xpcs *xpcs,bool enable) -{ -u16 mask, val; -int ret; - - mask =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 ; - -if (enable) - val =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 | -FIELD_PREP (DW_VR_MII_EEE_MULT_FACT_100NS , - xpcs->eee_mult_fact); -else - val =0 ; - - ret =xpcs_modify (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL0 , mask, - val); -if (ret <0 ) -return ret; - -return xpcs_modify (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL1 , -DW_VR_MII_EEE_TRN_LPI , - enable ?DW_VR_MII_EEE_TRN_LPI :0 ); -} -static void xpcs_pre_config (struct phylink_pcs *pcs,phy_interface_t interface) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);
@@ -1192,6 +1163,35 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) BMCR_ANRESTART); } +static int xpcs_config_eee (struct dw_xpcs *xpcs,bool enable) +{ +u16 mask, val; +int ret; + + mask =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 ; + +if (enable) + val =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 | +FIELD_PREP (DW_VR_MII_EEE_MULT_FACT_100NS , + xpcs->eee_mult_fact); +else + val =0 ; + + ret =xpcs_modify (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL0 , mask, + val); +if (ret <0 ) +return ret; + +return xpcs_modify (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_EEE_MCTRL1 , +DW_VR_MII_EEE_TRN_LPI , + enable ?DW_VR_MII_EEE_TRN_LPI :0 ); +} +static void xpcs_disable_eee (struct phylink_pcs *pcs) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);
Signature · 1 line
2.30.2