History

net: provide dev_lstats_add() helper

Many network drivers need it and hand-coded the same function. In order to ease u64_stats_t adoption, it is time to factorize.

Eric Dumazet committed 7 years ago

Commit dd5382a1 parent de7d5082 files · +12 −10Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/netdevice.h+10−0
@@ -2403,6 +2403,16 @@ struct pcpu_lstats { · 2402 unmodified lines
2403 2403
2404void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes);2404void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes);
2405 2405
2406static inline void dev_lstats_add(struct net_device *dev, unsigned int len)
2407{
2408 struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats);
2409
2410 u64_stats_update_begin(&lstats->syncp);
2411 lstats->bytes += len;
2412 lstats->packets++;
2413 u64_stats_update_end(&lstats->syncp);
2414}
2415
2406#define __netdev_alloc_pcpu_stats(type, gfp) \2416#define __netdev_alloc_pcpu_stats(type, gfp) \
2407({ \2417({ \
2408 typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\2418 typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t