Commit 451b05f4 authored by Fabian Frederick's avatar Fabian Frederick Committed by David S. Miller

net: netdevice.h: sw_netstats_rx_add helper

some drivers/network protocols update rx bytes/packets under
u64_stats_update_begin/end sequence.
Add a specific helper like dev_lstats_add()
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9b9dda5d
...@@ -2543,6 +2543,16 @@ struct pcpu_lstats { ...@@ -2543,6 +2543,16 @@ struct pcpu_lstats {
void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes); 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) static inline void dev_lstats_add(struct net_device *dev, unsigned int len)
{ {
struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats); struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment