[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjjFtUEDm2Dta1ez@lunn.ch>
Date: Mon, 21 Mar 2022 19:36:37 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Arun Ramadoss <arun.ramadoss@...rochip.com>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Russell King <linux@...linux.org.uk>,
Heiner Kallweit <hkallweit1@...il.com>,
UNGLinuxDriver@...rochip.com
Subject: Re: [RFC Patch net-next 3/3] net: phy: lan87xx: added ethtool SQI
support
> +#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
Powered by blists - more mailing lists