netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer
@ 2004-11-03 21:58 Thomas Graf
  2004-11-03 21:59 ` [PATCH 1/8] tcf_action: copy generic stats via TCA_ACT_STATS Thomas Graf
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 21:58 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Dave,

This is the last patchset in my attempt to clean up traffic
control statistics. It converts the action and policer code
to the gnet_stats API.

I decided to not provide backward compatibility for action
statistics and introduce a new TLV type TCA_ACT_STATS for them
in order to get some consistency and be prepared if we ever
introduce statistics to classifiers. This was approved by Jamal.

Shall I mark the old estimator and statistic API as __deprecated
or remove it right away?

Cheers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/8] tcf_action: copy generic stats via TCA_ACT_STATS
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
@ 2004-11-03 21:59 ` Thomas Graf
  2004-11-03 21:59 ` [PATCH 2/8] gact: use gnet_stats for action stats Thomas Graf
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 21:59 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Dumps the statistic common to all action modules via the newly
introduced TLV type TCA_ACT_STATS in tcf_action_copy_stats but
allows the corresponding module to dump its own statistic by
implementing the get_stats callback.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/include/linux/rtnetlink.h linux-2.6.10-rc1-bk11/include/linux/rtnetlink.h
--- linux-2.6.10-rc1-bk11.orig/include/linux/rtnetlink.h	2004-11-02 11:43:04.000000000 +0100
+++ linux-2.6.10-rc1-bk11/include/linux/rtnetlink.h	2004-11-02 12:02:44.000000000 +0100
@@ -699,6 +699,7 @@
 	TCA_RATE,
 	TCA_FCNT,
 	TCA_STATS2,
+	TCA_ACT_STATS,
 	__TCA_MAX
 };
 
diff -Nru linux-2.6.10-rc1-bk11.orig/include/net/act_api.h linux-2.6.10-rc1-bk11/include/net/act_api.h
--- linux-2.6.10-rc1-bk11.orig/include/net/act_api.h	2004-11-02 11:43:07.000000000 +0100
+++ linux-2.6.10-rc1-bk11/include/net/act_api.h	2004-11-02 12:02:33.000000000 +0100
@@ -44,10 +44,16 @@
 	u32 capab; \
 	int action; \
 	struct tcf_t tm; \
-	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 lock
 
+struct tcf_act_hdr
+{
+	tca_gen(act_hdr);
+};
 
 struct tc_action
 {
diff -Nru linux-2.6.10-rc1-bk11.orig/include/net/pkt_act.h linux-2.6.10-rc1-bk11/include/net/pkt_act.h
--- linux-2.6.10-rc1-bk11.orig/include/net/pkt_act.h	2004-11-02 11:43:07.000000000 +0100
+++ linux-2.6.10-rc1-bk11/include/net/pkt_act.h	2004-11-02 12:03:01.000000000 +0100
@@ -60,7 +60,7 @@
 			*p1p = p->next;
 			write_unlock_bh(&tcf_t_lock);
 #ifdef CONFIG_NET_ESTIMATOR
-			qdisc_kill_estimator(&p->stats);
+			gen_kill_estimator(&p->bstats, &p->rate_est);
 #endif
 			kfree(p);
 			return;
@@ -256,9 +256,8 @@
 	p->tm.install = jiffies;
 	p->tm.lastuse = jiffies;
 #ifdef CONFIG_NET_ESTIMATOR
-	if (est) {
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
-	}
+	if (est)
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_hash(p->index);
 	write_lock_bh(&tcf_t_lock);
diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/act_api.c linux-2.6.10-rc1-bk11/net/sched/act_api.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/act_api.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/act_api.c	2004-11-02 12:06:02.000000000 +0100
@@ -416,14 +416,37 @@
 
 int tcf_action_copy_stats (struct sk_buff *skb,struct tc_action *a)
 {
+	struct gnet_dump d;
+	struct tcf_act_hdr *h = a->priv;
+	
 #ifdef CONFIG_KMOD
 	/* place holder */
 #endif
 
-	if (NULL == a->ops || NULL == a->ops->get_stats)
-		return 1;
+	if (NULL == h)
+		goto errout;
+
+	if (gnet_stats_start_copy(skb, TCA_ACT_STATS, h->stats_lock, &d) < 0)
+		goto errout;
+
+	if (NULL != a->ops && NULL != a->ops->get_stats)
+		if (a->ops->get_stats(skb, a) < 0)
+			goto errout;
+
+	if (gnet_stats_copy_basic(&d, &h->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(&d, &h->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(&d, &h->qstats) < 0)
+		goto errout;
+
+	if (gnet_stats_finish_copy(&d) < 0)
+		goto errout;
+
+	return 0;
 
-	return a->ops->get_stats(skb,a);
+errout:
+	return -1;
 }
 
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/8] gact: use gnet_stats for action stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
  2004-11-03 21:59 ` [PATCH 1/8] tcf_action: copy generic stats via TCA_ACT_STATS Thomas Graf
