43 #include <linux/module.h>
44 #include <linux/slab.h>
45 #include <linux/types.h>
46 #include <linux/kernel.h>
47 #include <linux/errno.h>
49 #include <linux/prefetch.h>
54 #define DEFAULT_CODEL_LIMIT 1000
85 if (q->
stats.drop_count && sch->
q.qlen) {
87 q->
stats.drop_count = 0;
90 qdisc_bstats_update(sch, skb);
94 static int codel_qdisc_enqueue(
struct sk_buff *skb,
struct Qdisc *sch)
99 codel_set_enqueue_time(skb);
100 return qdisc_enqueue_tail(skb, sch);
104 return qdisc_drop(skb, sch);
124 err = nla_parse_nested(tb,
TCA_CODEL_MAX, opt, codel_policy);
131 u32 target = nla_get_u32(tb[TCA_CODEL_TARGET]);
137 u32 interval = nla_get_u32(tb[TCA_CODEL_INTERVAL]);
143 sch->
limit = nla_get_u32(tb[TCA_CODEL_LIMIT]);
146 q->
params.ecn = !!nla_get_u32(tb[TCA_CODEL_ECN]);
149 while (sch->
q.qlen > sch->
limit) {
150 struct sk_buff *skb = __skb_dequeue(&sch->
q);
152 sch->
qstats.backlog -= qdisc_pkt_len(skb);
153 qdisc_drop(skb, sch);
157 sch_tree_unlock(sch);
161 static int codel_init(
struct Qdisc *sch,
struct nlattr *opt)
167 codel_params_init(&q->
params);
168 codel_vars_init(&q->
vars);
169 codel_stats_init(&q->
stats);
172 int err = codel_change(sch, opt);
186 static int codel_dump(
struct Qdisc *sch,
struct sk_buff *skb)
193 goto nla_put_failure;
195 if (nla_put_u32(skb, TCA_CODEL_TARGET,
196 codel_time_to_us(q->
params.target)) ||
197 nla_put_u32(skb, TCA_CODEL_LIMIT,
199 nla_put_u32(skb, TCA_CODEL_INTERVAL,
200 codel_time_to_us(q->
params.interval)) ||
201 nla_put_u32(skb, TCA_CODEL_ECN,
203 goto nla_put_failure;
205 return nla_nest_end(skb, opts);
208 nla_nest_cancel(skb, opts);
216 .maxpacket = q->
stats.maxpacket,
217 .count = q->
vars.count,
218 .lastcount = q->
vars.lastcount,
220 .ldelay = codel_time_to_us(q->
vars.ldelay),
221 .dropping = q->
vars.dropping,
222 .ecn_mark = q->
stats.ecn_mark,
225 if (q->
vars.dropping) {
231 st.
drop_next = -codel_time_to_us(-delta);
237 static void codel_reset(
struct Qdisc *sch)
241 qdisc_reset_queue(sch);
242 codel_vars_init(&q->
vars);
249 .enqueue = codel_qdisc_enqueue,
250 .dequeue = codel_qdisc_dequeue,
251 .peek = qdisc_peek_dequeued,
253 .reset = codel_reset,
254 .change = codel_change,
256 .dump_stats = codel_dump_stats,
260 static int __init codel_module_init(
void)
265 static void __exit codel_module_exit(
void)