From: Simon Horman <simon.horman@netronome.com>
To: Russell King <rmk@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linville@tuxdriver.com, andrew@lunn.ch,
f.fainelli@gmail.com
Subject: Re: [PATCH 1/3] ethtool: correctly interpret bitrate of 255
Date: Mon, 21 Oct 2019 09:40:31 +0200 [thread overview]
Message-ID: <20191021074030.GB4486@netronome.com> (raw)
In-Reply-To: <E1iLYu1-0000sp-W5@rmk-PC.armlinux.org.uk>
On Fri, Oct 18, 2019 at 09:31:13PM +0100, Russell King wrote:
> From: Russell King <rmk+kernel@armlinux.org.uk>
>
> A bitrate of 255 is special, it means the bitrate is encoded in
> byte 66 in units of 250MBaud. Add support for parsing these bit
> rates.
Hi Russell,
it seems from the code either that 0 is also special or its
handling has been optimised. Perhaps that would be worth mentioning
in the changelog too.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> sfpid.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/sfpid.c b/sfpid.c
> index a1753d3a535f..71f0939c6282 100644
> --- a/sfpid.c
> +++ b/sfpid.c
> @@ -328,11 +328,24 @@ void sff8079_show_all(const __u8 *id)
> {
> sff8079_show_identifier(id);
> if (((id[0] == 0x02) || (id[0] == 0x03)) && (id[1] == 0x04)) {
> + unsigned int br_nom, br_min, br_max;
> +
> + if (id[12] == 0) {
> + br_nom = br_min = br_max = 0;
> + } else if (id[12] == 255) {
> + br_nom = id[66] * 250;
> + br_max = id[67];
> + br_min = id[67];
> + } else {
> + br_nom = id[12] * 100;
> + br_max = id[66];
> + br_min = id[67];
> + }
> sff8079_show_ext_identifier(id);
> sff8079_show_connector(id);
> sff8079_show_transceiver(id);
> sff8079_show_encoding(id);
> - sff8079_show_value_with_unit(id, 12, "BR, Nominal", 100, "MBd");
> + printf("\t%-41s : %u%s\n", "BR, Nominal", br_nom, "MBd");
> sff8079_show_rate_identifier(id);
> sff8079_show_value_with_unit(id, 14,
> "Length (SMF,km)", 1, "km");
> @@ -348,8 +361,8 @@ void sff8079_show_all(const __u8 *id)
> sff8079_show_ascii(id, 40, 55, "Vendor PN");
> sff8079_show_ascii(id, 56, 59, "Vendor rev");
> sff8079_show_options(id);
> - sff8079_show_value_with_unit(id, 66, "BR margin, max", 1, "%");
> - sff8079_show_value_with_unit(id, 67, "BR margin, min", 1, "%");
> + printf("\t%-41s : %u%s\n", "BR margin, max", br_max, "%");
> + printf("\t%-41s : %u%s\n", "BR margin, min", br_min, "%");
> sff8079_show_ascii(id, 68, 83, "Vendor SN");
> sff8079_show_ascii(id, 84, 91, "Date code");
> }
> --
> 2.7.4
>
next prev parent reply other threads:[~2019-10-21 7:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 20:31 [PATCH 1/3] ethtool: correctly interpret bitrate of 255 Russell King
2019-10-19 23:29 ` Andrew Lunn
2019-10-21 7:40 ` Simon Horman [this message]
2019-10-21 8:09 ` Russell King - ARM Linux admin
2019-10-21 16:35 ` Simon Horman
2019-10-29 17:55 ` 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=20191021074030.GB4486@netronome.com \
--to=simon.horman@netronome.com \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=rmk@armlinux.org.uk \
/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).