From: Andrew Lunn <andrew@lunn•ch>
To: "Allan W. Nielsen" <allan.nielsen@microsemi•com>
Cc: netdev@vger•kernel.org, raju.lakkaraju@microsemi•com
Subject: Re: [PATCH ethtool v2 2/2] Ethtool: Implements ETHTOOL_PHY_GTUNABLE/ETHTOOL_PHY_STUNABLE and PHY downshift
Date: Mon, 14 Nov 2016 15:03:03 +0100 [thread overview]
Message-ID: <20161114140303.GM26710@lunn.ch> (raw)
In-Reply-To: <1479115787-1265-3-git-send-email-allan.nielsen@microsemi.com>
> +.B \-\-get\-phy\-tunable
> +Gets the PHY tunable parameters.
> +.RS 4
> +.TP
> +.B downshift
> +For operation in cabling environments that are incompatible with 1000BAST-T,
BASE
> +PHY device provides an automatic link speed downshift operation.
> +Link speed downshift after N failed 1000BASE-T auto-negotiation attempts.
> +
> +Gets the PHY downshift count/status.
> +.RE
> .SH BUGS
> Not supported (in part or whole) on all network drivers.
> .SH AUTHOR
> diff --git a/ethtool.c b/ethtool.c
> index 49ac94e..3b7ea4e 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -4520,6 +4520,146 @@ static int do_seee(struct cmd_context *ctx)
> return 0;
> }
>
> +static int do_get_phy_tunable(struct cmd_context *ctx)
> +{
> + int argc = ctx->argc;
> + char **argp = ctx->argp;
> + int err, i;
> + u8 downshift_changed = 0;
> +
> + if (argc < 1)
> + exit_bad_args();
> + for (i = 0; i < argc; i++) {
> + if (!strcmp(argp[i], "downshift")) {
> + downshift_changed = 1;
> + i += 1;
> + } else {
> + exit_bad_args();
> + }
> + }
> +
> + if (downshift_changed) {
> + struct ethtool_tunable ds;
> + u8 count = 0;
> +
> + ds.cmd = ETHTOOL_PHY_GTUNABLE;
> + ds.id = ETHTOOL_PHY_DOWNSHIFT;
> + ds.type_id = ETHTOOL_TUNABLE_U8;
> + ds.len = 1;
> + ds.data[0] = &count;
> + err = send_ioctl(ctx, &ds);
> + if (err < 0) {
> + perror("Cannot Get PHY downshift count");
> + err = 87;
> + }
> + count = *((u8 *)&ds.data[0]);
> + if (count)
> + fprintf(stdout, " Downshift count: %d\n",
> + count);
> + else
> + fprintf(stdout, " Downshift disabled\n");
Please be consistent with the spaces.
Also, if send_ioctl() returns an error, you print the error message,
and then still print the value of count. You look to be missing a
return or an else.
Andrew
prev parent reply other threads:[~2016-11-14 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 9:29 [PATCH ethtool v2 0/2] Adding downshift support to ethtool Allan W. Nielsen
2016-11-14 9:29 ` [PATCH ethtool v2 1/2] ethtool-copy.h:sync with net Allan W. Nielsen
2016-11-14 9:29 ` [PATCH ethtool v2 2/2] Ethtool: Implements ETHTOOL_PHY_GTUNABLE/ETHTOOL_PHY_STUNABLE and PHY downshift Allan W. Nielsen
2016-11-14 14:03 ` Andrew Lunn [this message]
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=20161114140303.GM26710@lunn.ch \
--to=andrew@lunn$(echo .)ch \
--cc=allan.nielsen@microsemi$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=raju.lakkaraju@microsemi$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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