Many network drivers need it and hand-coded the same function. In order to ease u64_stats_t adoption, it is time to factorize.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -2403,6 +2403,16 @@ struct pcpu_lstats { · 2402 unmodified lines | ||
| 2403 | 2403 | |
| 2404 | 2404 | void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes); |
| 2405 | 2405 | |
| 2406 | +static 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 | 2416 | #define __netdev_alloc_pcpu_stats(type, gfp) \ |
| 2407 | 2417 | ({ \ |
| 2408 | 2418 | typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\ |