From 56b031106cb2ac98293124d5ed8ffb2629f5a3fa Mon Sep 17 00:00:00 2001 From: Kevin Darbyshire-Bryant Date: Thu, 28 May 2020 09:36:49 +0100 Subject: [PATCH] cake/iproute2/tc: Add diffserv5 LE tin Signed-off-by: Kevin Darbyshire-Bryant --- .../iproute2/patches/310-cake-diffserv5.patch | 69 +++++++++ .../generic/hack-6.1/648-cake-diffserv5.patch | 141 ++++++++++++++++++ .../generic/hack-6.6/648-cake-diffserv5.patch | 141 ++++++++++++++++++ 3 files changed, 351 insertions(+) create mode 100644 package/network/utils/iproute2/patches/310-cake-diffserv5.patch create mode 100644 target/linux/generic/hack-6.1/648-cake-diffserv5.patch create mode 100644 target/linux/generic/hack-6.6/648-cake-diffserv5.patch diff --git a/package/network/utils/iproute2/patches/310-cake-diffserv5.patch b/package/network/utils/iproute2/patches/310-cake-diffserv5.patch new file mode 100644 index 0000000000..943d883843 --- /dev/null +++ b/package/network/utils/iproute2/patches/310-cake-diffserv5.patch @@ -0,0 +1,69 @@ +From 99d00b3202c89b39a20ad97d969f198cadfb1f41 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Thu, 28 May 2020 09:51:40 +0100 +Subject: [PATCH] cake: diffserv5 + +Signed-off-by: Kevin Darbyshire-Bryant +--- + include/uapi/linux/pkt_sched.h | 3 ++- + tc/q_cake.c | 9 ++++++++- + 2 files changed, 10 insertions(+), 2 deletions(-) + +--- a/include/uapi/linux/pkt_sched.h ++++ b/include/uapi/linux/pkt_sched.h +@@ -1157,7 +1157,7 @@ enum { + CAKE_FLOW_DUAL_SRC, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_DUAL_DST, /* = CAKE_FLOW_DST_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_TRIPLE, /* = CAKE_FLOW_HOSTS | CAKE_FLOW_FLOWS */ +- CAKE_FLOW_MAX, ++ CAKE_FLOW_MAX + }; + + enum { +@@ -1166,6 +1166,7 @@ enum { + CAKE_DIFFSERV_DIFFSERV8, + CAKE_DIFFSERV_BESTEFFORT, + CAKE_DIFFSERV_PRECEDENCE, ++ CAKE_DIFFSERV_DIFFSERV5, + CAKE_DIFFSERV_MAX + }; + +--- a/tc/q_cake.c ++++ b/tc/q_cake.c +@@ -45,6 +45,7 @@ static const char * diffserv_names[CAKE_ + [CAKE_DIFFSERV_DIFFSERV8] = "diffserv8", + [CAKE_DIFFSERV_BESTEFFORT] = "besteffort", + [CAKE_DIFFSERV_PRECEDENCE] = "precedence", ++ [CAKE_DIFFSERV_DIFFSERV5] = "diffserv5" + }; + + static const char * flowmode_names[CAKE_FLOW_MAX] = { +@@ -74,7 +75,7 @@ static void explain(void) + "Usage: ... cake [ bandwidth RATE | unlimited* | autorate-ingress ]\n" + " [ rtt TIME | datacentre | lan | metro | regional |\n" + " internet* | oceanic | satellite | interplanetary ]\n" +- " [ besteffort | diffserv8 | diffserv4 | diffserv3* ]\n" ++ " [ besteffort | diffserv8 | diffserv5 | diffserv4 | diffserv3* ]\n" + " [ flowblind | srchost | dsthost | hosts | flows |\n" + " dual-srchost | dual-dsthost | triple-isolate* ]\n" + " [ nat | nonat* ]\n" +@@ -149,6 +150,8 @@ static int cake_parse_opt(struct qdisc_u + diffserv = CAKE_DIFFSERV_PRECEDENCE; + } else if (strcmp(*argv, "diffserv8") == 0) { + diffserv = CAKE_DIFFSERV_DIFFSERV8; ++ } else if (strcmp(*argv, "diffserv5") == 0) { ++ diffserv = CAKE_DIFFSERV_DIFFSERV5; + } else if (strcmp(*argv, "diffserv4") == 0) { + diffserv = CAKE_DIFFSERV_DIFFSERV4; + } else if (strcmp(*argv, "diffserv") == 0) { +@@ -761,6 +764,10 @@ static int cake_print_xstats(struct qdis + fprintf(f, " Bulk Best Effort Video Voice\n"); + break; + ++ case 5: ++ fprintf(f, " Least Effort Bulk Best Effort Video Voice\n"); ++ break; ++ + default: + fprintf(f, " "); + for (i = 0; i < num_tins; i++) diff --git a/target/linux/generic/hack-6.1/648-cake-diffserv5.patch b/target/linux/generic/hack-6.1/648-cake-diffserv5.patch new file mode 100644 index 0000000000..1c152b23e9 --- /dev/null +++ b/target/linux/generic/hack-6.1/648-cake-diffserv5.patch @@ -0,0 +1,141 @@ +From fe1d1fb237aaa8d5728a81707d1c2af6e89aeb23 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Wed, 27 May 2020 17:05:51 +0100 +Subject: [PATCH] experiment with diffserv5 incl an LE class + +Signed-off-by: Kevin Darbyshire-Bryant +--- + pkt_sched.h | 3 +- + sch_cake.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 90 insertions(+), 1 deletion(-) + +--- a/include/uapi/linux/pkt_sched.h ++++ b/include/uapi/linux/pkt_sched.h +@@ -1093,7 +1093,7 @@ enum { + CAKE_FLOW_DUAL_SRC, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_DUAL_DST, /* = CAKE_FLOW_DST_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_TRIPLE, /* = CAKE_FLOW_HOSTS | CAKE_FLOW_FLOWS */ +- CAKE_FLOW_MAX, ++ CAKE_FLOW_MAX + }; + + enum { +@@ -1102,6 +1102,7 @@ enum { + CAKE_DIFFSERV_DIFFSERV8, + CAKE_DIFFSERV_BESTEFFORT, + CAKE_DIFFSERV_PRECEDENCE, ++ CAKE_DIFFSERV_DIFFSERV5, + CAKE_DIFFSERV_MAX + }; + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -324,6 +324,17 @@ static const u8 diffserv8[] = { + 7, 2, 2, 2, 2, 2, 2, 2, + }; + ++static const u8 diffserv5[] = { ++ 0, 1, 0, 0, 3, 0, 0, 0, ++ 2, 0, 0, 0, 0, 0, 0, 0, ++ 3, 0, 3, 0, 3, 0, 3, 0, ++ 3, 0, 3, 0, 3, 0, 3, 0, ++ 4, 0, 3, 0, 3, 0, 3, 0, ++ 4, 0, 0, 0, 4, 0, 4, 0, ++ 4, 0, 0, 0, 0, 0, 0, 0, ++ 4, 0, 0, 0, 0, 0, 0, 0, ++}; ++ + static const u8 diffserv4[] = { + 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, +@@ -361,6 +372,7 @@ static const u8 besteffort[] = { + + static const u8 normal_order[] = {0, 1, 2, 3, 4, 5, 6, 7}; + static const u8 bulk_order[] = {1, 0, 2, 3}; ++static const u8 le_order[] = {1, 2, 0, 3, 4}; + + #define REC_INV_SQRT_CACHE (16) + static u32 cobalt_rec_inv_sqrt_cache[REC_INV_SQRT_CACHE] = {0}; +@@ -2315,7 +2327,7 @@ static int cake_config_precedence(struct + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; + u32 quantum = 256; +- u32 i; ++ u16 i; + + q->tin_cnt = 8; + q->tin_index = precedence; +@@ -2404,7 +2416,7 @@ static int cake_config_diffserv8(struct + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; + u32 quantum = 256; +- u32 i; ++ u16 i; + + q->tin_cnt = 8; + +@@ -2432,6 +2444,53 @@ static int cake_config_diffserv8(struct + return 0; + } + ++static int cake_config_diffserv5(struct Qdisc *sch) ++{ ++/* Further pruned list of traffic classes for four-class system: ++ * ++ * Latency Sensitive (CS7, CS6, EF, VA, CS5, CS4) ++ * Streaming Media (AF4x, AF3x, CS3, AF2x, TOS4, CS2, TOS1) ++ * Background Traffic (CS1) ++ * Best Effort (CS0, AF1x, TOS2, and those not specified) ++ * Least Effort (LE) ++ * ++ * Total 5 traffic classes. ++ */ ++ ++ struct cake_sched_data *q = qdisc_priv(sch); ++ u32 mtu = psched_mtu(qdisc_dev(sch)); ++ u64 rate = q->rate_bps; ++ u32 quantum = 1024; ++ u16 i; ++ ++ q->tin_cnt = 5; ++ ++ /* codepoint to class mapping */ ++ q->tin_index = diffserv5; ++ q->tin_order = le_order; ++ ++ /* class characteristics */ ++ cake_set_rate(&q->tins[0], rate, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[1], rate >> 6, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[2], rate >> 4, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[3], rate >> 1, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[4], rate >> 2, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ ++ /* bandwidth-sharing weights */ ++ q->tins[0].tin_quantum = quantum; /*BE*/ ++ q->tins[1].tin_quantum = quantum >> 6; /*LE*/ ++ q->tins[2].tin_quantum = quantum >> 4; /*BK*/ ++ q->tins[3].tin_quantum = quantum >> 1; /*VI*/ ++ q->tins[4].tin_quantum = quantum >> 2; /*VO*/ ++ ++ return 0; ++} ++ + static int cake_config_diffserv4(struct Qdisc *sch) + { + /* Further pruned list of traffic classes for four-class system: +@@ -2526,6 +2585,10 @@ static void cake_reconfigure(struct Qdis + ft = cake_config_diffserv8(sch); + break; + ++ case CAKE_DIFFSERV_DIFFSERV5: ++ ft = cake_config_diffserv5(sch); ++ break; ++ + case CAKE_DIFFSERV_DIFFSERV4: + ft = cake_config_diffserv4(sch); + break; diff --git a/target/linux/generic/hack-6.6/648-cake-diffserv5.patch b/target/linux/generic/hack-6.6/648-cake-diffserv5.patch new file mode 100644 index 0000000000..1c152b23e9 --- /dev/null +++ b/target/linux/generic/hack-6.6/648-cake-diffserv5.patch @@ -0,0 +1,141 @@ +From fe1d1fb237aaa8d5728a81707d1c2af6e89aeb23 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Wed, 27 May 2020 17:05:51 +0100 +Subject: [PATCH] experiment with diffserv5 incl an LE class + +Signed-off-by: Kevin Darbyshire-Bryant +--- + pkt_sched.h | 3 +- + sch_cake.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 90 insertions(+), 1 deletion(-) + +--- a/include/uapi/linux/pkt_sched.h ++++ b/include/uapi/linux/pkt_sched.h +@@ -1093,7 +1093,7 @@ enum { + CAKE_FLOW_DUAL_SRC, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_DUAL_DST, /* = CAKE_FLOW_DST_IP | CAKE_FLOW_FLOWS */ + CAKE_FLOW_TRIPLE, /* = CAKE_FLOW_HOSTS | CAKE_FLOW_FLOWS */ +- CAKE_FLOW_MAX, ++ CAKE_FLOW_MAX + }; + + enum { +@@ -1102,6 +1102,7 @@ enum { + CAKE_DIFFSERV_DIFFSERV8, + CAKE_DIFFSERV_BESTEFFORT, + CAKE_DIFFSERV_PRECEDENCE, ++ CAKE_DIFFSERV_DIFFSERV5, + CAKE_DIFFSERV_MAX + }; + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -324,6 +324,17 @@ static const u8 diffserv8[] = { + 7, 2, 2, 2, 2, 2, 2, 2, + }; + ++static const u8 diffserv5[] = { ++ 0, 1, 0, 0, 3, 0, 0, 0, ++ 2, 0, 0, 0, 0, 0, 0, 0, ++ 3, 0, 3, 0, 3, 0, 3, 0, ++ 3, 0, 3, 0, 3, 0, 3, 0, ++ 4, 0, 3, 0, 3, 0, 3, 0, ++ 4, 0, 0, 0, 4, 0, 4, 0, ++ 4, 0, 0, 0, 0, 0, 0, 0, ++ 4, 0, 0, 0, 0, 0, 0, 0, ++}; ++ + static const u8 diffserv4[] = { + 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, +@@ -361,6 +372,7 @@ static const u8 besteffort[] = { + + static const u8 normal_order[] = {0, 1, 2, 3, 4, 5, 6, 7}; + static const u8 bulk_order[] = {1, 0, 2, 3}; ++static const u8 le_order[] = {1, 2, 0, 3, 4}; + + #define REC_INV_SQRT_CACHE (16) + static u32 cobalt_rec_inv_sqrt_cache[REC_INV_SQRT_CACHE] = {0}; +@@ -2315,7 +2327,7 @@ static int cake_config_precedence(struct + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; + u32 quantum = 256; +- u32 i; ++ u16 i; + + q->tin_cnt = 8; + q->tin_index = precedence; +@@ -2404,7 +2416,7 @@ static int cake_config_diffserv8(struct + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; + u32 quantum = 256; +- u32 i; ++ u16 i; + + q->tin_cnt = 8; + +@@ -2432,6 +2444,53 @@ static int cake_config_diffserv8(struct + return 0; + } + ++static int cake_config_diffserv5(struct Qdisc *sch) ++{ ++/* Further pruned list of traffic classes for four-class system: ++ * ++ * Latency Sensitive (CS7, CS6, EF, VA, CS5, CS4) ++ * Streaming Media (AF4x, AF3x, CS3, AF2x, TOS4, CS2, TOS1) ++ * Background Traffic (CS1) ++ * Best Effort (CS0, AF1x, TOS2, and those not specified) ++ * Least Effort (LE) ++ * ++ * Total 5 traffic classes. ++ */ ++ ++ struct cake_sched_data *q = qdisc_priv(sch); ++ u32 mtu = psched_mtu(qdisc_dev(sch)); ++ u64 rate = q->rate_bps; ++ u32 quantum = 1024; ++ u16 i; ++ ++ q->tin_cnt = 5; ++ ++ /* codepoint to class mapping */ ++ q->tin_index = diffserv5; ++ q->tin_order = le_order; ++ ++ /* class characteristics */ ++ cake_set_rate(&q->tins[0], rate, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[1], rate >> 6, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[2], rate >> 4, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[3], rate >> 1, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ cake_set_rate(&q->tins[4], rate >> 2, mtu, ++ us_to_ns(q->target), us_to_ns(q->interval)); ++ ++ /* bandwidth-sharing weights */ ++ q->tins[0].tin_quantum = quantum; /*BE*/ ++ q->tins[1].tin_quantum = quantum >> 6; /*LE*/ ++ q->tins[2].tin_quantum = quantum >> 4; /*BK*/ ++ q->tins[3].tin_quantum = quantum >> 1; /*VI*/ ++ q->tins[4].tin_quantum = quantum >> 2; /*VO*/ ++ ++ return 0; ++} ++ + static int cake_config_diffserv4(struct Qdisc *sch) + { + /* Further pruned list of traffic classes for four-class system: +@@ -2526,6 +2585,10 @@ static void cake_reconfigure(struct Qdis + ft = cake_config_diffserv8(sch); + break; + ++ case CAKE_DIFFSERV_DIFFSERV5: ++ ft = cake_config_diffserv5(sch); ++ break; ++ + case CAKE_DIFFSERV_DIFFSERV4: + ft = cake_config_diffserv4(sch); + break; -- 2.30.2