Commit 51972072 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[PKT_SCHED]: police: use gnet_stats for old policer stats

Transforms old policer to use generic statistic via TCA_STATS2
and maintain backward compatibility via TCA_STATS. Adds a new
API for classifiers to invoke the dumping process.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7dad6cc5
...@@ -28,7 +28,9 @@ struct tcf_police ...@@ -28,7 +28,9 @@ struct tcf_police
struct qdisc_rate_table *R_tab; struct qdisc_rate_table *R_tab;
struct qdisc_rate_table *P_tab; struct qdisc_rate_table *P_tab;
struct tc_stats stats; struct gnet_stats_basic bstats;
struct gnet_stats_queue qstats;
struct gnet_stats_rate_est rate_est;
spinlock_t *stats_lock; spinlock_t *stats_lock;
}; };
...@@ -101,6 +103,7 @@ extern int qdisc_copy_stats(struct sk_buff *skb, struct tc_stats *st, spinlock_t ...@@ -101,6 +103,7 @@ extern int qdisc_copy_stats(struct sk_buff *skb, struct tc_stats *st, spinlock_t
extern void tcf_police_destroy(struct tcf_police *p); extern void tcf_police_destroy(struct tcf_police *p);
extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est); extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est);
extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p); extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p);
extern int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p);
static inline int static inline int
tcf_police_release(struct tcf_police *p, int bind) tcf_police_release(struct tcf_police *p, int bind)
......
...@@ -149,7 +149,7 @@ void tcf_police_destroy(struct tcf_police *p) ...@@ -149,7 +149,7 @@ void tcf_police_destroy(struct tcf_police *p)
*p1p = p->next; *p1p = p->next;
write_unlock_bh(&police_lock); write_unlock_bh(&police_lock);
#ifdef CONFIG_NET_ESTIMATOR #ifdef CONFIG_NET_ESTIMATOR
qdisc_kill_estimator(&p->stats); gen_kill_estimator(&p->bstats, &p->rate_est);
#endif #endif
if (p->R_tab) if (p->R_tab)
qdisc_put_rtab(p->R_tab); qdisc_put_rtab(p->R_tab);
...@@ -469,7 +469,7 @@ struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est) ...@@ -469,7 +469,7 @@ struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est)
p->action = parm->action; p->action = parm->action;
#ifdef CONFIG_NET_ESTIMATOR #ifdef CONFIG_NET_ESTIMATOR
if (est) if (est)
qdisc_new_estimator(&p->stats, p->stats_lock, est); gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
#endif #endif
h = tcf_police_hash(p->index); h = tcf_police_hash(p->index);
write_lock_bh(&police_lock); write_lock_bh(&police_lock);
...@@ -493,12 +493,12 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p) ...@@ -493,12 +493,12 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p)
spin_lock(&p->lock); spin_lock(&p->lock);
p->stats.bytes += skb->len; p->bstats.bytes += skb->len;
p->stats.packets++; p->bstats.packets++;
#ifdef CONFIG_NET_ESTIMATOR #ifdef CONFIG_NET_ESTIMATOR
if (p->ewma_rate && p->stats.bps >= p->ewma_rate) { if (p->ewma_rate && p->rate_est.bps >= p->ewma_rate) {
p->stats.overlimits++; p->qstats.overlimits++;
spin_unlock(&p->lock); spin_unlock(&p->lock);
return p->action; return p->action;
} }
...@@ -534,7 +534,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p) ...@@ -534,7 +534,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p)
} }
} }
p->stats.overlimits++; p->qstats.overlimits++;
spin_unlock(&p->lock); spin_unlock(&p->lock);
return p->action; return p->action;
} }
...@@ -570,9 +570,34 @@ int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p) ...@@ -570,9 +570,34 @@ int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p)
return -1; return -1;
} }
int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p)
{
struct gnet_dump d;
if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
TCA_XSTATS, p->stats_lock, &d) < 0)
if (gnet_stats_copy_basic(&d, &p->bstats) < 0 ||
#ifdef CONFIG_NET_ESTIMATOR
gnet_stats_copy_rate_est(&d, &p->rate_est) < 0 ||
#endif
gnet_stats_copy_queue(&d, &p->qstats) < 0)
goto errout;
if (gnet_stats_finish_copy(&d) < 0)
goto errout;
return 0;
errout:
return -1;
}
EXPORT_SYMBOL(tcf_police); EXPORT_SYMBOL(tcf_police);
EXPORT_SYMBOL(tcf_police_destroy); EXPORT_SYMBOL(tcf_police_destroy);
EXPORT_SYMBOL(tcf_police_dump); EXPORT_SYMBOL(tcf_police_dump);
EXPORT_SYMBOL(tcf_police_dump_stats);
EXPORT_SYMBOL(tcf_police_hash); EXPORT_SYMBOL(tcf_police_hash);
EXPORT_SYMBOL(tcf_police_ht); EXPORT_SYMBOL(tcf_police_ht);
EXPORT_SYMBOL(tcf_police_locate); EXPORT_SYMBOL(tcf_police_locate);
......
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