From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"f.fainelli@gmail.com" <f.fainelli@gmail.com>
Cc: "andrew@lunn.ch" <andrew@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"rmk@armlinux.org.uk" <rmk@armlinux.org.uk>,
"cphealy@gmail.com" <cphealy@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"nikita.yoush@cogentembedded.com"
<nikita.yoush@cogentembedded.com>,
"vivien.didelot@savoirfairelinux.com"
<vivien.didelot@savoirfairelinux.com>,
"Nisar.Sayed@microchip.com" <Nisar.Sayed@microchip.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH ethtool 2/2] ethtool: Add support for PHY test modes
Date: Thu, 17 Aug 2023 17:29:15 +0000 [thread overview]
Message-ID: <f390207c5c4fd17398b84ce8ae829a49a2c0768b.camel@siemens.com> (raw)
In-Reply-To: <20180428003237.1536-8-f.fainelli@gmail.com>
Hello Florian,
On Fri, 2018-04-27 at 17:32 -0700, Florian Fainelli wrote:
> Add two new commands:
>
> --get-phy-tests which allows fetching supported test modes by a given
> network device's PHY interface
> --set-phy-test which allows entering one of the modes listed before and
> pass an eventual set of test specific data
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
has this series ever been posted for merging, i.e. not as RFC?
It looks quite useful to me and I probably will be able to test
the series if you still will be posting it.
> ---
> ethtool.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 115 insertions(+)
>
> diff --git a/ethtool.c b/ethtool.c
> index 3289e0f6e8ec..f02cd3560197 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -4854,6 +4854,118 @@ static int do_reset(struct cmd_context *ctx)
> return 0;
> }
>
> +static int do_gphytest(struct cmd_context *ctx)
> +{
> + struct ethtool_gstrings *strings;
> + struct ethtool_phy_test test;
> + unsigned int i;
> + int max_len = 0, cur_len, rc;
> +
> + if (ctx->argc != 0)
> + exit_bad_args();
> +
> + strings = get_stringset(ctx, ETH_SS_PHY_TESTS, 0, 1);
> + if (!strings) {
> + perror("Cannot get PHY tests strings");
> + return 1;
> + }
> + if (strings->len == 0) {
> + fprintf(stderr, "No PHY tests defined\n");
> + rc = 1;
> + goto err;
> + }
> +
> + /* Find longest string and align all strings accordingly */
> + for (i = 0; i < strings->len; i++) {
> + cur_len = strlen((const char*)strings->data +
> + i * ETH_GSTRING_LEN);
> + if (cur_len > max_len)
> + max_len = cur_len;
> + }
> +
> + printf("PHY tests %s:\n", ctx->devname);
> + for (i = 0; i < strings->len; i++) {
> + memset(&test, 0, sizeof(test));
> + test.cmd = ETHTOOL_GPHYTEST;
> + test.mode = i;
> +
> + rc = send_ioctl(ctx, &test);
> + if (rc < 0)
> + continue;
> +
> + fprintf(stdout, " %.*s (Test data: %s)\n",
> + max_len,
> + (const char *)strings->data + i * ETH_GSTRING_LEN,
> + test.len ? "Yes" : "No");
> + }
> +
> + rc = 0;
> +
> +err:
> + free(strings);
> + return rc;
> +}
> +
> +static int do_sphytest(struct cmd_context *ctx)
> +{
> + struct ethtool_gstrings *strings;
> + struct ethtool_phy_test gtest;
> + struct ethtool_phy_test *stest;
> + unsigned int i;
> + int rc;
> +
> + if (ctx->argc < 1)
> + exit_bad_args();
> +
> + strings = get_stringset(ctx, ETH_SS_PHY_TESTS, 0, 1);
> + if (!strings) {
> + perror("Cannot get PHY test modes");
> + return 1;
> + }
> +
> + if (strings->len == 0) {
> + fprintf(stderr, "No PHY tests defined\n");
> + rc = 1;
> + goto err;
> + }
> +
> + for (i = 0; i < strings->len; i++) {
> + if (!strcmp(ctx->argp[0],
> + (const char *)strings->data + i * ETH_GSTRING_LEN))
> + break;
> + }
> +
> + if (i == strings->len)
> + exit_bad_args();
> +
> + memset(>est, 0, sizeof(gtest));
> + gtest.cmd = ETHTOOL_GPHYTEST;
> + gtest.mode = i;
> + rc = send_ioctl(ctx, >est);
> + if (rc < 0) {
> + rc = 1;
> + goto err;
> + }
> +
> + stest = calloc(1, sizeof(*stest) + gtest.len);
> + if (!stest) {
> + perror("Unable to allocate memory");
> + rc = 1;
> + goto err;
> + }
> +
> + stest->cmd = ETHTOOL_SPHYTEST;
> + stest->len = gtest.len;
> + stest->mode = i;
> +
> + rc = send_ioctl(ctx, stest);
> + free(stest);
> +err:
> + free(strings);
> + return rc;
> +}
> +
> +
> static int parse_named_bool(struct cmd_context *ctx, const char *name, u8 *on)
> {
> if (ctx->argc < 2)
> @@ -5223,6 +5335,9 @@ static const struct option {
> { "--show-fec", 1, do_gfec, "Show FEC settings"},
> { "--set-fec", 1, do_sfec, "Set FEC settings",
> " [ encoding auto|off|rs|baser ]\n"},
> + { "--get-phy-tests", 1, do_gphytest,"Get PHY test mode(s)" },
> + { "--set-phy-test", 1, do_sphytest, "Set PHY test mode",
> + " [ test options ]\n" },
> { "-h|--help", 0, show_usage, "Show this help" },
> { "--version", 0, do_version, "Show version number" },
> {}
--
Alexander Sverdlin
Siemens AG
www.siemens.com
next prev parent reply other threads:[~2023-08-17 17:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-28 0:32 [RFC net-next 0/5] Support " Florian Fainelli
2018-04-28 0:32 ` [RFC net-next 1/5] net: phy: Pass stringset argument to ethtool operations Florian Fainelli
2018-04-28 0:32 ` [RFC net-next 2/5] net: ethtool: Add UAPI for PHY test modes Florian Fainelli
2018-04-28 0:32 ` [RFC net-next 3/5] net: ethtool: Add plumbing to get/set " Florian Fainelli
2018-04-28 0:32 ` [RFC net-next 4/5] net: phy: Add support for IEEE standard " Florian Fainelli
2018-04-30 23:20 ` Andrew Lunn
2018-05-01 17:03 ` Florian Fainelli
2018-05-01 17:29 ` Woojung.Huh
2018-05-01 18:43 ` Florian Fainelli
2018-05-01 20:07 ` Woojung.Huh
2018-05-01 20:51 ` Florian Fainelli
2018-05-07 0:02 ` Woojung.Huh
2018-04-28 0:32 ` [RFC net-next 5/5] net: phy: broadcom: Add support for PHY " Florian Fainelli
2018-04-28 0:32 ` [PATCH ethtool 1/2] ethtool-copy.h: Sync with net-next Florian Fainelli
2018-04-28 0:32 ` [PATCH ethtool 2/2] ethtool: Add support for PHY test modes Florian Fainelli
2023-08-17 17:29 ` Sverdlin, Alexander [this message]
2018-04-30 2:55 ` [RFC net-next 0/5] Support " David Miller
2018-04-30 16:30 ` Florian Fainelli
2018-04-30 16:40 ` Andrew Lunn
2018-04-30 19:23 ` Florian Fainelli
2018-04-30 23:24 ` Andrew Lunn
2018-05-01 17:21 ` Florian Fainelli
2018-05-01 17:47 ` Andrew Lunn
2018-05-01 18:27 ` Florian Fainelli
2018-05-01 19:59 ` Andrew Lunn
2018-05-01 18:06 ` David Miller
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=f390207c5c4fd17398b84ce8ae829a49a2c0768b.camel@siemens.com \
--to=alexander.sverdlin@siemens.com \
--cc=Nisar.Sayed@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=cphealy@gmail.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikita.yoush@cogentembedded.com \
--cc=rmk@armlinux.org.uk \
--cc=vivien.didelot@savoirfairelinux.com \
/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
all inboxes | Powered by JetHome®