From: Pieter Jansen van Vuuren Date: Sat, 4 May 2019 11:46:24 +0000 (-0700) Subject: net/sched: allow stats updates from offloaded police actions X-Git-Tag: v5.15~6431^2~19^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12f02b6b1548367fb548e61105fac6778c1a9173;p=platform%2Fkernel%2Flinux-starfive.git net/sched: allow stats updates from offloaded police actions Implement the stats_update callback for the police action that will be used by drivers for hardware offload. Signed-off-by: Pieter Jansen van Vuuren Reviewed-by: Jakub Kicinski Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- diff --git a/net/sched/act_police.c b/net/sched/act_police.c index e33bcab..6173194 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -282,6 +282,20 @@ static void tcf_police_cleanup(struct tc_action *a) kfree_rcu(p, rcu); } +static void tcf_police_stats_update(struct tc_action *a, + u64 bytes, u32 packets, + u64 lastuse, bool hw) +{ + struct tcf_police *police = to_police(a); + struct tcf_t *tm = &police->tcf_tm; + + _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), bytes, packets); + if (hw) + _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats_hw), + bytes, packets); + tm->lastuse = max_t(u64, tm->lastuse, lastuse); +} + static int tcf_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) { @@ -345,6 +359,7 @@ static struct tc_action_ops act_police_ops = { .kind = "police", .id = TCA_ID_POLICE, .owner = THIS_MODULE, + .stats_update = tcf_police_stats_update, .act = tcf_police_act, .dump = tcf_police_dump, .init = tcf_police_init,