Skip to content

Commit

Permalink
net/sched: allow stats updates from offloaded police actions
Browse files Browse the repository at this point in the history
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 <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pieter Jansen van Vuuren authored and David S. Miller committed May 6, 2019
1 parent b7fe4ab commit 12f02b6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/sched/act_police.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 12f02b6

Please sign in to comment.