From: <Arun.Ramadoss@microchip.com>
To: <andrew@lunn.ch>
Cc: <linux-kernel@vger.kernel.org>, <UNGLinuxDriver@microchip.com>,
<linux@armlinux.org.uk>, <kuba@kernel.org>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <davem@davemloft.net>,
<hkallweit1@gmail.com>
Subject: Re: [RFC Patch net-next 3/3] net: phy: lan87xx: added ethtool SQI support
Date: Thu, 24 Mar 2022 15:48:57 +0000 [thread overview]
Message-ID: <ba1d251a9bd93cdf4c894313637dd9618cd8091c.camel@microchip.com> (raw)
In-Reply-To: <YjjFtUEDm2Dta1ez@lunn.ch>
Hi Andrew,
Thanks for the review.
On Mon, 2022-03-21 at 19:36 +0100, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> > +#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
I could get the algorithm for replacing array of LAN87XX_SQI_ENTRY(200)
to array of 8 (sqi values 0 to 7) and increment the array[sqi_value]
for every reading. And calculate the Average = ( 1 * array[1] + 2 *
array[2] ... + 7 * array[7])/LAN87XX_SQI_ENTRY. By this way we get the
average for 200 entries.
But I couldn't get the algorithm on how to discard the outliers from
the buckets. our main aim is to average from array[40] to arrary[160]
value. Can you bit elaborate on how to remove the outer histogram
buckets.
Arun
next prev parent reply other threads:[~2022-03-24 15:49 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
2022-03-24 15:48 ` Arun.Ramadoss [this message]
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=ba1d251a9bd93cdf4c894313637dd9618cd8091c.camel@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--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
all inboxes | Powered by JetHome®