Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: cake@lists.bufferbloat.net
Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>
Subject: [Cake] [PATCH] q_cake: Update xstats format to use per-tin structure
Date: Sun, 11 Feb 2018 18:26:18 +0100	[thread overview]
Message-ID: <20180211172618.13297-2-toke@toke.dk> (raw)
In-Reply-To: <20180211172618.13297-1-toke@toke.dk>

This updates tc to understand the updated cake xstats structure (which
splits out the tin stats in a separate structure the length of which is
included in the containing struct).

Old versions of the cake stats will no longer be understood by the
resulting version of tc.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
 tc/q_cake.c | 103 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 51 insertions(+), 52 deletions(-)

diff --git a/tc/q_cake.c b/tc/q_cake.c
index 6987c4d..3ddc13c 100644
--- a/tc/q_cake.c
+++ b/tc/q_cake.c
@@ -555,6 +555,11 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	return 0;
 }
 
+#define FOR_EACH_TIN(xstats, tst, i)				\
+	for(tst = xstats->tin_stats, i = 0;			\
+	i < xstats->tin_cnt;						\
+	    i++, tst = ((void *) xstats->tin_stats) + xstats->tin_stats_size * i)
+
 static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
 				 struct rtattr *xstats)
 {
@@ -597,17 +602,15 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
 				fprintf(f, " drop_next %s",
 					sprint_time(st->class_stats.drop_next, b1));
 		}
