summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2024-02-29 12:50:15 +0100
committerPaolo Abeni <pabeni@redhat.com>2024-02-29 12:50:16 +0100
commit489645d3f1332f65a9337cb31c0ee12a1259a484 (patch)
tree94ec4ece55e2b22686dd0642bd861ce4e7406464
parentnet: stmmac: fix typo in comment (diff)
parentnet: sit: Do not set .ndo_get_stats64 (diff)
downloadlinux-489645d3f1332f65a9337cb31c0ee12a1259a484.tar.xz
linux-489645d3f1332f65a9337cb31c0ee12a1259a484.zip
Merge branch 'net-collect-tstats-automatically'
Breno Leitao says: ==================== net: collect tstats automatically The commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and convert veth & vrf") added a field in struct_netdevice, which tells what type of statistics the driver supports. That field is used primarily to allocate stats structures automatically, but, it also could leveraged to simplify the drivers even further, such as, if the driver relies in the default stats collection, then it doesn't need to assign to .ndo_get_stats64. That means that drivers only assign functions to .ndo_get_stats64 if they are using something special. I started to move some of these drivers[1][2][3] to use the core allocation, and with this change in, I just need to touch the driver once, and be able to simplify the whole stats allocation and collection for generic case. There are 44 devices today that could benefit from this simplification. # grep -r .ndo_get_stats64 | grep dev_get_tstats64 | wc -l 44 As of today, netnext only has the `sit` driver fully ported to core stats allocation, hence the second patch. Links: [1] https://lore.kernel.org/all/20240227182338.2739884-1-leitao@debian.org/ [2] https://lore.kernel.org/all/20240222144117.1370101-1-leitao@debian.org/ [3] https://lore.kernel.org/all/20240223115839.3572852-1-leitao@debian.org/ ==================== Link: https://lore.kernel.org/r/20240228113125.3473685-1-leitao@debian.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--net/core/dev.c2
-rw-r--r--net/ipv6/sit.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 053fac78305c..34b39c03e97d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);
}
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 5ad01480854d..655c9b1a19b8 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1398,7 +1398,6 @@ static const struct net_device_ops ipip6_netdev_ops = {
.ndo_uninit = ipip6_tunnel_uninit,
.ndo_start_xmit = sit_tunnel_xmit,
.ndo_siocdevprivate = ipip6_tunnel_siocdevprivate,
- .ndo_get_stats64 = dev_get_tstats64,
.ndo_get_iflink = ip_tunnel_get_iflink,
.ndo_tunnel_ctl = ipip6_tunnel_ctl,
};