diff mbox series

[RFC/RFTv3,21/24] net: phylink: Add MAC_EEE to mac_capabilites

Message ID 20230331005518.2134652-22-andrew@lunn.ch (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: Rework EEE | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches (and no cover letter); Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 112 this patch: 112
netdev/cc_maintainers warning 4 maintainers not CCed: pabeni@redhat.com kuba@kernel.org edumazet@google.com davem@davemloft.net
netdev/build_clang success Errors and warnings before: 25 this patch: 25
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 112 this patch: 112
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 57 lines checked
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Andrew Lunn March 31, 2023, 12:55 a.m. UTC
If the MAC supports Energy Efficient Ethernet, it should indicate this
by setting the MAC_EEE bit in the config.mac_capabilities
bitmap. phylink will then enable EEE in the PHY, if it supports it.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
v3: Move MAC_EEE to BIT(2) and renumber link modes.
---
 drivers/net/phy/phylink.c |  3 +++
 include/linux/phylink.h   | 39 ++++++++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 17 deletions(-)

Comments

Florian Fainelli May 30, 2023, 6:18 p.m. UTC | #1
On 3/30/23 17:55, Andrew Lunn wrote:
> If the MAC supports Energy Efficient Ethernet, it should indicate this
> by setting the MAC_EEE bit in the config.mac_capabilities
> bitmap. phylink will then enable EEE in the PHY, if it supports it.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 61e4502086c3..191cafd37e62 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1647,6 +1647,9 @@  static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
 	 */
 	phy_support_asym_pause(phy);
 
+	if (pl->config->mac_capabilities & MAC_EEE)
+		phy_support_eee(phy);
+
 	memset(&config, 0, sizeof(config));
 	linkmode_copy(supported, phy->supported);
 	linkmode_copy(config.advertising, phy->advertising);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 52f29b648853..cb5204fb9106 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -52,26 +52,31 @@  enum {
 	 */
 	MAC_SYM_PAUSE	= BIT(0),
 	MAC_ASYM_PAUSE	= BIT(1),
-	MAC_10HD	= BIT(2),
-	MAC_10FD	= BIT(3),
+
+	/* MAC_EEE indicates that the MAC is Energy Efficient capable
+	 * and that the PHY should negotiate its use, if possible
+	 */
+	MAC_EEE		= BIT(2),
+	MAC_10HD	= BIT(3),
+	MAC_10FD	= BIT(4),
 	MAC_10		= MAC_10HD | MAC_10FD,
-	MAC_100HD	= BIT(4),
-	MAC_100FD	= BIT(5),
+	MAC_100HD	= BIT(5),
+	MAC_100FD	= BIT(6),
 	MAC_100		= MAC_100HD | MAC_100FD,
-	MAC_1000HD	= BIT(6),
-	MAC_1000FD	= BIT(7),
+	MAC_1000HD	= BIT(7),
+	MAC_1000FD	= BIT(8),
 	MAC_1000	= MAC_1000HD | MAC_1000FD,
-	MAC_2500FD	= BIT(8),
-	MAC_5000FD	= BIT(9),
-	MAC_10000FD	= BIT(10),
-	MAC_20000FD	= BIT(11),
-	MAC_25000FD	= BIT(12),
-	MAC_40000FD	= BIT(13),
-	MAC_50000FD	= BIT(14),
-	MAC_56000FD	= BIT(15),
-	MAC_100000FD	= BIT(16),
-	MAC_200000FD	= BIT(17),
-	MAC_400000FD	= BIT(18),
+	MAC_2500FD	= BIT(9),
+	MAC_5000FD	= BIT(10),
+	MAC_10000FD	= BIT(11),
+	MAC_20000FD	= BIT(12),
+	MAC_25000FD	= BIT(13),
+	MAC_40000FD	= BIT(14),
+	MAC_50000FD	= BIT(15),
+	MAC_56000FD	= BIT(16),
+	MAC_100000FD	= BIT(17),
+	MAC_200000FD	= BIT(18),
+	MAC_400000FD	= BIT(19),
 };
 
 static inline bool phylink_autoneg_inband(unsigned int mode)