net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks
authorAndrew Lunn <andrew@lunn.ch>
Sat, 2 Mar 2024 19:53:01 +0000 (20:53 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 Mar 2024 03:21:17 +0000 (19:21 -0800)
commite3b6876ab85061e7de198f023a0c2bfc7478b420
tree71f4b4baead0972c95decf5472c8344d94dd9421
parent6f2fc8584a46bb35787bfc1dad1fb7dd5898e21f
net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks

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>
Link: https://lore.kernel.org/r/20240302195306.3207716-3-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phy.c
include/linux/phy.h