@ 2004-11-03 21:59 ` Thomas Graf
  2004-11-03 22:00 ` [PATCH 3/8] ipt: " Thomas Graf
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 21:59 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/gact.c linux-2.6.10-rc1-bk11/net/sched/gact.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/gact.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/gact.c	2004-11-02 12:10:39.000000000 +0100
@@ -62,7 +62,7 @@
 
 int
 gact_determ(struct tcf_gact *p) {
-	if (p->stats.packets%p->pval)
+	if (p->bstats.packets%p->pval)
 		return p->action;
 	return p->paction;
 }
@@ -163,10 +163,10 @@
 #else
 	action = p->action;
 #endif
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 	if (TC_ACT_SHOT == action)
-		p->stats.drops++;
+		p->qstats.drops++;
 	p->tm.lastuse = jiffies;
 	spin_unlock(&p->lock);
 
@@ -214,17 +214,6 @@
 	return -1;
 }
 
-int
-tcf_gact_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_gact *p;
-	p = PRIV(a,gact);
-	if (NULL != p)
-		return qdisc_copy_stats(skb, &p->stats,p->stats_lock);
-
-	return 1;
-}
-
 struct tc_action_ops act_gact_ops = {
 	.next		=	NULL,
 	.kind		=	"gact",
@@ -232,7 +221,6 @@
 	.capab		=	TCA_CAP_NONE,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_gact,
-	.get_stats	=	tcf_gact_stats,
 	.dump		=	tcf_gact_dump,
 	.cleanup	=	tcf_gact_cleanup,
 	.lookup		=	tcf_hash_search,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/8] ipt: use gnet_stats for action stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
  2004-11-03 21:59 ` [PATCH 1/8] tcf_action: copy generic stats via TCA_ACT_STATS Thomas Graf
  2004-11-03 21:59 ` [PATCH 2/8] gact: use gnet_stats for action stats Thomas Graf
@ 2004-11-03 22:00 ` Thomas Graf
  2004-11-03 22:01 ` [PATCH 4/8] mirred: " Thomas Graf
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:00 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/ipt.c linux-2.6.10-rc1-bk11/net/sched/ipt.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/ipt.c	2004-11-02 11:59:44.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/ipt.c	2004-11-02 12:14:04.000000000 +0100
@@ -218,9 +218,8 @@
 	*/
 	p->tm.install = jiffies;
 #ifdef CONFIG_NET_ESTIMATOR
-	if (est) {
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
-	}
+	if (est)
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_hash(p->index);
 	write_lock_bh(&ipt_lock);
@@ -258,8 +257,8 @@
 	spin_lock(&p->lock);
 
 	p->tm.lastuse = jiffies;
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 
 	if (skb_cloned(skb) ) {
 		if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
@@ -278,7 +277,7 @@
 		break;
 	case NF_DROP:
 		result = TC_ACT_SHOT;
-		p->stats.drops++;
+		p->qstats.drops++;
 		break;
 	case IPT_CONTINUE:
 		result = TC_ACT_PIPE;
@@ -346,17 +345,6 @@
 	return -1;
 }
 
