612-v6.9-net-get-stats64-if-device-if-driver-is-configured.patch 1.2 KB

1234567891011121314151617181920212223242526272829
  1. From: Breno Leitao <[email protected]>
  2. Date: Wed, 28 Feb 2024 03:31:21 -0800
  3. Subject: [PATCH] net: get stats64 if device if driver is configured
  4. If the network driver is relying in the net core to do stats allocation,
  5. then we want to dev_get_tstats64() instead of netdev_stats_to_stats64(),
  6. since there are per-cpu stats that needs to be taken in consideration.
  7. This will also simplify the drivers in regard to statistics. Once the
  8. driver sets NETDEV_PCPU_STAT_TSTATS, it doesn't not need to allocate the
  9. stacks, neither it needs to set `.ndo_get_stats64 = dev_get_tstats64`
  10. for the generic stats collection function anymore.
  11. Signed-off-by: Breno Leitao <[email protected]>
  12. Reviewed-by: Simon Horman <[email protected]>
  13. Signed-off-by: Paolo Abeni <[email protected]>
  14. ---
  15. --- a/net/core/dev.c
  16. +++ b/net/core/dev.c
  17. @@ -10668,6 +10668,8 @@ struct rtnl_link_stats64 *dev_get_stats(
  18. ops->ndo_get_stats64(dev, storage);
  19. } else if (ops->ndo_get_stats) {
  20. netdev_stats_to_stats64(storage, ops->ndo_get_stats(dev));
  21. + } else if (dev->pcpu_stat_type == NETDEV_PCPU_STAT_TSTATS) {
  22. + dev_get_tstats64(dev, storage);
  23. } else {
  24. netdev_stats_to_stats64(storage, &dev->stats);
  25. }