linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Arun Ramadoss <arun.ramadoss@microchip.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Russell King <linux@armlinux.org.uk>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	UNGLinuxDriver@microchip.com
Subject: Re: [RFC Patch net-next 3/3] net: phy: lan87xx: added ethtool SQI support
Date: Mon, 21 Mar 2022 19:36:37 +0100	[thread overview]
Message-ID: <YjjFtUEDm2Dta1ez@lunn.ch> (raw)
In-Reply-To: <20220321155337.16260-4-arun.ramadoss@microchip.com>

> +#define T1_DCQ_SQI_MSK			GENMASK(3, 1)

> +static int lan87xx_get_sqi(struct phy_device *phydev)
> +{
> +	u16 sqi_value[LAN87XX_SQI_ENTRY];

> +	for (i = 0; i < LAN87XX_SQI_ENTRY; i++) {
> +
> +		sqi_value[i] = FIELD_GET(T1_DCQ_SQI_MSK, rc);

> +
> +	/* Sorting SQI values */
> +	sort(sqi_value, LAN87XX_SQI_ENTRY, sizeof(u16), lan87xx_sqi_cmp, NULL);

Sort is quite heavyweight. Your SQI values are in the range 0-7 right?
So rather than have an array of LAN87XX_SQI_ENTRY entries, why not
create a histogram? You then just need to keep 8 uints. There is no
need to perform a sort to discard the outliers, simply remove from the
outer histogram buckets. And then you can calculate the average.

That should be faster and use less memory.

     Andrew

  reply	other threads:[~2022-03-21 18:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 15:53 [RFC Patch net-next 0/3] add ethtool SQI support for LAN87xx T1 Phy Arun Ramadoss
2022-03-21 15:53 ` [RFC Patch net-next 1/3] net: phy: lan87xx: added lan87xx_update_link routine Arun Ramadoss
2022-03-21 15:53 ` [RFC Patch net-next 2/3] net: phy: lan937x: added PHY_POLL_CABLE_TEST flag Arun Ramadoss
2022-03-21 15:53 ` [RFC Patch net-next 3/3] net: phy: lan87xx: added ethtool SQI support Arun Ramadoss
2022-03-21 18:36   ` Andrew Lunn [this message]
2022-03-24 15:48     ` Arun.Ramadoss
2022-03-24 16:06       ` Andrew Lunn

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=YjjFtUEDm2Dta1ez@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=arun.ramadoss@microchip.com \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).