mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Wei Fang <wei.fang@nxp.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Russell King <linux@armlinux.org.uk>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Shenwei Wang <shenwei.wang@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH net-next v5 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks
Date: Fri, 23 Feb 2024 07:58:17 +0100	[thread overview]
Message-ID: <4a43c21e-1ba9-4853-b2e2-8d2f5f8be464@gmail.com> (raw)
In-Reply-To: <AM5PR04MB3139BF92ABAE988EAD75088D88552@AM5PR04MB3139.eurprd04.prod.outlook.com>

On 23.02.2024 06:36, Wei Fang wrote:
>> -----Original Message-----
>> From: Oleksij Rempel <o.rempel@pengutronix.de>
>> Sent: 2024年2月21日 14:21
>> To: Wei Fang <wei.fang@nxp.com>; David S. Miller <davem@davemloft.net>;
>> Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>;
>> Paolo Abeni <pabeni@redhat.com>; Andrew Lunn <andrew@lunn.ch>;
>> Heiner Kallweit <hkallweit1@gmail.com>; Russell King
>> <linux@armlinux.org.uk>
>> Cc: Florian Fainelli <florian.fainelli@broadcom.com>; Oleksij Rempel
>> <o.rempel@pengutronix.de>; kernel@pengutronix.de;
>> linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Shenwei Wang
>> <shenwei.wang@nxp.com>; Clark Wang <xiaoning.wang@nxp.com>;
>> dl-linux-imx <linux-imx@nxp.com>
>> Subject: [PATCH net-next v5 2/8] net: phy: Add phydev->enable_tx_lpi to
>> simplify adjust link callbacks
>>
>> From: Andrew Lunn <andrew@lunn.ch>
>>
>> MAC drivers which support EEE need to know the results of the EEE auto-neg
>> in order to program the hardware to perform EEE or not.  The oddly named
>> phy_init_eee() can be used to determine this, it returns 0 if EEE should be
>> used, or a negative error code, e.g. -EOPPROTONOTSUPPORT if the PHY does
>> not support EEE or negotiate resulted in it not being used.
>>
>> However, many MAC drivers get this wrong. Add phydev->enable_tx_lpi
>> which indicates the result of the autoneg for EEE, including if EEE is
>> administratively disabled with ethtool. The MAC driver can then access this in
>> the same way as link speed and duplex in the adjust link callback. If
>> enable_tx_lpi is true, the MAC should send low power indications and does
>> not need to consider anything else with respect to EEE.
>>
>> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
>> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
>> ---
>> v2 Check for errors from genphy_c45_eee_is_active
>> v5: Rename to enable_tx_lpi to fit better with phylink changes
>> ---
>>  drivers/net/phy/phy.c | 7 +++++++
>>  include/linux/phy.h   | 2 ++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index
>> 14224e06d69f..a54b1daf5d5f 100644
>> --- a/drivers/net/phy/phy.c
>> +++ b/drivers/net/phy/phy.c
>> @@ -983,9 +983,16 @@ static int phy_check_link_status(struct phy_device
>> *phydev)
>>  	if (phydev->link && phydev->state != PHY_RUNNING) {
>>  		phy_check_downshift(phydev);
>>  		phydev->state = PHY_RUNNING;
>> +		err = genphy_c45_eee_is_active(phydev,
>> +					       NULL, NULL, NULL);
>> +		if (err < 0)
>> +			phydev->enable_tx_lpi = false;
>> +		else
>> +			phydev->enable_tx_lpi = err;
> 
> phydev->enable_tx_lpi = !!err; Is this better?
> 
I don't think so. Effectively err is a bool value, and it's implicitly
converted.

>>  		phy_link_up(phydev);
>>  	} else if (!phydev->link && phydev->state != PHY_NOLINK) {
>>  		phydev->state = PHY_NOLINK;
>> +		phydev->enable_tx_lpi = false;
>>  		phy_link_down(phydev);
>>  	}
>>
>> diff --git a/include/linux/phy.h b/include/linux/phy.h index
>> e3ab2c347a59..a880f6d7170e 100644
>> --- a/include/linux/phy.h
>> +++ b/include/linux/phy.h
>> @@ -594,6 +594,7 @@ struct macsec_ops;
>>   * @supported_eee: supported PHY EEE linkmodes
>>   * @advertising_eee: Currently advertised EEE linkmodes
>>   * @eee_enabled: Flag indicating whether the EEE feature is enabled
>> + * @enable_tx_lpi: When True, MAC should transmit LPI to PHY
>>   * @lp_advertising: Current link partner advertised linkmodes
>>   * @host_interfaces: PHY interface modes supported by host
>>   * @eee_broken_modes: Energy efficient ethernet modes which should be
>> prohibited @@ -713,6 +714,7 @@ struct phy_device {
>>
>>  	/* Energy efficient ethernet modes which should be prohibited */
>>  	u32 eee_broken_modes;
>> +	bool enable_tx_lpi;
>>
>>  #ifdef CONFIG_LED_TRIGGER_PHY
>>  	struct phy_led_trigger *phy_led_triggers;
>> --
>> 2.39.2
> 


  reply	other threads:[~2024-02-23  6:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21  6:20 [PATCH net-next v5 0/8] net: ethernet: Rework EEE Oleksij Rempel
2024-02-21  6:21 ` [PATCH net-next v5 1/8] net: add helpers for EEE configuration Oleksij Rempel
2024-02-23  4:53   ` Florian Fainelli
2024-02-21  6:21 ` [PATCH net-next v5 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Oleksij Rempel
2024-02-23  5:36   ` Wei Fang
2024-02-23  6:58     ` Heiner Kallweit [this message]
2024-02-21  6:21 ` [PATCH net-next v5 3/8] net: phy: Add helper to set EEE Clock stop enable bit Oleksij Rempel
2024-02-23  4:47   ` Florian Fainelli
2024-02-23  8:54     ` Oleksij Rempel
2024-02-21  6:21 ` [PATCH net-next v5 4/8] net: phy: Keep track of EEE configuration Oleksij Rempel
2024-02-23  3:25   ` Jakub Kicinski
2024-02-23  4:53   ` Florian Fainelli
2024-02-21  6:21 ` [PATCH net-next v5 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Oleksij Rempel
2024-02-23  4:51   ` Florian Fainelli
2024-02-21  6:21 ` [PATCH net-next v5 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Oleksij Rempel
2024-02-23  4:52   ` Florian Fainelli
2024-02-23  5:47     ` Oleksij Rempel
2024-02-23 11:21     ` Russell King (Oracle)
2024-02-21  6:21 ` [PATCH net-next v5 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Oleksij Rempel
2024-02-23  6:03   ` Wei Fang
2024-02-21  6:21 ` [PATCH net-next v5 8/8] net: fec: Fixup EEE Oleksij Rempel
2024-02-23  6:03   ` Wei Fang

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=4a43c21e-1ba9-4853-b2e2-8d2f5f8be464@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=shenwei.wang@nxp.com \
    --cc=wei.fang@nxp.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

Powered by JetHome