Skip to content

Commit

Permalink
sch_cake: don't call diffserv parsing code when it is not needed
Browse files Browse the repository at this point in the history
As a further optimisation of the diffserv parsing codepath, we can skip it
entirely if CAKE is not configured to use diffserv-based classification, or
to zero out the diffserv bits.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Jun 25, 2020
1 parent 44cdfb5 commit 4897938
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sch_cake.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free)
return idx + (tin << 16);
}

static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash)
static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash)
{
const int offset = skb_network_offset(skb);
u16 *buf, buf_;
Expand Down Expand Up @@ -1723,14 +1723,17 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch,
{
struct cake_sched_data *q = qdisc_priv(sch);
u32 tin, mark;
bool wash;
u8 dscp;

/* Tin selection: Default to diffserv-based selection, allow overriding
* using firewall marks or skb->priority.
* using firewall marks or skb->priority. Call DSCP parsing early if
* wash is enabled, otherwise defer to below to skip unneeded parsing.
*/
dscp = cake_handle_diffserv(skb,
q->rate_flags & CAKE_FLAG_WASH);
mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft;
wash = !!(q->rate_flags & CAKE_FLAG_WASH);
if (wash)
dscp = cake_handle_diffserv(skb, wash);

if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
tin = 0;
Expand All @@ -1744,6 +1747,8 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch,
tin = q->tin_order[TC_H_MIN(skb->priority) - 1];

else {
if (!wash)
dscp = cake_handle_diffserv(skb, wash);
tin = q->tin_index[dscp];

if (unlikely(tin >= q->tin_cnt))
Expand Down

0 comments on commit 4897938

Please sign in to comment.