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

From: Alexander Lobakin
Date: Fri Feb 17 2023 - 10:03:46 EST


From: Rakesh Sankaranarayanan <rakesh.sankaranarayanan@xxxxxxxxxxxxx>
Date: Fri, 17 Feb 2023 16:32:09 +0530

> Add support for ethtool standard device statistics grouping.
> Support ethernet mac statistics grouping using eth-mac groups
> parameter in ethtool command.
>
> Signed-off-by: Rakesh Sankaranarayanan <rakesh.sankaranarayanan@xxxxxxxxxxxxx>

[...]

> +void ksz8_get_eth_mac_stats(struct ksz_device *dev, int port,
> + struct ethtool_eth_mac_stats *mac_stats)
> +{
> + struct ksz_port_mib *mib;
> + u64 *ctr;
> +
> + mib = &dev->ports[port].mib;
> +
> + mutex_lock(&mib->cnt_mutex);
> + ctr = mib->counters;
> +
> + while (mib->cnt_ptr < dev->info->mib_cnt) {
> + dev->dev_ops->r_mib_pkt(dev, port, mib->cnt_ptr,
> + NULL, &mib->counters[mib->cnt_ptr]);

(for example here)

> + ++mib->cnt_ptr;

Reason for the pre-increment? :)

> + }
> +
> + mac_stats->FramesTransmittedOK = ctr[KSZ8_TX_MCAST] +
> + ctr[KSZ8_TX_BCAST] +
> + ctr[KSZ8_TX_UCAST] +
> + ctr[KSZ8_TX_PAUSE] -
> + ctr[KSZ8_TX_DISCARDS];
[...]

Thanks,
Olek