cake/iproute2/tc: Add diffserv5 LE tin
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Thu, 28 May 2020 08:36:49 +0000 (09:36 +0100)
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Sun, 24 Apr 2022 08:18:55 +0000 (09:18 +0100)
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
package/network/utils/iproute2/patches/310-cake-diffserv5.patch [new file with mode: 0644]
target/linux/generic/hack-5.10/648-cake-diffserv5.patch [new file with mode: 0644]
target/linux/generic/hack-5.15/646-cake-traffic-stat.patch [new file with mode: 0644]
target/linux/generic/hack-5.15/648-cake-diffserv5.patch [new file with mode: 0644]
target/linux/generic/hack-5.4/648-cake-diffserv5.patch [new file with mode: 0644]

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 (file)
index 0000000..943d883
--- /dev/null
@@ -0,0 +1,69 @@
+From 99d00b3202c89b39a20ad97d969f198cadfb1f41 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Thu, 28 May 2020 09:51:40 +0100
+Subject: [PATCH] cake: diffserv5
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ 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-5.10/648-cake-diffserv5.patch b/target/linux/generic/hack-5.10/648-cake-diffserv5.patch
new file mode 100644 (file)
index 0000000..1c152b2
--- /dev/null
@@ -0,0 +1,141 @@
+From fe1d1fb237aaa8d5728a81707d1c2af6e89aeb23 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Wed, 27 May 2020 17:05:51 +0100
+Subject: [PATCH] experiment with diffserv5 incl an LE class
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ 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-5.15/646-cake-traffic-stat.patch b/target/linux/generic/hack-5.15/646-cake-traffic-stat.patch
new file mode 100644 (file)
index 0000000..c350e95
--- /dev/null
@@ -0,0 +1,58 @@
+From 69fa00eeb9e7a700ae3a8b5e9b4d1908d418796c Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Sun, 19 Jan 2020 09:13:22 +0000
+Subject: [PATCH] traffic stats
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ include/uapi/linux/pkt_sched.h |  2 ++
+ net/sched/sch_cake.c           | 13 ++++++++++++-
+ 2 files changed, 14 insertions(+), 1 deletion(-)
+
+--- a/include/uapi/linux/pkt_sched.h
++++ b/include/uapi/linux/pkt_sched.h
+@@ -1144,6 +1144,8 @@ enum {
+       TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS,
+       TCA_CAKE_TIN_STATS_MAX_SKBLEN,
+       TCA_CAKE_TIN_STATS_FLOW_QUANTUM,
++      TCA_CAKE_TIN_STATS_TRAFFIC_BYTES,
++      TCA_CAKE_TIN_STATS_TRAFFIC_TIME,
+       __TCA_CAKE_TIN_STATS_MAX
+ };
+ #define TCA_CAKE_TIN_STATS_MAX (__TCA_CAKE_TIN_STATS_MAX - 1)
+--- a/net/sched/sch_cake.c
++++ b/net/sched/sch_cake.c
+@@ -181,6 +181,8 @@ struct cake_tin_data {
+       u32     packets;
+       u64     bytes;
++      u64     prev_bytes;
++      ktime_t prev_time;
+       u32     ack_drops;
+@@ -2847,6 +2849,8 @@ static int cake_dump_stats(struct Qdisc
+       struct nlattr *stats = nla_nest_start_noflag(d->skb, TCA_STATS_APP);
+       struct cake_sched_data *q = qdisc_priv(sch);
+       struct nlattr *tstats, *ts;
++      ktime_t now;
++      u64 tin_bytes;
+       int i;
+       if (!stats)
+@@ -2896,7 +2900,14 @@ static int cake_dump_stats(struct Qdisc
+                       goto nla_put_failure;
+               PUT_TSTAT_U64(THRESHOLD_RATE64, b->tin_rate_bps);
+-              PUT_TSTAT_U64(SENT_BYTES64, b->bytes);
++              tin_bytes = b->bytes;
++              now = ktime_get();
++              PUT_TSTAT_U64(SENT_BYTES64, tin_bytes);
++              PUT_TSTAT_U32(TRAFFIC_BYTES, (u32)(tin_bytes - b->prev_bytes));
++              b->prev_bytes = tin_bytes;
++              PUT_TSTAT_U32(TRAFFIC_TIME, ktime_ms_delta(now, b->prev_time));
++              b->prev_time = now;
++
+               PUT_TSTAT_U32(BACKLOG_BYTES, b->tin_backlog);
+               PUT_TSTAT_U32(TARGET_US,
diff --git a/target/linux/generic/hack-5.15/648-cake-diffserv5.patch b/target/linux/generic/hack-5.15/648-cake-diffserv5.patch
new file mode 100644 (file)
index 0000000..e3acafe
--- /dev/null
@@ -0,0 +1,141 @@
+From fe1d1fb237aaa8d5728a81707d1c2af6e89aeb23 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Wed, 27 May 2020 17:05:51 +0100
+Subject: [PATCH] experiment with diffserv5 incl an LE class
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ 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
+@@ -1160,7 +1160,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 {
+@@ -1169,6 +1169,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};
+@@ -2317,7 +2329,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;
+@@ -2406,7 +2418,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;
+@@ -2434,6 +2446,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:
+@@ -2528,6 +2587,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-5.4/648-cake-diffserv5.patch b/target/linux/generic/hack-5.4/648-cake-diffserv5.patch
new file mode 100644 (file)
index 0000000..1c152b2
--- /dev/null
@@ -0,0 +1,141 @@
+From fe1d1fb237aaa8d5728a81707d1c2af6e89aeb23 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Wed, 27 May 2020 17:05:51 +0100
+Subject: [PATCH] experiment with diffserv5 incl an LE class
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ 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;