iproute2: cake: add 'mpu' minimum packet length support

Add 'mpu' minimum length packet size parameter for scheduling/bandwidth
accounting.

Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
This commit is contained in:
Kevin Darbyshire-Bryant 2016-12-31 17:15:56 +00:00 committed by Jo-Philipp Wich
parent e38bafb65a
commit a40f3f90d6
2 changed files with 28 additions and 4 deletions

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=iproute2 PKG_NAME:=iproute2
PKG_VERSION:=4.4.0 PKG_VERSION:=4.4.0
PKG_RELEASE:=6 PKG_RELEASE:=7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2

View file

@ -1,6 +1,6 @@
--- a/include/linux/pkt_sched.h --- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h
@@ -850,4 +850,59 @@ struct tc_pie_xstats { @@ -850,4 +850,60 @@ struct tc_pie_xstats {
__u32 maxq; /* maximum queue size */ __u32 maxq; /* maximum queue size */
__u32 ecn_mark; /* packets marked with ecn*/ __u32 ecn_mark; /* packets marked with ecn*/
}; };
@ -13,6 +13,7 @@
+ TCA_CAKE_ATM, + TCA_CAKE_ATM,
+ TCA_CAKE_FLOW_MODE, + TCA_CAKE_FLOW_MODE,
+ TCA_CAKE_OVERHEAD, + TCA_CAKE_OVERHEAD,
+ TCA_CAKE_MPU,
+ TCA_CAKE_RTT, + TCA_CAKE_RTT,
+ TCA_CAKE_TARGET, + TCA_CAKE_TARGET,
+ TCA_CAKE_AUTORATE, + TCA_CAKE_AUTORATE,
@ -72,7 +73,7 @@
--- /dev/null --- /dev/null
+++ b/tc/q_cake.c +++ b/tc/q_cake.c
@@ -0,0 +1,663 @@ @@ -0,0 +1,686 @@
+/* +/*
+ * Common Applications Kept Enhanced -- CAKE + * Common Applications Kept Enhanced -- CAKE
+ * + *
@ -130,7 +131,7 @@
+ " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n" + " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n"
+ " [ besteffort | precedence | diffserv8 | diffserv4 | diffserv-llt | diffserv3* ]\n" + " [ besteffort | precedence | diffserv8 | diffserv4 | diffserv-llt | diffserv3* ]\n"
+ " [ flowblind | srchost | dsthost | hosts | flows | dual-srchost | dual-dsthost | triple-isolate* ] [ nat | nonat* ]\n" + " [ flowblind | srchost | dsthost | hosts | flows | dual-srchost | dual-dsthost | triple-isolate* ] [ nat | nonat* ]\n"
+ " [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n" + " [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ] [ mpu N ]\n"
+ " [ wash | nowash* ]\n" + " [ wash | nowash* ]\n"
+ " [ memlimit LIMIT ]\n" + " [ memlimit LIMIT ]\n"
+ " (* marks defaults)\n"); + " (* marks defaults)\n");
@ -149,6 +150,7 @@
+ bool overhead_set = false; + bool overhead_set = false;
+ bool overhead_override = false; + bool overhead_override = false;
+ int wash = -1; + int wash = -1;
+ int mpu = 0;
+ int flowmode = -1; + int flowmode = -1;
+ int nat = -1; + int nat = -1;
+ int atm = -1; + int atm = -1;
@ -332,6 +334,7 @@
+ * you may need to add vlan tag */ + * you may need to add vlan tag */
+ overhead += 38; + overhead += 38;
+ overhead_set = true; + overhead_set = true;
+ mpu = 84;
+ +
+ /* Additional Ethernet-related overhead used by some ISPs */ + /* Additional Ethernet-related overhead used by some ISPs */
+ } else if (strcmp(*argv, "ether-vlan") == 0) { + } else if (strcmp(*argv, "ether-vlan") == 0) {
@ -347,6 +350,7 @@
+ atm = 0; + atm = 0;
+ overhead += 18; + overhead += 18;
+ overhead_set = true; + overhead_set = true;
+ mpu = 64;
+ +
+ } else if (strcmp(*argv, "overhead") == 0) { + } else if (strcmp(*argv, "overhead") == 0) {
+ char* p = NULL; + char* p = NULL;
@ -358,6 +362,15 @@
+ } + }
+ overhead_set = true; + 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) { + } else if (strcmp(*argv, "memlimit") == 0) {
+ NEXT_ARG(); + NEXT_ARG();
+ if(get_size(&memlimit, *argv)) { + if(get_size(&memlimit, *argv)) {
@ -392,6 +405,8 @@
+ unsigned zero = 0; + unsigned zero = 0;
+ addattr_l(n, 1024, TCA_CAKE_ETHERNET, &zero, sizeof(zero)); + 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) + if (interval)
+ addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval)); + addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
+ if (target) + if (target)
@ -420,6 +435,7 @@
+ unsigned memlimit = 0; + unsigned memlimit = 0;
+ int overhead = 0; + int overhead = 0;
+ int ethernet = 0; + int ethernet = 0;
+ int mpu = 0;
+ int atm = 0; + int atm = 0;
+ int nat = 0; + int nat = 0;
+ int autorate = 0; + int autorate = 0;
@ -525,6 +541,10 @@
+ RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) { + RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) {
+ overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]); + 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] && + if (tb[TCA_CAKE_ETHERNET] &&
+ RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) { + RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) {
+ ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]); + ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]);
@ -558,6 +578,10 @@
+ fprintf(f, "via-ethernet "); + fprintf(f, "via-ethernet ");
+ } + }
+ +
+ if (mpu) {
+ fprintf(f, "mpu %d ", mpu);
+ }
+
+ if (memlimit) + if (memlimit)
+ fprintf(f, "memlimit %s", sprint_size(memlimit, b1)); + fprintf(f, "memlimit %s", sprint_size(memlimit, b1));
+ +