From: Anatoliy Oleinikov via B4 Relay <devnull+admin.wizle.tech@kernel.org>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Anatoliy Oleinikov <admin@wizle.tech>
Subject: [PATCH ethtool] ethtool: let energy-detect-power-down on use the default TX interval
Date: Wed, 02 Dec 2026 19:11:41 +0300 [thread overview]
Message-ID: <20261202-edpd-default-v1-1-50ef70d3ca34@wizle.tech> (raw)
From: Anatoliy Oleinikov <admin@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 <admin@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 <admin@wizle.tech>
reply other threads:[~2026-12-02 16:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261202-edpd-default-v1-1-50ef70d3ca34@wizle.tech \
--to=devnull+admin.wizle.tech@kernel.org \
--cc=admin@wizle.tech \
--cc=andrew@lunn.ch \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
/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