public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v1 1/3] net: phy: dp83td510: add SQI support
Date: Tue, 7 Jun 2022 14:50:19 +0200	[thread overview]
Message-ID: <Yp9Ji2/FrbRxPayP@lunn.ch> (raw)
In-Reply-To: <20220607101710.2833332-1-o.rempel@pengutronix.de>

> +struct dp83td510_mse_sqi_range {
> +	u16 end;
> +	u16 start;
> +};
> +
> +/* Register values are converted to SNR(dB) as suggested by
> + * "Application Report - DP83TD510E Cable Diagnostics Toolkit":
> + * SNR(dB) = -10 * log10 (VAL/2^17) - 1.76 dB.
> + * SQI ranges are implemented according to "OPEN ALLIANCE - Advanced diagnostic
> + * features for 100BASE-T1 automotive Ethernet PHYs"
> + */
> +static const struct dp83td510_mse_sqi_range dp83td510_mse_sqi_map[] = {
> +	{ 0xffff, 0x0569 }, /* < 18dB */
> +	{ 0x0569, 0x044c }, /* 18dB =< SNR < 19dB */
> +	{ 0x044c, 0x0369 }, /* 19dB =< SNR < 20dB */
> +	{ 0x0369, 0x02b6 }, /* 20dB =< SNR < 21dB */
> +	{ 0x02b6, 0x0227 }, /* 21dB =< SNR < 22dB */
> +	{ 0x0227, 0x01b6 }, /* 22dB =< SNR < 23dB */
> +	{ 0x01b6, 0x015b }, /* 23dB =< SNR < 24dB */
> +	{ 0x015b, 0x0000 }, /* 24dB =< SNR */
> +};

You only really need start here, since the values always decrease.

> +	for (sqi = 0; sqi < ARRAY_SIZE(dp83td510_mse_sqi_map); sqi++) {
> +		if (mse_val >= dp83td510_mse_sqi_map[sqi].start &&
> +		    mse_val <= dp83td510_mse_sqi_map[sqi].end)

and then don't compare with end. Saves 8 words and a little bit of
code.

	Andrew

      parent reply	other threads:[~2022-06-07 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 10:17 [PATCH net-next v1 1/3] net: phy: dp83td510: add SQI support Oleksij Rempel
2022-06-07 10:17 ` [PATCH net-next v1 2/3] net: phy: dp83td510: add cable testing support Oleksij Rempel
2022-06-07 10:17 ` [PATCH net-next v1 3/3] net: phy: dp83td510: disable cable test support for 1Vpp PHYs Oleksij Rempel
2022-06-07 12:50 ` 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=Yp9Ji2/FrbRxPayP@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.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