lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 7 Jun 2022 14:50:19 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Oleksij Rempel <o.rempel@...gutronix.de>
Cc:     Heiner Kallweit <hkallweit1@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v1 1/3] net: phy: dp83td510: add SQI support

> +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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