-int
-tcf_ipt_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_ipt *p;
-	p = PRIV(a,ipt);
-	if (NULL != p)
-		return qdisc_copy_stats(skb, &p->stats, p->stats_lock);
-
-	return 1;
-}
-
 struct tc_action_ops act_ipt_ops = {
 	.next		=	NULL,
 	.kind		=	"ipt",
@@ -364,7 +352,6 @@
 	.capab		=	TCA_CAP_NONE,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_ipt,
-	.get_stats	=	tcf_ipt_stats,
 	.dump		=	tcf_ipt_dump,
 	.cleanup	=	tcf_ipt_cleanup,
 	.lookup		=	tcf_hash_search,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/8] mirred: use gnet_stats for action stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (2 preceding siblings ...)
  2004-11-03 22:00 ` [PATCH 3/8] ipt: " Thomas Graf
@ 2004-11-03 22:01 ` Thomas Graf
  2004-11-03 22:01 ` [PATCH 5/8] pedit: " Thomas Graf
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:01 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/mirred.c linux-2.6.10-rc1-bk11/net/sched/mirred.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/mirred.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/mirred.c	2004-11-02 12:10:07.000000000 +0100
@@ -195,9 +195,9 @@
 bad_mirred:
 		if (NULL != skb2)
 			kfree_skb(skb2);
-		p->stats.overlimits++;
-		p->stats.bytes += skb->len;
-		p->stats.packets++;
+		p->qstats.overlimits++;
+		p->bstats.bytes += skb->len;
+		p->bstats.packets++;
 		spin_unlock(&p->lock);
 		/* should we be asking for packet to be dropped?
 		 * may make sense for redirect case only 
@@ -216,8 +216,8 @@
 		goto bad_mirred;
 	}
 
-	p->stats.bytes += skb2->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb2->len;
+	p->bstats.packets++;
 	if ( !(at & AT_EGRESS)) {
 		if (p->ok_push) {
 			skb_push(skb2, skb2->dev->hard_header_len);
@@ -268,18 +268,6 @@
 	return -1;
 }
 
-int
-tcf_mirred_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_mirred *p;
-	p = PRIV(a,mirred);
-
-	if (NULL != p)
-		return qdisc_copy_stats(skb, &p->stats, p->stats_lock);
-
-	return 1;
-}
-
 static struct tc_action_ops act_mirred_ops = {
 	.next		=	NULL,
 	.kind		=	"mirred",
@@ -287,7 +275,6 @@
 	.capab		=	TCA_CAP_NONE,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_mirred,
-	.get_stats	=	tcf_mirred_stats,
 	.dump		=	tcf_mirred_dump,
 	.cleanup	=	tcf_mirred_cleanup,
 	.lookup		=	tcf_hash_search,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/8] pedit: use gnet_stats for action stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (3 preceding siblings ...)
  2004-11-03 22:01 ` [PATCH 4/8] mirred: " Thomas Graf
@ 2004-11-03 22:01 ` Thomas Graf
  2004-11-03 22:02 ` [PATCH 6/8] police: use gnet_stats for action policer stats Thomas Graf
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:01 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/pedit.c linux-2.6.10-rc1-bk11/net/sched/pedit.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/pedit.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/pedit.c	2004-11-02 12:11:11.000000000 +0100
@@ -183,10 +183,10 @@
 	}
 
 bad:
-	p->stats.overlimits++;
+	p->qstats.overlimits++;
 done:
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 	spin_unlock(&p->lock);
 	return p->action;
 }
@@ -255,17 +255,6 @@
 	return -1;
 }
 
-int
-tcf_pedit_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_pedit *p;
-	p = PRIV(a,pedit);
-	if (NULL != p)
-		return qdisc_copy_stats(skb, &p->stats, p->stats_lock);
-
-	return 1;
-}
-
 static
 struct tc_action_ops act_pedit_ops = {
 	.kind		=	"pedit",
@@ -273,7 +262,6 @@
 	.capab		=	TCA_CAP_NONE,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_pedit,
-	.get_stats	=	tcf_pedit_stats,
 	.dump		=	tcf_pedit_dump,
 	.cleanup	=	tcf_pedit_cleanup,
 	.lookup		=	tcf_hash_search,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 6/8] police: use gnet_stats for action policer stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (4 preceding siblings ...)
  2004-11-03 22:01 ` [PATCH 5/8] pedit: " Thomas Graf
@ 2004-11-03 22:02 ` Thomas Graf
  2004-11-03 22:02 ` [PATCH 7/8] police: use gnet_stats for old " Thomas Graf
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:02 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/police.c linux-2.6.10-rc1-bk11/net/sched/police.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/police.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/police.c	2004-11-02 13:54:14.000000000 +0100
@@ -245,7 +245,7 @@
 	p->index = parm->index ? : tcf_police_new_index();
 #ifdef CONFIG_NET_ESTIMATOR
 	if (est)
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_police_hash(p->index);
 	write_lock_bh(&police_lock);
@@ -275,16 +275,6 @@
 	return 0;
 }
 
-int tcf_act_police_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_police *p;
-	p = PRIV(a);
-	if (NULL != p) 
-		return qdisc_copy_stats(skb, &p->stats, p->stats_lock);
-
-	return 1;
-}
-
 int tcf_act_police(struct sk_buff **pskb, struct tc_action *a)
 {
 	psched_time_t now;
@@ -302,12 +292,12 @@
 
 	spin_lock(&p->lock);
 
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 
 #ifdef CONFIG_NET_ESTIMATOR
-	if (p->ewma_rate && p->stats.bps >= p->ewma_rate) {
-		p->stats.overlimits++;
+	if (p->ewma_rate && p->rate_est.bps >= p->ewma_rate) {
+		p->qstats.overlimits++;
 		spin_unlock(&p->lock);
 		return p->action;
 	}
@@ -343,7 +333,7 @@
 		}
 	}
 
-	p->stats.overlimits++;
+	p->qstats.overlimits++;
 	spin_unlock(&p->lock);
 	return p->action;
 }
@@ -400,7 +390,6 @@
 	.capab		=	TCA_CAP_NONE, 
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_act_police,
-	.get_stats	=	tcf_act_police_stats,
 	.dump		=	tcf_act_police_dump,
 	.cleanup	=	tcf_act_police_cleanup,
 	.lookup		=	tcf_hash_search,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 7/8] police: use gnet_stats for old policer stats
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (5 preceding siblings ...)
  2004-11-03 22:02 ` [PATCH 6/8] police: use gnet_stats for action policer stats Thomas Graf
