c8f70da13249ed2f3c7214b0a60efe47bf7e8634
[openwrt/staging/lynxis.git] / package / network / utils / iproute2 / patches / 950-add-cake-to-tc.patch
1 --- a/include/uapi/linux/pkt_sched.h
2 +++ b/include/uapi/linux/pkt_sched.h
3 @@ -934,4 +934,75 @@ enum {
4
5 #define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
6
7 +/* CAKE */
8 +enum {
9 + TCA_CAKE_UNSPEC,
10 + TCA_CAKE_BASE_RATE,
11 + TCA_CAKE_DIFFSERV_MODE,
12 + TCA_CAKE_ATM,
13 + TCA_CAKE_FLOW_MODE,
14 + TCA_CAKE_OVERHEAD,
15 + TCA_CAKE_RTT,
16 + TCA_CAKE_TARGET,
17 + TCA_CAKE_AUTORATE,
18 + TCA_CAKE_MEMORY,
19 + TCA_CAKE_NAT,
20 + TCA_CAKE_RAW, // was _ETHERNET
21 + TCA_CAKE_WASH,
22 + TCA_CAKE_MPU,
23 + TCA_CAKE_INGRESS,
24 + TCA_CAKE_ACK_FILTER,
25 + __TCA_CAKE_MAX
26 +};
27 +#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
28 +
29 +struct tc_cake_traffic_stats {
30 + __u32 packets;
31 + __u32 link_ms;
32 + __u64 bytes;
33 +};
34 +
35 +#define TC_CAKE_MAX_TINS (8)
36 +struct tc_cake_tin_stats {
37 +
38 + __u32 threshold_rate;
39 + __u32 target_us;
40 + struct tc_cake_traffic_stats sent;
41 + struct tc_cake_traffic_stats dropped;
42 + struct tc_cake_traffic_stats ecn_marked;
43 + struct tc_cake_traffic_stats backlog;
44 + __u32 interval_us;
45 + __u32 way_indirect_hits;
46 + __u32 way_misses;
47 + __u32 way_collisions;
48 + __u32 peak_delay_us; /* ~= bulk flow delay */
49 + __u32 avge_delay_us;
50 + __u32 base_delay_us; /* ~= sparse flows delay */
51 + __u16 sparse_flows;
52 + __u16 bulk_flows;
53 + __u16 unresponse_flows;
54 + __u16 spare;
55 + __u32 max_skblen;
56 + struct tc_cake_traffic_stats ack_drops;
57 +};
58 +
59 +struct tc_cake_xstats {
60 + __u16 version;
61 + __u16 tin_stats_size; /* == sizeof(struct tc_cake_tin_stats) */
62 + __u32 capacity_estimate;
63 + __u32 memory_limit;
64 + __u32 memory_used;
65 + __u8 tin_cnt;
66 + __u8 avg_trnoff;
67 + __u16 max_trnlen;
68 + __u16 max_adjlen;
69 + __u16 min_trnlen;
70 + __u16 min_adjlen;
71 +
72 + __u16 spare1;
73 + __u32 spare2;
74 +
75 + struct tc_cake_tin_stats tin_stats[0]; /* keep last */
76 +};
77 +
78 #endif
79 --- /dev/null
80 +++ b/man/man8/tc-cake.8
81 @@ -0,0 +1,678 @@
82 +.TH CAKE 8 "23 November 2017" "iproute2" "Linux"
83 +.SH NAME
84 +CAKE \- COMMON Applications Kept Enhanced (CAKE)
85 +.SH SYNOPSIS
86 +.B tc qdisc ... cake
87 +.br
88 +[
89 +.BR bandwidth
90 +RATE |
91 +.BR unlimited*
92 +|
93 +.BR autorate_ingress
94 +]
95 +.br
96 +[
97 +.BR rtt
98 +TIME |
99 +.BR datacentre
100 +|
101 +.BR lan
102 +|
103 +.BR metro
104 +|
105 +.BR regional
106 +|
107 +.BR internet*
108 +|
109 +.BR oceanic
110 +|
111 +.BR satellite
112 +|
113 +.BR interplanetary
114 +]
115 +.br
116 +[
117 +.BR besteffort
118 +|
119 +.BR diffserv8
120 +|
121 +.BR diffserv4
122 +|
123 +.BR diffserv-llt
124 +|
125 +.BR diffserv3*
126 +]
127 +.br
128 +[
129 +.BR flowblind
130 +|
131 +.BR srchost
132 +|
133 +.BR dsthost
134 +|
135 +.BR hosts
136 +|
137 +.BR flows
138 +|
139 +.BR dual-srchost
140 +|
141 +.BR dual-dsthost
142 +|
143 +.BR triple-isolate*
144 +]
145 +.br
146 +[
147 +.BR nat
148 +|
149 +.BR nonat*
150 +]
151 +.br
152 +[
153 +.BR wash
154 +|
155 +.BR nowash*
156 +]
157 +.br
158 +[
159 +.BR ack-filter
160 +|
161 +.BR ack-filter-aggressive
162 +|
163 +.BR no-ack-filter*
164 +]
165 +.br
166 +[
167 +.BR memlimit
168 +LIMIT ]
169 +.br
170 +[
171 +.BR ptm
172 +|
173 +.BR atm
174 +|
175 +.BR noatm*
176 +]
177 +.br
178 +[
179 +.BR overhead
180 +N |
181 +.BR conservative
182 +|
183 +.BR raw*
184 +]
185 +.br
186 +[
187 +.BR mpu
188 +N ]
189 +.br
190 +[
191 +.BR ingress
192 +|
193 +.BR egress*
194 +]
195 +.br
196 +(* marks defaults)
197 +
198 +
199 +.SH DESCRIPTION
200 +CAKE (Common Applications Kept Enhanced) is a shaping-capable queue discipline
201 +which uses both AQM and FQ. It combines COBALT, which is an AQM algorithm
202 +combining Codel and BLUE, a shaper which operates in deficit mode, and a variant
203 +of DRR++ for flow isolation. 8-way set-associative hashing is used to virtually
204 +eliminate hash collisions. Priority queuing is available through a simplified
205 +diffserv implementation. Overhead compensation for various encapsulation
206 +schemes is tightly integrated.
207 +
208 +All settings are optional; the default settings are chosen to be sensible in
209 +most common deployments. Most people will only need to set the
210 +.B bandwidth
211 +parameter to get useful results, but reading the
212 +.B Overhead Compensation
213 +and
214 +.B Round Trip Time
215 +sections is strongly encouraged.
216 +
217 +.SH SHAPER PARAMETERS
218 +CAKE uses a deficit-mode shaper, which does not exhibit the initial burst
219 +typical of token-bucket shapers. It will automatically burst precisely as much
220 +as required to maintain the configured throughput. As such, it is very
221 +straightforward to configure.
222 +.PP
223 +.B unlimited
224 +(default)
225 +.br
226 + No limit on the bandwidth.
227 +.PP
228 +.B bandwidth
229 +RATE
230 +.br
231 + Set the shaper bandwidth. See
232 +.BR tc(8)
233 +or examples below for details of the RATE value.
234 +.PP
235 +.B autorate_ingress
236 +.br
237 + Automatic capacity estimation based on traffic arriving at this qdisc.
238 +This is most likely to be useful with cellular links, which tend to change
239 +quality randomly. A
240 +.B bandwidth
241 +parameter can be used in conjunction to specify an initial estimate. The shaper
242 +will periodically be set to a bandwidth slightly below the estimated rate. This
243 +estimator cannot estimate the bandwidth of links downstream of itself.
244 +
245 +.SH OVERHEAD COMPENSATION PARAMETERS
246 +The size of each packet on the wire may differ from that seen by Linux. The
247 +following parameters allow CAKE to compensate for this difference by internally
248 +considering each packet to be bigger than Linux informs it. To assist users who
249 +are not expert network engineers, keywords have been provided to represent a
250 +number of common link technologies.
251 +
252 +.SS Manual Overhead Specification
253 +.B overhead
254 +BYTES
255 +.br
256 + Adds BYTES to the size of each packet. BYTES may be negative; values
257 +between -64 and 256 (inclusive) are accepted.
258 +.PP
259 +.B mpu
260 +BYTES
261 +.br
262 + Rounds each packet (including overhead) up to a minimum length
263 +BYTES. BYTES may not be negative; values between 0 and 256 (inclusive)
264 +are accepted.
265 +.PP
266 +.B atm
267 +.br
268 + Compensates for ATM cell framing, which is normally found on ADSL links.
269 +This is performed after the
270 +.B overhead
271 +parameter above. ATM uses fixed 53-byte cells, each of which can carry 48 bytes
272 +payload.
273 +.PP
274 +.B ptm
275 +.br
276 + Compensates for PTM encoding, which is normally found on VDSL2 links and
277 +uses a 64b/65b encoding scheme. It is even more efficient to simply
278 +derate the specified shaper bandwidth by a factor of 64/65 or 0.984. See
279 +ITU G.992.3 Annex N and IEEE 802.3 Section 61.3 for details.
280 +.PP
281 +.B noatm
282 +.br
283 + Disables ATM and PTM compensation.
284 +
285 +.SS Failsafe Overhead Keywords
286 +These two keywords are provided for quick-and-dirty setup. Use them if you
287 +can't be bothered to read the rest of this section.
288 +.PP
289 +.B raw
290 +(default)
291 +.br
292 + Turns off all overhead compensation in CAKE. The packet size reported
293 +by Linux will be used directly.
294 +.PP
295 + Other overhead keywords may be added after "raw". The effect of this is
296 +to make the overhead compensation operate relative to the reported packet size,
297 +not the underlying IP packet size.
298 +.PP
299 +.B conservative
300 +.br
301 + Compensates for more overhead than is likely to occur on any
302 +widely-deployed link technology.
303 +.br
304 + Equivalent to
305 +.B overhead 48 atm.
306 +
307 +.SS ADSL Overhead Keywords
308 +Most ADSL modems have a way to check which framing scheme is in use. Often this
309 +is also specified in the settings document provided by the ISP. The keywords in
310 +this section are intended to correspond with these sources of information. All
311 +of them implicitly set the
312 +.B atm
313 +flag.
314 +.PP
315 +.B pppoa-vcmux
316 +.br
317 + Equivalent to
318 +.B overhead 10 atm
319 +.PP
320 +.B pppoa-llc
321 +.br
322 + Equivalent to
323 +.B overhead 14 atm
324 +.PP
325 +.B pppoe-vcmux
326 +.br
327 + Equivalent to
328 +.B overhead 32 atm
329 +.PP
330 +.B pppoe-llcsnap
331 +.br
332 + Equivalent to
333 +.B overhead 40 atm
334 +.PP
335 +.B bridged-vcmux
336 +.br
337 + Equivalent to
338 +.B overhead 24 atm
339 +.PP
340 +.B bridged-llcsnap
341 +.br
342 + Equivalent to
343 +.B overhead 32 atm
344 +.PP
345 +.B ipoa-vcmux
346 +.br
347 + Equivalent to
348 +.B overhead 8 atm
349 +.PP
350 +.B ipoa-llcsnap
351 +.br
352 + Equivalent to
353 +.B overhead 16 atm
354 +.PP
355 +See also the Ethernet Correction Factors section below.
356 +
357 +.SS VDSL2 Overhead Keywords
358 +ATM was dropped from VDSL2 in favour of PTM, which is a much more
359 +straightforward framing scheme. Some ISPs retained PPPoE for compatibility with
360 +their existing back-end systems.
361 +.PP
362 +.B pppoe-ptm
363 +.br
364 + Equivalent to
365 +.B overhead 30 ptm
366 +
367 +.br
368 + PPPoE: 2B PPP + 6B PPPoE +
369 +.br
370 + ETHERNET: 6B dest MAC + 6B src MAC + 2B ethertype + 4B Frame Check Sequence +
371 +.br
372 + PTM: 1B Start of Frame (S) + 1B End of Frame (Ck) + 2B TC-CRC (PTM-FCS)
373 +.br
374 +.PP
375 +.B bridged-ptm
376 +.br
377 + Equivalent to
378 +.B overhead 22 ptm
379 +.br
380 + ETHERNET: 6B dest MAC + 6B src MAC + 2B ethertype + 4B Frame Check Sequence +
381 +.br
382 + PTM: 1B Start of Frame (S) + 1B End of Frame (Ck) + 2B TC-CRC (PTM-FCS)
383 +.br
384 +.PP
385 +See also the Ethernet Correction Factors section below.
386 +
387 +.SS DOCSIS Cable Overhead Keyword
388 +DOCSIS is the universal standard for providing Internet service over cable-TV
389 +infrastructure.
390 +
391 +In this case, the actual on-wire overhead is less important than the packet size
392 +the head-end equipment uses for shaping and metering. This is specified to be
393 +an Ethernet frame including the CRC (aka FCS).
394 +.PP
395 +.B docsis
396 +.br
397 + Equivalent to
398 +.B overhead 18 mpu 64 noatm
399 +
400 +.SS Ethernet Overhead Keywords
401 +.PP
402 +.B ethernet
403 +.br
404 + Accounts for Ethernet's preamble, inter-frame gap, and Frame Check
405 +Sequence. Use this keyword when the bottleneck being shaped for is an
406 +actual Ethernet cable.
407 +.br
408 + Equivalent to
409 +.B overhead 38 mpu 84 noatm
410 +.PP
411 +.B ether-vlan
412 +.br
413 + Adds 4 bytes to the overhead compensation, accounting for an IEEE 802.1Q
414 +VLAN header appended to the Ethernet frame header. NB: Some ISPs use one or
415 +even two of these within PPPoE; this keyword may be repeated as necessary to
416 +express this.
417 +
418 +.SH ROUND TRIP TIME PARAMETERS
419 +Active Queue Management (AQM) consists of embedding congestion signals in the
420 +packet flow, which receivers use to instruct senders to slow down when the queue
421 +is persistently occupied. CAKE uses ECN signalling when available, and packet
422 +drops otherwise, according to a combination of the Codel and BLUE AQM algorithms
423 +called COBALT.
424 +
425 +Very short latencies require a very rapid AQM response to adequately control
426 +latency. However, such a rapid response tends to impair throughput when the
427 +actual RTT is relatively long. CAKE allows specifying the RTT it assumes for
428 +tuning various parameters. Actual RTTs within an order of magnitude of this
429 +will generally work well for both throughput and latency management.
430 +
431 +At the 'lan' setting and below, the time constants are similar in magnitude to
432 +the jitter in the Linux kernel itself, so congestion might be signalled
433 +prematurely. The flows will then become sparse and total throughput reduced,
434 +leaving little or no back-pressure for the fairness logic to work against. Use
435 +the "metro" setting for local lans unless you have a custom kernel.
436 +.PP
437 +.B rtt
438 +TIME
439 +.br
440 + Manually specify an RTT.
441 +.PP
442 +.B datacentre
443 +.br
444 + For extremely high-performance 10GigE+ networks only. Equivalent to
445 +.B rtt 100us.
446 +.PP
447 +.B lan
448 +.br
449 + For pure Ethernet (not Wi-Fi) networks, at home or in the office. Don't
450 +use this when shaping for an Internet access link. Equivalent to
451 +.B rtt 1ms.
452 +.PP
453 +.B metro
454 +.br
455 + For traffic mostly within a single city. Equivalent to
456 +.B rtt 10ms.
457 +.PP
458 +.B regional
459 +.br
460 + For traffic mostly within a European-sized country. Equivalent to
461 +.B rtt 30ms.
462 +.PP
463 +.B internet
464 +(default)
465 +.br
466 + This is suitable for most Internet traffic. Equivalent to
467 +.B rtt 100ms.
468 +.PP
469 +.B oceanic
470 +.br
471 + For Internet traffic with generally above-average latency, such as that
472 +suffered by Australasian residents. Equivalent to
473 +.B rtt 300ms.
474 +.PP
475 +.B satellite
476 +.br
477 + For traffic via geostationary satellites. Equivalent to
478 +.B rtt 1000ms.
479 +.PP
480 +.B interplanetary
481 +.br
482 + So named because Jupiter is about 1 light-hour from Earth. Use this to
483 +(almost) completely disable AQM actions. Equivalent to
484 +.B rtt 1000s.
485 +
486 +.SH FLOW ISOLATION PARAMETERS
487 +With flow isolation enabled, CAKE places packets from different flows into
488 +different queues, each of which carries its own AQM state. Packets from each
489 +queue are then delivered fairly, according to a DRR++ algorithm which minimises
490 +latency for "sparse" flows. CAKE uses a set-associative hashing algorithm to
491 +minimise flow collisions.
492 +
493 +These keywords specify whether fairness based on source address, destination
494 +address, individual flows, or any combination of those is desired.
495 +.PP
496 +.B flowblind
497 +.br
498 + Disables flow isolation; all traffic passes through a single queue for
499 +each tin.
500 +.PP
501 +.B srchost
502 +.br
503 + Flows are defined only by source address. Could be useful on the egress
504 +path of an ISP backhaul.
505 +.PP
506 +.B dsthost
507 +.br
508 + Flows are defined only by destination address. Could be useful on the
509 +ingress path of an ISP backhaul.
510 +.PP
511 +.B hosts
512 +.br
513 + Flows are defined by source-destination host pairs. This is host
514 +isolation, rather than flow isolation.
515 +.PP
516 +.B flows
517 +.br
518 + Flows are defined by the entire 5-tuple of source address, destination
519 +address, transport protocol, source port and destination port. This is the type
520 +of flow isolation performed by SFQ and fq_codel.
521 +.PP
522 +.B dual-srchost
523 +.br
524 + Flows are defined by the 5-tuple, and fairness is applied first over
525 +source addresses, then over individual flows. Good for use on egress traffic
526 +from a LAN to the internet, where it'll prevent any one LAN host from
527 +monopolising the uplink, regardless of the number of flows they use.
528 +.PP
529 +.B dual-dsthost
530 +.br
531 + Flows are defined by the 5-tuple, and fairness is applied first over
532 +destination addresses, then over individual flows. Good for use on ingress
533 +traffic to a LAN from the internet, where it'll prevent any one LAN host from
534 +monopolising the downlink, regardless of the number of flows they use.
535 +.PP
536 +.B triple-isolate
537 +(default)
538 +.br
539 + Flows are defined by the 5-tuple, and fairness is applied over source
540 +*and* destination addresses intelligently (ie. not merely by host-pairs), and
541 +also over individual flows. Use this if you're not certain whether to use
542 +dual-srchost or dual-dsthost; it'll do both jobs at once, preventing any one
543 +host on *either* side of the link from monopolising it with a large number of
544 +flows.
545 +.PP
546 +.B nat
547 +.br
548 + Instructs Cake to perform a NAT lookup before applying flow-isolation
549 +rules, to determine the true addresses and port numbers of the packet, to
550 +improve fairness between hosts "inside" the NAT. This has no practical effect
551 +in "flowblind" or "flows" modes, or if NAT is performed on a different host.
552 +.PP
553 +.B nonat
554 +(default)
555 +.br
556 + Cake will not perform a NAT lookup. Flow isolation will be performed
557 +using the addresses and port numbers directly visible to the interface Cake is
558 +attached to.
559 +
560 +.SH PRIORITY QUEUE PARAMETERS
561 +CAKE can divide traffic into "tins" based on the Diffserv field. Each tin has
562 +its own independent set of flow-isolation queues, and is serviced based on a WRR
563 +algorithm. To avoid perverse Diffserv marking incentives, tin weights have a
564 +"priority sharing" value when bandwidth used by that tin is below a threshold,
565 +and a lower "bandwidth sharing" value when above. Bandwidth is compared against
566 +the threshold using the same algorithm as the deficit-mode shaper.
567 +
568 +Detailed customisation of tin parameters is not provided. The following presets
569 +perform all necessary tuning, relative to the current shaper bandwidth and RTT
570 +settings.
571 +.PP
572 +.B besteffort
573 +.br
574 + Disables priority queuing by placing all traffic in one tin.
575 +.PP
576 +.B precedence
577 +.br
578 + Enables legacy interpretation of TOS "Precedence" field. Use of this
579 +preset on the modern Internet is firmly discouraged.
580 +.PP
581 +.B diffserv-llt
582 +.br
583 + Provides a "Latency-Loss Tradeoff" implementation with five tins:
584 +.br
585 + Low Loss (TOS1, TOS2), 100% threshold, increased Codel target.
586 +.br
587 + Best Effort (general), 100% threshold, normal Codel target & interval.
588 +.br
589 + Low Latency (TOS4, TOS5, VA, EF), 100% threshold, reduced Codel interval.
590 +.br
591 + Bulk (CS1), 6.25% threshold, normal Codel target & interval.
592 +.br
593 + Net Control (CS6, CS7), 6.25% threshold, increased Codel target & interval.
594 +.PP
595 +.B diffserv4
596 +.br
597 + Provides a general-purpose Diffserv implementation with four tins:
598 +.br
599 + Bulk (CS1), 6.25% threshold, generally low priority.
600 +.br
601 + Best Effort (general), 100% threshold.
602 +.br
603 + Video (AF4x, AF3x, CS3, AF2x, CS2, TOS4, TOS1), 50% threshold.
604 +.br
605 + Voice (CS7, CS6, EF, VA, CS5, CS4), 25% threshold.
606 +.PP
607 +.B diffserv3
608 +(default)
609 +.br
610 + Provides a simple, general-purpose Diffserv implementation with three tins:
611 +.br
612 + Bulk (CS1), 6.25% threshold, generally low priority.
613 +.br
614 + Best Effort (general), 100% threshold.
615 +.br
616 + Voice (CS7, CS6, EF, VA, TOS4), 25% threshold, reduced Codel interval.
617 +
618 +.SH OTHER PARAMETERS
619 +.B memlimit
620 +LIMIT
621 +.br
622 + Limit the memory consumed by Cake to LIMIT bytes. Note that this does
623 +not translate directly to queue size (so do not size this based on bandwidth
624 +delay product considerations, but rather on worst case acceptable memory
625 +consumption), as there is some overhead in the data structures containing the
626 +packets, especially for small packets.
627 +
628 + By default, the limit is calculated based on the bandwidth and RTT
629 +settings.
630 +
631 +.PP
632 +.B wash
633 +
634 +.br
635 + Traffic entering your diffserv domain is frequently mis-marked in
636 +transit from the perspective of your network, and traffic exiting yours may be
637 +mis-marked from the perspective of the transiting provider.
638 +
639 +Apply the wash option to clear all extra diffserv (but not ECN bits), after
640 +priority queuing has taken place.
641 +
642 +If you are shaping inbound, and cannot trust the diffserv markings (as is the
643 +case for Comcast Cable, among others), it is best to use a single queue
644 +"besteffort" mode with wash.
645 +
646 +.SH EXAMPLES
647 +# tc qdisc delete root dev eth0
648 +.br
649 +# tc qdisc add root dev eth0 cake bandwidth 9500Kbit pppoe-ptm ether-vlan
650 +.br
651 +# tc -s qdisc show dev eth0
652 +.br
653 +qdisc cake 8007: root refcnt 6 bandwidth 9500Kbit diffserv3 triple-isolate rtt 100.0ms ptm overhead 34 via-ethernet total_overhead 34 hard_header_len 14
654 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
655 + backlog 0b 0p requeues 0
656 + memory used: 0b of 4Mb
657 + capacity estimate: 9500Kbit
658 +.br
659 + Bulk Best Effort Voice
660 +.br
661 + thresh 593744bit 9500Kbit 2375Kbit
662 +.br
663 + target 30.6ms 5.0ms 7.6ms
664 +.br
665 + interval 125.6ms 100.0ms 102.6ms
666 +.br
667 + pk_delay 0us 0us 0us
668 +.br
669 + av_delay 0us 0us 0us
670 +.br
671 + sp_delay 0us 0us 0us
672 +.br
673 + pkts 0 0 0
674 +.br
675 + bytes 0 0 0
676 +.br
677 + way_inds 0 0 0
678 +.br
679 + way_miss 0 0 0
680 +.br
681 + way_cols 0 0 0
682 +.br
683 + drops 0 0 0
684 +.br
685 + marks 0 0 0
686 +.br
687 + ack_drop 0 0 0
688 +.br
689 + sp_flows 0 0 0
690 +.br
691 + bk_flows 0 0 0
692 +.br
693 + un_flows 0 0 0
694 +.br
695 + max_len 0 0 0
696 +.br
697 +
698 +After some use:
699 +.br
700 +# tc -s qdisc show dev eth0
701 +
702 +qdisc cake 8007: root refcnt 6 bandwidth 9500Kbit diffserv3 triple-isolate rtt 100.0ms ptm overhead 34 via-ethernet total_overhead 34 hard_header_len 14
703 + Sent 110769306 bytes 313857 pkt (dropped 18, overlimits 741791 requeues 0)
704 + backlog 0b 0p requeues 0
705 + memory used: 110488b of 4Mb
706 + capacity estimate: 9500Kbit
707 +.br
708 + Bulk Best Effort Voice
709 +.br
710 + thresh 593744bit 9500Kbit 2375Kbit
711 +.br
712 + target 30.6ms 5.0ms 7.6ms
713 +.br
714 + interval 125.6ms 100.0ms 102.6ms
715 +.br
716 + pk_delay 16.0ms 545us 15us
717 +.br
718 + av_delay 2.4ms 161us 3us
719 +.br
720 + sp_delay 59us 1us 1us
721 +.br
722 + pkts 32866 195815 85194
723 +.br
724 + bytes 8132614 69517496 33122156
725 +.br
726 + way_inds 0 29208 0
727 +.br
728 + way_miss 7 173 17
729 +.br
730 + way_cols 0 0 0
731 +.br
732 + drops 10 7 1
733 +.br
734 + marks 217 692 300
735 +.br
736 + ack_drop 0 0 0
737 +.br
738 + sp_flows 0 0 0
739 +.br
740 + bk_flows 0 0 1
741 +.br
742 + un_flows 0 0 0
743 +.br
744 + max_len 3028 3012 3028
745 +.br
746 +
747 +.SH SEE ALSO
748 +.BR tc (8),
749 +.BR tc-codel (8),
750 +.BR tc-fq_codel (8),
751 +.BR tc-red (8)
752 +
753 +.SH AUTHORS
754 +Cake's principal author is Jonathan Morton, with contributions from
755 +Tony Ambardar, Kevin Darbyshire-Bryant, Toke Høiland-Jørgensen,
756 +Sebastian Moeller, Ryan Mounce, Dean Scarff, Nils Andreas Svee, and Dave Täht.
757 +
758 +This manual page was written by Loganaden Velvindron. Please report corrections
759 +to the Linux Networking mailing list <netdev@vger.kernel.org>.
760 --- a/tc/Makefile
761 +++ b/tc/Makefile
762 @@ -64,6 +64,7 @@ TCMODULES += em_meta.o
763 TCMODULES += q_mqprio.o
764 TCMODULES += q_codel.o
765 TCMODULES += q_fq_codel.o
766 +TCMODULES += q_cake.o
767 TCMODULES += q_fq.o
768 TCMODULES += q_pie.o
769 TCMODULES += q_hhf.o
770 --- /dev/null
771 +++ b/tc/q_cake.c
772 @@ -0,0 +1,770 @@
773 +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
774 +/*
775 + * Common Applications Kept Enhanced -- CAKE
776 + *
777 + * Copyright (C) 2014-2018 Jonathan Morton <chromatix99@gmail.com>
778 + * Copyright (C) 2017-2018 Toke Høiland-Jørgensen <toke@toke.dk>
779 + *
780 + * Redistribution and use in source and binary forms, with or without
781 + * modification, are permitted provided that the following conditions
782 + * are met:
783 + * 1. Redistributions of source code must retain the above copyright
784 + * notice, this list of conditions, and the following disclaimer,
785 + * without modification.
786 + * 2. Redistributions in binary form must reproduce the above copyright
787 + * notice, this list of conditions and the following disclaimer in the
788 + * documentation and/or other materials provided with the distribution.
789 + * 3. The names of the authors may not be used to endorse or promote products
790 + * derived from this software without specific prior written permission.
791 + *
792 + * Alternatively, provided that this notice is retained in full, this
793 + * software may be distributed under the terms of the GNU General
794 + * Public License ("GPL") version 2, in which case the provisions of the
795 + * GPL apply INSTEAD OF those given above.
796 + *
797 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
798 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
799 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
800 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
801 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
802 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
803 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
804 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
805 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
806 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
807 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
808 + * DAMAGE.
809 + *
810 + */
811 +
812 +#include <stddef.h>
813 +#include <stdio.h>
814 +#include <stdlib.h>
815 +#include <unistd.h>
816 +#include <syslog.h>
817 +#include <fcntl.h>
818 +#include <sys/socket.h>
819 +#include <netinet/in.h>
820 +#include <arpa/inet.h>
821 +#include <string.h>
822 +
823 +#include "utils.h"
824 +#include "tc_util.h"
825 +
826 +static void explain(void)
827 +{
828 + fprintf(stderr,
829 +"Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
830 +" [ rtt TIME | datacentre | lan | metro | regional |\n"
831 +" internet* | oceanic | satellite | interplanetary ]\n"
832 +" [ besteffort | diffserv8 | diffserv4 | diffserv-llt |\n"
833 +" diffserv3* ]\n"
834 +" [ flowblind | srchost | dsthost | hosts | flows |\n"
835 +" dual-srchost | dual-dsthost | triple-isolate* ]\n"
836 +" [ nat | nonat* ]\n"
837 +" [ wash | nowash* ]\n"
838 +" [ ack-filter | ack-filter-aggressive | no-ack-filter* ]\n"
839 +" [ memlimit LIMIT ]\n"
840 +" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
841 +" [ mpu N ] [ ingress | egress* ]\n"
842 +" (* marks defaults)\n");
843 +}
844 +
845 +static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
846 + struct nlmsghdr *n, const char *dev)
847 +{
848 + int unlimited = 0;
849 + unsigned bandwidth = 0;
850 + unsigned interval = 0;
851 + unsigned target = 0;
852 + unsigned diffserv = 0;
853 + unsigned memlimit = 0;
854 + int overhead = 0;
855 + bool overhead_set = false;
856 + bool overhead_override = false;
857 + int mpu = 0;
858 + int flowmode = -1;
859 + int nat = -1;
860 + int atm = -1;
861 + int autorate = -1;
862 + int wash = -1;
863 + int ingress = -1;
864 + int ack_filter = -1;
865 + struct rtattr *tail;
866 +
867 + while (argc > 0) {
868 + if (strcmp(*argv, "bandwidth") == 0) {
869 + NEXT_ARG();
870 + if (get_rate(&bandwidth, *argv)) {
871 + fprintf(stderr, "Illegal \"bandwidth\"\n");
872 + return -1;
873 + }
874 + unlimited = 0;
875 + autorate = 0;
876 + } else if (strcmp(*argv, "unlimited") == 0) {
877 + bandwidth = 0;
878 + unlimited = 1;
879 + autorate = 0;
880 + } else if (strcmp(*argv, "autorate_ingress") == 0) {
881 + autorate = 1;
882 +
883 + } else if (strcmp(*argv, "rtt") == 0) {
884 + NEXT_ARG();
885 + if (get_time(&interval, *argv)) {
886 + fprintf(stderr, "Illegal \"rtt\"\n");
887 + return -1;
888 + }
889 + target = interval / 20;
890 + if(!target)
891 + target = 1;
892 + } else if (strcmp(*argv, "datacentre") == 0) {
893 + interval = 100;
894 + target = 5;
895 + } else if (strcmp(*argv, "lan") == 0) {
896 + interval = 1000;
897 + target = 50;
898 + } else if (strcmp(*argv, "metro") == 0) {
899 + interval = 10000;
900 + target = 500;
901 + } else if (strcmp(*argv, "regional") == 0) {
902 + interval = 30000;
903 + target = 1500;
904 + } else if (strcmp(*argv, "internet") == 0) {
905 + interval = 100000;
906 + target = 5000;
907 + } else if (strcmp(*argv, "oceanic") == 0) {
908 + interval = 300000;
909 + target = 15000;
910 + } else if (strcmp(*argv, "satellite") == 0) {
911 + interval = 1000000;
912 + target = 50000;
913 + } else if (strcmp(*argv, "interplanetary") == 0) {
914 + interval = 1000000000;
915 + target = 50000000;
916 +
917 + } else if (strcmp(*argv, "besteffort") == 0) {
918 + diffserv = 1;
919 + } else if (strcmp(*argv, "precedence") == 0) {
920 + diffserv = 2;
921 + } else if (strcmp(*argv, "diffserv8") == 0) {
922 + diffserv = 3;
923 + } else if (strcmp(*argv, "diffserv4") == 0) {
924 + diffserv = 4;
925 + } else if (strcmp(*argv, "diffserv") == 0) {
926 + diffserv = 4;
927 + } else if (strcmp(*argv, "diffserv-llt") == 0) {
928 + diffserv = 5;
929 + } else if (strcmp(*argv, "diffserv3") == 0) {
930 + diffserv = 6;
931 +
932 + } else if (strcmp(*argv, "nowash") == 0) {
933 + wash = 0;
934 + } else if (strcmp(*argv, "wash") == 0) {
935 + wash = 1;
936 +
937 + } else if (strcmp(*argv, "flowblind") == 0) {
938 + flowmode = 0;
939 + } else if (strcmp(*argv, "srchost") == 0) {
940 + flowmode = 1;
941 + } else if (strcmp(*argv, "dsthost") == 0) {
942 + flowmode = 2;
943 + } else if (strcmp(*argv, "hosts") == 0) {
944 + flowmode = 3;
945 + } else if (strcmp(*argv, "flows") == 0) {
946 + flowmode = 4;
947 + } else if (strcmp(*argv, "dual-srchost") == 0) {
948 + flowmode = 5;
949 + } else if (strcmp(*argv, "dual-dsthost") == 0) {
950 + flowmode = 6;
951 + } else if (strcmp(*argv, "triple-isolate") == 0) {
952 + flowmode = 7;
953 +
954 + } else if (strcmp(*argv, "nat") == 0) {
955 + nat = 1;
956 + } else if (strcmp(*argv, "nonat") == 0) {
957 + nat = 0;
958 +
959 + } else if (strcmp(*argv, "ptm") == 0) {
960 + atm = 2;
961 + } else if (strcmp(*argv, "atm") == 0) {
962 + atm = 1;
963 + } else if (strcmp(*argv, "noatm") == 0) {
964 + atm = 0;
965 +
966 + } else if (strcmp(*argv, "raw") == 0) {
967 + atm = 0;
968 + overhead = 0;
969 + overhead_set = true;
970 + overhead_override = true;
971 + } else if (strcmp(*argv, "conservative") == 0) {
972 + /*
973 + * Deliberately over-estimate overhead:
974 + * one whole ATM cell plus ATM framing.
975 + * A safe choice if the actual overhead is unknown.
976 + */
977 + atm = 1;
978 + overhead = 48;
979 + overhead_set = true;
980 +
981 + /* Various ADSL framing schemes, all over ATM cells */
982 + } else if (strcmp(*argv, "ipoa-vcmux") == 0) {
983 + atm = 1;
984 + overhead += 8;
985 + overhead_set = true;
986 + } else if (strcmp(*argv, "ipoa-llcsnap") == 0) {
987 + atm = 1;
988 + overhead += 16;
989 + overhead_set = true;
990 + } else if (strcmp(*argv, "bridged-vcmux") == 0) {
991 + atm = 1;
992 + overhead += 24;
993 + overhead_set = true;
994 + } else if (strcmp(*argv, "bridged-llcsnap") == 0) {
995 + atm = 1;
996 + overhead += 32;
997 + overhead_set = true;
998 + } else if (strcmp(*argv, "pppoa-vcmux") == 0) {
999 + atm = 1;
1000 + overhead += 10;
1001 + overhead_set = true;
1002 + } else if (strcmp(*argv, "pppoa-llc") == 0) {
1003 + atm = 1;
1004 + overhead += 14;
1005 + overhead_set = true;
1006 + } else if (strcmp(*argv, "pppoe-vcmux") == 0) {
1007 + atm = 1;
1008 + overhead += 32;
1009 + overhead_set = true;
1010 + } else if (strcmp(*argv, "pppoe-llcsnap") == 0) {
1011 + atm = 1;
1012 + overhead += 40;
1013 + overhead_set = true;
1014 +
1015 + /* Typical VDSL2 framing schemes, both over PTM */
1016 + /* PTM has 64b/65b coding which absorbs some bandwidth */
1017 + } else if (strcmp(*argv, "pppoe-ptm") == 0) {
1018 + /* 2B PPP + 6B PPPoE + 6B dest MAC + 6B src MAC
1019 + * + 2B ethertype + 4B Frame Check Sequence
1020 + * + 1B Start of Frame (S) + 1B End of Frame (Ck)
1021 + * + 2B TC-CRC (PTM-FCS) = 30B
1022 + */
1023 + atm = 2;
1024 + overhead += 30;
1025 + overhead_set = true;
1026 + } else if (strcmp(*argv, "bridged-ptm") == 0) {
1027 + /* 6B dest MAC + 6B src MAC + 2B ethertype
1028 + * + 4B Frame Check Sequence
1029 + * + 1B Start of Frame (S) + 1B End of Frame (Ck)
1030 + * + 2B TC-CRC (PTM-FCS) = 22B
1031 + */
1032 + atm = 2;
1033 + overhead += 22;
1034 + overhead_set = true;
1035 +
1036 + } else if (strcmp(*argv, "via-ethernet") == 0) {
1037 + /*
1038 + * We used to use this flag to manually compensate for
1039 + * Linux including the Ethernet header on Ethernet-type
1040 + * interfaces, but not on IP-type interfaces.
1041 + *
1042 + * It is no longer needed, because Cake now adjusts for
1043 + * that automatically, and is thus ignored.
1044 + *
1045 + * It would be deleted entirely, but it appears in the
1046 + * stats output when the automatic compensation is
1047 + * active.
1048 + */
1049 +
1050 + } else if (strcmp(*argv, "ethernet") == 0) {
1051 + /* ethernet pre-amble & interframe gap & FCS
1052 + * you may need to add vlan tag */
1053 + overhead += 38;
1054 + overhead_set = true;
1055 + mpu = 84;
1056 +
1057 + /* Additional Ethernet-related overhead used by some ISPs */
1058 + } else if (strcmp(*argv, "ether-vlan") == 0) {
1059 + /* 802.1q VLAN tag - may be repeated */
1060 + overhead += 4;
1061 + overhead_set = true;
1062 +
1063 + /*
1064 + * DOCSIS cable shapers account for Ethernet frame with FCS,
1065 + * but not interframe gap or preamble.
1066 + */
1067 + } else if (strcmp(*argv, "docsis") == 0) {
1068 + atm = 0;
1069 + overhead += 18;
1070 + overhead_set = true;
1071 + mpu = 64;
1072 +
1073 + } else if (strcmp(*argv, "overhead") == 0) {
1074 + char* p = NULL;
1075 + NEXT_ARG();
1076 + overhead = strtol(*argv, &p, 10);
1077 + if(!p || *p || !*argv || overhead < -64 || overhead > 256) {
1078 + fprintf(stderr, "Illegal \"overhead\", valid range is -64 to 256\\n");
1079 + return -1;
1080 + }
1081 + overhead_set = true;
1082 +
1083 + } else if (strcmp(*argv, "mpu") == 0) {
1084 + char* p = NULL;
1085 + NEXT_ARG();
1086 + mpu = strtol(*argv, &p, 10);
1087 + if(!p || *p || !*argv || mpu < 0 || mpu > 256) {
1088 + fprintf(stderr, "Illegal \"mpu\", valid range is 0 to 256\\n");
1089 + return -1;
1090 + }
1091 +
1092 + } else if (strcmp(*argv, "ingress") == 0) {
1093 + ingress = 1;
1094 + } else if (strcmp(*argv, "egress") == 0) {
1095 + ingress = 0;
1096 +
1097 + } else if (strcmp(*argv, "no-ack-filter") == 0) {
1098 + ack_filter = 0;
1099 + } else if (strcmp(*argv, "ack-filter") == 0) {
1100 + ack_filter = 0x0200;
1101 + } else if (strcmp(*argv, "ack-filter-aggressive") == 0) {
1102 + ack_filter = 0x0600;
1103 +
1104 + } else if (strcmp(*argv, "memlimit") == 0) {
1105 + NEXT_ARG();
1106 + if(get_size(&memlimit, *argv)) {
1107 + fprintf(stderr, "Illegal value for \"memlimit\": \"%s\"\n", *argv);
1108 + return -1;
1109 + }
1110 +
1111 + } else if (strcmp(*argv, "help") == 0) {
1112 + explain();
1113 + return -1;
1114 + } else {
1115 + fprintf(stderr, "What is \"%s\"?\n", *argv);
1116 + explain();
1117 + return -1;
1118 + }
1119 + argc--; argv++;
1120 + }
1121 +
1122 + tail = NLMSG_TAIL(n);
1123 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
1124 + if (bandwidth || unlimited)
1125 + addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth));
1126 + if (diffserv)
1127 + addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
1128 + if (atm != -1)
1129 + addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
1130 + if (flowmode != -1)
1131 + addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
1132 + if (overhead_set)
1133 + addattr_l(n, 1024, TCA_CAKE_OVERHEAD, &overhead, sizeof(overhead));
1134 + if (overhead_override) {
1135 + unsigned zero = 0;
1136 + addattr_l(n, 1024, TCA_CAKE_RAW, &zero, sizeof(zero));
1137 + }
1138 + if (mpu > 0)
1139 + addattr_l(n, 1024, TCA_CAKE_MPU, &mpu, sizeof(mpu));
1140 + if (interval)
1141 + addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
1142 + if (target)
1143 + addattr_l(n, 1024, TCA_CAKE_TARGET, &target, sizeof(target));
1144 + if (autorate != -1)
1145 + addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate));
1146 + if (memlimit)
1147 + addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit));
1148 + if (nat != -1)
1149 + addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
1150 + if (wash != -1)
1151 + addattr_l(n, 1024, TCA_CAKE_WASH, &wash, sizeof(wash));
1152 + if (ingress != -1)
1153 + addattr_l(n, 1024, TCA_CAKE_INGRESS, &ingress, sizeof(ingress));
1154 + if (ack_filter != -1)
1155 + addattr_l(n, 1024, TCA_CAKE_ACK_FILTER, &ack_filter, sizeof(ack_filter));
1156 +
1157 + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
1158 + return 0;
1159 +}
1160 +
1161 +
1162 +static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1163 +{
1164 + struct rtattr *tb[TCA_CAKE_MAX + 1];
1165 + unsigned bandwidth = 0;
1166 + unsigned diffserv = 0;
1167 + unsigned flowmode = 0;
1168 + unsigned interval = 0;
1169 + unsigned memlimit = 0;
1170 + int overhead = 0;
1171 + int raw = 0;
1172 + int mpu = 0;
1173 + int atm = 0;
1174 + int nat = 0;
1175 + int autorate = 0;
1176 + int wash = 0;
1177 + int ingress = 0;
1178 + int ack_filter = 0;
1179 + SPRINT_BUF(b1);
1180 + SPRINT_BUF(b2);
1181 +
1182 + if (opt == NULL)
1183 + return 0;
1184 +
1185 + parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
1186 +
1187 + if (tb[TCA_CAKE_BASE_RATE] &&
1188 + RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) {
1189 + bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]);
1190 + if(bandwidth) {
1191 + print_uint(PRINT_JSON, "bandwidth", NULL, bandwidth);
1192 + print_string(PRINT_FP, NULL, "bandwidth %s ", sprint_rate(bandwidth, b1));
1193 + } else
1194 + print_string(PRINT_ANY, "bandwidth", "bandwidth %s ", "unlimited");
1195 + }
1196 + if (tb[TCA_CAKE_AUTORATE] &&
1197 + RTA_PAYLOAD(tb[TCA_CAKE_AUTORATE]) >= sizeof(__u32)) {
1198 + autorate = rta_getattr_u32(tb[TCA_CAKE_AUTORATE]);
1199 + if(autorate == 1)
1200 + print_string(PRINT_ANY, "autorate", "autorate_%s ", "ingress");
1201 + else if(autorate)
1202 + print_string(PRINT_ANY, "autorate", "(?autorate?) ", "unknown");
1203 + }
1204 + if (tb[TCA_CAKE_DIFFSERV_MODE] &&
1205 + RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
1206 + diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
1207 + switch(diffserv) {
1208 + case 1:
1209 + print_string(PRINT_ANY, "diffserv", "%s ", "besteffort");
1210 + break;
1211 + case 2:
1212 + print_string(PRINT_ANY, "diffserv", "%s ", "precedence");
1213 + break;
1214 + case 3:
1215 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv8");
1216 + break;
1217 + case 4:
1218 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv4");
1219 + break;
1220 + case 5:
1221 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv-llt");
1222 + break;
1223 + case 6:
1224 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv3");
1225 + break;
1226 + default:
1227 + print_string(PRINT_ANY, "diffserv", "(?diffserv?) ", "unknown");
1228 + break;
1229 + };
1230 + }
1231 + if (tb[TCA_CAKE_FLOW_MODE] &&
1232 + RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
1233 + flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
1234 + nat = !!(flowmode & 64);
1235 + flowmode &= ~64;
1236 + switch(flowmode) {
1237 + case 0:
1238 + print_string(PRINT_ANY, "flowmode", "%s ", "flowblind");
1239 + break;
1240 + case 1:
1241 + print_string(PRINT_ANY, "flowmode", "%s ", "srchost");
1242 + break;
1243 + case 2:
1244 + print_string(PRINT_ANY, "flowmode", "%s ", "dsthost");
1245 + break;
1246 + case 3:
1247 + print_string(PRINT_ANY, "flowmode", "%s ", "hosts");
1248 + break;
1249 + case 4:
1250 + print_string(PRINT_ANY, "flowmode", "%s ", "flows");
1251 + break;
1252 + case 5:
1253 + print_string(PRINT_ANY, "flowmode", "%s ", "dual-srchost");
1254 + break;
1255 + case 6:
1256 + print_string(PRINT_ANY, "flowmode", "%s ", "dual-dsthost");
1257 + break;
1258 + case 7:
1259 + print_string(PRINT_ANY, "flowmode", "%s ", "triple-isolate");
1260 + break;
1261 + default:
1262 + print_string(PRINT_ANY, "flowmode", "(?flowmode?) ", "unknown");
1263 + break;
1264 + };
1265 +
1266 + if(nat)
1267 + print_string(PRINT_FP, NULL, "nat ", NULL);
1268 + print_bool(PRINT_JSON, "nat", NULL, nat);
1269 + }
1270 + if (tb[TCA_CAKE_WASH] &&
1271 + RTA_PAYLOAD(tb[TCA_CAKE_WASH]) >= sizeof(__u32)) {
1272 + wash = rta_getattr_u32(tb[TCA_CAKE_WASH]);
1273 + }
1274 + if (tb[TCA_CAKE_ATM] &&
1275 + RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
1276 + atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
1277 + }
1278 + if (tb[TCA_CAKE_OVERHEAD] &&
1279 + RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) {
1280 + overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]);
1281 + }
1282 + if (tb[TCA_CAKE_MPU] &&
1283 + RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
1284 + mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
1285 + }
1286 + if (tb[TCA_CAKE_INGRESS] &&
1287 + RTA_PAYLOAD(tb[TCA_CAKE_INGRESS]) >= sizeof(__u32)) {
1288 + ingress = rta_getattr_u32(tb[TCA_CAKE_INGRESS]);
1289 + }
1290 + if (tb[TCA_CAKE_ACK_FILTER] &&
1291 + RTA_PAYLOAD(tb[TCA_CAKE_ACK_FILTER]) >= sizeof(__u32)) {
1292 + ack_filter = rta_getattr_u32(tb[TCA_CAKE_ACK_FILTER]);
1293 + }
1294 + if (tb[TCA_CAKE_RAW]) {
1295 + raw = 1;
1296 + }
1297 + if (tb[TCA_CAKE_RTT] &&
1298 + RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) {
1299 + interval = rta_getattr_u32(tb[TCA_CAKE_RTT]);
1300 + }
1301 +
1302 + if (wash)
1303 + print_string(PRINT_FP, NULL, "wash ", NULL);
1304 + print_bool(PRINT_JSON, "wash", NULL, wash);
1305 +
1306 + if (ingress)
1307 + print_string(PRINT_FP, NULL, "ingress ", NULL);
1308 + print_bool(PRINT_JSON, "ingress", NULL, ingress);
1309 +
1310 + if (ack_filter == 0x0600)
1311 + print_string(PRINT_ANY, "ack-filter", "ack-filter-%s ", "aggressive");
1312 + else if (ack_filter)
1313 + print_string(PRINT_ANY, "ack-filter", "ack-filter ", "enabled");
1314 + else
1315 + print_string(PRINT_JSON, "ack-filter", NULL, "disabled");
1316 +
1317 + if (interval)
1318 + print_string(PRINT_FP, NULL, "rtt %s ", sprint_time(interval, b2));
1319 + print_uint(PRINT_JSON, "rtt", NULL, interval);
1320 +
1321 + if (raw)
1322 + print_string(PRINT_FP, NULL, "raw ", NULL);
1323 + print_bool(PRINT_JSON, "raw", NULL, raw);
1324 +
1325 + if (atm == 1)
1326 + print_string(PRINT_ANY, "atm", "%s ", "atm");
1327 + else if (atm == 2)
1328 + print_string(PRINT_ANY, "atm", "%s ", "ptm");
1329 + else if (!raw)
1330 + print_string(PRINT_ANY, "atm", "%s ", "noatm");
1331 +
1332 + print_uint(PRINT_ANY, "overhead", "overhead %d ", overhead);
1333 +
1334 + if (mpu)
1335 + print_uint(PRINT_ANY, "mpu", "mpu %d ", mpu);
1336 +
1337 + if (memlimit) {
1338 + print_uint(PRINT_JSON, "memlimit", NULL, memlimit);
1339 + print_string(PRINT_FP, NULL, "memlimit %s", sprint_size(memlimit, b1));
1340 + }
1341 +
1342 + return 0;
1343 +}
1344 +
1345 +#define FOR_EACH_TIN(xstats, tst, i) \
1346 + for(tst = xstats->tin_stats, i = 0; \
1347 + i < xstats->tin_cnt; \
1348 + i++, tst = ((void *) xstats->tin_stats) + xstats->tin_stats_size * i)
1349 +
1350 +static void cake_print_json_tin(struct tc_cake_tin_stats *tst)
1351 +{
1352 + open_json_object(NULL);
1353 + print_uint(PRINT_JSON, "threshold_rate", NULL, tst->threshold_rate);
1354 + print_uint(PRINT_JSON, "target", NULL, tst->target_us);
1355 + print_uint(PRINT_JSON, "interval", NULL, tst->interval_us);
1356 + print_uint(PRINT_JSON, "peak_delay", NULL, tst->peak_delay_us);
1357 + print_uint(PRINT_JSON, "average_delay", NULL, tst->avge_delay_us);
1358 + print_uint(PRINT_JSON, "base_delay", NULL, tst->base_delay_us);
1359 + print_uint(PRINT_JSON, "sent_packets", NULL, tst->sent.packets);
1360 + print_uint(PRINT_JSON, "sent_bytes", NULL, tst->sent.bytes);
1361 + print_uint(PRINT_JSON, "way_indirect_hits", NULL, tst->way_indirect_hits);
1362 + print_uint(PRINT_JSON, "way_misses", NULL, tst->way_misses);
1363 + print_uint(PRINT_JSON, "way_collisions", NULL, tst->way_collisions);
1364 + print_uint(PRINT_JSON, "drops", NULL, tst->dropped.packets);
1365 + print_uint(PRINT_JSON, "ecn_mark", NULL, tst->ecn_marked.packets);
1366 + print_uint(PRINT_JSON, "ack_drops", NULL, tst->ack_drops.packets);
1367 + print_uint(PRINT_JSON, "sparse_flows", NULL, tst->sparse_flows);
1368 + print_uint(PRINT_JSON, "bulk_flows", NULL, tst->bulk_flows);
1369 + print_uint(PRINT_JSON, "unresponsive_flows", NULL, tst->unresponse_flows);
1370 + print_uint(PRINT_JSON, "max_pkt_len", NULL, tst->max_skblen);
1371 + close_json_object();
1372 +}
1373 +
1374 +static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
1375 + struct rtattr *xstats)
1376 +{
1377 + struct tc_cake_xstats *stnc;
1378 + struct tc_cake_tin_stats *tst;
1379 + SPRINT_BUF(b1);
1380 + int i;
1381 +
1382 + if (xstats == NULL)
1383 + return 0;
1384 +
1385 + if (RTA_PAYLOAD(xstats) < sizeof(*stnc))
1386 + return -1;
1387 +
1388 + stnc = RTA_DATA(xstats);
1389 +
1390 + if (stnc->version < 0x101 ||
1391 + RTA_PAYLOAD(xstats) < (sizeof(struct tc_cake_xstats) +
1392 + stnc->tin_stats_size * stnc->tin_cnt))
1393 + return -1;
1394 +
1395 + print_uint(PRINT_JSON, "memory_used", NULL, stnc->memory_used);
1396 + print_uint(PRINT_JSON, "memory_limit", NULL, stnc->memory_limit);
1397 + print_uint(PRINT_JSON, "capacity_estimate", NULL, stnc->capacity_estimate);
1398 +
1399 + print_string(PRINT_FP, NULL, " memory used: %s",
1400 + sprint_size(stnc->memory_used, b1));
1401 + print_string(PRINT_FP, NULL, " of %s\n",
1402 + sprint_size(stnc->memory_limit, b1));
1403 + print_string(PRINT_FP, NULL, " capacity estimate: %s\n",
1404 + sprint_rate(stnc->capacity_estimate, b1));
1405 +
1406 + print_uint(PRINT_ANY, "min_transport_size", " min/max transport layer size: %10u",
1407 + stnc->min_trnlen);
1408 + print_uint(PRINT_ANY, "max_transport_size", " /%8u\n", stnc->max_trnlen);
1409 + print_uint(PRINT_ANY, "min_adj_size", " min/max overhead-adjusted size: %8u",
1410 + stnc->min_adjlen);
1411 + print_uint(PRINT_ANY, "max_adj_size", " /%8u\n", stnc->max_adjlen);
1412 + print_uint(PRINT_ANY, "avg_hdr_offset", " average transport hdr offset: %10u\n\n",
1413 + stnc->avg_trnoff);
1414 +
1415 + if (is_json_context()) {
1416 + open_json_array(PRINT_JSON, "tins");
1417 + FOR_EACH_TIN(stnc, tst, i)
1418 + cake_print_json_tin(tst);
1419 + close_json_array(PRINT_JSON, NULL);
1420 + return 0;
1421 + }
1422 +
1423 +
1424 + switch(stnc->tin_cnt) {
1425 + case 3:
1426 + fprintf(f, " Bulk Best Effort Voice\n");
1427 + break;
1428 +
1429 + case 4:
1430 + fprintf(f, " Bulk Best Effort Video Voice\n");
1431 + break;
1432 +
1433 + case 5:
1434 + fprintf(f, " Low Loss Best Effort Low Delay Bulk Net Control\n");
1435 + break;
1436 +
1437 + default:
1438 + fprintf(f, " ");
1439 + for(i=0; i < stnc->tin_cnt; i++)
1440 + fprintf(f, " Tin %u", i);
1441 + fprintf(f, "\n");
1442 + };
1443 +
1444 + fprintf(f, " thresh ");
1445 + FOR_EACH_TIN(stnc, tst, i)
1446 + fprintf(f, " %12s", sprint_rate(tst->threshold_rate, b1));
1447 + fprintf(f, "\n");
1448 +
1449 + fprintf(f, " target ");
1450 + FOR_EACH_TIN(stnc, tst, i)
1451 + fprintf(f, " %12s", sprint_time(tst->target_us, b1));
1452 + fprintf(f, "\n");
1453 +
1454 + fprintf(f, " interval");
1455 + FOR_EACH_TIN(stnc, tst, i)
1456 + fprintf(f, " %12s", sprint_time(tst->interval_us, b1));
1457 + fprintf(f, "\n");
1458 +
1459 + fprintf(f, " pk_delay");
1460 + FOR_EACH_TIN(stnc, tst, i)
1461 + fprintf(f, " %12s", sprint_time(tst->peak_delay_us, b1));
1462 + fprintf(f, "\n");
1463 +
1464 + fprintf(f, " av_delay");
1465 + FOR_EACH_TIN(stnc, tst, i)
1466 + fprintf(f, " %12s", sprint_time(tst->avge_delay_us, b1));
1467 + fprintf(f, "\n");
1468 +
1469 + fprintf(f, " sp_delay");
1470 + FOR_EACH_TIN(stnc, tst, i)
1471 + fprintf(f, " %12s", sprint_time(tst->base_delay_us, b1));
1472 + fprintf(f, "\n");
1473 +
1474 + fprintf(f, " pkts ");
1475 + FOR_EACH_TIN(stnc, tst, i)
1476 + fprintf(f, " %12u", tst->sent.packets);
1477 + fprintf(f, "\n");
1478 +
1479 + fprintf(f, " bytes ");
1480 + FOR_EACH_TIN(stnc, tst, i)
1481 + fprintf(f, " %12llu", tst->sent.bytes);
1482 + fprintf(f, "\n");
1483 +
1484 + fprintf(f, " way_inds");
1485 + FOR_EACH_TIN(stnc, tst, i)
1486 + fprintf(f, " %12u", tst->way_indirect_hits);
1487 + fprintf(f, "\n");
1488 +
1489 + fprintf(f, " way_miss");
1490 + FOR_EACH_TIN(stnc, tst, i)
1491 + fprintf(f, " %12u", tst->way_misses);
1492 + fprintf(f, "\n");
1493 +
1494 + fprintf(f, " way_cols");
1495 + FOR_EACH_TIN(stnc, tst, i)
1496 + fprintf(f, " %12u", tst->way_collisions);
1497 + fprintf(f, "\n");
1498 +
1499 + fprintf(f, " drops ");
1500 + FOR_EACH_TIN(stnc, tst, i)
1501 + fprintf(f, " %12u", tst->dropped.packets);
1502 + fprintf(f, "\n");
1503 +
1504 + fprintf(f, " marks ");
1505 + FOR_EACH_TIN(stnc, tst, i)
1506 + fprintf(f, " %12u", tst->ecn_marked.packets);
1507 + fprintf(f, "\n");
1508 +
1509 + fprintf(f, " ack_drop");
1510 + FOR_EACH_TIN(stnc, tst, i)
1511 + fprintf(f, " %12u", tst->ack_drops.packets);
1512 + fprintf(f, "\n");
1513 +
1514 + fprintf(f, " sp_flows");
1515 + FOR_EACH_TIN(stnc, tst, i)
1516 + fprintf(f, " %12u", tst->sparse_flows);
1517 + fprintf(f, "\n");
1518 +
1519 + fprintf(f, " bk_flows");
1520 + FOR_EACH_TIN(stnc, tst, i)
1521 + fprintf(f, " %12u", tst->bulk_flows);
1522 + fprintf(f, "\n");
1523 +
1524 + fprintf(f, " un_flows");
1525 + FOR_EACH_TIN(stnc, tst, i)
1526 + fprintf(f, " %12u", tst->unresponse_flows);
1527 + fprintf(f, "\n");
1528 +
1529 + fprintf(f, " max_len ");
1530 + FOR_EACH_TIN(stnc, tst, i)
1531 + fprintf(f, " %12u", tst->max_skblen);
1532 + fprintf(f, "\n");
1533 +
1534 + return 0;
1535 +}
1536 +
1537 +struct qdisc_util cake_qdisc_util = {
1538 + .id = "cake",
1539 + .parse_qopt = cake_parse_opt,
1540 + .print_qopt = cake_print_opt,
1541 + .print_xstats = cake_print_xstats,
1542 +};