lkml.org 
[lkml]   [2022]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2022-03-21 19:37    [W:0.079 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site