Skip to content

Commit d3fd654

Browse files
hkallweitkuba-moo
authored andcommitted
net: core: add dev_sw_netstats_tx_add
Add dev_sw_netstats_tx_add(), complementing already existing dev_sw_netstats_rx_add(). Other than dev_sw_netstats_rx_add allow to pass the number of packets as function argument. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4e5d79b commit d3fd654

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/netdevice.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,18 @@ static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int l
25572557
u64_stats_update_end(&tstats->syncp);
25582558
}
25592559

2560+
static inline void dev_sw_netstats_tx_add(struct net_device *dev,
2561+
unsigned int packets,
2562+
unsigned int len)
2563+
{
2564+
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
2565+
2566+
u64_stats_update_begin(&tstats->syncp);
2567+
tstats->tx_bytes += len;
2568+
tstats->tx_packets += packets;
2569+
u64_stats_update_end(&tstats->syncp);
2570+
}
2571+
25602572
static inline void dev_lstats_add(struct net_device *dev, unsigned int len)
25612573
{
25622574
struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats);

0 commit comments

Comments
 (0)