diff mbox series

[net-next,5/5] net: phy: c45: extend genphy_c45_ethtool_[set|get]_eee

Message ID e7b66d99-e51b-4c8f-83da-99184e5f41ec@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ethtool: add support for EEE linkmodes beyond bit 32 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 1113 this patch: 1113
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
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: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 42 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiner Kallweit Jan. 1, 2024, 9:28 p.m. UTC
Extend both functions to use the linkmode bitmap extension if available.

Note: The linkmode extension for now is supported only if ethtool uses
netlink. It's not supported for ioctl.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy-c45.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 9d8b2b5eb..e276dba19 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -1454,6 +1454,7 @@  int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(lp) = {};
 	bool overflow = false, is_enabled;
+	struct ethtool_keee *keee;
 	int ret;
 
 	ret = genphy_c45_eee_is_active(phydev, adv, lp, &is_enabled);
@@ -1463,6 +1464,16 @@  int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
 	data->eee_enabled = is_enabled;
 	data->eee_active = ret;
 
+	keee = ethtool_eee2keee(data);
+	if (keee) {
+		linkmode_copy(keee->link_modes.supported,
+			      phydev->supported_eee);
+		linkmode_copy(keee->link_modes.advertising, adv);
+		linkmode_copy(keee->link_modes.lp_advertising, lp);
+		keee->use_link_modes = 1;
+		return 0;
+	}
+
 	if (!ethtool_convert_link_mode_to_legacy_u32(&data->supported,
 						     phydev->supported_eee))
 		overflow = true;
@@ -1494,6 +1505,7 @@  int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(adv);
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp);
+	struct ethtool_keee *keee;
 	bool unsupported;
 	int ret;
 
@@ -1501,7 +1513,11 @@  int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
 	if (!data->eee_enabled)
 		goto eee_aneg;
 
-	ethtool_convert_legacy_u32_to_link_mode(adv, data->advertised);
+	keee = ethtool_eee2keee(data);
+	if (keee && keee->use_link_modes)
+		linkmode_copy(adv, keee->link_modes.advertising);
+	else
+		ethtool_convert_legacy_u32_to_link_mode(adv, data->advertised);
 
 	if (linkmode_empty(adv)) {
 		linkmode_copy(phydev->advertising_eee, phydev->supported_eee);