Commit 26b537a8 authored by Vlad Buslov's avatar Vlad Buslov Committed by David S. Miller

net: sched: extract qstats update code into functions

Extract common code that increments cpu_qstats counters into standalone act
API functions. Change hardware offloaded actions that use percpu counter
allocation to use the new functions instead of accessing cpu_qstats
directly.

This commit doesn't change functionality.
Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e1ad95b
...@@ -193,6 +193,22 @@ static inline void tcf_action_update_bstats(struct tc_action *a, ...@@ -193,6 +193,22 @@ static inline void tcf_action_update_bstats(struct tc_action *a,
bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb); bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb);
} }
static inline struct gnet_stats_queue *
tcf_action_get_qstats(struct tc_action *a)
{
return this_cpu_ptr(a->cpu_qstats);
}
static inline void tcf_action_inc_drop_qstats(struct tc_action *a)
{
qstats_drop_inc(this_cpu_ptr(a->cpu_qstats));
}
static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a)
{
qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats));
}
void tcf_action_update_stats(struct tc_action *a, u64 bytes, u32 packets, void tcf_action_update_stats(struct tc_action *a, u64 bytes, u32 packets,
bool drop, bool hw); bool drop, bool hw);
int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
......
...@@ -624,7 +624,7 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -624,7 +624,7 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a,
return action; return action;
drop: drop:
qstats_drop_inc(this_cpu_ptr(p->common.cpu_qstats)); tcf_action_inc_drop_qstats(&p->common);
action = TC_ACT_SHOT; action = TC_ACT_SHOT;
goto out; goto out;
} }
......
...@@ -469,7 +469,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -469,7 +469,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
return retval; return retval;
drop: drop:
qstats_drop_inc(this_cpu_ptr(a->cpu_qstats)); tcf_action_inc_drop_qstats(&c->common);
return TC_ACT_SHOT; return TC_ACT_SHOT;
} }
......
...@@ -163,7 +163,7 @@ static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -163,7 +163,7 @@ static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a,
#endif #endif
tcf_action_update_bstats(&gact->common, skb); tcf_action_update_bstats(&gact->common, skb);
if (action == TC_ACT_SHOT) if (action == TC_ACT_SHOT)
qstats_drop_inc(this_cpu_ptr(gact->common.cpu_qstats)); tcf_action_inc_drop_qstats(&gact->common);
tcf_lastuse_update(&gact->tcf_tm); tcf_lastuse_update(&gact->tcf_tm);
......
...@@ -303,7 +303,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -303,7 +303,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
if (err) { if (err) {
out: out:
qstats_overlimit_inc(this_cpu_ptr(m->common.cpu_qstats)); tcf_action_inc_overlimit_qstats(&m->common);
if (tcf_mirred_is_act_redirect(m_eaction)) if (tcf_mirred_is_act_redirect(m_eaction))
retval = TC_ACT_SHOT; retval = TC_ACT_SHOT;
} }
......
...@@ -88,7 +88,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -88,7 +88,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
return action; return action;
drop: drop:
qstats_drop_inc(this_cpu_ptr(v->common.cpu_qstats)); tcf_action_inc_drop_qstats(&v->common);
return TC_ACT_SHOT; return TC_ACT_SHOT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment