From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, cake@lists.bufferbloat.net
Subject: [Cake] [PATCH net-next v1 3/3] sch_cake: Simplify logic in cake_select_tin()
Date: Fri, 01 Mar 2019 16:04:05 +0100 [thread overview]
Message-ID: <155145264579.2564.12320265553780481623.stgit@alrua-x1> (raw)
In-Reply-To: <155145264557.2564.18246059144961803752.stgit@alrua-x1>
From: Toke Høiland-Jørgensen <toke@toke.dk>
With more modes added the logic in cake_select_tin() was getting a bit
hairy, and it turns out we can actually simplify it quite a bit. This also
allows us to get rid of one of the two diffserv parsing functions, which
has the added benefit that already-zeroed DSCP fields won't get re-written.
Suggested-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
net/sched/sch_cake.c | 61 +++++++++++++++++++-------------------------------
1 file changed, 23 insertions(+), 38 deletions(-)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index f1cc4779699b..1d2a12132abc 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1513,20 +1513,6 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free)
return idx + (tin << 16);
}
-static void cake_wash_diffserv(struct sk_buff *skb)
-{
- switch (skb->protocol) {
- case htons(ETH_P_IP):
- ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, 0);
- break;
- case htons(ETH_P_IPV6):
- ipv6_change_dsfield(ipv6_hdr(skb), INET_ECN_MASK, 0);
- break;
- default:
- break;
- }
-}
-
static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash)
{
u8 dscp;
@@ -1558,33 +1544,32 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch,
{
struct cake_sched_data *q = qdisc_priv(sch);
u32 tin;
+ u8 dscp;
- if (TC_H_MAJ(skb->priority) == sch->handle &&
- TC_H_MIN(skb->priority) > 0 &&
- TC_H_MIN(skb->priority) <= q->tin_cnt) {
- tin = q->tin_order[TC_H_MIN(skb->priority) - 1];
+ /* Tin selection: Default to diffserv-based selection, allow overriding
+ * using firewall marks or skb->priority.
+ */
+ dscp = cake_handle_diffserv(skb,
+ q->rate_flags & CAKE_FLAG_WASH);
- if (q->rate_flags & CAKE_FLAG_WASH)
- cake_wash_diffserv(skb);
- } else if (q->tin_mode != CAKE_DIFFSERV_BESTEFFORT) {
- if (q->rate_flags & CAKE_FLAG_FWMARK && /* use fw mark */
- skb->mark &&
- skb->mark <= q->tin_cnt) {
- tin = q->tin_order[skb->mark - 1];
- if (q->rate_flags & CAKE_FLAG_WASH)
- cake_wash_diffserv(skb);
- } else {
- /* extract the Diffserv Precedence field, if it exists */
- /* and clear DSCP bits if washing */
- tin = q->tin_index[cake_handle_diffserv(skb,
- q->rate_flags & CAKE_FLAG_WASH)];
- if (unlikely(tin >= q->tin_cnt))
- tin = 0;
- }
- } else {
+ if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
tin = 0;
- if (q->rate_flags & CAKE_FLAG_WASH)
- cake_wash_diffserv(skb);
+
+ else if (q->rate_flags & CAKE_FLAG_FWMARK && /* use fw mark */
+ skb->mark &&
+ skb->mark <= q->tin_cnt)
+ tin = q->tin_order[skb->mark - 1];
+
+ else if (TC_H_MAJ(skb->priority) == sch->handle &&
+ TC_H_MIN(skb->priority) > 0 &&
+ TC_H_MIN(skb->priority) <= q->tin_cnt)
+ tin = q->tin_order[TC_H_MIN(skb->priority) - 1];
+
+ else {
+ tin = q->tin_index[dscp];
+
+ if (unlikely(tin >= q->tin_cnt))
+ tin = 0;
}
return &q->tins[tin];
next prev parent reply other threads:[~2019-03-01 15:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-01 15:04 [Cake] [PATCH net-next v1 0/3] sched: Patches from out-of-tree version of sch_cake Toke Høiland-Jørgensen
2019-03-01 15:04 ` Toke Høiland-Jørgensen [this message]
2019-03-01 15:04 ` [Cake] [PATCH net-next v1 2/3] sch_cake: Permit use of connmarks as tin classifiers Toke Høiland-Jørgensen
2019-03-01 15:04 ` [Cake] [PATCH net-next v1 1/3] sch_cake: Make the dual modes fairer Toke Høiland-Jørgensen
2019-03-04 4:38 ` [Cake] [PATCH net-next v1 0/3] sched: Patches from out-of-tree version of sch_cake David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155145264579.2564.12320265553780481623.stgit@alrua-x1 \
--to=toke@redhat.com \
--cc=cake@lists.bufferbloat.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox