Skip to content

Commit e72aeb9

Browse files
edumazetdavem330
authored andcommitted
fq_codel: implement L4S style ce_threshold_ect1 marking
Add TCA_FQ_CODEL_CE_THRESHOLD_ECT1 boolean option to select Low Latency, Low Loss, Scalable Throughput (L4S) style marking, along with ce_threshold. If enabled, only packets with ECT(1) can be transformed to CE if their sojourn time is above the ce_threshold. Note that this new option does not change rules for codel law. In particular, if TCA_FQ_CODEL_ECN is left enabled (this is the default when fq_codel qdisc is created), ECT(0) packets can still get CE if codel law (as governed by limit/target) decides so. Section 4.3.b of current draft [1] states: b. A scheduler with per-flow queues such as FQ-CoDel or FQ-PIE can be used for L4S. For instance within each queue of an FQ-CoDel system, as well as a CoDel AQM, there is typically also ECN marking at an immediate (unsmoothed) shallow threshold to support use in data centres (see Sec.5.2.7 of [RFC8290]). This can be modified so that the shallow threshold is solely applied to ECT(1) packets. Then if there is a flow of non-ECN or ECT(0) packets in the per-flow-queue, the Classic AQM (e.g. CoDel) is applied; while if there is a flow of ECT(1) packets in the queue, the shallower (typically sub-millisecond) threshold is applied. Tested: tc qd replace dev eth1 root fq_codel ce_threshold_ect1 50usec netperf ... -t TCP_STREAM -- K dctcp tc -s -d qd sh dev eth1 qdisc fq_codel 8022: root refcnt 32 limit 10240p flows 1024 quantum 9212 target 5ms ce_threshold_ect1 49us interval 100ms memory_limit 32Mb ecn drop_batch 64 Sent 14388596616 bytes 9543449 pkt (dropped 0, overlimits 0 requeues 152013) backlog 0b 0p requeues 152013 maxpacket 68130 drop_overlimit 0 new_flow_count 95678 ecn_mark 0 ce_mark 7639 new_flows_len 0 old_flows_len 0 [1] L4S current draft: https://datatracker.ietf.org/doc/html/draft-ietf-tsvwg-l4s-arch Signed-off-by: Eric Dumazet <[email protected]> Cc: Neal Cardwell <[email protected]> Cc: Ingemar Johansson S <[email protected]> Cc: Tom Henderson <[email protected]> Cc: Bob Briscoe <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 70e939d commit e72aeb9

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

include/net/codel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ static inline u32 codel_time_to_us(codel_time_t val)
102102
* @interval: width of moving time window
103103
* @mtu: device mtu, or minimal queue backlog in bytes.
104104
* @ecn: is Explicit Congestion Notification enabled
105+
* @ce_threshold_ect1: if ce_threshold only marks ECT(1) packets
105106
*/
106107
struct codel_params {
107108
codel_time_t target;
108109
codel_time_t ce_threshold;
109110
codel_time_t interval;
110111
u32 mtu;
111112
bool ecn;
113+
bool ce_threshold_ect1;
112114
};
113115

114116
/**

include/net/codel_impl.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static void codel_params_init(struct codel_params *params)
5454
params->interval = MS2TIME(100);
5555
params->target = MS2TIME(5);
5656
params->ce_threshold = CODEL_DISABLED_THRESHOLD;
57+
params->ce_threshold_ect1 = false;
5758
params->ecn = false;
5859
}
5960

@@ -246,9 +247,20 @@ static struct sk_buff *codel_dequeue(void *ctx,
246247
vars->rec_inv_sqrt);
247248
}
248249
end:
249-
if (skb && codel_time_after(vars->ldelay, params->ce_threshold) &&
250-
INET_ECN_set_ce(skb))
251-
stats->ce_mark++;
250+
if (skb && codel_time_after(vars->ldelay, params->ce_threshold)) {
251+
bool set_ce = true;
252+
253+
if (params->ce_threshold_ect1) {
254+
/* Note: if skb_get_dsfield() returns -1, following
255+
* gives INET_ECN_MASK, which is != INET_ECN_ECT_1.
256+
*/
257+
u8 ecn = skb_get_dsfield(skb) & INET_ECN_MASK;
258+
259+
set_ce = (ecn == INET_ECN_ECT_1);
260+
}
261+
if (set_ce && INET_ECN_set_ce(skb))
262+
stats->ce_mark++;
263+
}
252264
return skb;
253265
}
254266

include/uapi/linux/pkt_sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ enum {
840840
TCA_FQ_CODEL_CE_THRESHOLD,
841841
TCA_FQ_CODEL_DROP_BATCH_SIZE,
842842
TCA_FQ_CODEL_MEMORY_LIMIT,
843+
TCA_FQ_CODEL_CE_THRESHOLD_ECT1,
843844
__TCA_FQ_CODEL_MAX
844845
};
845846

net/mac80211/sta_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
513513
sta->cparams.target = MS2TIME(20);
514514
sta->cparams.interval = MS2TIME(100);
515515
sta->cparams.ecn = true;
516+
sta->cparams.ce_threshold_ect1 = false;
516517

517518
sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
518519

net/sched/sch_fq_codel.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = {
362362
[TCA_FQ_CODEL_CE_THRESHOLD] = { .type = NLA_U32 },
363363
[TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .type = NLA_U32 },
364364
[TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NLA_U32 },
365+
[TCA_FQ_CODEL_CE_THRESHOLD_ECT1] = { .type = NLA_U8 },
365366
};
366367

367368
static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
@@ -408,6 +409,9 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
408409
q->cparams.ce_threshold = (val * NSEC_PER_USEC) >> CODEL_SHIFT;
409410
}
410411

412+
if (tb[TCA_FQ_CODEL_CE_THRESHOLD_ECT1])
413+
q->cparams.ce_threshold_ect1 = !!nla_get_u8(tb[TCA_FQ_CODEL_CE_THRESHOLD_ECT1]);
414+
411415
if (tb[TCA_FQ_CODEL_INTERVAL]) {
412416
u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]);
413417

@@ -544,10 +548,13 @@ static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb)
544548
q->flows_cnt))
545549
goto nla_put_failure;
546550

547-
if (q->cparams.ce_threshold != CODEL_DISABLED_THRESHOLD &&
548-
nla_put_u32(skb, TCA_FQ_CODEL_CE_THRESHOLD,
549-
codel_time_to_us(q->cparams.ce_threshold)))
550-
goto nla_put_failure;
551+
if (q->cparams.ce_threshold != CODEL_DISABLED_THRESHOLD) {
552+
if (nla_put_u32(skb, TCA_FQ_CODEL_CE_THRESHOLD,
553+
codel_time_to_us(q->cparams.ce_threshold)))
554+
goto nla_put_failure;
555+
if (nla_put_u8(skb, TCA_FQ_CODEL_CE_THRESHOLD_ECT1, q->cparams.ce_threshold_ect1))
556+
goto nla_put_failure;
557+
}
551558

552559
return nla_nest_end(skb, opts);
553560

0 commit comments

Comments
 (0)