mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-27 05:20:58 +07:00
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>
This commit is contained in:
parent
ffcb97388b
commit
77a1abf54f
@ -2557,6 +2557,8 @@ extern void dev_load(struct net *net, const char *name);
|
||||
extern void dev_mcast_init(void);
|
||||
extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
|
||||
struct rtnl_link_stats64 *storage);
|
||||
extern void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
|
||||
const struct net_device_stats *netdev_stats);
|
||||
|
||||
extern int netdev_max_backlog;
|
||||
extern int netdev_tstamp_prequeue;
|
||||
|
@ -5834,12 +5834,12 @@ void netdev_run_todo(void)
|
||||
/* Convert net_device_stats to rtnl_link_stats64. They have the same
|
||||
* fields in the same order, with only the type differing.
|
||||
*/
|
||||
static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
|
||||
const struct net_device_stats *netdev_stats)
|
||||
void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
|
||||
const struct net_device_stats *netdev_stats)
|
||||
{
|
||||
#if BITS_PER_LONG == 64
|
||||
BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats));
|
||||
memcpy(stats64, netdev_stats, sizeof(*stats64));
|
||||
BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats));
|
||||
memcpy(stats64, netdev_stats, sizeof(*stats64));
|
||||
#else
|
||||
size_t i, n = sizeof(*stats64) / sizeof(u64);
|
||||
const unsigned long *src = (const unsigned long *)netdev_stats;
|
||||
@ -5851,6 +5851,7 @@ static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
|
||||
dst[i] = src[i];
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(netdev_stats_to_stats64);
|
||||
|
||||
/**
|
||||
* dev_get_stats - get network device statistics
|
||||
|
Loading…
Reference in New Issue
Block a user