diff mbox series

[net-next,1/2] net: get stats64 if device if driver is configured

Message ID 20240228113125.3473685-2-leitao@debian.org (mailing list archive)
State Accepted
Commit 3e2f544dd8a33b2f650b32920b9bef103da2a7cd
Delegated to: Netdev Maintainers
Headers show
Series net: collect tstats automatically | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 947 this patch: 947
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 958 this patch: 958
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 964 this patch: 964
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-28--18-00 (tests: 882)

Commit Message

Breno Leitao Feb. 28, 2024, 11:31 a.m. UTC
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>
---
 net/core/dev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Horman Feb. 28, 2024, 2:34 p.m. UTC | #1
On Wed, Feb 28, 2024 at 03:31:21AM -0800, Breno Leitao wrote:
> 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>
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 275fd5259a4a..3577620e39bd 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10701,6 +10701,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);
 	}