diff options
| author | David S. Miller <davem@davemloft.net> | 2020-10-06 06:23:22 -0700 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2020-10-06 06:23:22 -0700 |
| commit | 02da0b615b4bd7db747ed77199d5f1a161a0411a (patch) | |
| tree | 308afaf8af52666ef3ad1a77cf7ec9ffcac7bd6e /include | |
| parent | 9b9dda5d1dc843a55722cfa07f5570840f31d591 (diff) | |
| parent | 560b50cf6c18c5223929de2cb74504f67253ed47 (diff) | |
Merge branch 'drivers-net-add-sw_netstats_rx_add-helper'
Fabian Frederick says:
====================
drivers/net: add sw_netstats_rx_add helper
This small patchset creates netstats addition dev_sw_netstats_rx_add()
based on dev_lstats_add() and replaces some open coding
in both drivers/net and net branches.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/netdevice.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d126e36580c9..a0df43b13839 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2543,6 +2543,16 @@ struct pcpu_lstats { void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes); +static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int len) +{ + struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + + u64_stats_update_begin(&tstats->syncp); + tstats->rx_bytes += len; + tstats->rx_packets++; + u64_stats_update_end(&tstats->syncp); +} + static inline void dev_lstats_add(struct net_device *dev, unsigned int len) { struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats); |
