]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: get stats64 if device if driver is configured
authorBreno Leitao <leitao@debian.org>
Wed, 28 Feb 2024 11:31:21 +0000 (03:31 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 29 Feb 2024 11:50:13 +0000 (12:50 +0100)
If the network driver is relying in the net core to do stats allocation,
then we want to dev_get_tstats64() instead of netdev_stats_to_stats64(),
since there are per-cpu stats that needs to be taken in consideration.

This will also simplify the drivers in regard to statistics. Once the
driver sets NETDEV_PCPU_STAT_TSTATS, it doesn't not need to allocate the
stacks, neither it needs to set `.ndo_get_stats64 = dev_get_tstats64`
for the generic stats collection function anymore.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/dev.c

index 053fac78305c7322b894ceb07a925f7e64ed70aa..34b39c03e97dedc47c556732df8b3c243f0d5e2a 100644 (file)
@@ -10702,6 +10702,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
                ops->ndo_get_stats64(dev, storage);
        } else if (ops->ndo_get_stats) {
                netdev_stats_to_stats64(storage, ops->ndo_get_stats(dev));
+       } else if (dev->pcpu_stat_type == NETDEV_PCPU_STAT_TSTATS) {
+               dev_get_tstats64(dev, storage);
        } else {
                netdev_stats_to_stats64(storage, &dev->stats);
        }