diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2012-03-04 23:50:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-05 15:38:32 -0500 |
commit | 77a1abf54f4b003ad6e59c535045b2ad89fedfeb (patch) | |
tree | a76af8ea1df05266c70202e204dd639c38586334 | |
parent | ffcb97388b1d41b1db063eb041cb9af408662127 (diff) |
net: export netdev_stats_to_stats64
Some drivers use internal netdev stats member to store part of their
stats, yet advertize ndo_get_stats64() to implement some 64bit fields.
Allow them to use netdev_stats_to_stats64() helper to make the copy of
netdev stats before they compute their 64bit counters.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netdevice.h | 2 | ||||
-rw-r--r-- | net/core/dev.c | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f1b7d037c2c..4d279c5287f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -2557,6 +2557,8 @@ extern void dev_load(struct net *net, const char *name); | |||
2557 | extern void dev_mcast_init(void); | 2557 | extern void dev_mcast_init(void); |
2558 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, | 2558 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, |
2559 | struct rtnl_link_stats64 *storage); | 2559 | struct rtnl_link_stats64 *storage); |
2560 | extern void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, | ||
2561 | const struct net_device_stats *netdev_stats); | ||
2560 | 2562 | ||
2561 | extern int netdev_max_backlog; | 2563 | extern int netdev_max_backlog; |
2562 | extern int netdev_tstamp_prequeue; | 2564 | extern int netdev_tstamp_prequeue; |
diff --git a/net/core/dev.c b/net/core/dev.c index 763a0eda715..5ef3b65c368 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -5834,12 +5834,12 @@ void netdev_run_todo(void) | |||
5834 | /* Convert net_device_stats to rtnl_link_stats64. They have the same | 5834 | /* Convert net_device_stats to rtnl_link_stats64. They have the same |
5835 | * fields in the same order, with only the type differing. | 5835 | * fields in the same order, with only the type differing. |
5836 | */ | 5836 | */ |
5837 | static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, | 5837 | void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, |
5838 | const struct net_device_stats *netdev_stats) | 5838 | const struct net_device_stats *netdev_stats) |
5839 | { | 5839 | { |
5840 | #if BITS_PER_LONG == 64 | 5840 | #if BITS_PER_LONG == 64 |
5841 | BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats)); | 5841 | BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats)); |
5842 | memcpy(stats64, netdev_stats, sizeof(*stats64)); | 5842 | memcpy(stats64, netdev_stats, sizeof(*stats64)); |
5843 | #else | 5843 | #else |
5844 | size_t i, n = sizeof(*stats64) / sizeof(u64); | 5844 | size_t i, n = sizeof(*stats64) / sizeof(u64); |
5845 | const unsigned long *src = (const unsigned long *)netdev_stats; | 5845 | const unsigned long *src = (const unsigned long *)netdev_stats; |
@@ -5851,6 +5851,7 @@ static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, | |||
5851 | dst[i] = src[i]; | 5851 | dst[i] = src[i]; |
5852 | #endif | 5852 | #endif |
5853 | } | 5853 | } |
5854 | EXPORT_SYMBOL(netdev_stats_to_stats64); | ||
5854 | 5855 | ||
5855 | /** | 5856 | /** |
5856 | * dev_get_stats - get network device statistics | 5857 | * dev_get_stats - get network device statistics |