X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=package%2Fnetwork%2Futils%2Fiproute2%2Fpatches%2F950-add-cake-to-tc.patch;h=eacad074f1e47f997e483d1dd15ee9db653d4e6a;hb=db18cee2d75d88e2ae88e3d1f75b5b3359ed6f19;hp=5e5178498a7d589056ac19f043c535500339f2d4;hpb=56cf1adc506a1b981a8ad8dd318c6bd9cf95f43f;p=openwrt%2Fstaging%2Fdedeckeh.git diff --git a/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch index 5e5178498a..eacad074f1 100644 --- a/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch +++ b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch @@ -1,6 +1,6 @@ --- a/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h -@@ -850,4 +850,56 @@ struct tc_pie_xstats { +@@ -871,4 +871,60 @@ struct tc_pie_xstats { __u32 maxq; /* maximum queue size */ __u32 ecn_mark; /* packets marked with ecn*/ }; @@ -17,6 +17,10 @@ + TCA_CAKE_TARGET, + TCA_CAKE_AUTORATE, + TCA_CAKE_MEMORY, ++ TCA_CAKE_NAT, ++ TCA_CAKE_ETHERNET, ++ TCA_CAKE_WASH, ++ TCA_CAKE_MPU, + __TCA_CAKE_MAX +}; +#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1) @@ -59,17 +63,17 @@ #endif --- a/tc/Makefile +++ b/tc/Makefile -@@ -63,6 +63,7 @@ TCMODULES += q_codel.o +@@ -69,6 +69,7 @@ TCMODULES += q_codel.o TCMODULES += q_fq_codel.o TCMODULES += q_fq.o TCMODULES += q_pie.o +TCMODULES += q_cake.o TCMODULES += q_hhf.o + TCMODULES += q_clsact.o TCMODULES += e_bpf.o - --- /dev/null +++ b/tc/q_cake.c -@@ -0,0 +1,600 @@ +@@ -0,0 +1,692 @@ +/* + * Common Applications Kept Enhanced -- CAKE + * @@ -123,13 +127,20 @@ + +static void explain(void) +{ -+ fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n" -+ " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n" -+ " [ besteffort | precedence | diffserv8 | diffserv4* ]\n" -+ " [ flowblind | srchost | dsthost | hosts | flows* | dual-srchost | dual-dsthost | triple-isolate ]\n" -+ " [ atm | noatm* ] [ overhead N | conservative | raw* ]\n" -+ " [ memlimit LIMIT ]\n" -+ " (* marks defaults)\n"); ++ fprintf(stderr, ++"Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n" ++" [ rtt TIME | datacentre | lan | metro | regional |\n" ++" internet* | oceanic | satellite | interplanetary ]\n" ++" [ besteffort | diffserv8 | diffserv4 | diffserv-llt |\n" ++" diffserv3* ]\n" ++" [ flowblind | srchost | dsthost | hosts | flows |\n" ++" dual-srchost | dual-dsthost | triple-isolate* ]\n" ++" [ nat | nonat* ]\n" ++" [ wash | nowash * ]\n" ++" [ memlimit LIMIT ]\n" ++" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n" ++" [ mpu N ]\n" ++" (* marks defaults)\n"); +} + +static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv, @@ -143,7 +154,11 @@ + unsigned memlimit = 0; + int overhead = 0; + bool overhead_set = false; ++ bool overhead_override = false; ++ int wash = -1; ++ int mpu = 0; + int flowmode = -1; ++ int nat = -1; + int atm = -1; + int autorate = -1; + struct rtattr *tail; @@ -210,6 +225,13 @@ + diffserv = 4; + } else if (strcmp(*argv, "diffserv-llt") == 0) { + diffserv = 5; ++ } else if (strcmp(*argv, "diffserv3") == 0) { ++ diffserv = 6; ++ ++ } else if (strcmp(*argv, "nowash") == 0) { ++ wash = 0; ++ } else if (strcmp(*argv, "wash") == 0) { ++ wash = 1; + + } else if (strcmp(*argv, "flowblind") == 0) { + flowmode = 0; @@ -228,6 +250,13 @@ + } else if (strcmp(*argv, "triple-isolate") == 0) { + flowmode = 7; + ++ } else if (strcmp(*argv, "nat") == 0) { ++ nat = 1; ++ } else if (strcmp(*argv, "nonat") == 0) { ++ nat = 0; ++ ++ } else if (strcmp(*argv, "ptm") == 0) { ++ atm = 2; + } else if (strcmp(*argv, "atm") == 0) { + atm = 1; + } else if (strcmp(*argv, "noatm") == 0) { @@ -237,6 +266,7 @@ + atm = 0; + overhead = 0; + overhead_set = true; ++ overhead_override = true; + } else if (strcmp(*argv, "conservative") == 0) { + /* + * Deliberately over-estimate overhead: @@ -247,7 +277,7 @@ + overhead = 48; + overhead_set = true; + -+ /* Various ADSL framing schemes */ ++ /* Various ADSL framing schemes, all over ATM cells */ + } else if (strcmp(*argv, "ipoa-vcmux") == 0) { + atm = 1; + overhead += 8; @@ -281,48 +311,53 @@ + overhead += 40; + overhead_set = true; + -+ /* Typical VDSL2 framing schemes */ -+ /* NB: PTM includes HDLC's 0x7D/7E expansion, adds extra 1/128 */ ++ /* Typical VDSL2 framing schemes, both over PTM */ ++ /* PTM has 64b/65b coding which absorbs some bandwidth */ + } else if (strcmp(*argv, "pppoe-ptm") == 0) { -+ atm = 0; ++ atm = 2; + overhead += 27; ++ overhead_set = true; + } else if (strcmp(*argv, "bridged-ptm") == 0) { -+ atm = 0; ++ atm = 2; + overhead += 19; ++ overhead_set = true; + + } else if (strcmp(*argv, "via-ethernet") == 0) { + /* -+ * The above overheads are relative to an IP packet, -+ * but if the physical interface is Ethernet, Linux -+ * includes Ethernet framing overhead already. ++ * We used to use this flag to manually compensate for ++ * Linux including the Ethernet header on Ethernet-type ++ * interfaces, but not on IP-type interfaces. ++ * ++ * It is no longer needed, because Cake now adjusts for ++ * that automatically, and is thus ignored. ++ * ++ * It would be deleted entirely, but it appears in the ++ * stats output when the automatic compensation is active. + */ -+ overhead -= 14; -+ overhead_set = true; + -+ /* Additional Ethernet-related overheads used by some ISPs */ -+ } else if (strcmp(*argv, "ether-phy") == 0) { -+ /* ethernet pre-amble & interframe gap 20 bytes -+ * Linux will have already accounted for MACs & frame type 14 bytes -+ * you probably want to add an FCS as well*/ -+ overhead += 20; -+ overhead_set = true; -+ } else if (strcmp(*argv, "ether-all") == 0) { ++ } else if (strcmp(*argv, "ethernet") == 0) { + /* ethernet pre-amble & interframe gap & FCS -+ * Linux will have already accounted for MACs & frame type 14 bytes -+ * you may need to add vlan tag*/ -+ overhead += 24; ++ * you may need to add vlan tag */ ++ overhead += 38; + overhead_set = true; ++ mpu = 84; + -+ } else if (strcmp(*argv, "ether-fcs") == 0) { -+ /* Frame Check Sequence */ -+ /* we ignore the minimum frame size, because IP packets usually meet it */ -+ overhead += 4; -+ overhead_set = true; ++ /* Additional Ethernet-related overhead used by some ISPs */ + } else if (strcmp(*argv, "ether-vlan") == 0) { + /* 802.1q VLAN tag - may be repeated */ + overhead += 4; + overhead_set = true; + ++ /* ++ * DOCSIS cable shapers account for Ethernet frame with FCS, ++ * but not interframe gap nor preamble. ++ */ ++ } else if (strcmp(*argv, "docsis") == 0) { ++ atm = 0; ++ overhead += 18; ++ overhead_set = true; ++ mpu = 64; ++ + } else if (strcmp(*argv, "overhead") == 0) { + char* p = NULL; + NEXT_ARG(); @@ -333,6 +368,15 @@ + } + overhead_set = true; + ++ } else if (strcmp(*argv, "mpu") == 0) { ++ char* p = NULL; ++ NEXT_ARG(); ++ mpu = strtol(*argv, &p, 10); ++ if(!p || *p || !*argv || mpu < 0 || mpu > 256) { ++ fprintf(stderr, "Illegal \"mpu\", valid range is 0 to 256\\n"); ++ return -1; ++ } ++ + } else if (strcmp(*argv, "memlimit") == 0) { + NEXT_ARG(); + if(get_size(&memlimit, *argv)) { @@ -363,6 +407,12 @@ + addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode)); + if (overhead_set) + addattr_l(n, 1024, TCA_CAKE_OVERHEAD, &overhead, sizeof(overhead)); ++ if (overhead_override) { ++ unsigned zero = 0; ++ addattr_l(n, 1024, TCA_CAKE_ETHERNET, &zero, sizeof(zero)); ++ } ++ if (mpu > 0) ++ addattr_l(n, 1024, TCA_CAKE_MPU, &mpu, sizeof(mpu)); + if (interval) + addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval)); + if (target) @@ -371,6 +421,10 @@ + addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate)); + if (memlimit) + addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit)); ++ if (nat != -1) ++ addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat)); ++ if (wash != -1) ++ addattr_l(n, 1024, TCA_CAKE_WASH, &wash, sizeof(wash)); + + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; + return 0; @@ -386,8 +440,12 @@ + unsigned interval = 0; + unsigned memlimit = 0; + int overhead = 0; ++ int ethernet = 0; ++ int mpu = 0; + int atm = 0; ++ int nat = 0; + int autorate = 0; ++ int wash = 0; + SPRINT_BUF(b1); + SPRINT_BUF(b2); + @@ -431,6 +489,9 @@ + case 5: + fprintf(f, "diffserv-llt "); + break; ++ case 6: ++ fprintf(f, "diffserv3 "); ++ break; + default: + fprintf(f, "(?diffserv?) "); + break; @@ -439,6 +500,8 @@ + if (tb[TCA_CAKE_FLOW_MODE] && + RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) { + flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]); ++ nat = !!(flowmode & 64); ++ flowmode &= ~64; + switch(flowmode) { + case 0: + fprintf(f, "flowblind "); @@ -468,6 +531,13 @@ + fprintf(f, "(?flowmode?) "); + break; + }; ++ ++ if(nat) ++ fprintf(f, "nat "); ++ } ++ if (tb[TCA_CAKE_WASH] && ++ RTA_PAYLOAD(tb[TCA_CAKE_WASH]) >= sizeof(__u32)) { ++ wash = rta_getattr_u32(tb[TCA_CAKE_WASH]); + } + if (tb[TCA_CAKE_ATM] && + RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) { @@ -477,24 +547,46 @@ + RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) { + overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]); + } ++ if (tb[TCA_CAKE_MPU] && ++ RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) { ++ mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]); ++ } ++ if (tb[TCA_CAKE_ETHERNET] && ++ RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) { ++ ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]); ++ } + if (tb[TCA_CAKE_RTT] && + RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) { + interval = rta_getattr_u32(tb[TCA_CAKE_RTT]); + } + ++ if (wash) ++ fprintf(f,"wash "); ++ + if (interval) + fprintf(f, "rtt %s ", sprint_time(interval, b2)); + -+ if (atm) -+ fprintf(f, "atm "); -+ else if (overhead) -+ fprintf(f, "noatm "); ++ if (!atm && overhead == ethernet) { ++ fprintf(f, "raw "); ++ } else { ++ if (atm == 1) ++ fprintf(f, "atm "); ++ else if (atm == 2) ++ fprintf(f, "ptm "); ++ else ++ fprintf(f, "noatm "); + -+ if (overhead || atm) + fprintf(f, "overhead %d ", overhead); + -+ if (!atm && !overhead) -+ fprintf(f, "raw "); ++ // This is actually the *amount* of automatic compensation, but we only report ++ // its presence as a boolean for now. ++ if (ethernet) ++ fprintf(f, "via-ethernet "); ++ } ++ ++ if (mpu) { ++ fprintf(f, "mpu %d ", mpu); ++ } + + if (memlimit) + fprintf(f, "memlimit %s", sprint_size(memlimit, b1)); @@ -557,6 +649,10 @@ + fprintf(f, " capacity estimate: %s\n", sprint_rate(stnc->capacity_estimate, b1)); + + switch(stnc->tin_cnt) { ++ case 3: ++ fprintf(f, " Bulk Best Effort Voice\n"); ++ break; ++ + case 4: + fprintf(f, " Bulk Best Effort Video Voice\n"); + break;