From: Heiner Kallweit <hkallweit1@gmail.com>
To: John Linville <linville@tuxdriver.com>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH v2 3/4] ethtool: add support for PHY tunable Fast Link Down
Date: Fri, 29 Mar 2019 20:15:54 +0100 [thread overview]
Message-ID: <14d0f457-49f3-a97f-3e9a-29f5a861fba0@gmail.com> (raw)
In-Reply-To: <86b1ab67-fd7e-2789-1218-8c14e8198a60@gmail.com>
This patch adds support for PHY tunable Fast Link Down. Like downshift
it uses an u8 parameter.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
ethtool.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index f67cd1b..f56a604 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4840,6 +4840,28 @@ static int do_get_phy_tunable(struct cmd_context *ctx)
fprintf(stdout, "Downshift count: %d\n", cont.count);
else
fprintf(stdout, "Downshift disabled\n");
+ } else if (!strcmp(argp[0], "fast-link-down")) {
+ struct {
+ struct ethtool_tunable fld;
+ u8 msecs;
+ } cont;
+
+ cont.fld.cmd = ETHTOOL_PHY_GTUNABLE;
+ cont.fld.id = ETHTOOL_PHY_FAST_LINK_DOWN;
+ cont.fld.type_id = ETHTOOL_TUNABLE_U8;
+ cont.fld.len = 1;
+ if (send_ioctl(ctx, &cont.fld) < 0) {
+ perror("Cannot Get PHY Fast Link Down value");
+ return 87;
+ }
+
+ if (cont.msecs == ETHTOOL_PHY_FAST_LINK_DOWN_ON)
+ fprintf(stdout, "Fast Link Down enabled\n");
+ else if (cont.msecs == ETHTOOL_PHY_FAST_LINK_DOWN_OFF)
+ fprintf(stdout, "Fast Link Down disabled\n");
+ else
+ fprintf(stdout, "Fast Link Down enabled, %d msecs\n",
+ cont.msecs);
} else {
exit_bad_args();
}
@@ -4982,11 +5004,17 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
int err = 0;
u8 ds_cnt = DOWNSHIFT_DEV_DEFAULT_COUNT;
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;
/* Parse arguments */
if (parse_named_bool(ctx, "downshift", &ds_enable)) {
ds_changed = 1;
ds_has_cnt = parse_named_u8(ctx, "count", &ds_cnt);
+ } else if (parse_named_bool(ctx, "fast-link-down", &fld_enable)) {
+ fld_changed = 1;
+ if (fld_enable)
+ parse_named_u8(ctx, "msecs", &fld_msecs);
} else {
exit_bad_args();
}
@@ -5006,6 +5034,11 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
if (!ds_enable)
ds_cnt = DOWNSHIFT_DEV_DISABLE;
+ } else if (fld_changed) {
+ if (!fld_enable)
+ fld_msecs = ETHTOOL_PHY_FAST_LINK_DOWN_OFF;
+ else if (fld_msecs == ETHTOOL_PHY_FAST_LINK_DOWN_OFF)
+ exit_bad_args();
}
/* Do it */
@@ -5025,6 +5058,22 @@ static int do_set_phy_tunable(struct cmd_context *ctx)
perror("Cannot Set PHY downshift count");
err = 87;
}
+ } else if (fld_changed) {
+ struct {
+ struct ethtool_tunable fld;
+ u8 msecs;
+ } cont;
+
+ cont.fld.cmd = ETHTOOL_PHY_STUNABLE;
+ cont.fld.id = ETHTOOL_PHY_FAST_LINK_DOWN;
+ cont.fld.type_id = ETHTOOL_TUNABLE_U8;
+ cont.fld.len = 1;
+ cont.msecs = fld_msecs;
+ err = send_ioctl(ctx, &cont.fld);
+ if (err < 0) {
+ perror("Cannot Set PHY Fast Link Down value");
+ err = 87;
+ }
}
return err;
@@ -5276,9 +5325,11 @@ static const struct option {
" [ tx-lpi on|off ]\n"
" [ tx-timer %d ]\n"},
{ "--set-phy-tunable", 1, do_set_phy_tunable, "Set PHY tunable",
- " [ downshift on|off [count N] ]\n"},
+ " [ downshift on|off [count N] ]\n"
+ " [ fast-link-down on|off [msecs N] ]\n"},
{ "--get-phy-tunable", 1, do_get_phy_tunable, "Get PHY tunable",
- " [ downshift ]\n"},
+ " [ downshift ]\n"
+ " [ fast-link-down ]\n"},
{ "--reset", 1, do_reset, "Reset components",
" [ flags %x ]\n"
" [ mgmt ]\n"
--
2.21.0
next prev parent reply other threads:[~2019-03-29 19:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 19:13 [PATCH v2 0/4] ethtool: add support for new PHY tunable Fast Link Down Heiner Kallweit
2019-03-29 19:14 ` [PATCH v2 1/4] ethtool: sync ethtool-copy.h with linux-next from 03/28/2019 Heiner Kallweit
2019-03-29 21:24 ` Florian Fainelli
2019-03-29 19:15 ` [PATCH v2 2/4] ethtool: simplify handling of PHY tunable downshift Heiner Kallweit
2019-03-29 21:24 ` Florian Fainelli
2019-03-29 19:15 ` Heiner Kallweit [this message]
2019-03-29 21:25 ` [PATCH v2 3/4] ethtool: add support for PHY tunable Fast Link Down Florian Fainelli
2019-03-29 19:17 ` [PATCH v2 4/4] ethtool: add PHY Fast Link Down tunable to man page Heiner Kallweit
2019-03-29 21:26 ` Florian Fainelli
2019-03-30 8:39 ` Andrew Lunn
2019-04-09 18:43 ` [PATCH v2 0/4] ethtool: add support for new PHY tunable Fast Link Down John W. Linville
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=14d0f457-49f3-a97f-3e9a-29f5a861fba0@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=linville@tuxdriver.com \
--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;
as well as URLs for NNTP newsgroup(s).