From: Anatoliy Oleinikov <adm…@wizle.tech>
Without msecs, "--set-phy-tunable DEV energy-detect-power-down on" is
meant to send the default TX interval, ETHTOOL_PHY_EDPD_DFLT_TX_MSECS
(0xffff), as the man page describes. The range check of the interval
rejects that value as above 65533 first, so EDPD can only be turned on
with an explicit msecs, and drivers that take only the default interval
cannot be turned on at all. An explicit msecs of 65534, which is
ETHTOOL_PHY_EDPD_NO_TX, passes the check instead and turns the TX pulses
off.
Check the range only when msecs is given, and reject 65534 as well.
Fixes: e5684313dbf1 ("ethtool: implement support for Energy Detect Power Down")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Anatoliy Oleinikov <adm…@wizle.tech>
---
Tested on an RTL8214FC, whose driver takes only the default interval
and off: "energy-detect-power-down on" failed with "'msecs' max value is
65533." before and turns EDPD on with this patch; "on msecs 65534" is
rejected now.
---
ethtool.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 30a1d97..6c02f3d 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5699,7 +5699,7 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
u8 ds_changed = 0, ds_has_cnt = 0, ds_enable = 0;
u8 fld_changed = 0, fld_enable = 0;
u8 fld_msecs = ETHTOOL_PHY_FAST_LINK_DOWN_ON;
- u8 edpd_changed = 0, edpd_enable = 0;
+ u8 edpd_changed = 0, edpd_enable = 0, edpd_has_msecs = 0;
u16 edpd_tx_interval = ETHTOOL_PHY_EDPD_DFLT_TX_MSECS;
u8 scp_changed = 0, scp_enable = 0;
u8 lpf_bw_changed = 0;
@@ -5719,7 +5719,8 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
&edpd_enable)) {
edpd_changed = 1;
if (edpd_enable)
- parse_named_u16(ctx, "msecs", &edpd_tx_interval);
+ edpd_has_msecs = parse_named_u16(ctx, "msecs",
+ &edpd_tx_interval);
} else if (parse_named_bool(ctx, "short-cable-preset", &scp_enable)) {
scp_changed = 1;
} else if (parse_named_u32(ctx, "lpf-bandwidth", &lpf_bw)) {
@@ -5755,7 +5756,8 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
edpd_tx_interval = ETHTOOL_PHY_EDPD_DISABLE;
else if (edpd_tx_interval == 0)
edpd_tx_interval = ETHTOOL_PHY_EDPD_NO_TX;
- else if (edpd_tx_interval > ETHTOOL_PHY_EDPD_NO_TX) {
+ else if (edpd_has_msecs &&
+ edpd_tx_interval >= ETHTOOL_PHY_EDPD_NO_TX) {
fprintf(stderr, "'msecs' max value is %d.\n",
(ETHTOOL_PHY_EDPD_NO_TX - 1));
exit_bad_args();
---
base-commit: bae2dbda89883ba47a8c6e3d1533aaff4f9b3e8f
change-id: 20261202-edpd-default-083dffd75ea4
Best regards,
--
Anatoliy Oleinikov <adm…@wizle.tech>
[PATCH ethtool] ethtool: let energy-detect-power-down on use the default TX interval
- From
- devn…@kernel.org (Anatoliy Oleinikov via B4 Relay)
- Organization
- Usenet Network
- Message-ID
- <2026…@wizle.tech>
- Date
- Newsgroups
- linux.kernel.netdev