@ 2004-11-03 22:02 ` Thomas Graf
  2004-11-03 22:03 ` [PATCH 8/8] cls_*: use tcf_police_dump_stats to dump via new gnet_stats API Thomas Graf
  2004-11-03 22:18 ` [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer David S. Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:02 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

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: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk13.orig/include/net/act_api.h linux-2.6.10-rc1-bk13/include/net/act_api.h
--- linux-2.6.10-rc1-bk13.orig/include/net/act_api.h	2004-11-03 17:04:58.000000000 +0100
+++ linux-2.6.10-rc1-bk13/include/net/act_api.h	2004-11-03 17:04:44.000000000 +0100
@@ -28,7 +28,9 @@
 	struct qdisc_rate_table *R_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;
 };
 
@@ -101,6 +103,7 @@
 extern void tcf_police_destroy(struct tcf_police *p);
 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_stats(struct sk_buff *skb, struct tcf_police *p);
 
 static inline int
 tcf_police_release(struct tcf_police *p, int bind)
diff -Nru linux-2.6.10-rc1-bk13.orig/net/sched/police.c linux-2.6.10-rc1-bk13/net/sched/police.c
--- linux-2.6.10-rc1-bk13.orig/net/sched/police.c	2004-11-03 17:05:10.000000000 +0100
+++ linux-2.6.10-rc1-bk13/net/sched/police.c	2004-11-03 17:04:44.000000000 +0100
@@ -149,7 +149,7 @@
 			*p1p = p->next;
 			write_unlock_bh(&police_lock);
 #ifdef CONFIG_NET_ESTIMATOR
-			qdisc_kill_estimator(&p->stats);
+			gen_kill_estimator(&p->bstats, &p->rate_est);
 #endif
 			if (p->R_tab)
 				qdisc_put_rtab(p->R_tab);
@@ -469,7 +469,7 @@
 	p->action = parm->action;
 #ifdef CONFIG_NET_ESTIMATOR
 	if (est)
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_police_hash(p->index);
 	write_lock_bh(&police_lock);
@@ -493,12 +493,12 @@
 
 	spin_lock(&p->lock);
 
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 
 #ifdef CONFIG_NET_ESTIMATOR
-	if (p->ewma_rate && p->stats.bps >= p->ewma_rate) {
-		p->stats.overlimits++;
+	if (p->ewma_rate && p->rate_est.bps >= p->ewma_rate) {
+		p->qstats.overlimits++;
 		spin_unlock(&p->lock);
 		return p->action;
 	}
@@ -534,7 +534,7 @@
 		}
 	}
 
-	p->stats.overlimits++;
+	p->qstats.overlimits++;
 	spin_unlock(&p->lock);
 	return p->action;
 }
@@ -570,9 +570,34 @@
 	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_destroy);
 EXPORT_SYMBOL(tcf_police_dump);
+EXPORT_SYMBOL(tcf_police_dump_stats);
 EXPORT_SYMBOL(tcf_police_hash);
 EXPORT_SYMBOL(tcf_police_ht);
 EXPORT_SYMBOL(tcf_police_locate);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 8/8] cls_*: use tcf_police_dump_stats to dump via new gnet_stats API
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (6 preceding siblings ...)
  2004-11-03 22:02 ` [PATCH 7/8] police: use gnet_stats for old " Thomas Graf
@ 2004-11-03 22:03 ` Thomas Graf
  2004-11-03 22:18 ` [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer David S. Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-03 22:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

Signed-off-by: Thomas Graf <tgraf@suug.ch>

diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/cls_fw.c linux-2.6.10-rc1-bk11/net/sched/cls_fw.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/cls_fw.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/cls_fw.c	2004-11-02 13:53:52.000000000 +0100
@@ -395,11 +395,9 @@
 	}
 #else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-			f->police->stats_lock))
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
 			goto rtattr_failure;
