Re: [PATCH v2 net-next 2/5] net: dsa: microchip: add eth ctrl grouping for ethtool statistics

From: Rakesh.Sankaranarayanan
Date: Tue Feb 21 2023 - 02:14:18 EST


Hi Vlad,
On Fri, 2023-02-17 at 19:08 +0200, Vladimir Oltean wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> On Fri, Feb 17, 2023 at 04:32:08PM +0530, Rakesh Sankaranarayanan
> wrote:
> > +void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port,
> > +                          struct ethtool_eth_ctrl_stats
> > *ctrl_stats)
> > +{
> > +     struct ksz_port_mib *mib;
> > +     u64 *cnt;
> > +
> > +     mib = &dev->ports[port].mib;
> > +
> > +     mutex_lock(&mib->cnt_mutex);
> > +
> > +     cnt = &mib->counters[KSZ8_TX_PAUSE];
> > +     dev->dev_ops->r_mib_pkt(dev, port, KSZ8_TX_PAUSE, NULL, cnt);
> > +     ctrl_stats->MACControlFramesTransmitted = *cnt;
> > +
> > +     cnt = &mib->counters[KSZ8_RX_PAUSE];
> > +     dev->dev_ops->r_mib_pkt(dev, port, KSZ8_RX_PAUSE, NULL, cnt);
> > +     ctrl_stats->MACControlFramesReceived = *cnt;
> > +
> > +     mutex_unlock(&mib->cnt_mutex);
> > +}
>
> These should be reported as standard pause stats as well (ethtool -I
> --show-pause swpN).
Yes, these are reported as standards stats through get_pause_stats call
back.
static void ksz_get_pause_stats(struct dsa_switch *ds, int port,
struct ethtool_pause_stats
*pause_stats)
{
struct ksz_device *dev = ds->priv;
struct ksz_port_mib *mib;

mib = &dev->ports[port].mib;

spin_lock(&mib->stats64_lock);
memcpy(pause_stats, &mib->pause_stats, sizeof(*pause_stats));
spin_unlock(&mib->stats64_lock);
}