diff options
author | Amir Vadai <amirva@mellanox.com> | 2016-05-13 15:55:35 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-16 20:43:50 +0300 |
commit | 3804070235264ea883c3fdccd9ed16fef20b5ccb (patch) | |
tree | b4f8a120e4159fcd3061b3b92a41b402a0bd8375 /include/net/sch_generic.h | |
parent | 388665a9be5fd16abd3d9762b1995208355e6f6d (diff) | |
download | linux-3804070235264ea883c3fdccd9ed16fef20b5ccb.tar.xz |
net/sched: Enable netdev drivers to update statistics of offloaded actions
Introduce stats_update callback. netdev driver could call it for offloaded
actions to update the basic statistics (packets, bytes and last use).
Since bstats_update() and bstats_cpu_update() use skb as an argument to
get the counters, _bstats_update() and _bstats_cpu_update(), that get
bytes and packets as arguments, were added.
Signed-off-by: Amir Vadai <amirva@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sch_generic.h')
-rw-r--r-- | include/net/sch_generic.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 46e55f0202a6..a1fd76c22a59 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -527,11 +527,27 @@ static inline bool qdisc_is_percpu_stats(const struct Qdisc *q) return q->flags & TCQ_F_CPUSTATS; } +static inline void _bstats_update(struct gnet_stats_basic_packed *bstats, + __u64 bytes, __u32 packets) +{ + bstats->bytes += bytes; + bstats->packets += packets; +} + static inline void bstats_update(struct gnet_stats_basic_packed *bstats, const struct sk_buff *skb) { - bstats->bytes += qdisc_pkt_len(skb); - bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1; + _bstats_update(bstats, + qdisc_pkt_len(skb), + skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1); +} + +static inline void _bstats_cpu_update(struct gnet_stats_basic_cpu *bstats, + __u64 bytes, __u32 packets) +{ + u64_stats_update_begin(&bstats->syncp); + _bstats_update(&bstats->bstats, bytes, packets); + u64_stats_update_end(&bstats->syncp); } static inline void bstats_cpu_update(struct gnet_stats_basic_cpu *bstats, |