From: Andrew Lunn <andrew@lunn.ch>
To: netdev <netdev@vger.kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <rmk+kernel@armlinux.org.uk>,
Oleksij Rempel <linux@rempel-privat.de>,
Andrew Lunn <andrew@lunn.ch>
Subject: [RFC/RFTv3 14/24] net: sxgdb: Fixup EEE
Date: Fri, 31 Mar 2023 02:55:08 +0200 [thread overview]
Message-ID: <20230331005518.2134652-15-andrew@lunn.ch> (raw)
In-Reply-To: <20230331005518.2134652-1-andrew@lunn.ch>
The enabling/disabling of EEE in the MAC should happen as a result of
auto negotiation. So rework sxgbe_eee_adjust() to take the result of
negotiation into account.
sxgbe_set_eee() now just stores LTI timer value. Everything else is
passed to phylib, so it can correctly setup the PHY.
sxgbe_get_eee() relies on phylib doing most of the work, the MAC
driver just adds the LTI timer value.
The hw_cap.eee is now used to control timers, rather than eee_enabled,
which was wrongly being set based on the value of phy_init_eee()
before auto-neg even completed.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
.../net/ethernet/samsung/sxgbe/sxgbe_common.h | 3 --
.../ethernet/samsung/sxgbe/sxgbe_ethtool.c | 21 ++---------
.../net/ethernet/samsung/sxgbe/sxgbe_main.c | 36 ++++++-------------
3 files changed, 12 insertions(+), 48 deletions(-)
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
index 0f45107db8dd..c25588b90a13 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
@@ -502,8 +502,6 @@ struct sxgbe_priv_data {
struct timer_list eee_ctrl_timer;
bool tx_path_in_lpi_mode;
int lpi_irq;
- int eee_enabled;
- int eee_active;
int tx_lpi_timer;
};
@@ -528,5 +526,4 @@ int sxgbe_restore(struct net_device *ndev);
const struct sxgbe_mtl_ops *sxgbe_get_mtl_ops(void);
void sxgbe_disable_eee_mode(struct sxgbe_priv_data * const priv);
-bool sxgbe_eee_init(struct sxgbe_priv_data * const priv);
#endif /* __SXGBE_COMMON_H__ */
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c
index 8ba017ec9849..e7128864a3ef 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c
@@ -140,8 +140,6 @@ static int sxgbe_get_eee(struct net_device *dev,
if (!priv->hw_cap.eee)
return -EOPNOTSUPP;
- edata->eee_enabled = priv->eee_enabled;
- edata->eee_active = priv->eee_active;
edata->tx_lpi_timer = priv->tx_lpi_timer;
return phy_ethtool_get_eee(dev->phydev, edata);
@@ -152,22 +150,7 @@ static int sxgbe_set_eee(struct net_device *dev,
{
struct sxgbe_priv_data *priv = netdev_priv(dev);
- priv->eee_enabled = edata->eee_enabled;
-
- if (!priv->eee_enabled) {
- sxgbe_disable_eee_mode(priv);
- } else {
- /* We are asking for enabling the EEE but it is safe
- * to verify all by invoking the eee_init function.
- * In case of failure it will return an error.
- */
- priv->eee_enabled = sxgbe_eee_init(priv);
- if (!priv->eee_enabled)
- return -EOPNOTSUPP;
-
- /* Do not change tx_lpi_timer in case of failure */
- priv->tx_lpi_timer = edata->tx_lpi_timer;
- }
+ priv->tx_lpi_timer = edata->tx_lpi_timer;
return phy_ethtool_set_eee(dev->phydev, edata);
}
@@ -230,7 +213,7 @@ static void sxgbe_get_ethtool_stats(struct net_device *dev,
int i;
char *p;
- if (priv->eee_enabled) {
+ if (dev->phydev->eee_active) {
int val = phy_get_eee_err(dev->phydev);
if (val)
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 9664f029fa16..cf549a524674 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -119,18 +119,10 @@ static void sxgbe_eee_ctrl_timer(struct timer_list *t)
* phy can also manage EEE, so enable the LPI state and start the timer
* to verify if the tx path can enter in LPI state.
*/
-bool sxgbe_eee_init(struct sxgbe_priv_data * const priv)
+static void sxgbe_eee_init(struct sxgbe_priv_data * const priv)
{
- struct net_device *ndev = priv->dev;
- bool ret = false;
-
/* MAC core supports the EEE feature. */
if (priv->hw_cap.eee) {
- /* Check if the PHY supports EEE */
- if (phy_init_eee(ndev->phydev, true))
- return false;
-
- priv->eee_active = 1;
timer_setup(&priv->eee_ctrl_timer, sxgbe_eee_ctrl_timer, 0);
priv->eee_ctrl_timer.expires = SXGBE_LPI_TIMER(eee_timer);
add_timer(&priv->eee_ctrl_timer);
@@ -140,23 +132,15 @@ bool sxgbe_eee_init(struct sxgbe_priv_data * const priv)
priv->tx_lpi_timer);
pr_info("Energy-Efficient Ethernet initialized\n");
-
- ret = true;
}
-
- return ret;
}
-static void sxgbe_eee_adjust(const struct sxgbe_priv_data *priv)
+static void sxgbe_eee_adjust(const struct sxgbe_priv_data *priv,
+ bool eee_active)
{
- struct net_device *ndev = priv->dev;
-
- /* When the EEE has been already initialised we have to
- * modify the PLS bit in the LPI ctrl & status reg according
- * to the PHY link status. For this reason.
- */
- if (priv->eee_enabled)
- priv->hw->mac->set_eee_pls(priv->ioaddr, ndev->phydev->link);
+ if (priv->hw_cap.eee)
+ priv->hw->mac->set_eee_pls(priv->ioaddr, eee_active);
+ phy_eee_clk_stop_enable(priv->dev->phydev);
}
/**
@@ -250,7 +234,7 @@ static void sxgbe_adjust_link(struct net_device *dev)
phy_print_status(phydev);
/* Alter the MAC settings for EEE */
- sxgbe_eee_adjust(priv);
+ sxgbe_eee_adjust(priv, phydev->eee_active);
}
/**
@@ -803,7 +787,7 @@ static void sxgbe_tx_all_clean(struct sxgbe_priv_data * const priv)
sxgbe_tx_queue_clean(tqueue);
}
- if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) {
+ if (priv->hw_cap.eee && !priv->tx_path_in_lpi_mode) {
sxgbe_enable_eee_mode(priv);
mod_timer(&priv->eee_ctrl_timer, SXGBE_LPI_TIMER(eee_timer));
}
@@ -1181,7 +1165,7 @@ static int sxgbe_open(struct net_device *dev)
}
priv->tx_lpi_timer = SXGBE_DEFAULT_LPI_TIMER;
- priv->eee_enabled = sxgbe_eee_init(priv);
+ sxgbe_eee_init(priv);
napi_enable(&priv->napi);
netif_start_queue(dev);
@@ -1208,7 +1192,7 @@ static int sxgbe_release(struct net_device *dev)
{
struct sxgbe_priv_data *priv = netdev_priv(dev);
- if (priv->eee_enabled)
+ if (priv->hw_cap.eee)
del_timer_sync(&priv->eee_ctrl_timer);
/* Stop and disconnect the PHY */
--
2.40.0
next prev parent reply other threads:[~2023-03-31 0:55 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 0:54 [RFC/RFTv3 00/24] net: ethernet: Rework EEE Andrew Lunn
2023-03-31 0:54 ` [RFC/RFTv3 01/24] net: phy: Add phydev->eee_active to simplify adjust link callbacks Andrew Lunn
2023-05-30 17:51 ` Florian Fainelli
2023-03-31 0:54 ` [RFC/RFTv3 02/24] net: phylink: Add mac_set_eee() callback Andrew Lunn
2023-03-31 0:54 ` [RFC/RFTv3 03/24] net: phy: Add helper to set EEE Clock stop enable bit Andrew Lunn
2023-03-31 0:54 ` [RFC/RFTv3 04/24] net: phy: Keep track of EEE tx_lpi_enabled Andrew Lunn
2023-05-30 18:11 ` Florian Fainelli
2023-05-30 18:14 ` Russell King (Oracle)
2023-03-31 0:54 ` [RFC/RFTv3 05/24] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 06/24] net: phylink: Handle change in EEE from phylib Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 07/24] net: marvell: mvneta: Simplify EEE configuration Andrew Lunn
2023-05-30 18:03 ` Florian Fainelli
2023-03-31 0:55 ` [RFC/RFTv3 08/24] net: stmmac: Drop usage of phy_init_eee() Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 09/24] net: stmmac: Simplify ethtool get eee Andrew Lunn
2023-05-19 7:11 ` Oleksij Rempel
2023-03-31 0:55 ` [RFC/RFTv3 10/24] net: lan743x: Fixup EEE Andrew Lunn
2023-05-30 18:03 ` Florian Fainelli
2023-03-31 0:55 ` [RFC/RFTv3 11/24] net: fec: Move fec_enet_eee_mode_set() and helper earlier Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 12/24] net: FEC: Fixup EEE Andrew Lunn
2023-05-19 10:27 ` Oleksij Rempel
2023-03-31 0:55 ` [RFC/RFTv3 13/24] net: genet: " Andrew Lunn
2023-05-30 18:01 ` Florian Fainelli
2023-03-31 0:55 ` Andrew Lunn [this message]
2023-03-31 0:55 ` [RFC/RFTv3 15/24] net: dsa: mt7530: Swap to using phydev->eee_active Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 16/24] net: dsa: b53: " Andrew Lunn
2023-05-30 18:05 ` Florian Fainelli
2023-03-31 0:55 ` [RFC/RFTv3 17/24] net: phylink: Remove unused phylink_init_eee() Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 18/24] net: phy: remove unused phy_init_eee() Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 19/24] net: usb: lan78xx: Fixup EEE Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 20/24] net: phy: Add phy_support_eee() indicating MAC support EEE Andrew Lunn
2023-05-30 18:16 ` Florian Fainelli
2023-03-31 0:55 ` [RFC/RFTv3 21/24] net: phylink: Add MAC_EEE to mac_capabilites Andrew Lunn
2023-05-30 18:18 ` Florian Fainelli
2023-03-31 0:55 ` [RFC/RFTv3 22/24] net: phylink: Extend mac_capabilities in MAC drivers which support EEE Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 23/24] net: phylib: call phy_support_eee() " Andrew Lunn
2023-03-31 0:55 ` [RFC/RFTv3 24/24] net: phy: Disable EEE advertisement by default Andrew Lunn
2023-05-26 8:56 ` [RFC/RFTv3 00/24] net: ethernet: Rework EEE Oleksij Rempel
2023-05-26 12:08 ` Andrew Lunn
2023-05-26 16:13 ` Florian Fainelli
2023-05-30 18:31 ` Florian Fainelli
2023-05-30 19:35 ` Russell King (Oracle)
2023-05-30 19:49 ` Russell King (Oracle)
2023-05-31 7:14 ` Oleksij Rempel
2023-05-31 14:41 ` Russell King (Oracle)
2023-05-30 19:48 ` Andrew Lunn
2023-05-30 20:03 ` Florian Fainelli
2023-05-30 20:36 ` Russell King (Oracle)
2023-05-30 20:28 ` Russell King (Oracle)
2023-05-30 23:03 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331005518.2134652-15-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux@rempel-privat.de \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).