1 --- a/include/uapi/linux/pkt_sched.h
2 +++ b/include/uapi/linux/pkt_sched.h
3 @@ -934,4 +934,118 @@ enum {
5 #define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
11 + TCA_CAKE_BASE_RATE64,
12 + TCA_CAKE_DIFFSERV_MODE,
21 + TCA_CAKE_RAW, // was _ETHERNET
25 + TCA_CAKE_ACK_FILTER,
29 +#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
32 + __TCA_CAKE_STATS_INVALID,
34 + TCA_CAKE_STATS_CAPACITY_ESTIMATE64,
35 + TCA_CAKE_STATS_MEMORY_LIMIT,
36 + TCA_CAKE_STATS_MEMORY_USED,
37 + TCA_CAKE_STATS_AVG_NETOFF,
38 + TCA_CAKE_STATS_MIN_NETLEN,
39 + TCA_CAKE_STATS_MAX_NETLEN,
40 + TCA_CAKE_STATS_MIN_ADJLEN,
41 + TCA_CAKE_STATS_MAX_ADJLEN,
42 + TCA_CAKE_STATS_TIN_STATS,
43 + TCA_CAKE_STATS_DEFICIT,
44 + TCA_CAKE_STATS_COBALT_COUNT,
45 + TCA_CAKE_STATS_DROPPING,
46 + TCA_CAKE_STATS_DROP_NEXT_US,
47 + TCA_CAKE_STATS_P_DROP,
48 + TCA_CAKE_STATS_BLUE_TIMER_US,
49 + __TCA_CAKE_STATS_MAX
51 +#define TCA_CAKE_STATS_MAX (__TCA_CAKE_STATS_MAX - 1)
54 + __TCA_CAKE_TIN_STATS_INVALID,
55 + TCA_CAKE_TIN_STATS_PAD,
56 + TCA_CAKE_TIN_STATS_SENT_PACKETS,
57 + TCA_CAKE_TIN_STATS_SENT_BYTES64,
58 + TCA_CAKE_TIN_STATS_DROPPED_PACKETS,
59 + TCA_CAKE_TIN_STATS_DROPPED_BYTES64,
60 + TCA_CAKE_TIN_STATS_ACKS_DROPPED_PACKETS,
61 + TCA_CAKE_TIN_STATS_ACKS_DROPPED_BYTES64,
62 + TCA_CAKE_TIN_STATS_ECN_MARKED_PACKETS,
63 + TCA_CAKE_TIN_STATS_ECN_MARKED_BYTES64,
64 + TCA_CAKE_TIN_STATS_BACKLOG_PACKETS,
65 + TCA_CAKE_TIN_STATS_BACKLOG_BYTES,
66 + TCA_CAKE_TIN_STATS_THRESHOLD_RATE64,
67 + TCA_CAKE_TIN_STATS_TARGET_US,
68 + TCA_CAKE_TIN_STATS_INTERVAL_US,
69 + TCA_CAKE_TIN_STATS_WAY_INDIRECT_HITS,
70 + TCA_CAKE_TIN_STATS_WAY_MISSES,
71 + TCA_CAKE_TIN_STATS_WAY_COLLISIONS,
72 + TCA_CAKE_TIN_STATS_PEAK_DELAY_US,
73 + TCA_CAKE_TIN_STATS_AVG_DELAY_US,
74 + TCA_CAKE_TIN_STATS_BASE_DELAY_US,
75 + TCA_CAKE_TIN_STATS_SPARSE_FLOWS,
76 + TCA_CAKE_TIN_STATS_BULK_FLOWS,
77 + TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS,
78 + TCA_CAKE_TIN_STATS_MAX_SKBLEN,
79 + TCA_CAKE_TIN_STATS_FLOW_QUANTUM,
80 + __TCA_CAKE_TIN_STATS_MAX
82 +#define TCA_CAKE_TIN_STATS_MAX (__TCA_CAKE_TIN_STATS_MAX - 1)
83 +#define TC_CAKE_MAX_TINS (8)
89 + CAKE_FLOW_HOSTS, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_DST_IP */
91 + CAKE_FLOW_DUAL_SRC, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_FLOWS */
92 + CAKE_FLOW_DUAL_DST, /* = CAKE_FLOW_DST_IP | CAKE_FLOW_FLOWS */
93 + CAKE_FLOW_TRIPLE, /* = CAKE_FLOW_HOSTS | CAKE_FLOW_FLOWS */
98 + CAKE_DIFFSERV_DIFFSERV3 = 0,
99 + CAKE_DIFFSERV_DIFFSERV4,
100 + CAKE_DIFFSERV_DIFFSERV8,
101 + CAKE_DIFFSERV_BESTEFFORT,
102 + CAKE_DIFFSERV_PRECEDENCE,
109 + CAKE_ACK_AGGRESSIVE,
123 +++ b/man/man8/tc-cake.8
125 +.TH CAKE 8 "23 November 2017" "iproute2" "Linux"
127 +CAKE \- Common Applications Kept Enhanced (CAKE)
129 +.B tc qdisc ... cake
136 +.BR autorate_ingress
202 +.BR ack-filter-aggressive
241 +CAKE (Common Applications Kept Enhanced) is a shaping-capable queue discipline
242 +which uses both AQM and FQ. It combines COBALT, which is an AQM algorithm
243 +combining Codel and BLUE, a shaper which operates in deficit mode, and a variant
244 +of DRR++ for flow isolation. 8-way set-associative hashing is used to virtually
245 +eliminate hash collisions. Priority queuing is available through a simplified
246 +diffserv implementation. Overhead compensation for various encapsulation
247 +schemes is tightly integrated.
249 +All settings are optional; the default settings are chosen to be sensible in
250 +most common deployments. Most people will only need to set the
252 +parameter to get useful results, but reading the
253 +.B Overhead Compensation
256 +sections is strongly encouraged.
258 +.SH SHAPER PARAMETERS
259 +CAKE uses a deficit-mode shaper, which does not exhibit the initial burst
260 +typical of token-bucket shapers. It will automatically burst precisely as much
261 +as required to maintain the configured throughput. As such, it is very
262 +straightforward to configure.
267 + No limit on the bandwidth.
272 + Set the shaper bandwidth. See
274 +or examples below for details of the RATE value.
278 + Automatic capacity estimation based on traffic arriving at this qdisc.
279 +This is most likely to be useful with cellular links, which tend to change
282 +parameter can be used in conjunction to specify an initial estimate. The shaper
283 +will periodically be set to a bandwidth slightly below the estimated rate. This
284 +estimator cannot estimate the bandwidth of links downstream of itself.
286 +.SH OVERHEAD COMPENSATION PARAMETERS
287 +The size of each packet on the wire may differ from that seen by Linux. The
288 +following parameters allow CAKE to compensate for this difference by internally
289 +considering each packet to be bigger than Linux informs it. To assist users who
290 +are not expert network engineers, keywords have been provided to represent a
291 +number of common link technologies.
293 +.SS Manual Overhead Specification
297 + Adds BYTES to the size of each packet. BYTES may be negative; values
298 +between -64 and 256 (inclusive) are accepted.
303 + Rounds each packet (including overhead) up to a minimum length
304 +BYTES. BYTES may not be negative; values between 0 and 256 (inclusive)
309 + Compensates for ATM cell framing, which is normally found on ADSL links.
310 +This is performed after the
312 +parameter above. ATM uses fixed 53-byte cells, each of which can carry 48 bytes
317 + Compensates for PTM encoding, which is normally found on VDSL2 links and
318 +uses a 64b/65b encoding scheme. It is even more efficient to simply
319 +derate the specified shaper bandwidth by a factor of 64/65 or 0.984. See
320 +ITU G.992.3 Annex N and IEEE 802.3 Section 61.3 for details.
324 + Disables ATM and PTM compensation.
326 +.SS Failsafe Overhead Keywords
327 +These two keywords are provided for quick-and-dirty setup. Use them if you
328 +can't be bothered to read the rest of this section.
333 + Turns off all overhead compensation in CAKE. The packet size reported
334 +by Linux will be used directly.
336 + Other overhead keywords may be added after "raw". The effect of this is
337 +to make the overhead compensation operate relative to the reported packet size,
338 +not the underlying IP packet size.
342 + Compensates for more overhead than is likely to occur on any
343 +widely-deployed link technology.
348 +.SS ADSL Overhead Keywords
349 +Most ADSL modems have a way to check which framing scheme is in use. Often this
350 +is also specified in the settings document provided by the ISP. The keywords in
351 +this section are intended to correspond with these sources of information. All
352 +of them implicitly set the
396 +See also the Ethernet Correction Factors section below.
398 +.SS VDSL2 Overhead Keywords
399 +ATM was dropped from VDSL2 in favour of PTM, which is a much more
400 +straightforward framing scheme. Some ISPs retained PPPoE for compatibility with
401 +their existing back-end systems.
409 + PPPoE: 2B PPP + 6B PPPoE +
411 + ETHERNET: 6B dest MAC + 6B src MAC + 2B ethertype + 4B Frame Check Sequence +
413 + PTM: 1B Start of Frame (S) + 1B End of Frame (Ck) + 2B TC-CRC (PTM-FCS)
421 + ETHERNET: 6B dest MAC + 6B src MAC + 2B ethertype + 4B Frame Check Sequence +
423 + PTM: 1B Start of Frame (S) + 1B End of Frame (Ck) + 2B TC-CRC (PTM-FCS)
426 +See also the Ethernet Correction Factors section below.
428 +.SS DOCSIS Cable Overhead Keyword
429 +DOCSIS is the universal standard for providing Internet service over cable-TV
432 +In this case, the actual on-wire overhead is less important than the packet size
433 +the head-end equipment uses for shaping and metering. This is specified to be
434 +an Ethernet frame including the CRC (aka FCS).
439 +.B overhead 18 mpu 64 noatm
441 +.SS Ethernet Overhead Keywords
445 + Accounts for Ethernet's preamble, inter-frame gap, and Frame Check
446 +Sequence. Use this keyword when the bottleneck being shaped for is an
447 +actual Ethernet cable.
450 +.B overhead 38 mpu 84 noatm
454 + Adds 4 bytes to the overhead compensation, accounting for an IEEE 802.1Q
455 +VLAN header appended to the Ethernet frame header. NB: Some ISPs use one or
456 +even two of these within PPPoE; this keyword may be repeated as necessary to
459 +.SH ROUND TRIP TIME PARAMETERS
460 +Active Queue Management (AQM) consists of embedding congestion signals in the
461 +packet flow, which receivers use to instruct senders to slow down when the queue
462 +is persistently occupied. CAKE uses ECN signalling when available, and packet
463 +drops otherwise, according to a combination of the Codel and BLUE AQM algorithms
466 +Very short latencies require a very rapid AQM response to adequately control
467 +latency. However, such a rapid response tends to impair throughput when the
468 +actual RTT is relatively long. CAKE allows specifying the RTT it assumes for
469 +tuning various parameters. Actual RTTs within an order of magnitude of this
470 +will generally work well for both throughput and latency management.
472 +At the 'lan' setting and below, the time constants are similar in magnitude to
473 +the jitter in the Linux kernel itself, so congestion might be signalled
474 +prematurely. The flows will then become sparse and total throughput reduced,
475 +leaving little or no back-pressure for the fairness logic to work against. Use
476 +the "metro" setting for local lans unless you have a custom kernel.
481 + Manually specify an RTT.
485 + For extremely high-performance 10GigE+ networks only. Equivalent to
490 + For pure Ethernet (not Wi-Fi) networks, at home or in the office. Don't
491 +use this when shaping for an Internet access link. Equivalent to
496 + For traffic mostly within a single city. Equivalent to
501 + For traffic mostly within a European-sized country. Equivalent to
507 + This is suitable for most Internet traffic. Equivalent to
512 + For Internet traffic with generally above-average latency, such as that
513 +suffered by Australasian residents. Equivalent to
518 + For traffic via geostationary satellites. Equivalent to
523 + So named because Jupiter is about 1 light-hour from Earth. Use this to
524 +(almost) completely disable AQM actions. Equivalent to
527 +.SH FLOW ISOLATION PARAMETERS
528 +With flow isolation enabled, CAKE places packets from different flows into
529 +different queues, each of which carries its own AQM state. Packets from each
530 +queue are then delivered fairly, according to a DRR++ algorithm which minimises
531 +latency for "sparse" flows. CAKE uses a set-associative hashing algorithm to
532 +minimise flow collisions.
534 +These keywords specify whether fairness based on source address, destination
535 +address, individual flows, or any combination of those is desired.
539 + Disables flow isolation; all traffic passes through a single queue for
544 + Flows are defined only by source address. Could be useful on the egress
545 +path of an ISP backhaul.
549 + Flows are defined only by destination address. Could be useful on the
550 +ingress path of an ISP backhaul.
554 + Flows are defined by source-destination host pairs. This is host
555 +isolation, rather than flow isolation.
559 + Flows are defined by the entire 5-tuple of source address, destination
560 +address, transport protocol, source port and destination port. This is the type
561 +of flow isolation performed by SFQ and fq_codel.
565 + Flows are defined by the 5-tuple, and fairness is applied first over
566 +source addresses, then over individual flows. Good for use on egress traffic
567 +from a LAN to the internet, where it'll prevent any one LAN host from
568 +monopolising the uplink, regardless of the number of flows they use.
572 + Flows are defined by the 5-tuple, and fairness is applied first over
573 +destination addresses, then over individual flows. Good for use on ingress
574 +traffic to a LAN from the internet, where it'll prevent any one LAN host from
575 +monopolising the downlink, regardless of the number of flows they use.
580 + Flows are defined by the 5-tuple, and fairness is applied over source
581 +*and* destination addresses intelligently (ie. not merely by host-pairs), and
582 +also over individual flows. Use this if you're not certain whether to use
583 +dual-srchost or dual-dsthost; it'll do both jobs at once, preventing any one
584 +host on *either* side of the link from monopolising it with a large number of
589 + Instructs Cake to perform a NAT lookup before applying flow-isolation
590 +rules, to determine the true addresses and port numbers of the packet, to
591 +improve fairness between hosts "inside" the NAT. This has no practical effect
592 +in "flowblind" or "flows" modes, or if NAT is performed on a different host.
597 + Cake will not perform a NAT lookup. Flow isolation will be performed
598 +using the addresses and port numbers directly visible to the interface Cake is
601 +.SH PRIORITY QUEUE PARAMETERS
602 +CAKE can divide traffic into "tins" based on the Diffserv field. Each tin has
603 +its own independent set of flow-isolation queues, and is serviced based on a WRR
604 +algorithm. To avoid perverse Diffserv marking incentives, tin weights have a
605 +"priority sharing" value when bandwidth used by that tin is below a threshold,
606 +and a lower "bandwidth sharing" value when above. Bandwidth is compared against
607 +the threshold using the same algorithm as the deficit-mode shaper.
609 +Detailed customisation of tin parameters is not provided. The following presets
610 +perform all necessary tuning, relative to the current shaper bandwidth and RTT
615 + Disables priority queuing by placing all traffic in one tin.
619 + Enables legacy interpretation of TOS "Precedence" field. Use of this
620 +preset on the modern Internet is firmly discouraged.
624 + Provides a general-purpose Diffserv implementation with four tins:
626 + Bulk (CS1), 6.25% threshold, generally low priority.
628 + Best Effort (general), 100% threshold.
630 + Video (AF4x, AF3x, CS3, AF2x, CS2, TOS4, TOS1), 50% threshold.
632 + Voice (CS7, CS6, EF, VA, CS5, CS4), 25% threshold.
637 + Provides a simple, general-purpose Diffserv implementation with three tins:
639 + Bulk (CS1), 6.25% threshold, generally low priority.
641 + Best Effort (general), 100% threshold.
643 + Voice (CS7, CS6, EF, VA, TOS4), 25% threshold, reduced Codel interval.
645 +.SH OTHER PARAMETERS
649 + Limit the memory consumed by Cake to LIMIT bytes. Note that this does
650 +not translate directly to queue size (so do not size this based on bandwidth
651 +delay product considerations, but rather on worst case acceptable memory
652 +consumption), as there is some overhead in the data structures containing the
653 +packets, especially for small packets.
655 + By default, the limit is calculated based on the bandwidth and RTT
662 + Traffic entering your diffserv domain is frequently mis-marked in
663 +transit from the perspective of your network, and traffic exiting yours may be
664 +mis-marked from the perspective of the transiting provider.
666 +Apply the wash option to clear all extra diffserv (but not ECN bits), after
667 +priority queuing has taken place.
669 +If you are shaping inbound, and cannot trust the diffserv markings (as is the
670 +case for Comcast Cable, among others), it is best to use a single queue
671 +"besteffort" mode with wash.
674 +# tc qdisc delete root dev eth0
676 +# tc qdisc add root dev eth0 cake bandwidth 100Mbit ethernet
678 +# tc -s qdisc show dev eth0
680 +qdisc cake 1: dev eth0 root refcnt 2 bandwidth 100Mbit diffserv3 triple-isolate rtt 100.0ms noatm overhead 38 mpu 84
681 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
682 + backlog 0b 0p requeues 0
683 + memory used: 0b of 5000000b
684 + capacity estimate: 100Mbit
685 + min/max network layer size: 65535 / 0
686 + min/max overhead-adjusted size: 65535 / 0
687 + average network hdr offset: 0
689 + Bulk Best Effort Voice
690 + thresh 6250Kbit 100Mbit 25Mbit
691 + target 5.0ms 5.0ms 5.0ms
692 + interval 100.0ms 100.0ms 100.0ms
693 + pk_delay 0us 0us 0us
694 + av_delay 0us 0us 0us
695 + sp_delay 0us 0us 0us
708 + quantum 300 1514 762
712 +# tc -s qdisc show dev eth0
714 +qdisc cake 1: root refcnt 2 bandwidth 100Mbit diffserv3 triple-isolate rtt 100.0ms noatm overhead 38 mpu 84
715 + Sent 44709231 bytes 31931 pkt (dropped 45, overlimits 93782 requeues 0)
716 + backlog 33308b 22p requeues 0
717 + memory used: 292352b of 5000000b
718 + capacity estimate: 100Mbit
719 + min/max network layer size: 28 / 1500
720 + min/max overhead-adjusted size: 84 / 1538
721 + average network hdr offset: 14
723 + Bulk Best Effort Voice
724 + thresh 6250Kbit 100Mbit 25Mbit
725 + target 5.0ms 5.0ms 5.0ms
726 + interval 100.0ms 100.0ms 100.0ms
727 + pk_delay 8.7ms 6.9ms 5.0ms
728 + av_delay 4.9ms 5.3ms 3.8ms
729 + sp_delay 727us 1.4ms 511us
730 + pkts 2590 21271 8137
731 + bytes 3081804 30302659 11426206
741 + max_len 1514 1514 1514
742 + quantum 300 1514 762
747 +.BR tc-fq_codel (8),
751 +Cake's principal author is Jonathan Morton, with contributions from
752 +Tony Ambardar, Kevin Darbyshire-Bryant, Toke Høiland-Jørgensen,
753 +Sebastian Moeller, Ryan Mounce, Dean Scarff, Nils Andreas Svee, and Dave Täht.
755 +This manual page was written by Loganaden Velvindron. Please report corrections
756 +to the Linux Networking mailing list <netdev@vger.kernel.org>.
759 @@ -64,6 +64,7 @@ TCMODULES += em_meta.o
760 TCMODULES += q_mqprio.o
761 TCMODULES += q_codel.o
762 TCMODULES += q_fq_codel.o
763 +TCMODULES += q_cake.o
770 +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
772 + * Common Applications Kept Enhanced -- CAKE
774 + * Copyright (C) 2014-2018 Jonathan Morton <chromatix99@gmail.com>
775 + * Copyright (C) 2017-2018 Toke Høiland-Jørgensen <toke@toke.dk>
784 +#include <sys/socket.h>
785 +#include <netinet/in.h>
786 +#include <arpa/inet.h>
790 +#include "tc_util.h"
792 +struct cake_preset {
794 + unsigned int target;
795 + unsigned int interval;
798 +static struct cake_preset presets[] = {
799 + {"datacentre", 5, 100},
801 + {"metro", 500, 10000},
802 + {"regional", 1500, 30000},
803 + {"internet", 5000, 100000},
804 + {"oceanic", 15000, 300000},
805 + {"satellite", 50000, 1000000},
806 + {"interplanetary", 50000000, 1000000000},
810 +static struct cake_preset *find_preset(char *argv)
814 + for (i = 0; i < ARRAY_SIZE(presets); i++)
815 + if (!strcmp(argv, presets[i].name))
816 + return &presets[i];
820 +static void explain(void)
823 +"Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
824 +" [ rtt TIME | datacentre | lan | metro | regional |\n"
825 +" internet* | oceanic | satellite | interplanetary ]\n"
826 +" [ besteffort | diffserv8 | diffserv4 | diffserv3* ]\n"
827 +" [ flowblind | srchost | dsthost | hosts | flows |\n"
828 +" dual-srchost | dual-dsthost | triple-isolate* ]\n"
829 +" [ nat | nonat* ]\n"
830 +" [ wash | nowash* ]\n"
831 +" [ ack-filter | ack-filter-aggressive | no-ack-filter* ]\n"
832 +" [ memlimit LIMIT ]\n"
833 +" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
834 +" [ mpu N ] [ ingress | egress* ]\n"
835 +" (* marks defaults)\n");
838 +static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
839 + struct nlmsghdr *n, const char *dev)
842 + __u64 bandwidth = 0;
843 + unsigned interval = 0;
844 + unsigned target = 0;
845 + unsigned diffserv = 0;
846 + unsigned memlimit = 0;
848 + bool overhead_set = false;
849 + bool overhead_override = false;
857 + int ack_filter = -1;
858 + struct rtattr *tail;
859 + struct cake_preset *preset, *preset_set = NULL;
862 + if (strcmp(*argv, "bandwidth") == 0) {
864 + if (get_rate64(&bandwidth, *argv)) {
865 + fprintf(stderr, "Illegal \"bandwidth\"\n");
870 + } else if (strcmp(*argv, "unlimited") == 0) {
874 + } else if (strcmp(*argv, "autorate_ingress") == 0) {
877 + } else if (strcmp(*argv, "rtt") == 0) {
879 + if (get_time(&interval, *argv)) {
880 + fprintf(stderr, "Illegal \"rtt\"\n");
883 + target = interval / 20;
886 + } else if ((preset = find_preset(*argv))) {
888 + duparg(*argv, preset_set->name);
889 + preset_set = preset;
890 + target = preset->target;
891 + interval = preset->interval;
893 + } else if (strcmp(*argv, "besteffort") == 0) {
894 + diffserv = CAKE_DIFFSERV_BESTEFFORT;
895 + } else if (strcmp(*argv, "precedence") == 0) {
896 + diffserv = CAKE_DIFFSERV_PRECEDENCE;
897 + } else if (strcmp(*argv, "diffserv8") == 0) {
898 + diffserv = CAKE_DIFFSERV_DIFFSERV8;
899 + } else if (strcmp(*argv, "diffserv4") == 0) {
900 + diffserv = CAKE_DIFFSERV_DIFFSERV4;
901 + } else if (strcmp(*argv, "diffserv") == 0) {
902 + diffserv = CAKE_DIFFSERV_DIFFSERV4;
903 + } else if (strcmp(*argv, "diffserv3") == 0) {
904 + diffserv = CAKE_DIFFSERV_DIFFSERV3;
906 + } else if (strcmp(*argv, "nowash") == 0) {
908 + } else if (strcmp(*argv, "wash") == 0) {
911 + } else if (strcmp(*argv, "flowblind") == 0) {
912 + flowmode = CAKE_FLOW_NONE;
913 + } else if (strcmp(*argv, "srchost") == 0) {
914 + flowmode = CAKE_FLOW_SRC_IP;
915 + } else if (strcmp(*argv, "dsthost") == 0) {
916 + flowmode = CAKE_FLOW_DST_IP;
917 + } else if (strcmp(*argv, "hosts") == 0) {
918 + flowmode = CAKE_FLOW_HOSTS;
919 + } else if (strcmp(*argv, "flows") == 0) {
920 + flowmode = CAKE_FLOW_FLOWS;
921 + } else if (strcmp(*argv, "dual-srchost") == 0) {
922 + flowmode = CAKE_FLOW_DUAL_SRC;
923 + } else if (strcmp(*argv, "dual-dsthost") == 0) {
924 + flowmode = CAKE_FLOW_DUAL_DST;
925 + } else if (strcmp(*argv, "triple-isolate") == 0) {
926 + flowmode = CAKE_FLOW_TRIPLE;
928 + } else if (strcmp(*argv, "nat") == 0) {
930 + } else if (strcmp(*argv, "nonat") == 0) {
933 + } else if (strcmp(*argv, "ptm") == 0) {
934 + atm = CAKE_ATM_PTM;
935 + } else if (strcmp(*argv, "atm") == 0) {
936 + atm = CAKE_ATM_ATM;
937 + } else if (strcmp(*argv, "noatm") == 0) {
938 + atm = CAKE_ATM_NONE;
940 + } else if (strcmp(*argv, "raw") == 0) {
941 + atm = CAKE_ATM_NONE;
943 + overhead_set = true;
944 + overhead_override = true;
945 + } else if (strcmp(*argv, "conservative") == 0) {
947 + * Deliberately over-estimate overhead:
948 + * one whole ATM cell plus ATM framing.
949 + * A safe choice if the actual overhead is unknown.
951 + atm = CAKE_ATM_ATM;
953 + overhead_set = true;
955 + /* Various ADSL framing schemes, all over ATM cells */
956 + } else if (strcmp(*argv, "ipoa-vcmux") == 0) {
957 + atm = CAKE_ATM_ATM;
959 + overhead_set = true;
960 + } else if (strcmp(*argv, "ipoa-llcsnap") == 0) {
961 + atm = CAKE_ATM_ATM;
963 + overhead_set = true;
964 + } else if (strcmp(*argv, "bridged-vcmux") == 0) {
965 + atm = CAKE_ATM_ATM;
967 + overhead_set = true;
968 + } else if (strcmp(*argv, "bridged-llcsnap") == 0) {
969 + atm = CAKE_ATM_ATM;
971 + overhead_set = true;
972 + } else if (strcmp(*argv, "pppoa-vcmux") == 0) {
973 + atm = CAKE_ATM_ATM;
975 + overhead_set = true;
976 + } else if (strcmp(*argv, "pppoa-llc") == 0) {
977 + atm = CAKE_ATM_ATM;
979 + overhead_set = true;
980 + } else if (strcmp(*argv, "pppoe-vcmux") == 0) {
981 + atm = CAKE_ATM_ATM;
983 + overhead_set = true;
984 + } else if (strcmp(*argv, "pppoe-llcsnap") == 0) {
985 + atm = CAKE_ATM_ATM;
987 + overhead_set = true;
989 + /* Typical VDSL2 framing schemes, both over PTM */
990 + /* PTM has 64b/65b coding which absorbs some bandwidth */
991 + } else if (strcmp(*argv, "pppoe-ptm") == 0) {
992 + /* 2B PPP + 6B PPPoE + 6B dest MAC + 6B src MAC
993 + * + 2B ethertype + 4B Frame Check Sequence
994 + * + 1B Start of Frame (S) + 1B End of Frame (Ck)
995 + * + 2B TC-CRC (PTM-FCS) = 30B
997 + atm = CAKE_ATM_PTM;
999 + overhead_set = true;
1000 + } else if (strcmp(*argv, "bridged-ptm") == 0) {
1001 + /* 6B dest MAC + 6B src MAC + 2B ethertype
1002 + * + 4B Frame Check Sequence
1003 + * + 1B Start of Frame (S) + 1B End of Frame (Ck)
1004 + * + 2B TC-CRC (PTM-FCS) = 22B
1006 + atm = CAKE_ATM_PTM;
1008 + overhead_set = true;
1010 + } else if (strcmp(*argv, "via-ethernet") == 0) {
1012 + * We used to use this flag to manually compensate for
1013 + * Linux including the Ethernet header on Ethernet-type
1014 + * interfaces, but not on IP-type interfaces.
1016 + * It is no longer needed, because Cake now adjusts for
1017 + * that automatically, and is thus ignored.
1019 + * It would be deleted entirely, but it appears in the
1020 + * stats output when the automatic compensation is
1024 + } else if (strcmp(*argv, "ethernet") == 0) {
1025 + /* ethernet pre-amble & interframe gap & FCS
1026 + * you may need to add vlan tag */
1028 + overhead_set = true;
1031 + /* Additional Ethernet-related overhead used by some ISPs */
1032 + } else if (strcmp(*argv, "ether-vlan") == 0) {
1033 + /* 802.1q VLAN tag - may be repeated */
1035 + overhead_set = true;
1038 + * DOCSIS cable shapers account for Ethernet frame with FCS,
1039 + * but not interframe gap or preamble.
1041 + } else if (strcmp(*argv, "docsis") == 0) {
1042 + atm = CAKE_ATM_NONE;
1044 + overhead_set = true;
1047 + } else if (strcmp(*argv, "overhead") == 0) {
1050 + overhead = strtol(*argv, &p, 10);
1051 + if(!p || *p || !*argv || overhead < -64 || overhead > 256) {
1052 + fprintf(stderr, "Illegal \"overhead\", valid range is -64 to 256\\n");
1055 + overhead_set = true;
1057 + } else if (strcmp(*argv, "mpu") == 0) {
1060 + mpu = strtol(*argv, &p, 10);
1061 + if(!p || *p || !*argv || mpu < 0 || mpu > 256) {
1062 + fprintf(stderr, "Illegal \"mpu\", valid range is 0 to 256\\n");
1066 + } else if (strcmp(*argv, "ingress") == 0) {
1068 + } else if (strcmp(*argv, "egress") == 0) {
1071 + } else if (strcmp(*argv, "no-ack-filter") == 0) {
1072 + ack_filter = CAKE_ACK_NONE;
1073 + } else if (strcmp(*argv, "ack-filter") == 0) {
1074 + ack_filter = CAKE_ACK_FILTER;
1075 + } else if (strcmp(*argv, "ack-filter-aggressive") == 0) {
1076 + ack_filter = CAKE_ACK_AGGRESSIVE;
1078 + } else if (strcmp(*argv, "memlimit") == 0) {
1080 + if(get_size(&memlimit, *argv)) {
1081 + fprintf(stderr, "Illegal value for \"memlimit\": \"%s\"\n", *argv);
1085 + } else if (strcmp(*argv, "help") == 0) {
1089 + fprintf(stderr, "What is \"%s\"?\n", *argv);
1096 + tail = NLMSG_TAIL(n);
1097 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
1098 + if (bandwidth || unlimited)
1099 + addattr_l(n, 1024, TCA_CAKE_BASE_RATE64, &bandwidth, sizeof(bandwidth));
1101 + addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
1103 + addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
1104 + if (flowmode != -1)
1105 + addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
1107 + addattr_l(n, 1024, TCA_CAKE_OVERHEAD, &overhead, sizeof(overhead));
1108 + if (overhead_override) {
1109 + unsigned zero = 0;
1110 + addattr_l(n, 1024, TCA_CAKE_RAW, &zero, sizeof(zero));
1113 + addattr_l(n, 1024, TCA_CAKE_MPU, &mpu, sizeof(mpu));
1115 + addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
1117 + addattr_l(n, 1024, TCA_CAKE_TARGET, &target, sizeof(target));
1118 + if (autorate != -1)
1119 + addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate));
1121 + addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit));
1123 + addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
1125 + addattr_l(n, 1024, TCA_CAKE_WASH, &wash, sizeof(wash));
1126 + if (ingress != -1)
1127 + addattr_l(n, 1024, TCA_CAKE_INGRESS, &ingress, sizeof(ingress));
1128 + if (ack_filter != -1)
1129 + addattr_l(n, 1024, TCA_CAKE_ACK_FILTER, &ack_filter, sizeof(ack_filter));
1131 + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
1136 +static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1138 + struct rtattr *tb[TCA_CAKE_MAX + 1];
1139 + __u64 bandwidth = 0;
1140 + unsigned diffserv = 0;
1141 + unsigned flowmode = 0;
1142 + unsigned interval = 0;
1143 + unsigned memlimit = 0;
1152 + int ack_filter = 0;
1153 + int split_gso = 0;
1160 + parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
1162 + if (tb[TCA_CAKE_BASE_RATE64] &&
1163 + RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE64]) >= sizeof(bandwidth)) {
1164 + bandwidth = rta_getattr_u64(tb[TCA_CAKE_BASE_RATE64]);
1166 + print_uint(PRINT_JSON, "bandwidth", NULL, bandwidth);
1167 + print_string(PRINT_FP, NULL, "bandwidth %s ", sprint_rate(bandwidth, b1));
1169 + print_string(PRINT_ANY, "bandwidth", "bandwidth %s ", "unlimited");
1171 + if (tb[TCA_CAKE_AUTORATE] &&
1172 + RTA_PAYLOAD(tb[TCA_CAKE_AUTORATE]) >= sizeof(__u32)) {
1173 + autorate = rta_getattr_u32(tb[TCA_CAKE_AUTORATE]);
1175 + print_string(PRINT_ANY, "autorate", "autorate_%s ", "ingress");
1177 + print_string(PRINT_ANY, "autorate", "(?autorate?) ", "unknown");
1179 + if (tb[TCA_CAKE_DIFFSERV_MODE] &&
1180 + RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
1181 + diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
1182 + switch(diffserv) {
1183 + case CAKE_DIFFSERV_DIFFSERV3:
1184 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv3");
1186 + case CAKE_DIFFSERV_DIFFSERV4:
1187 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv4");
1189 + case CAKE_DIFFSERV_DIFFSERV8:
1190 + print_string(PRINT_ANY, "diffserv", "%s ", "diffserv8");
1192 + case CAKE_DIFFSERV_BESTEFFORT:
1193 + print_string(PRINT_ANY, "diffserv", "%s ", "besteffort");
1195 + case CAKE_DIFFSERV_PRECEDENCE:
1196 + print_string(PRINT_ANY, "diffserv", "%s ", "precedence");
1199 + print_string(PRINT_ANY, "diffserv", "(?diffserv?) ", "unknown");
1203 + if (tb[TCA_CAKE_FLOW_MODE] &&
1204 + RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
1205 + flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
1206 + switch(flowmode) {
1207 + case CAKE_FLOW_NONE:
1208 + print_string(PRINT_ANY, "flowmode", "%s ", "flowblind");
1210 + case CAKE_FLOW_SRC_IP:
1211 + print_string(PRINT_ANY, "flowmode", "%s ", "srchost");
1213 + case CAKE_FLOW_DST_IP:
1214 + print_string(PRINT_ANY, "flowmode", "%s ", "dsthost");
1216 + case CAKE_FLOW_HOSTS:
1217 + print_string(PRINT_ANY, "flowmode", "%s ", "hosts");
1219 + case CAKE_FLOW_FLOWS:
1220 + print_string(PRINT_ANY, "flowmode", "%s ", "flows");
1222 + case CAKE_FLOW_DUAL_SRC:
1223 + print_string(PRINT_ANY, "flowmode", "%s ", "dual-srchost");
1225 + case CAKE_FLOW_DUAL_DST:
1226 + print_string(PRINT_ANY, "flowmode", "%s ", "dual-dsthost");
1228 + case CAKE_FLOW_TRIPLE:
1229 + print_string(PRINT_ANY, "flowmode", "%s ", "triple-isolate");
1232 + print_string(PRINT_ANY, "flowmode", "(?flowmode?) ", "unknown");
1238 + if (tb[TCA_CAKE_NAT] &&
1239 + RTA_PAYLOAD(tb[TCA_CAKE_NAT]) >= sizeof(__u32)) {
1240 + nat = rta_getattr_u32(tb[TCA_CAKE_NAT]);
1244 + print_string(PRINT_FP, NULL, "nat ", NULL);
1245 + print_bool(PRINT_JSON, "nat", NULL, nat);
1247 + if (tb[TCA_CAKE_WASH] &&
1248 + RTA_PAYLOAD(tb[TCA_CAKE_WASH]) >= sizeof(__u32)) {
1249 + wash = rta_getattr_u32(tb[TCA_CAKE_WASH]);
1251 + if (tb[TCA_CAKE_ATM] &&
1252 + RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
1253 + atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
1255 + if (tb[TCA_CAKE_OVERHEAD] &&
1256 + RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__s32)) {
1257 + overhead = *(__s32 *) RTA_DATA(tb[TCA_CAKE_OVERHEAD]);
1259 + if (tb[TCA_CAKE_MPU] &&
1260 + RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
1261 + mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
1263 + if (tb[TCA_CAKE_INGRESS] &&
1264 + RTA_PAYLOAD(tb[TCA_CAKE_INGRESS]) >= sizeof(__u32)) {
1265 + ingress = rta_getattr_u32(tb[TCA_CAKE_INGRESS]);
1267 + if (tb[TCA_CAKE_ACK_FILTER] &&
1268 + RTA_PAYLOAD(tb[TCA_CAKE_ACK_FILTER]) >= sizeof(__u32)) {
1269 + ack_filter = rta_getattr_u32(tb[TCA_CAKE_ACK_FILTER]);
1271 + if (tb[TCA_CAKE_SPLIT_GSO] &&
1272 + RTA_PAYLOAD(tb[TCA_CAKE_SPLIT_GSO]) >= sizeof(__u32)) {
1273 + split_gso = rta_getattr_u32(tb[TCA_CAKE_SPLIT_GSO]);
1275 + if (tb[TCA_CAKE_RAW]) {
1278 + if (tb[TCA_CAKE_RTT] &&
1279 + RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) {
1280 + interval = rta_getattr_u32(tb[TCA_CAKE_RTT]);
1284 + print_string(PRINT_FP, NULL, "wash ", NULL);
1285 + print_bool(PRINT_JSON, "wash", NULL, wash);
1288 + print_string(PRINT_FP, NULL, "ingress ", NULL);
1289 + print_bool(PRINT_JSON, "ingress", NULL, ingress);
1291 + if (ack_filter == CAKE_ACK_AGGRESSIVE)
1292 + print_string(PRINT_ANY, "ack-filter", "ack-filter-%s ", "aggressive");
1293 + else if (ack_filter == CAKE_ACK_FILTER)
1294 + print_string(PRINT_ANY, "ack-filter", "ack-filter ", "enabled");
1296 + print_string(PRINT_JSON, "ack-filter", NULL, "disabled");
1299 + print_string(PRINT_FP, NULL, "split-gso ", NULL);
1300 + print_bool(PRINT_JSON, "split_gso", NULL, split_gso);
1303 + print_string(PRINT_FP, NULL, "rtt %s ", sprint_time(interval, b2));
1304 + print_uint(PRINT_JSON, "rtt", NULL, interval);
1307 + print_string(PRINT_FP, NULL, "raw ", NULL);
1308 + print_bool(PRINT_JSON, "raw", NULL, raw);
1310 + if (atm == CAKE_ATM_ATM)
1311 + print_string(PRINT_ANY, "atm", "%s ", "atm");
1312 + else if (atm == CAKE_ATM_PTM)
1313 + print_string(PRINT_ANY, "atm", "%s ", "ptm");
1315 + print_string(PRINT_ANY, "atm", "%s ", "noatm");
1317 + print_int(PRINT_ANY, "overhead", "overhead %d ", overhead);
1320 + print_uint(PRINT_ANY, "mpu", "mpu %u ", mpu);
1323 + print_uint(PRINT_JSON, "memlimit", NULL, memlimit);
1324 + print_string(PRINT_FP, NULL, "memlimit %s", sprint_size(memlimit, b1));
1330 +static void cake_print_json_tin(struct rtattr **tstat)
1332 +#define PRINT_TSTAT_JSON(type, name, attr) if (tstat[TCA_CAKE_TIN_STATS_ ## attr]) \
1333 + print_u64(PRINT_JSON, name, NULL, \
1334 + rta_getattr_ ## type((struct rtattr *)tstat[TCA_CAKE_TIN_STATS_ ## attr]))
1336 + open_json_object(NULL);
1337 + PRINT_TSTAT_JSON(u64, "threshold_rate", THRESHOLD_RATE64);
1338 + PRINT_TSTAT_JSON(u64, "sent_bytes", SENT_BYTES64);
1339 + PRINT_TSTAT_JSON(u32, "backlog_bytes", BACKLOG_BYTES);
1340 + PRINT_TSTAT_JSON(u32, "target_us", TARGET_US);
1341 + PRINT_TSTAT_JSON(u32, "interval_us", INTERVAL_US);
1342 + PRINT_TSTAT_JSON(u32, "peak_delay_us", PEAK_DELAY_US);
1343 + PRINT_TSTAT_JSON(u32, "avg_delay_us", AVG_DELAY_US);
1344 + PRINT_TSTAT_JSON(u32, "base_delay_us", BASE_DELAY_US);
1345 + PRINT_TSTAT_JSON(u32, "sent_packets", SENT_PACKETS);
1346 + PRINT_TSTAT_JSON(u32, "way_indirect_hits", WAY_INDIRECT_HITS);
1347 + PRINT_TSTAT_JSON(u32, "way_misses", WAY_MISSES);
1348 + PRINT_TSTAT_JSON(u32, "way_collisions", WAY_COLLISIONS);
1349 + PRINT_TSTAT_JSON(u32, "drops", DROPPED_PACKETS);
1350 + PRINT_TSTAT_JSON(u32, "ecn_mark", ECN_MARKED_PACKETS);
1351 + PRINT_TSTAT_JSON(u32, "ack_drops", ACKS_DROPPED_PACKETS);
1352 + PRINT_TSTAT_JSON(u32, "sparse_flows", SPARSE_FLOWS);
1353 + PRINT_TSTAT_JSON(u32, "bulk_flows", BULK_FLOWS);
1354 + PRINT_TSTAT_JSON(u32, "unresponsive_flows", UNRESPONSIVE_FLOWS);
1355 + PRINT_TSTAT_JSON(u32, "max_pkt_len", MAX_SKBLEN);
1356 + PRINT_TSTAT_JSON(u32, "flow_quantum", FLOW_QUANTUM);
1357 + close_json_object();
1359 +#undef PRINT_TSTAT_JSON
1362 +static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
1363 + struct rtattr *xstats)
1366 + struct rtattr *st[TCA_CAKE_STATS_MAX + 1];
1369 + if (xstats == NULL)
1372 +#define GET_STAT_U32(attr) rta_getattr_u32(st[TCA_CAKE_STATS_ ## attr])
1373 +#define GET_STAT_S32(attr) (*(__s32*)RTA_DATA(st[TCA_CAKE_STATS_ ## attr]))
1374 +#define GET_STAT_U64(attr) rta_getattr_u64(st[TCA_CAKE_STATS_ ## attr])
1376 + parse_rtattr_nested(st, TCA_CAKE_STATS_MAX, xstats);
1378 + if (st[TCA_CAKE_STATS_MEMORY_USED] &&
1379 + st[TCA_CAKE_STATS_MEMORY_LIMIT]) {
1380 + print_string(PRINT_FP, NULL, " memory used: %s",
1381 + sprint_size(GET_STAT_U32(MEMORY_USED), b1));
1383 + print_string(PRINT_FP, NULL, " of %s\n",
1384 + sprint_size(GET_STAT_U32(MEMORY_LIMIT), b1));
1386 + print_uint(PRINT_JSON, "memory_used", NULL,
1387 + GET_STAT_U32(MEMORY_USED));
1388 + print_uint(PRINT_JSON, "memory_limit", NULL,
1389 + GET_STAT_U32(MEMORY_LIMIT));
1392 + if (st[TCA_CAKE_STATS_CAPACITY_ESTIMATE64]) {
1393 + print_string(PRINT_FP, NULL, " capacity estimate: %s\n",
1394 + sprint_rate(GET_STAT_U64(CAPACITY_ESTIMATE64), b1));
1395 + print_uint(PRINT_JSON, "capacity_estimate", NULL,
1396 + GET_STAT_U64(CAPACITY_ESTIMATE64));
1399 + if (st[TCA_CAKE_STATS_MIN_NETLEN] &&
1400 + st[TCA_CAKE_STATS_MAX_NETLEN]) {
1401 + print_uint(PRINT_ANY, "min_network_size",
1402 + " min/max network layer size: %8u",
1403 + GET_STAT_U32(MIN_NETLEN));
1404 + print_uint(PRINT_ANY, "max_network_size",
1405 + " /%8u\n", GET_STAT_U32(MAX_NETLEN));
1408 + if (st[TCA_CAKE_STATS_MIN_ADJLEN] &&
1409 + st[TCA_CAKE_STATS_MAX_ADJLEN]) {
1410 + print_uint(PRINT_ANY, "min_adj_size",
1411 + " min/max overhead-adjusted size: %8u",
1412 + GET_STAT_U32(MIN_ADJLEN));
1413 + print_uint(PRINT_ANY, "max_adj_size",
1414 + " /%8u\n", GET_STAT_U32(MAX_ADJLEN));
1417 + if (st[TCA_CAKE_STATS_AVG_NETOFF])
1418 + print_uint(PRINT_ANY, "avg_hdr_offset",
1419 + " average network hdr offset: %8u\n\n",
1420 + GET_STAT_U32(AVG_NETOFF));
1423 + if (st[TCA_CAKE_STATS_DEFICIT])
1424 + print_int(PRINT_ANY, "deficit", " deficit %u",
1425 + GET_STAT_S32(DEFICIT));
1426 + if (st[TCA_CAKE_STATS_COBALT_COUNT])
1427 + print_uint(PRINT_ANY, "count", " count %u",
1428 + GET_STAT_U32(COBALT_COUNT));
1430 + if (st[TCA_CAKE_STATS_DROPPING] && GET_STAT_U32(DROPPING)) {
1431 + print_bool(PRINT_ANY, "dropping", " dropping", true);
1432 + if (st[TCA_CAKE_STATS_DROP_NEXT_US]) {
1433 + int drop_next = GET_STAT_S32(DROP_NEXT_US);
1434 + if (drop_next < 0) {
1435 + print_string(PRINT_FP, NULL, " drop_next -%s",
1436 + sprint_time(drop_next, b1));
1438 + print_uint(PRINT_JSON, "drop_next", NULL,
1440 + print_string(PRINT_FP, NULL, " drop_next %s",
1441 + sprint_time(drop_next, b1));
1446 + if (st[TCA_CAKE_STATS_P_DROP]) {
1447 + print_uint(PRINT_ANY, "blue_prob", " blue_prob %u",
1448 + GET_STAT_U32(P_DROP));
1449 + if (st[TCA_CAKE_STATS_BLUE_TIMER_US]) {
1450 + int blue_timer = GET_STAT_S32(BLUE_TIMER_US);
1451 + if (blue_timer < 0) {
1452 + print_string(PRINT_FP, NULL, " blue_timer -%s",
1453 + sprint_time(blue_timer, b1));
1455 + print_uint(PRINT_JSON, "blue_timer", NULL,
1457 + print_string(PRINT_FP, NULL, " blue_timer %s",
1458 + sprint_time(blue_timer, b1));
1463 +#undef GET_STAT_U32
1464 +#undef GET_STAT_S32
1465 +#undef GET_STAT_U64
1467 + if (st[TCA_CAKE_STATS_TIN_STATS]) {
1468 + struct rtattr *tins[TC_CAKE_MAX_TINS + 1];
1469 + struct rtattr *tstat[TC_CAKE_MAX_TINS][TCA_CAKE_TIN_STATS_MAX + 1];
1472 + parse_rtattr_nested(tins, TC_CAKE_MAX_TINS, st[TCA_CAKE_STATS_TIN_STATS]);
1474 + for (i = 1; i <= TC_CAKE_MAX_TINS && tins[i]; i++) {
1475 + parse_rtattr_nested(tstat[i-1], TCA_CAKE_TIN_STATS_MAX, tins[i]);
1482 + if (is_json_context()) {
1483 + open_json_array(PRINT_JSON, "tins");
1484 + for (i = 0; i < num_tins; i++)
1485 + cake_print_json_tin(tstat[i]);
1486 + close_json_array(PRINT_JSON, NULL);
1492 + switch(num_tins) {
1494 + fprintf(f, " Bulk Best Effort Voice\n");
1498 + fprintf(f, " Bulk Best Effort Video Voice\n");
1503 + for(i=0; i < num_tins; i++)
1504 + fprintf(f, " Tin %u", i);
1508 +#define GET_TSTAT(i, attr) (tstat[i][TCA_CAKE_TIN_STATS_ ## attr])
1509 +#define PRINT_TSTAT(name, attr, fmts, val) do { \
1510 + if (GET_TSTAT(0, attr)) { \
1511 + fprintf(f, name); \
1512 + for (i = 0; i < num_tins; i++) \
1513 + fprintf(f, " %12" fmts, val); \
1514 + fprintf(f, "\n"); \
1518 +#define SPRINT_TSTAT(pfunc, type, name, attr) PRINT_TSTAT( \
1519 + name, attr, "s", sprint_ ## pfunc( \
1520 + rta_getattr_ ## type(GET_TSTAT(i, attr)), b1))
1522 +#define PRINT_TSTAT_U32(name, attr) PRINT_TSTAT( \
1523 + name, attr, "u", rta_getattr_u32(GET_TSTAT(i, attr)))
1525 +#define PRINT_TSTAT_U64(name, attr) PRINT_TSTAT( \
1526 + name, attr, "llu", rta_getattr_u64(GET_TSTAT(i, attr)))
1528 + SPRINT_TSTAT(rate, u64, " thresh ", THRESHOLD_RATE64);
1529 + SPRINT_TSTAT(time, u32, " target ", TARGET_US);
1530 + SPRINT_TSTAT(time, u32, " interval", INTERVAL_US);
1531 + SPRINT_TSTAT(time, u32, " pk_delay", PEAK_DELAY_US);
1532 + SPRINT_TSTAT(time, u32, " av_delay", AVG_DELAY_US);
1533 + SPRINT_TSTAT(time, u32, " sp_delay", BASE_DELAY_US);
1534 + SPRINT_TSTAT(size, u32, " backlog ", BACKLOG_BYTES);
1536 + PRINT_TSTAT_U32(" pkts ", SENT_PACKETS);
1537 + PRINT_TSTAT_U64(" bytes ", SENT_BYTES64);
1539 + PRINT_TSTAT_U32(" way_inds", WAY_INDIRECT_HITS);
1540 + PRINT_TSTAT_U32(" way_miss", WAY_MISSES);
1541 + PRINT_TSTAT_U32(" way_cols", WAY_COLLISIONS);
1542 + PRINT_TSTAT_U32(" drops ", DROPPED_PACKETS);
1543 + PRINT_TSTAT_U32(" marks ", ECN_MARKED_PACKETS);
1544 + PRINT_TSTAT_U32(" ack_drop", ACKS_DROPPED_PACKETS);
1545 + PRINT_TSTAT_U32(" sp_flows", SPARSE_FLOWS);
1546 + PRINT_TSTAT_U32(" bk_flows", BULK_FLOWS);
1547 + PRINT_TSTAT_U32(" un_flows", UNRESPONSIVE_FLOWS);
1548 + PRINT_TSTAT_U32(" max_len ", MAX_SKBLEN);
1549 + PRINT_TSTAT_U32(" quantum ", FLOW_QUANTUM);
1553 +#undef SPRINT_TSTAT
1554 +#undef PRINT_TSTAT_U32
1555 +#undef PRINT_TSTAT_U64
1560 +struct qdisc_util cake_qdisc_util = {
1562 + .parse_qopt = cake_parse_opt,
1563 + .print_qopt = cake_print_opt,
1564 + .print_xstats = cake_print_xstats,
1566 --- a/tc/q_ingress.c
1567 +++ b/tc/q_ingress.c
1568 @@ -40,7 +40,7 @@ static int ingress_parse_opt(struct qdis
1569 static int ingress_print_opt(struct qdisc_util *qu, FILE *f,
1572 - fprintf(f, "---------------- ");
1573 + print_string(PRINT_FP, NULL, "---------------- ", NULL);