Skip to content

Commit

Permalink
net: sched: extract bstats update code into function
Browse files Browse the repository at this point in the history
Extract common code that increments cpu_bstats counter into standalone act
API function. Change hardware offloaded actions that use percpu counter
allocation to use the new function instead of incrementing cpu_bstats
directly.

This commit doesn't change functionality.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Oct 31, 2019
1 parent c8ecebd commit 5e1ad95
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions include/net/act_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind,
int ref);
int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);

static inline void tcf_action_update_bstats(struct tc_action *a,
struct sk_buff *skb)
{
bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb);
}

void tcf_action_update_stats(struct tc_action *a, u64 bytes, u32 packets,
bool drop, bool hw);
int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_csum.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a,
params = rcu_dereference_bh(p->params);

tcf_lastuse_update(&p->tcf_tm);
bstats_cpu_update(this_cpu_ptr(p->common.cpu_bstats), skb);
tcf_action_update_bstats(&p->common, skb);

action = READ_ONCE(p->tcf_action);
if (unlikely(action == TC_ACT_SHOT))
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
skb_push_rcsum(skb, nh_ofs);

out:
bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb);
tcf_action_update_bstats(&c->common, skb);
return retval;

drop:
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_gact.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a,
action = gact_rand[ptype](gact);
}
#endif
bstats_cpu_update(this_cpu_ptr(gact->common.cpu_bstats), skb);
tcf_action_update_bstats(&gact->common, skb);
if (action == TC_ACT_SHOT)
qstats_drop_inc(this_cpu_ptr(gact->common.cpu_qstats));

Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
}

tcf_lastuse_update(&m->tcf_tm);
bstats_cpu_update(this_cpu_ptr(m->common.cpu_bstats), skb);
tcf_action_update_bstats(&m->common, skb);

m_mac_header_xmit = READ_ONCE(m->tcfm_mac_header_xmit);
m_eaction = READ_ONCE(m->tcfm_eaction);
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_tunnel_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
params = rcu_dereference_bh(t->params);

tcf_lastuse_update(&t->tcf_tm);
bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
tcf_action_update_bstats(&t->common, skb);
action = READ_ONCE(t->tcf_action);

switch (params->tcft_action) {
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
u16 tci;

tcf_lastuse_update(&v->tcf_tm);
bstats_cpu_update(this_cpu_ptr(v->common.cpu_bstats), skb);
tcf_action_update_bstats(&v->common, skb);

/* Ensure 'data' points at mac_header prior calling vlan manipulating
* functions.
Expand Down

0 comments on commit 5e1ad95

Please sign in to comment.