1 #ifndef __NET_SCHED_CODEL_H
2 #define __NET_SCHED_CODEL_H
44 #include <linux/types.h>
65 #define CODEL_SHIFT 10
66 #define MS2TIME(a) ((a * NSEC_PER_MSEC) >> CODEL_SHIFT)
75 #define codel_time_after(a, b) ((s32)(a) - (s32)(b) > 0)
76 #define codel_time_after_eq(a, b) ((s32)(a) - (s32)(b) >= 0)
77 #define codel_time_before(a, b) ((s32)(a) - (s32)(b) < 0)
78 #define codel_time_before_eq(a, b) ((s32)(a) - (s32)(b) <= 0)
87 qdisc_cb_private_validate(skb,
sizeof(
struct codel_skb_cb));
93 return get_codel_cb(skb)->enqueue_time;
96 static void codel_set_enqueue_time(
struct sk_buff *
skb)
98 get_codel_cb(skb)->enqueue_time = codel_get_time();
143 #define REC_INV_SQRT_BITS (8 * sizeof(u16))
145 #define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS)
166 static void codel_vars_init(
struct codel_vars *vars)
168 memset(vars, 0,
sizeof(*vars));
182 static void codel_Newton_step(
struct codel_vars *vars)
185 u32 invsqrt2 = ((
u64)invsqrt * invsqrt) >> 32;
189 val = (val * invsqrt) >> (32 - 2 + 1);
207 static bool codel_should_drop(
const struct sk_buff *
skb,
221 vars->
ldelay = now - codel_get_enqueue_time(skb);
222 sch->
qstats.backlog -= qdisc_pkt_len(skb);
254 struct sk_buff *skb = dequeue_func(vars, sch);
262 now = codel_get_time();
263 drop = codel_should_drop(skb, sch, vars, params, stats, now);
282 codel_Newton_step(vars);
283 if (params->
ecn && INET_ECN_set_ce(skb)) {
291 qdisc_drop(skb, sch);
293 skb = dequeue_func(vars, sch);
294 if (!codel_should_drop(skb, sch,
295 vars, params, stats, now)) {
310 if (params->
ecn && INET_ECN_set_ce(skb)) {
313 qdisc_drop(skb, sch);
316 skb = dequeue_func(vars, sch);
317 drop = codel_should_drop(skb, sch, vars, params,
334 codel_Newton_step(vars);