From: <Rakesh.Sankaranarayanan@microchip.com>
To: <aleksander.lobakin@intel.com>
Cc: <andrew@lunn.ch>, <olteanv@gmail.com>, <davem@davemloft.net>,
<Thangaraj.S@microchip.com>, <Woojung.Huh@microchip.com>,
<linux-kernel@vger.kernel.org>, <pabeni@redhat.com>,
<f.fainelli@gmail.com>, <netdev@vger.kernel.org>,
<UNGLinuxDriver@microchip.com>, <edumazet@google.com>,
<kuba@kernel.org>
Subject: Re: [PATCH v2 net-next 1/5] net: dsa: microchip: add rmon grouping for ethtool statistics
Date: Tue, 21 Feb 2023 04:37:54 +0000 [thread overview]
Message-ID: <d514e373b9e299b5e59bab2f6246236ecf59c77e.camel@microchip.com> (raw)
In-Reply-To: <03dedec9-2383-b0bd-eb2e-4d3b334e8c0b@intel.com>
On Fri, 2023-02-17 at 15:59 +0100, Alexander Lobakin wrote:
> [Some people who received this message don't often get email from
> aleksander.lobakin@intel.com. Learn why this is important at
> https://aka.ms/LearnAboutSenderIdentification ]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> From: Rakesh Sankaranarayanan <rakesh.sankaranarayanan@microchip.com>
> Date: Fri, 17 Feb 2023 16:32:07 +0530
>
> > Add support for ethtool standard device statistics grouping.
> > Support rmon
> > statistics grouping using rmon groups parameter in ethtool
> > command. rmon
> > provides packet size based range grouping. Common mib
> > parameters are used
> > across all KSZ series swtches for packet size statistics,
> > except for
> > KSZ8830. KSZ series have mib counters for packets with size:
>
> [...]
>
> > +void ksz8_get_rmon_stats(struct ksz_device *dev, int port,
> > + struct ethtool_rmon_stats *rmon_stats,
> > + const struct ethtool_rmon_hist_range
> > **ranges)
> > +{
> > + struct ksz_port_mib *mib;
> > + u64 *cnt;
>
> Nit: I guess it can be const since you only read it (in every such
> callback)?
This variable is getting updated on every call back after reading from
registers, so we cannot have it as constant.
>
> > + u8 i;
> > +
> > + mib = &dev->ports[port].mib;
> > +
> > + mutex_lock(&mib->cnt_mutex);
> > +
> > + cnt = &mib->counters[KSZ8_RX_UNDERSIZE];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ8_RX_UNDERSIZE, NULL,
> > cnt);
> > + rmon_stats->undersize_pkts = *cnt;
> > +
> > + cnt = &mib->counters[KSZ8_RX_OVERSIZE];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ8_RX_OVERSIZE, NULL,
> > cnt);
> > + rmon_stats->oversize_pkts = *cnt;
> > +
> > + cnt = &mib->counters[KSZ8_RX_FRAGMENTS];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ8_RX_FRAGMENTS, NULL,
> > cnt);
> > + rmon_stats->fragments = *cnt;
> > +
> > + cnt = &mib->counters[KSZ8_RX_JABBERS];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ8_RX_JABBERS, NULL,
> > cnt);
> > + rmon_stats->jabbers = *cnt;
> > +
> > + for (i = 0; i < KSZ8_HIST_LEN; i++) {
> > + cnt = &mib->counters[KSZ8_RX_64_OR_LESS + i];
> > + dev->dev_ops->r_mib_pkt(dev, port,
> > + (KSZ8_RX_64_OR_LESS + i), NULL, cnt);
>
> Weird linewrap. Please align the following lines with the opening
> brace
> of the first one, e.g.
>
> dev->dev_ops->r_mib_pkt(dev, port,
> KSZ8_RX_64_OR_LESS + i, NULL,
> cnt);
>
> BUT I don't see why you need those braces around `macro + i` and
> without
> them you can fit it into the previous line I believe.
Will update it in next revision
>
> > + rmon_stats->hist[i] = *cnt;
> > + }
> > +
> > + mutex_unlock(&mib->cnt_mutex);
> > +
> > + *ranges = ksz_rmon_ranges;
> > +}
> > +
> > +void ksz9477_get_rmon_stats(struct ksz_device *dev, int port,
> > + struct ethtool_rmon_stats *rmon_stats,
> > + const struct ethtool_rmon_hist_range
> > **ranges)
> > +{
> > + struct ksz_port_mib *mib;
> > + u64 *cnt;
> > + u8 i;
> > +
> > + mib = &dev->ports[port].mib;
> > +
> > + mutex_lock(&mib->cnt_mutex);
> > +
> > + cnt = &mib->counters[KSZ9477_RX_UNDERSIZE];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ9477_RX_UNDERSIZE,
> > NULL, cnt);
> > + rmon_stats->undersize_pkts = *cnt;
> > +
> > + cnt = &mib->counters[KSZ9477_RX_OVERSIZE];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ9477_RX_OVERSIZE, NULL,
> > cnt);
> > + rmon_stats->oversize_pkts = *cnt;
> > +
> > + cnt = &mib->counters[KSZ9477_RX_FRAGMENTS];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ9477_RX_FRAGMENTS,
> > NULL, cnt);
> > + rmon_stats->fragments = *cnt;
> > +
> > + cnt = &mib->counters[KSZ9477_RX_JABBERS];
> > + dev->dev_ops->r_mib_pkt(dev, port, KSZ9477_RX_JABBERS, NULL,
> > cnt);
> > + rmon_stats->jabbers = *cnt;
> > +
> > + for (i = 0; i < KSZ9477_HIST_LEN; i++) {
> > + cnt = &mib->counters[KSZ9477_RX_64_OR_LESS + i];
> > + dev->dev_ops->r_mib_pkt(dev, port,
> > + (KSZ9477_RX_64_OR_LESS + i), NULL,
> > cnt);
>
> (same, and please check all other places in the series)
sure, will update in next version.
>
> > + rmon_stats->hist[i] = *cnt;
> > + }
> > +
> > + mutex_unlock(&mib->cnt_mutex);
> > +
> > + *ranges = ksz_rmon_ranges;
> > +}
> [...]
>
> Thanks,
> Olek
next prev parent reply other threads:[~2023-02-21 4:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 11:02 [PATCH v2 net-next 0/5] add ethtool categorized statistics Rakesh Sankaranarayanan
2023-02-17 11:02 ` [PATCH v2 net-next 1/5] net: dsa: microchip: add rmon grouping for ethtool statistics Rakesh Sankaranarayanan
2023-02-17 14:59 ` Alexander Lobakin
2023-02-21 4:37 ` Rakesh.Sankaranarayanan [this message]
2023-02-17 16:53 ` Vladimir Oltean
2023-02-17 17:40 ` Andrew Lunn
2023-02-21 4:40 ` Rakesh.Sankaranarayanan
2023-02-17 11:02 ` [PATCH v2 net-next 2/5] net: dsa: microchip: add eth ctrl " Rakesh Sankaranarayanan
2023-02-17 17:08 ` Vladimir Oltean
2023-02-21 7:14 ` Rakesh.Sankaranarayanan
2023-02-17 11:02 ` [PATCH v2 net-next 3/5] net: dsa: microchip: add eth mac " Rakesh Sankaranarayanan
2023-02-17 15:01 ` Alexander Lobakin
2023-02-17 16:42 ` Vladimir Oltean
2023-02-24 16:07 ` Alexander Lobakin
2023-02-24 21:53 ` Vladimir Oltean
2023-02-27 14:31 ` Alexander Lobakin
2023-02-27 14:52 ` Andrew Lunn
2023-02-28 10:53 ` Alexander Lobakin
2023-02-17 11:02 ` [PATCH v2 net-next 4/5] net: dsa: microchip: add eth phy " Rakesh Sankaranarayanan
2023-02-17 11:02 ` [PATCH v2 net-next 5/5] net: dsa: microchip: remove num_alus_variable Rakesh Sankaranarayanan
2023-02-17 17:16 ` Vladimir Oltean
2023-02-21 7:25 ` Rakesh.Sankaranarayanan
2023-02-17 14:54 ` [PATCH v2 net-next 0/5] add ethtool categorized statistics Alexander Lobakin
2023-02-17 16:48 ` Vladimir Oltean
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=d514e373b9e299b5e59bab2f6246236ecf59c77e.camel@microchip.com \
--to=rakesh.sankaranarayanan@microchip.com \
--cc=Thangaraj.S@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--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).