From: Choong Yong Liang <yong.liang.choong@linux.intel.com>
To: Heiner Kallweit <hkallweit1@gmail.com>, Andrew Lunn <andrew@lunn.ch>
Cc: Russell King <linux@armlinux.org.uk>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net v1 1/2] net: phy: Introduce phy_update_eee() to update eee_cfg values
Date: Thu, 14 Nov 2024 12:35:36 +0800 [thread overview]
Message-ID: <5401b791-3c69-4603-ba14-7d430df25667@linux.intel.com> (raw)
In-Reply-To: <392105cb-3f73-4765-a702-7cce0c6ac62c@gmail.com>
On 14/11/2024 5:48 am, Heiner Kallweit wrote:
> "relies on" may be the wrong term here. There's an API definition,
> and phy_ethtool_get_eee() takes care of the PHY-related kernel part,
> provided that the MAC driver uses phylib.
> I say "PHY-related part", because tx_lpi_timer is something relevant
> for the MAC only. Therefore phylib stores the master config timer value
> only, not the actual value.
> The MAC driver should populate tx_lpi_timer in the get_eee() callback,
> in addition to what phy_ethtool_get_eee() populates.
> This may result in the master config value being overwritten with actual
> value in cases where the MAC doesn't support the master config value.
>
> One (maybe there are more) special case of tx_lpi_timer handling is
> Realtek chips, as they store the LPI timer in bytes. Means whenever
> the link speed changes, the actual timer value also changes implicitly.
>
> Few values exist twice: As a master config value, and as status.
> struct phy_device has the status values:
> @eee_enabled: Flag indicating whether the EEE feature is enabled
> @enable_tx_lpi: When True, MAC should transmit LPI to PHY
>
> And master config values are in struct eee_cfg:
>
> struct eee_config {
> u32 tx_lpi_timer;
> bool tx_lpi_enabled;
> bool eee_enabled;
> };
>
> And yes, it may be a little misleading that eee_enabled exists twice,
> you have to be careful which one you're referring to.
>
> ethtool handles the master config values, only "active" is a status
> information.
>
> So the MAC driver should:
> - provide a link change handler in e.g. phy_connect_direct()
> - this handler should:
> - use phydev->enable_tx_lpi to set whether MAC transmits LPI or not
> - use phydev->eee_cfg.tx_lpi_timer to set the timer (if the config
> value is set)
>
> Important note:
> This describes how MAC drivers *should* behave. Some don't get it right.
> So part of your confusion may be caused by misbehaving MAC drivers.
> One example of a MAC driver bug is what I wrote earlier about
> stmmac_ethtool_op_get_eee().
>
> And what I write here refers to plain phylib, I don't cover phylink as
> additional layer.
>
Thank you for your detailed explanation. It has been very helpful and has
clarified how the code behaves.
Based on your and Andrew's input, I agree that phy_update_eee() is not needed.
I will ensure that our implementation follows these guidelines and will
address any potential issues with misbehaving MAC drivers.
Thank you again for your valuable insights.
next prev parent reply other threads:[~2024-11-14 4:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 7:24 [PATCH net v1 0/2] Fix ethtool --show-eee for stmmac Choong Yong Liang
2024-11-12 7:24 ` [PATCH net v1 1/2] net: phy: Introduce phy_update_eee() to update eee_cfg values Choong Yong Liang
2024-11-12 11:03 ` Heiner Kallweit
2024-11-12 13:04 ` Andrew Lunn
2024-11-13 10:10 ` Choong Yong Liang
2024-11-13 21:48 ` Heiner Kallweit
2024-11-14 4:35 ` Choong Yong Liang [this message]
2024-11-13 23:05 ` Andrew Lunn
2024-11-14 4:37 ` Choong Yong Liang
2024-11-14 9:02 ` Russell King (Oracle)
2024-11-14 9:12 ` Russell King (Oracle)
2024-11-14 10:15 ` Russell King (Oracle)
2024-11-12 7:24 ` [PATCH net v1 2/2] net: stmmac: update eee_cfg after mac link up/down Choong Yong Liang
2024-11-12 9:24 ` [PATCH net v1 0/2] Fix ethtool --show-eee for stmmac Russell King (Oracle)
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=5401b791-3c69-4603-ba14-7d430df25667@linux.intel.com \
--to=yong.liang.choong@linux.intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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