-	} else if (stnc->version >= 1 && stnc->version < 0xFF
-				&& stnc->max_tins == TC_CAKE_MAX_TINS
-				&& RTA_PAYLOAD(xstats) >= offsetof(struct tc_cake_xstats, capacity_estimate))
+	} else if (stnc->version > 0xFF
+		&& RTA_PAYLOAD(xstats) >= (sizeof(struct tc_cake_xstats) +
+					stnc->tin_stats_size * stnc->tin_cnt))
 	{
+		struct tc_cake_tin_stats  *tst;
 		int i;
 
-		if(stnc->version >= 3)
-			fprintf(f, " memory used: %s of %s\n", sprint_size(stnc->memory_used, b1), sprint_size(stnc->memory_limit, b2));
-
-		if(stnc->version >= 2)
-			fprintf(f, " capacity estimate: %s\n", sprint_rate(stnc->capacity_estimate, b1));
+		fprintf(f, " memory used: %s of %s\n", sprint_size(stnc->memory_used, b1), sprint_size(stnc->memory_limit, b2));
+		fprintf(f, " capacity estimate: %s\n", sprint_rate(stnc->capacity_estimate, b1));
 
 		switch(stnc->tin_cnt) {
 		case 3:
@@ -630,97 +633,93 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
 		};
 
 		fprintf(f, "  thresh  ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_rate(stnc->threshold_rate[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_rate(tst->threshold_rate, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  target  ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_time(stnc->target_us[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_time(tst->target_us, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  interval");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_time(stnc->interval_us[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_time(tst->interval_us, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  pk_delay");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_time(stnc->peak_delay_us[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_time(tst->peak_delay_us, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  av_delay");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_time(stnc->avge_delay_us[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_time(tst->avge_delay_us, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  sp_delay");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12s", sprint_time(stnc->base_delay_us[i], b1));
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12s", sprint_time(tst->base_delay_us, b1));
 		fprintf(f, "\n");
 
 		fprintf(f, "  pkts    ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->sent[i].packets);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->sent.packets);
 		fprintf(f, "\n");
 
 		fprintf(f, "  bytes   ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12llu", stnc->sent[i].bytes);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12llu", tst->sent.bytes);
 		fprintf(f, "\n");
 
 		fprintf(f, "  way_inds");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->way_indirect_hits[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->way_indirect_hits);
 		fprintf(f, "\n");
 
 		fprintf(f, "  way_miss");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->way_misses[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->way_misses);
 		fprintf(f, "\n");
 
 		fprintf(f, "  way_cols");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->way_collisions[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->way_collisions);
 		fprintf(f, "\n");
 
 		fprintf(f, "  drops   ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->dropped[i].packets);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->dropped.packets);
 		fprintf(f, "\n");
 
 		fprintf(f, "  marks   ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->ecn_marked[i].packets);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->ecn_marked.packets);
 		fprintf(f, "\n");
 
-		if(stnc->version >= 5) {
-			fprintf(f, "  ack_drop");
-			for(i=0; i < stnc->tin_cnt; i++)
-				fprintf(f, "%12u", stnc->ack_drops[i].packets);
-			fprintf(f, "\n");
-		}
+		fprintf(f, "  ack_drop");
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->ack_drops.packets);
+		fprintf(f, "\n");
 
 		fprintf(f, "  sp_flows");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->sparse_flows[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->sparse_flows);
 		fprintf(f, "\n");
 
 		fprintf(f, "  bk_flows");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->bulk_flows[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->bulk_flows);
 		fprintf(f, "\n");
 
-		if(stnc->version >= 4) {
-			fprintf(f, "  un_flows");
-			for(i=0; i < stnc->tin_cnt; i++)
-				fprintf(f, "%12u", stnc->unresponse_flows[i]);
-			fprintf(f, "\n");
-		}
+		fprintf(f, "  un_flows");
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->unresponse_flows);
+		fprintf(f, "\n");
 
 		fprintf(f, "  max_len ");
-		for(i=0; i < stnc->tin_cnt; i++)
-			fprintf(f, "%12u", stnc->max_skblen[i]);
+		FOR_EACH_TIN(stnc, tst, i)
+			fprintf(f, "%12u", tst->max_skblen);
 		fprintf(f, "\n");
 	} else {
 		return -1;
-- 
2.16.1


  reply	other threads:[~2018-02-11 17:27 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-26 15:08 [Cake] [PATCH] Split tin stats to its own structure to decrease size of tc_cake_xstats Toke Høiland-Jørgensen
2017-12-26 16:28 ` Dave Taht
2017-12-26 16:32   ` Toke Høiland-Jørgensen
2018-01-27 13:05 ` [Cake] [PATCH v2] " Toke Høiland-Jørgensen
2018-02-09 12:58   ` Jonathan Morton
2018-02-09 13:08     ` Toke Høiland-Jørgensen
2018-02-11 17:26   ` [Cake] [PATCH v3] " Toke Høiland-Jørgensen
2018-02-11 17:26     ` Toke Høiland-Jørgensen [this message]
2018-03-01 11:02       ` [Cake] [PATCH] q_cake: Update xstats format to use per-tin structure Jonathan Morton
2018-03-01 11:06         ` Sebastian Moeller
2018-03-01 13:59           ` Toke Høiland-Jørgensen
2018-03-05 23:08           ` Jonathan Morton
2018-03-06 11:17             ` Toke Høiland-Jørgensen
2018-03-06 11:46               ` Jonathan Morton
2018-03-06 12:10                 ` Sebastian Moeller
2018-03-06 13:08                   ` Jonathan Morton
2018-03-06 13:18                     ` Sebastian Moeller
2018-03-01 13:59         ` Toke Høiland-Jørgensen
2018-03-04 11:14           ` Toke Høiland-Jørgensen
2018-03-06 15:56       ` Stephen Hemminger
2018-03-06 18:33         ` Toke Høiland-Jørgensen
2018-03-06 21:06           ` Toke Høiland-Jørgensen
2018-03-06 22:31             ` Jonathan Morton
2018-03-07  8:50               ` Toke Høiland-Jørgensen
2018-03-07 10:08                 ` Kevin Darbyshire-Bryant
2018-03-07 10:31                   ` Toke Høiland-Jørgensen
2018-03-07 10:36                     ` Toke Høiland-Jørgensen
2018-03-07 11:08                       ` Kevin Darbyshire-Bryant
2018-03-07 11:28                         ` Toke Høiland-Jørgensen
2018-03-07 11:59                           ` Kevin Darbyshire-Bryant
2018-03-07 12:59                             ` Toke Høiland-Jørgensen
2018-03-07 14:21                               ` Sebastian Moeller
2018-03-07 14:30                                 ` Toke Høiland-Jørgensen
2018-03-07 15:25                                   ` Dave Taht
2018-03-07 15:52                                     ` Toke Høiland-Jørgensen
2018-03-07 17:26                                       ` Dave Taht
2018-03-08 22:29                                         ` Pete Heist
2018-03-07 18:27                               ` Kevin Darbyshire-Bryant
2018-03-07 18:35                                 ` Kevin Darbyshire-Bryant
2018-03-07 18:37                                 ` Jonathan Morton
2018-03-07 21:34                                 ` Toke Høiland-Jørgensen
2018-03-08  0:49                                   ` Jonathan Morton
2018-03-08  7:59                                     ` Kevin Darbyshire-Bryant
2018-03-08  9:21                                       ` Kevin Darbyshire-Bryant
2018-03-08 10:32                                         ` Toke Høiland-Jørgensen
     [not found]                                           ` <D8A90884-6DAE-42A6-A680-CD11599DDD97@darbyshire-bryant.me.uk>
2018-03-08 10:57                                             ` Toke Høiland-Jørgensen
2018-03-08 11:09                                               ` Kevin Darbyshire-Bryant
2018-03-08 11:14                                                 ` Kevin Darbyshire-Bryant
2018-03-08 11:21                                                   ` Toke Høiland-Jørgensen
2018-03-08 18:32                                                     ` Georgios Amanakis
2018-03-10 15:56                                                     ` Kevin Darbyshire-Bryant
2018-03-10 16:30                                                       ` Luis E. Garcia
2018-03-07 11:07                     ` Kevin Darbyshire-Bryant
2018-03-07 11:19                       ` Sebastian Moeller
2018-03-07 11:31                       ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180211172618.13297-2-toke@toke.dk \
    --to=toke@toke.dk \
    --cc=cake@lists.bufferbloat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox