netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>, netdev <netdev@vger.kernel.org>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Landen Chao <Landen.Chao@mediatek.com>,
	DENG Qingfang <dqfext@gmail.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	Doug Berger <opendmb@gmail.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Wei Fang <wei.fang@nxp.com>, Shenwei Wang <shenwei.wang@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	UNGLinuxDriver@microchip.com, Byungho An <bh74.an@samsung.com>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Woojung Huh <woojung.huh@microchip.com>,
	Oleksij Rempel <linux@rempel-privat.de>
Subject: Re: [PATCH RFC 09/18] net: genet: Fixup EEE
Date: Thu, 16 Feb 2023 19:48:30 -0800	[thread overview]
Message-ID: <30ec2581-ab5d-2cf8-e5cb-dc7c99f43d3c@gmail.com> (raw)
In-Reply-To: <20230217034230.1249661-10-andrew@lunn.ch>



On 2/16/2023 7:42 PM, Andrew Lunn wrote:
> The enabling/disabling of EEE in the MAC should happen as a result of
> auto negotiation. So move the enable/disable into bcmgenet_mii_setup()
> which gets called by phylib when there is a change in link status.
> 
> bcmgenet_set_eee() now just writes the LTI timer value to the hardware
> and stores if TX LPI should be enabled. Everything else is passed to
> phylib, so it can correctly setup the PHY.
> 
> bcmgenet_get_eee() relies on phylib doing most of the work, the MAC
> driver just adds the LTI timer value from hardware and the stored
> tx_lpi_enabled.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

This looks similar to a number of patches for GENET that I need to 
resurrect against net-next, or even submit to net. LGTM at first glance, 
I will give you series a test.