-	}
 #endif /* CONFIG_NET_CLS_POLICE */
 #endif /* CONFIG_NET_CLS_ACT */
 	return skb->len;
diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/cls_route.c linux-2.6.10-rc1-bk11/net/sched/cls_route.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/cls_route.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/cls_route.c	2004-11-02 13:53:52.000000000 +0100
@@ -566,11 +566,9 @@
 
 	rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-				     f->police->stats_lock))
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 	return skb->len;
 
diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/cls_rsvp.h linux-2.6.10-rc1-bk11/net/sched/cls_rsvp.h
--- linux-2.6.10-rc1-bk11.orig/net/sched/cls_rsvp.h	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/cls_rsvp.h	2004-11-02 13:53:52.000000000 +0100
@@ -631,11 +631,9 @@
 
 	rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-				     f->police->stats_lock))
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 	return skb->len;
 
diff -Nru linux-2.6.10-rc1-bk11.orig/net/sched/cls_u32.c linux-2.6.10-rc1-bk11/net/sched/cls_u32.c
--- linux-2.6.10-rc1-bk11.orig/net/sched/cls_u32.c	2004-11-02 11:43:27.000000000 +0100
+++ linux-2.6.10-rc1-bk11/net/sched/cls_u32.c	2004-11-02 13:53:52.000000000 +0100
@@ -775,11 +775,9 @@
 	}
 #else
 #ifdef CONFIG_NET_CLS_POLICE
-	if (TC_U32_KEY(n->handle) && n->police) {
-		if (qdisc_copy_stats(skb, &n->police->stats,
-				     n->police->stats_lock))
+	if (TC_U32_KEY(n->handle) && n->police)
+		if (tcf_police_dump_stats(skb, n->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 #endif
 	return skb->len;

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer
  2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
                   ` (7 preceding siblings ...)
  2004-11-03 22:03 ` [PATCH 8/8] cls_*: use tcf_police_dump_stats to dump via new gnet_stats API Thomas Graf
@ 2004-11-03 22:18 ` David S. Miller
  2004-11-04  0:43   ` Thomas Graf
  8 siblings, 1 reply; 11+ messages in thread
From: David S. Miller @ 2004-11-03 22:18 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev, hadi

On Wed, 3 Nov 2004 22:58:16 +0100
Thomas Graf <tgraf@suug.ch> wrote:

> This is the last patchset in my attempt to clean up traffic
> control statistics. It converts the action and policer code
> to the gnet_stats API.
> 
> I decided to not provide backward compatibility for action
> statistics and introduce a new TLV type TCA_ACT_STATS for them
> in order to get some consistency and be prepared if we ever
> introduce statistics to classifiers. This was approved by Jamal.

All applied, very nice work Thomas.

> Shall I mark the old estimator and statistic API as __deprecated
> or remove it right away?

Since nothing in the tree uses it any more, let's just kill it
outright.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer
  2004-11-03 22:18 ` [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer David S. Miller
@ 2004-11-04  0:43   ` Thomas Graf
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Graf @ 2004-11-04  0:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, hadi

* David S. Miller <20041103141820.7a0c7832.davem@davemloft.net> 2004-11-03 14:18
> > Shall I mark the old estimator and statistic API as __deprecated
> > or remove it right away?
> 
> Since nothing in the tree uses it any more, let's just kill it
> outright.

I will come up with a patch tomorrow together with the iproute2
patch which needs some more work. Thanks for the quick applying.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-11-04  0:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 21:58 [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer Thomas Graf
2004-11-03 21:59 ` [PATCH 1/8] tcf_action: copy generic stats via TCA_ACT_STATS Thomas Graf
2004-11-03 21:59 ` [PATCH 2/8] gact: use gnet_stats for action stats Thomas Graf
2004-11-03 22:00 ` [PATCH 3/8] ipt: " Thomas Graf
2004-11-03 22:01 ` [PATCH 4/8] mirred: " Thomas Graf
2004-11-03 22:01 ` [PATCH 5/8] pedit: " Thomas Graf
2004-11-03 22:02 ` [PATCH 6/8] police: use gnet_stats for action policer stats Thomas Graf
2004-11-03 22:02 ` [PATCH 7/8] police: use gnet_stats for old " Thomas Graf
2004-11-03 22:03 ` [PATCH 8/8] cls_*: use tcf_police_dump_stats to dump via new gnet_stats API Thomas Graf
2004-11-03 22:18 ` [PATCHSET 0/8] PKT_SCHED: Use gnet_stats for actions and policer David S. Miller
2004-11-04  0:43   ` Thomas Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).