dnsmasq: Add broken realtime clock build switch in full variant
[openwrt/staging/lynxis/omap.git] / package / network / utils / iproute2 / patches / 950-add-cake-to-tc.patch
1 --- a/include/linux/pkt_sched.h
2 +++ b/include/linux/pkt_sched.h
3 @@ -877,4 +877,55 @@ struct tc_pie_xstats {
4 __u32 maxq; /* maximum queue size */
5 __u32 ecn_mark; /* packets marked with ecn*/
6 };
7 +
8 +/* CAKE */
9 +enum {
10 + TCA_CAKE_UNSPEC,
11 + TCA_CAKE_BASE_RATE,
12 + TCA_CAKE_DIFFSERV_MODE,
13 + TCA_CAKE_ATM,
14 + TCA_CAKE_FLOW_MODE,
15 + TCA_CAKE_OVERHEAD,
16 + TCA_CAKE_RTT,
17 + TCA_CAKE_TARGET,
18 + TCA_CAKE_AUTORATE,
19 + TCA_CAKE_MEMORY,
20 + __TCA_CAKE_MAX
21 +};
22 +#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
23 +
24 +struct tc_cake_traffic_stats {
25 + __u32 packets;
26 + __u32 link_ms;
27 + __u64 bytes;
28 +};
29 +
30 +#define TC_CAKE_MAX_TINS (8)
31 +struct tc_cake_xstats {
32 + __u16 version; /* == 3, increments when struct extended */
33 + __u8 max_tins; /* == TC_CAKE_MAX_TINS */
34 + __u8 tin_cnt; /* <= TC_CAKE_MAX_TINS */
35 +
36 + __u32 threshold_rate [TC_CAKE_MAX_TINS];
37 + __u32 target_us [TC_CAKE_MAX_TINS];
38 + struct tc_cake_traffic_stats sent [TC_CAKE_MAX_TINS];
39 + struct tc_cake_traffic_stats dropped [TC_CAKE_MAX_TINS];
40 + struct tc_cake_traffic_stats ecn_marked[TC_CAKE_MAX_TINS];
41 + struct tc_cake_traffic_stats backlog [TC_CAKE_MAX_TINS];
42 + __u32 interval_us [TC_CAKE_MAX_TINS];
43 + __u32 way_indirect_hits[TC_CAKE_MAX_TINS];
44 + __u32 way_misses [TC_CAKE_MAX_TINS];
45 + __u32 way_collisions [TC_CAKE_MAX_TINS];
46 + __u32 peak_delay_us [TC_CAKE_MAX_TINS]; /* ~= delay to bulk flows */
47 + __u32 avge_delay_us [TC_CAKE_MAX_TINS];
48 + __u32 base_delay_us [TC_CAKE_MAX_TINS]; /* ~= delay to sparse flows */
49 + __u16 sparse_flows [TC_CAKE_MAX_TINS];
50 + __u16 bulk_flows [TC_CAKE_MAX_TINS];
51 + __u32 last_skblen [TC_CAKE_MAX_TINS]; /* skb_headlen */
52 + __u32 max_skblen [TC_CAKE_MAX_TINS];
53 + __u32 capacity_estimate; /* version 2 */
54 + __u32 memory_limit; /* version 3 */
55 + __u32 memory_used; /* version 3 */
56 +};
57 +
58 #endif
59 --- a/tc/Makefile
60 +++ b/tc/Makefile
61 @@ -64,6 +64,7 @@ TCMODULES += q_codel.o
62 TCMODULES += q_fq_codel.o
63 TCMODULES += q_fq.o
64 TCMODULES += q_pie.o
65 +TCMODULES += q_cake.o
66 TCMODULES += q_hhf.o
67 TCMODULES += e_bpf.o
68
69 --- /dev/null
70 +++ b/tc/q_cake.c
71 @@ -0,0 +1,598 @@
72 +/*
73 + * Common Applications Kept Enhanced -- CAKE
74 + *
75 + * Copyright (C) 2014-2015 Jonathan Morton <chromatix99@gmail.com>
76 + *
77 + * Redistribution and use in source and binary forms, with or without
78 + * modification, are permitted provided that the following conditions
79 + * are met:
80 + * 1. Redistributions of source code must retain the above copyright
81 + * notice, this list of conditions, and the following disclaimer,
82 + * without modification.
83 + * 2. Redistributions in binary form must reproduce the above copyright
84 + * notice, this list of conditions and the following disclaimer in the
85 + * documentation and/or other materials provided with the distribution.
86 + * 3. The names of the authors may not be used to endorse or promote products
87 + * derived from this software without specific prior written permission.
88 + *
89 + * Alternatively, provided that this notice is retained in full, this
90 + * software may be distributed under the terms of the GNU General
91 + * Public License ("GPL") version 2, in which case the provisions of the
92 + * GPL apply INSTEAD OF those given above.
93 + *
94 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
95 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
96 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
97 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
98 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
99 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
100 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
101 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
102 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
103 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
104 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
105 + * DAMAGE.
106 + *
107 + */
108 +
109 +#include <stddef.h>
110 +#include <stdio.h>
111 +#include <stdlib.h>
112 +#include <unistd.h>
113 +#include <syslog.h>
114 +#include <fcntl.h>
115 +#include <sys/socket.h>
116 +#include <netinet/in.h>
117 +#include <arpa/inet.h>
118 +#include <string.h>
119 +
120 +#include "utils.h"
121 +#include "tc_util.h"
122 +
123 +static void explain(void)
124 +{
125 + fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
126 + " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n"
127 + " [ besteffort | precedence | diffserv8 | diffserv4* ]\n"
128 + " [ flowblind | srchost | dsthost | hosts | flows* | dual-srchost | dual-dsthost | triple-isolate ]\n"
129 + " [ atm | noatm* ] [ overhead N | conservative | raw* ]\n"
130 + " [ memlimit LIMIT ]\n"
131 + " (* marks defaults)\n");
132 +}
133 +
134 +static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
135 + struct nlmsghdr *n)
136 +{
137 + int unlimited = 0;
138 + unsigned bandwidth = 0;
139 + unsigned interval = 0;
140 + unsigned target = 0;
141 + unsigned diffserv = 0;
142 + unsigned memlimit = 0;
143 + int overhead = 0;
144 + bool overhead_set = false;
145 + int flowmode = -1;
146 + int atm = -1;
147 + int autorate = -1;
148 + struct rtattr *tail;
149 +
150 + while (argc > 0) {
151 + if (strcmp(*argv, "bandwidth") == 0) {
152 + NEXT_ARG();
153 + if (get_rate(&bandwidth, *argv)) {
154 + fprintf(stderr, "Illegal \"bandwidth\"\n");
155 + return -1;
156 + }
157 + unlimited = 0;
158 + autorate = 0;
159 + } else if (strcmp(*argv, "unlimited") == 0) {
160 + bandwidth = 0;
161 + unlimited = 1;
162 + autorate = 0;
163 + } else if (strcmp(*argv, "autorate_ingress") == 0) {
164 + autorate = 1;
165 +
166 + } else if (strcmp(*argv, "rtt") == 0) {
167 + NEXT_ARG();
168 + if (get_time(&interval, *argv)) {
169 + fprintf(stderr, "Illegal \"rtt\"\n");
170 + return -1;
171 + }
172 + target = interval / 20;
173 + if(!target)
174 + target = 1;
175 + } else if (strcmp(*argv, "datacentre") == 0) {
176 + interval = 100;
177 + target = 5;
178 + } else if (strcmp(*argv, "lan") == 0) {
179 + interval = 1000;
180 + target = 50;
181 + } else if (strcmp(*argv, "metro") == 0) {
182 + interval = 10000;
183 + target = 500;
184 + } else if (strcmp(*argv, "regional") == 0) {
185 + interval = 30000;
186 + target = 1500;
187 + } else if (strcmp(*argv, "internet") == 0) {
188 + interval = 100000;
189 + target = 5000;
190 + } else if (strcmp(*argv, "oceanic") == 0) {
191 + interval = 300000;
192 + target = 15000;
193 + } else if (strcmp(*argv, "satellite") == 0) {
194 + interval = 1000000;
195 + target = 50000;
196 + } else if (strcmp(*argv, "interplanetary") == 0) {
197 + interval = 3600000000U;
198 + target = 5000;
199 +
200 + } else if (strcmp(*argv, "besteffort") == 0) {
201 + diffserv = 1;
202 + } else if (strcmp(*argv, "precedence") == 0) {
203 + diffserv = 2;
204 + } else if (strcmp(*argv, "diffserv8") == 0) {
205 + diffserv = 3;
206 + } else if (strcmp(*argv, "diffserv4") == 0) {
207 + diffserv = 4;
208 + } else if (strcmp(*argv, "diffserv") == 0) {
209 + diffserv = 4;
210 + } else if (strcmp(*argv, "diffserv-llt") == 0) {
211 + diffserv = 5;
212 +
213 + } else if (strcmp(*argv, "flowblind") == 0) {
214 + flowmode = 0;
215 + } else if (strcmp(*argv, "srchost") == 0) {
216 + flowmode = 1;
217 + } else if (strcmp(*argv, "dsthost") == 0) {
218 + flowmode = 2;
219 + } else if (strcmp(*argv, "hosts") == 0) {
220 + flowmode = 3;
221 + } else if (strcmp(*argv, "flows") == 0) {
222 + flowmode = 4;
223 + } else if (strcmp(*argv, "dual-srchost") == 0) {
224 + flowmode = 5;
225 + } else if (strcmp(*argv, "dual-dsthost") == 0) {
226 + flowmode = 6;
227 + } else if (strcmp(*argv, "triple-isolate") == 0) {
228 + flowmode = 7;
229 +
230 + } else if (strcmp(*argv, "atm") == 0) {
231 + atm = 1;
232 + } else if (strcmp(*argv, "noatm") == 0) {
233 + atm = 0;
234 +
235 + } else if (strcmp(*argv, "raw") == 0) {
236 + atm = 0;
237 + overhead = 0;
238 + overhead_set = true;
239 + } else if (strcmp(*argv, "conservative") == 0) {
240 + /*
241 + * Deliberately over-estimate overhead:
242 + * one whole ATM cell plus ATM framing.
243 + * A safe choice if the actual overhead is unknown.
244 + */
245 + atm = 1;
246 + overhead = 48;
247 + overhead_set = true;
248 +
249 + /* Various ADSL framing schemes */
250 + } else if (strcmp(*argv, "ipoa-vcmux") == 0) {
251 + atm = 1;
252 + overhead += 8;
253 + overhead_set = true;
254 + } else if (strcmp(*argv, "ipoa-llcsnap") == 0) {
255 + atm = 1;
256 + overhead += 16;
257 + overhead_set = true;
258 + } else if (strcmp(*argv, "bridged-vcmux") == 0) {
259 + atm = 1;
260 + overhead += 24;
261 + overhead_set = true;
262 + } else if (strcmp(*argv, "bridged-llcsnap") == 0) {
263 + atm = 1;
264 + overhead += 32;
265 + overhead_set = true;
266 + } else if (strcmp(*argv, "pppoa-vcmux") == 0) {
267 + atm = 1;
268 + overhead += 10;
269 + overhead_set = true;
270 + } else if (strcmp(*argv, "pppoa-llc") == 0) {
271 + atm = 1;
272 + overhead += 14;
273 + overhead_set = true;
274 + } else if (strcmp(*argv, "pppoe-vcmux") == 0) {
275 + atm = 1;
276 + overhead += 32;
277 + overhead_set = true;
278 + } else if (strcmp(*argv, "pppoe-llcsnap") == 0) {
279 + atm = 1;
280 + overhead += 40;
281 + overhead_set = true;
282 +
283 + /* Typical VDSL2 framing schemes */
284 + /* NB: PTM includes HDLC's 0x7D/7E expansion, adds extra 1/128 */
285 + } else if (strcmp(*argv, "pppoe-ptm") == 0) {
286 + atm = 0;
287 + overhead += 27;
288 + } else if (strcmp(*argv, "bridged-ptm") == 0) {
289 + atm = 0;
290 + overhead += 19;
291 +
292 + } else if (strcmp(*argv, "via-ethernet") == 0) {
293 + /*
294 + * The above overheads are relative to an IP packet,
295 + * but if the physical interface is Ethernet, Linux
296 + * includes Ethernet framing overhead already.
297 + */
298 + overhead -= 14;
299 + overhead_set = true;
300 +
301 + /* Additional Ethernet-related overheads used by some ISPs */
302 + } else if (strcmp(*argv, "ether-phy") == 0) {
303 + /* ethernet pre-amble & interframe gap 20 bytes
304 + * Linux will have already accounted for MACs & frame type 14 bytes
305 + * you probably want to add an FCS as well*/
306 + overhead += 20;
307 + overhead_set = true;
308 + } else if (strcmp(*argv, "ether-all") == 0) {
309 + /* ethernet pre-amble & interframe gap & FCS
310 + * Linux will have already accounted for MACs & frame type 14 bytes
311 + * you may need to add vlan tag*/
312 + overhead += 24;
313 + overhead_set = true;
314 +
315 + } else if (strcmp(*argv, "ether-fcs") == 0) {
316 + /* Frame Check Sequence */
317 + /* we ignore the minimum frame size, because IP packets usually meet it */
318 + overhead += 4;
319 + overhead_set = true;
320 + } else if (strcmp(*argv, "ether-vlan") == 0) {
321 + /* 802.1q VLAN tag - may be repeated */
322 + overhead += 4;
323 + overhead_set = true;
324 +
325 + } else if (strcmp(*argv, "overhead") == 0) {
326 + char* p = NULL;
327 + NEXT_ARG();
328 + overhead = strtol(*argv, &p, 10);
329 + if(!p || *p || !*argv || overhead < -64 || overhead > 256) {
330 + fprintf(stderr, "Illegal \"overhead\", valid range is -64 to 256\\n");
331 + return -1;
332 + }
333 + overhead_set = true;
334 +
335 + } else if (strcmp(*argv, "memlimit") == 0) {
336 + NEXT_ARG();
337 + if(get_size(&memlimit, *argv)) {
338 + fprintf(stderr, "Illegal value for \"memlimit\": \"%s\"\n", *argv);
339 + return -1;
340 + }
341 +
342 + } else if (strcmp(*argv, "help") == 0) {
343 + explain();
344 + return -1;
345 + } else {
346 + fprintf(stderr, "What is \"%s\"?\n", *argv);
347 + explain();
348 + return -1;
349 + }
350 + argc--; argv++;
351 + }
352 +
353 + tail = NLMSG_TAIL(n);
354 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
355 + if (bandwidth || unlimited)
356 + addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth));
357 + if (diffserv)
358 + addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
359 + if (atm != -1)
360 + addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
361 + if (flowmode != -1)
362 + addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
363 + if (overhead_set)
364 + addattr_l(n, 1024, TCA_CAKE_OVERHEAD, &overhead, sizeof(overhead));
365 + if (interval)
366 + addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
367 + if (target)
368 + addattr_l(n, 1024, TCA_CAKE_TARGET, &target, sizeof(target));
369 + if (autorate != -1)
370 + addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate));
371 + if (memlimit)
372 + addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit));
373 +
374 + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
375 + return 0;
376 +}
377 +
378 +
379 +static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
380 +{
381 + struct rtattr *tb[TCA_CAKE_MAX + 1];
382 + unsigned bandwidth = 0;
383 + unsigned diffserv = 0;
384 + unsigned flowmode = 0;
385 + unsigned interval = 0;
386 + unsigned memlimit = 0;
387 + int overhead = 0;
388 + int atm = 0;
389 + int autorate = 0;
390 + SPRINT_BUF(b1);
391 + SPRINT_BUF(b2);
392 +
393 + if (opt == NULL)
394 + return 0;
395 +
396 + parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
397 +
398 + if (tb[TCA_CAKE_BASE_RATE] &&
399 + RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) {
400 + bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]);
401 + if(bandwidth)
402 + fprintf(f, "bandwidth %s ", sprint_rate(bandwidth, b1));
403 + else
404 + fprintf(f, "unlimited ");
405 + }
406 + if (tb[TCA_CAKE_AUTORATE] &&
407 + RTA_PAYLOAD(tb[TCA_CAKE_AUTORATE]) >= sizeof(__u32)) {
408 + autorate = rta_getattr_u32(tb[TCA_CAKE_AUTORATE]);
409 + if(autorate == 1)
410 + fprintf(f, "autorate_ingress ");
411 + else if(autorate)
412 + fprintf(f, "(?autorate?) ");
413 + }
414 + if (tb[TCA_CAKE_DIFFSERV_MODE] &&
415 + RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
416 + diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
417 + switch(diffserv) {
418 + case 1:
419 + fprintf(f, "besteffort ");
420 + break;
421 + case 2:
422 + fprintf(f, "precedence ");
423 + break;
424 + case 3:
425 + fprintf(f, "diffserv8 ");
426 + break;
427 + case 4:
428 + fprintf(f, "diffserv4 ");
429 + break;
430 + case 5:
431 + fprintf(f, "diffserv-llt ");
432 + break;
433 + default:
434 + fprintf(f, "(?diffserv?) ");
435 + break;
436 + };
437 + }
438 + if (tb[TCA_CAKE_FLOW_MODE] &&
439 + RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
440 + flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
441 + switch(flowmode) {
442 + case 0:
443 + fprintf(f, "flowblind ");
444 + break;
445 + case 1:
446 + fprintf(f, "srchost ");
447 + break;
448 + case 2:
449 + fprintf(f, "dsthost ");
450 + break;
451 + case 3:
452 + fprintf(f, "hosts ");
453 + break;
454 + case 4:
455 + fprintf(f, "flows ");
456 + break;
457 + case 5:
458 + fprintf(f, "dual-srchost ");
459 + break;
460 + case 6:
461 + fprintf(f, "dual-dsthost ");
462 + break;
463 + case 7:
464 + fprintf(f, "triple-isolate ");
465 + break;
466 + default:
467 + fprintf(f, "(?flowmode?) ");
468 + break;
469 + };
470 + }
471 + if (tb[TCA_CAKE_ATM] &&
472 + RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
473 + atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
474 + }
475 + if (tb[TCA_CAKE_OVERHEAD] &&
476 + RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) {
477 + overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]);
478 + }
479 + if (tb[TCA_CAKE_RTT] &&
480 + RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) {
481 + interval = rta_getattr_u32(tb[TCA_CAKE_RTT]);
482 + }
483 +
484 + if (interval)
485 + fprintf(f, "rtt %s ", sprint_time(interval, b2));
486 +
487 + if (atm)
488 + fprintf(f, "atm ");
489 + else if (overhead)
490 + fprintf(f, "noatm ");
491 +
492 + if (overhead || atm)
493 + fprintf(f, "overhead %d ", overhead);
494 +
495 + if (!atm && !overhead)
496 + fprintf(f, "raw ");
497 +
498 + if (memlimit)
499 + fprintf(f, "memlimit %s", sprint_size(memlimit, b1));
500 +
501 + return 0;
502 +}
503 +
504 +static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
505 + struct rtattr *xstats)
506 +{
507 + /* fq_codel stats format borrowed */
508 + struct tc_fq_codel_xstats *st;
509 + struct tc_cake_xstats *stnc;
510 + SPRINT_BUF(b1);
511 + SPRINT_BUF(b2);
512 +
513 + if (xstats == NULL)
514 + return 0;
515 +
516 + if (RTA_PAYLOAD(xstats) < sizeof(st->type))
517 + return -1;
518 +
519 + st = RTA_DATA(xstats);
520 + stnc = RTA_DATA(xstats);
521 +
522 + if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
523 + fprintf(f, " maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
524 + st->qdisc_stats.maxpacket,
525 + st->qdisc_stats.drop_overlimit,
526 + st->qdisc_stats.new_flow_count,
527 + st->qdisc_stats.ecn_mark);
528 + fprintf(f, "\n new_flows_len %u old_flows_len %u",
529 + st->qdisc_stats.new_flows_len,
530 + st->qdisc_stats.old_flows_len);
531 + } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
532 + fprintf(f, " deficit %d count %u lastcount %u ldelay %s",
533 + st->class_stats.deficit,
534 + st->class_stats.count,
535 + st->class_stats.lastcount,
536 + sprint_time(st->class_stats.ldelay, b1));
537 + if (st->class_stats.dropping) {
538 + fprintf(f, " dropping");
539 + if (st->class_stats.drop_next < 0)
540 + fprintf(f, " drop_next -%s",
541 + sprint_time(-st->class_stats.drop_next, b1));
542 + else
543 + fprintf(f, " drop_next %s",
544 + sprint_time(st->class_stats.drop_next, b1));
545 + }
546 + } else if (stnc->version >= 1 && stnc->version < 0xFF
547 + && stnc->max_tins == TC_CAKE_MAX_TINS
548 + && RTA_PAYLOAD(xstats) >= offsetof(struct tc_cake_xstats, capacity_estimate))
549 + {
550 + int i;
551 +
552 + if(stnc->version >= 3)
553 + fprintf(f, " memory used: %s of %s\n", sprint_size(stnc->memory_used, b1), sprint_size(stnc->memory_limit, b2));
554 +
555 + if(stnc->version >= 2)
556 + fprintf(f, " capacity estimate: %s\n", sprint_rate(stnc->capacity_estimate, b1));
557 +
558 + switch(stnc->tin_cnt) {
559 + case 4:
560 + fprintf(f, " Bulk Best Effort Video Voice\n");
561 + break;
562 +
563 + case 5:
564 + fprintf(f, " Low Loss Best Effort Low Delay Bulk Net Control\n");
565 + break;
566 +
567 + default:
568 + fprintf(f, " ");
569 + for(i=0; i < stnc->tin_cnt; i++)
570 + fprintf(f, " Tin %u", i);
571 + fprintf(f, "\n");
572 + };
573 +
574 + fprintf(f, " thresh ");
575 + for(i=0; i < stnc->tin_cnt; i++)
576 + fprintf(f, "%12s", sprint_rate(stnc->threshold_rate[i], b1));
577 + fprintf(f, "\n");
578 +
579 + fprintf(f, " target ");
580 + for(i=0; i < stnc->tin_cnt; i++)
581 + fprintf(f, "%12s", sprint_time(stnc->target_us[i], b1));
582 + fprintf(f, "\n");
583 +
584 + fprintf(f, " interval");
585 + for(i=0; i < stnc->tin_cnt; i++)
586 + fprintf(f, "%12s", sprint_time(stnc->interval_us[i], b1));
587 + fprintf(f, "\n");
588 +
589 + fprintf(f, " pk_delay");
590 + for(i=0; i < stnc->tin_cnt; i++)
591 + fprintf(f, "%12s", sprint_time(stnc->peak_delay_us[i], b1));
592 + fprintf(f, "\n");
593 +
594 + fprintf(f, " av_delay");
595 + for(i=0; i < stnc->tin_cnt; i++)
596 + fprintf(f, "%12s", sprint_time(stnc->avge_delay_us[i], b1));
597 + fprintf(f, "\n");
598 +
599 + fprintf(f, " sp_delay");
600 + for(i=0; i < stnc->tin_cnt; i++)
601 + fprintf(f, "%12s", sprint_time(stnc->base_delay_us[i], b1));
602 + fprintf(f, "\n");
603 +
604 + fprintf(f, " pkts ");
605 + for(i=0; i < stnc->tin_cnt; i++)
606 + fprintf(f, "%12u", stnc->sent[i].packets);
607 + fprintf(f, "\n");
608 +
609 + fprintf(f, " bytes ");
610 + for(i=0; i < stnc->tin_cnt; i++)
611 + fprintf(f, "%12llu", stnc->sent[i].bytes);
612 + fprintf(f, "\n");
613 +
614 + fprintf(f, " way_inds");
615 + for(i=0; i < stnc->tin_cnt; i++)
616 + fprintf(f, "%12u", stnc->way_indirect_hits[i]);
617 + fprintf(f, "\n");
618 +
619 + fprintf(f, " way_miss");
620 + for(i=0; i < stnc->tin_cnt; i++)
621 + fprintf(f, "%12u", stnc->way_misses[i]);
622 + fprintf(f, "\n");
623 +
624 + fprintf(f, " way_cols");
625 + for(i=0; i < stnc->tin_cnt; i++)
626 + fprintf(f, "%12u", stnc->way_collisions[i]);
627 + fprintf(f, "\n");
628 +
629 + fprintf(f, " drops ");
630 + for(i=0; i < stnc->tin_cnt; i++)
631 + fprintf(f, "%12u", stnc->dropped[i].packets);
632 + fprintf(f, "\n");
633 +
634 + fprintf(f, " marks ");
635 + for(i=0; i < stnc->tin_cnt; i++)
636 + fprintf(f, "%12u", stnc->ecn_marked[i].packets);
637 + fprintf(f, "\n");
638 +
639 + fprintf(f, " sp_flows");
640 + for(i=0; i < stnc->tin_cnt; i++)
641 + fprintf(f, "%12u", stnc->sparse_flows[i]);
642 + fprintf(f, "\n");
643 +
644 + fprintf(f, " bk_flows");
645 + for(i=0; i < stnc->tin_cnt; i++)
646 + fprintf(f, "%12u", stnc->bulk_flows[i]);
647 + fprintf(f, "\n");
648 +
649 + fprintf(f, " last_len");
650 + for(i=0; i < stnc->tin_cnt; i++)
651 + fprintf(f, "%12u", stnc->last_skblen[i]);
652 + fprintf(f, "\n");
653 +
654 + fprintf(f, " max_len ");
655 + for(i=0; i < stnc->tin_cnt; i++)
656 + fprintf(f, "%12u", stnc->max_skblen[i]);
657 + fprintf(f, "\n");
658 + } else {
659 + return -1;
660 + }
661 + return 0;
662 +}
663 +
664 +struct qdisc_util cake_qdisc_util = {
665 + .id = "cake",
666 + .parse_qopt = cake_parse_opt,
667 + .print_qopt = cake_print_opt,
668 + .print_xstats = cake_print_xstats,
669 +};