Skip to content

Commit f3fafbc

Browse files
committed
Merge branch 'L4S-style-ce_threshold_ect1-marking'
Eric Dumazet says: ==================== net/sched: implement L4S style ce_threshold_ect1 marking As suggested by Ingemar Johansson, Neal Cardwell, and others, fq_codel can be used for Low Latency, Low Loss, Scalable Throughput (L4S) with a small change. In ce_threshold_ect1 mode, only ECT(1) packets can be marked to CE if their sojourn time is above the threshold. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 19757ce + e72aeb9 commit f3fafbc

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-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/net/inet_ecn.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
188188
return 0;
189189
}
190190

191+
static inline int skb_get_dsfield(struct sk_buff *skb)
192+
{
193+
switch (skb_protocol(skb, true)) {
194+
case cpu_to_be16(ETH_P_IP):
195+
if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
196+
break;
197+
return ipv4_get_dsfield(ip_hdr(skb));
198+
199+
case cpu_to_be16(ETH_P_IPV6):
200+
if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
201+
break;
202+
return ipv6_get_dsfield(ipv6_hdr(skb));
203+
}
204+
205+
return -1;
206+
}
207+
191208
static inline int INET_ECN_set_ect1(struct sk_buff *skb)
192209
{
193210
switch (skb_protocol(skb, true)) {

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)