> ---
>   .../net/ethernet/broadcom/genet/bcmgenet.c    | 31 ++++++-------------
>   .../net/ethernet/broadcom/genet/bcmgenet.h    |  1 +
>   drivers/net/ethernet/broadcom/genet/bcmmii.c  |  1 +
>   3 files changed, 12 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index d937daa8ee88..2793d94ed32c 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -1272,12 +1272,17 @@ static void bcmgenet_get_ethtool_stats(struct net_device *dev,
>   	}
>   }
>   
> -static void bcmgenet_eee_enable_set(struct net_device *dev, bool enable)
> +void bcmgenet_eee_enable_set(struct net_device *dev, bool eee_active)
>   {
>   	struct bcmgenet_priv *priv = netdev_priv(dev);
> -	u32 off = priv->hw_params->tbuf_offset + TBUF_ENERGY_CTRL;

Seems unnecessary, yes it does not quite abide by the RCT style, but no 
need to fix that yet.

> +	struct ethtool_eee *p = &priv->eee;
> +	bool enable;
> +	u32 off;
>   	u32 reg;
>   
> +	off = priv->hw_params->tbuf_offset + TBUF_ENERGY_CTRL;
> +	enable = eee_active && p->tx_lpi_enabled;
> +
>   	if (enable && !priv->clk_eee_enabled) {
>   		clk_prepare_enable(priv->clk_eee);
>   		priv->clk_eee_enabled = true;
> @@ -1310,9 +1315,6 @@ static void bcmgenet_eee_enable_set(struct net_device *dev, bool enable)
>   		clk_disable_unprepare(priv->clk_eee);
>   		priv->clk_eee_enabled = false;
>   	}
> -
> -	priv->eee.eee_enabled = enable;
> -	priv->eee.eee_active = enable;
>   }
>   
>   static int bcmgenet_get_eee(struct net_device *dev, struct ethtool_eee *e)
> @@ -1326,8 +1328,7 @@ static int bcmgenet_get_eee(struct net_device *dev, struct ethtool_eee *e)
>   	if (!dev->phydev)
>   		return -ENODEV;
>   
> -	e->eee_enabled = p->eee_enabled;
> -	e->eee_active = p->eee_active;
> +	e->tx_lpi_enabled = p->tx_lpi_enabled;
>   	e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER);
>   
>   	return phy_ethtool_get_eee(dev->phydev, e);
> @@ -1337,7 +1338,6 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)
>   {
>   	struct bcmgenet_priv *priv = netdev_priv(dev);
>   	struct ethtool_eee *p = &priv->eee;
> -	int ret = 0;
>   
>   	if (GENET_IS_V1(priv))
>   		return -EOPNOTSUPP;
> @@ -1345,20 +1345,9 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)
>   	if (!dev->phydev)
>   		return -ENODEV;
>   
> -	p->eee_enabled = e->eee_enabled;
> +	p->tx_lpi_enabled = e->tx_lpi_enabled;
>   
> -	if (!p->eee_enabled) {
> -		bcmgenet_eee_enable_set(dev, false);
> -	} else {
> -		ret = phy_init_eee(dev->phydev, false);
> -		if (ret) {
> -			netif_err(priv, hw, dev, "EEE initialization failed\n");
> -			return ret;
> -		}
> -
> -		bcmgenet_umac_writel(priv, e->tx_lpi_timer, UMAC_EEE_LPI_TIMER);
> -		bcmgenet_eee_enable_set(dev, true);
> -	}
> +	bcmgenet_umac_writel(priv, e->tx_lpi_timer, UMAC_EEE_LPI_TIMER);
>   
>   	return phy_ethtool_set_eee(dev->phydev, e);
>   }
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> index 946f6e283c4e..7458a62afc2c 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> @@ -703,4 +703,5 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv,
>   void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
>   			       enum bcmgenet_power_mode mode);
>   
> +void bcmgenet_eee_enable_set(struct net_device *dev, bool eee_active);
>   #endif /* __BCMGENET_H__ */
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> index b615176338b2..eb1747503c2e 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> @@ -100,6 +100,7 @@ void bcmgenet_mii_setup(struct net_device *dev)
>   
>   	if (phydev->link) {
>   		bcmgenet_mac_config(dev);
> +		bcmgenet_eee_enable_set(dev, phydev->eee_active);
>   	} else {
>   		reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
>   		reg &= ~RGMII_LINK;

-- 
Florian

  reply	other threads:[~2023-02-17  3:48 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17  3:42 [PATCH RFC 00/18] Rework MAC drivers EEE support Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 01/18] net: phy: Add phydev->eee_active to simplify adjust link callbacks Andrew Lunn
2023-02-17  9:09   ` Oleksij Rempel
2023-02-17 13:35     ` Andrew Lunn
2023-02-17 11:36   ` Russell King (Oracle)
2023-02-17 13:37     ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 02/18] net: phy: Add helper to set EEE Clock stop enable bit Andrew Lunn
2023-02-17 13:33   ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 03/18] net: marvell: mvneta: Simplify EEE configuration Andrew Lunn
2023-02-17 11:35   ` Russell King (Oracle)
2023-02-17 11:59   ` Russell King (Oracle)
2023-02-17 13:13     ` Russell King (Oracle)
2023-02-17 13:45     ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 04/18] net: stmmac: Drop usage of phy_init_eee() Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 05/18] net: stmmac: Simplify ethtool get eee Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 06/18] net: lan743x: Fixup EEE Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 07/18] net: fec: Move fec_enet_eee_mode_set() and helper earlier Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 08/18] net: FEC: Fixup EEE Andrew Lunn
2023-02-17  8:19   ` Oleksij Rempel
2023-02-17 12:32     ` Russell King (Oracle)
2023-02-17 13:58     ` Andrew Lunn
2023-02-18  2:00     ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 09/18] net: genet: " Andrew Lunn
2023-02-17  3:48   ` Florian Fainelli [this message]
2023-02-17 14:00     ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 10/18] net: sxgdb: " Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 11/18] net: dsa: mt7530: Swap to using phydev->eee_active Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 12/18] net: dsa: mt7530: Call phylib for set_eee and get_eee Andrew Lunn
2023-02-17 11:48   ` Russell King (Oracle)
2023-02-17 14:10     ` Andrew Lunn
2023-02-18  2:10     ` Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 13/18] net: dsa: b53: Swap to using phydev->eee_active Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 14/18] net: dsa: b53: Call phylib for set_eee and get_eee Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 15/18] net: phylink: Remove unused phylink_init_eee() Andrew Lunn
2023-02-17 11:42   ` Russell King (Oracle)
2023-02-17  3:42 ` [PATCH RFC 16/18] net: phylink: Update comment about configuring EEE in mac_link_up() Andrew Lunn
2023-02-17 11:43   ` Russell King (Oracle)
2023-02-17  3:42 ` [PATCH RFC 17/18] net: phy: remove unused phy_init_eee() Andrew Lunn
2023-02-17  3:42 ` [PATCH RFC 18/18] net: usb: lan78xx: Fixup EEE Andrew Lunn
2023-02-17 11:42 ` [PATCH RFC 00/18] Rework MAC drivers EEE support Russell King (Oracle)
2023-02-17 14:17   ` Andrew Lunn
2023-02-17 14:25 ` Russell King (Oracle)
2023-02-18 12:25   ` Oleksij Rempel

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=30ec2581-ab5d-2cf8-e5cb-dc7c99f43d3c@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=Landen.Chao@mediatek.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bh74.an@samsung.com \
    --cc=dqfext@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=linux-imx@nxp.com \
    --cc=linux@rempel-privat.de \
    --cc=matthias.bgg@gmail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=peppe.cavallaro@st.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=sean.wang@mediatek.com \
    --cc=shenwei.wang@nxp.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=woojung.huh@microchip.com \
    --cc=xiaoning.wang@nxp.com \
    /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).