Skip to content

Commit 3e2f544

Browse files
leitaoPaolo Abeni
authored andcommitted
net: get stats64 if device if driver is configured
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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 39de857 commit 3e2f544

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10702,6 +10702,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
1070210702
ops->ndo_get_stats64(dev, storage);
1070310703
} else if (ops->ndo_get_stats) {
1070410704
netdev_stats_to_stats64(storage, ops->ndo_get_stats(dev));
10705+
} else if (dev->pcpu_stat_type == NETDEV_PCPU_STAT_TSTATS) {
10706+
dev_get_tstats64(dev, storage);
1070510707
} else {
1070610708
netdev_stats_to_stats64(storage, &dev->stats);
1070710709
}

0 commit comments

Comments
 (0)