11 #include <linux/module.h>
12 #include <linux/slab.h>
14 #include <linux/errno.h>
15 #include <linux/netdevice.h>
47 clc = qdisc_class_find(&q->
clhash, classid);
55 unsigned int len = cl->
qdisc->q.qlen;
65 static int drr_change_class(
struct Qdisc *sch,
u32 classid,
u32 parentid,
78 err = nla_parse_nested(tb,
TCA_DRR_MAX, opt, drr_policy);
83 quantum = nla_get_u32(tb[TCA_DRR_QUANTUM]);
87 quantum = psched_mtu(qdisc_dev(sch));
92 qdisc_root_sleeping_lock(sch),
99 if (tb[TCA_DRR_QUANTUM])
101 sch_tree_unlock(sch);
111 cl->
common.classid = classid;
114 &pfifo_qdisc_ops, classid);
120 qdisc_root_sleeping_lock(sch),
131 sch_tree_unlock(sch);
135 *arg = (
unsigned long)cl;
139 static void drr_destroy_class(
struct Qdisc *sch,
struct drr_class *cl)
146 static int drr_delete_class(
struct Qdisc *sch,
unsigned long arg)
165 sch_tree_unlock(sch);
169 static unsigned long drr_get_class(
struct Qdisc *sch,
u32 classid)
171 struct drr_class *cl = drr_find_class(sch, classid);
176 return (
unsigned long)
cl;
179 static void drr_put_class(
struct Qdisc *sch,
unsigned long arg)
184 drr_destroy_class(sch, cl);
187 static struct tcf_proto **drr_tcf_chain(
struct Qdisc *sch,
unsigned long cl)
197 static unsigned long drr_bind_tcf(
struct Qdisc *sch,
unsigned long parent,
200 struct drr_class *cl = drr_find_class(sch, classid);
205 return (
unsigned long)
cl;
208 static void drr_unbind_tcf(
struct Qdisc *sch,
unsigned long arg)
215 static int drr_graft_class(
struct Qdisc *sch,
unsigned long arg,
222 &pfifo_qdisc_ops, cl->
common.classid);
231 sch_tree_unlock(sch);
235 static struct Qdisc *drr_class_leaf(
struct Qdisc *sch,
unsigned long arg)
242 static void drr_qlen_notify(
struct Qdisc *csh,
unsigned long arg)
246 if (cl->
qdisc->q.qlen == 0)
250 static int drr_dump_class(
struct Qdisc *sch,
unsigned long arg,
262 goto nla_put_failure;
263 if (nla_put_u32(skb, TCA_DRR_QUANTUM, cl->
quantum))
264 goto nla_put_failure;
265 return nla_nest_end(skb, nest);
268 nla_nest_cancel(skb, nest);
272 static int drr_dump_class_stats(
struct Qdisc *sch,
unsigned long arg,
278 memset(&xstats, 0,
sizeof(xstats));
279 if (cl->
qdisc->q.qlen) {
302 for (i = 0; i < q->
clhash.hashsize; i++) {
308 if (arg->
fn(sch, (
unsigned long)cl, arg) < 0) {
326 cl = drr_find_class(sch, skb->
priority);
334 #ifdef CONFIG_NET_CLS_ACT
345 cl = drr_find_class(sch,
res.classid);
351 static int drr_enqueue(
struct sk_buff *skb,
struct Qdisc *sch)
357 cl = drr_classify(skb, sch, &err);
365 err = qdisc_enqueue(skb, cl->
qdisc);
374 if (cl->
qdisc->q.qlen == 1) {
390 if (list_empty(&q->
active))
398 len = qdisc_pkt_len(skb);
399 if (len <= cl->deficit) {
401 skb = qdisc_dequeue_peeked(cl->
qdisc);
402 if (cl->
qdisc->q.qlen == 0)
405 bstats_update(&cl->
bstats, skb);
406 qdisc_bstats_update(sch, skb);
418 static unsigned int drr_drop(
struct Qdisc *sch)
425 if (cl->
qdisc->ops->drop) {
429 if (cl->
qdisc->q.qlen == 0)
438 static int drr_init_qdisc(
struct Qdisc *sch,
struct nlattr *opt)
446 INIT_LIST_HEAD(&q->
active);
450 static void drr_reset_qdisc(
struct Qdisc *sch)
457 for (i = 0; i < q->
clhash.hashsize; i++) {
459 if (cl->
qdisc->q.qlen)
467 static void drr_destroy_qdisc(
struct Qdisc *sch)
476 for (i = 0; i < q->
clhash.hashsize; i++) {
479 drr_destroy_class(sch, cl);
485 .
change = drr_change_class,
486 .delete = drr_delete_class,
487 .get = drr_get_class,
488 .put = drr_put_class,
489 .tcf_chain = drr_tcf_chain,
490 .bind_tcf = drr_bind_tcf,
491 .unbind_tcf = drr_unbind_tcf,
492 .graft = drr_graft_class,
493 .leaf = drr_class_leaf,
494 .qlen_notify = drr_qlen_notify,
495 .dump = drr_dump_class,
496 .dump_stats = drr_dump_class_stats,
501 .cl_ops = &drr_class_ops,
504 .enqueue = drr_enqueue,
505 .dequeue = drr_dequeue,
506 .peek = qdisc_peek_dequeued,
508 .init = drr_init_qdisc,
509 .reset = drr_reset_qdisc,
510 .destroy = drr_destroy_qdisc,
514 static int __init drr_init(
void)
519 static void __exit drr_exit(
void)