blob: 39157f7bc046017e50c8a0b4fb837f2cdeb4abd7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * net/sched/sch_prio.c Simple 3-band priority "scheduler".
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
YOSHIFUJI Hideaki10297b92007-02-09 23:25:16 +090010 * Fixes: 19990609: J Hadi Salim <hadi@nortelnetworks.com>:
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * Init -- EINVAL when opt undefined
12 */
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/types.h>
16#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/skbuff.h>
Arnaldo Carvalho de Melodc5fc572007-03-25 23:06:12 -070020#include <net/netlink.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <net/pkt_sched.h>
22
23
24struct prio_sched_data
25{
26 int bands;
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -070027 int curband; /* for round-robin */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 struct tcf_proto *filter_list;
29 u8 prio2band[TC_PRIO_MAX+1];
30 struct Qdisc *queues[TCQ_PRIO_BANDS];
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -070031 int mq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032};
33
34
35static struct Qdisc *
36prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
37{
38 struct prio_sched_data *q = qdisc_priv(sch);
39 u32 band = skb->priority;
40 struct tcf_result res;
Patrick McHardybdba91e2007-07-30 17:07:14 -070041 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Jamal Hadi Salim29f1df62006-01-08 22:35:55 -080043 *qerr = NET_XMIT_BYPASS;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 if (TC_H_MAJ(skb->priority) != sch->handle) {
Patrick McHardybdba91e2007-07-30 17:07:14 -070045 err = tc_classify(skb, q->filter_list, &res);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#ifdef CONFIG_NET_CLS_ACT
Lucas Nussbaumdbaaa072007-08-30 22:35:46 -070047 switch (err) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 case TC_ACT_STOLEN:
49 case TC_ACT_QUEUED:
50 *qerr = NET_XMIT_SUCCESS;
51 case TC_ACT_SHOT:
52 return NULL;
Stephen Hemminger3ff50b72007-04-20 17:09:22 -070053 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif
Patrick McHardybdba91e2007-07-30 17:07:14 -070055 if (!q->filter_list || err < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 if (TC_H_MAJ(band))
57 band = 0;
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -070058 band = q->prio2band[band&TC_PRIO_MAX];
59 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 }
61 band = res.classid;
62 }
63 band = TC_H_MIN(band) - 1;
Jamal Hadi Salim3e5c2d32007-05-14 02:57:19 -070064 if (band >= q->bands)
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -070065 band = q->prio2band[0];
66out:
67 if (q->mq)
68 skb_set_queue_mapping(skb, band);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 return q->queues[band];
70}
71
72static int
73prio_enqueue(struct sk_buff *skb, struct Qdisc *sch)
74{
75 struct Qdisc *qdisc;
76 int ret;
77
78 qdisc = prio_classify(skb, sch, &ret);
79#ifdef CONFIG_NET_CLS_ACT
80 if (qdisc == NULL) {
Jamal Hadi Salim29f1df62006-01-08 22:35:55 -080081
82 if (ret == NET_XMIT_BYPASS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 sch->qstats.drops++;
84 kfree_skb(skb);
85 return ret;
86 }
87#endif
88
89 if ((ret = qdisc->enqueue(skb, qdisc)) == NET_XMIT_SUCCESS) {
90 sch->bstats.bytes += skb->len;
91 sch->bstats.packets++;
92 sch->q.qlen++;
93 return NET_XMIT_SUCCESS;
94 }
95 sch->qstats.drops++;
YOSHIFUJI Hideaki10297b92007-02-09 23:25:16 +090096 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097}
98
99
100static int
101prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
102{
103 struct Qdisc *qdisc;
104 int ret;
105
106 qdisc = prio_classify(skb, sch, &ret);
107#ifdef CONFIG_NET_CLS_ACT
108 if (qdisc == NULL) {
Jamal Hadi Salim29f1df62006-01-08 22:35:55 -0800109 if (ret == NET_XMIT_BYPASS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 sch->qstats.drops++;
111 kfree_skb(skb);
112 return ret;
113 }
114#endif
115
116 if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) {
117 sch->q.qlen++;
118 sch->qstats.requeues++;
119 return 0;
120 }
121 sch->qstats.drops++;
122 return NET_XMIT_DROP;
123}
124
125
126static struct sk_buff *
127prio_dequeue(struct Qdisc* sch)
128{
129 struct sk_buff *skb;
130 struct prio_sched_data *q = qdisc_priv(sch);
131 int prio;
132 struct Qdisc *qdisc;
133
134 for (prio = 0; prio < q->bands; prio++) {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700135 /* Check if the target subqueue is available before
136 * pulling an skb. This way we avoid excessive requeues
137 * for slower queues.
138 */
David S. Miller5ce2d482008-07-08 17:06:30 -0700139 if (!__netif_subqueue_stopped(qdisc_dev(sch),
140 (q->mq ? prio : 0))) {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700141 qdisc = q->queues[prio];
142 skb = qdisc->dequeue(qdisc);
143 if (skb) {
144 sch->q.qlen--;
145 return skb;
146 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
148 }
149 return NULL;
150
151}
152
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700153static struct sk_buff *rr_dequeue(struct Qdisc* sch)
154{
155 struct sk_buff *skb;
156 struct prio_sched_data *q = qdisc_priv(sch);
157 struct Qdisc *qdisc;
158 int bandcount;
159
160 /* Only take one pass through the queues. If nothing is available,
161 * return nothing.
162 */
163 for (bandcount = 0; bandcount < q->bands; bandcount++) {
164 /* Check if the target subqueue is available before
165 * pulling an skb. This way we avoid excessive requeues
166 * for slower queues. If the queue is stopped, try the
167 * next queue.
168 */
David S. Miller5ce2d482008-07-08 17:06:30 -0700169 if (!__netif_subqueue_stopped(qdisc_dev(sch),
170 (q->mq ? q->curband : 0))) {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700171 qdisc = q->queues[q->curband];
172 skb = qdisc->dequeue(qdisc);
173 if (skb) {
174 sch->q.qlen--;
175 q->curband++;
176 if (q->curband >= q->bands)
177 q->curband = 0;
178 return skb;
179 }
180 }
181 q->curband++;
182 if (q->curband >= q->bands)
183 q->curband = 0;
184 }
185 return NULL;
186}
187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188static unsigned int prio_drop(struct Qdisc* sch)
189{
190 struct prio_sched_data *q = qdisc_priv(sch);
191 int prio;
192 unsigned int len;
193 struct Qdisc *qdisc;
194
195 for (prio = q->bands-1; prio >= 0; prio--) {
196 qdisc = q->queues[prio];
Patrick McHardy6d037a22006-03-20 19:00:49 -0800197 if (qdisc->ops->drop && (len = qdisc->ops->drop(qdisc)) != 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 sch->q.qlen--;
199 return len;
200 }
201 }
202 return 0;
203}
204
205
206static void
207prio_reset(struct Qdisc* sch)
208{
209 int prio;
210 struct prio_sched_data *q = qdisc_priv(sch);
211
212 for (prio=0; prio<q->bands; prio++)
213 qdisc_reset(q->queues[prio]);
214 sch->q.qlen = 0;
215}
216
217static void
218prio_destroy(struct Qdisc* sch)
219{
220 int prio;
221 struct prio_sched_data *q = qdisc_priv(sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Patrick McHardyff31ab52008-07-01 19:52:38 -0700223 tcf_destroy_chain(&q->filter_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 for (prio=0; prio<q->bands; prio++)
225 qdisc_destroy(q->queues[prio]);
226}
227
Patrick McHardy1e904742008-01-22 22:11:17 -0800228static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229{
230 struct prio_sched_data *q = qdisc_priv(sch);
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700231 struct tc_prio_qopt *qopt;
Patrick McHardy1e904742008-01-22 22:11:17 -0800232 struct nlattr *tb[TCA_PRIO_MAX + 1];
Patrick McHardycee63722008-01-23 20:33:32 -0800233 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 int i;
235
Patrick McHardycee63722008-01-23 20:33:32 -0800236 err = nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt,
237 sizeof(*qopt));
238 if (err < 0)
239 return err;
240
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700241 q->bands = qopt->bands;
242 /* If we're multiqueue, make sure the number of incoming bands
243 * matches the number of queues on the device we're associating with.
244 * If the number of bands requested is zero, then set q->bands to
Peter P Waskiewicz Jr07731922007-07-30 17:13:45 -0700245 * dev->egress_subqueue_count. Also, the root qdisc must be the
246 * only one that is enabled for multiqueue, since it's the only one
247 * that interacts with the underlying device.
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700248 */
Patrick McHardy1e904742008-01-22 22:11:17 -0800249 q->mq = nla_get_flag(tb[TCA_PRIO_MQ]);
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700250 if (q->mq) {
Peter P Waskiewicz Jr07731922007-07-30 17:13:45 -0700251 if (sch->parent != TC_H_ROOT)
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700252 return -EINVAL;
David S. Miller5ce2d482008-07-08 17:06:30 -0700253 if (netif_is_multiqueue(qdisc_dev(sch))) {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700254 if (q->bands == 0)
David S. Miller5ce2d482008-07-08 17:06:30 -0700255 q->bands = qdisc_dev(sch)->egress_subqueue_count;
256 else if (q->bands != qdisc_dev(sch)->egress_subqueue_count)
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700257 return -EINVAL;
258 } else
259 return -EOPNOTSUPP;
260 }
261
262 if (q->bands > TCQ_PRIO_BANDS || q->bands < 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 return -EINVAL;
264
265 for (i=0; i<=TC_PRIO_MAX; i++) {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700266 if (qopt->priomap[i] >= q->bands)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 return -EINVAL;
268 }
269
270 sch_tree_lock(sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);
272
273 for (i=q->bands; i<TCQ_PRIO_BANDS; i++) {
274 struct Qdisc *child = xchg(&q->queues[i], &noop_qdisc);
Patrick McHardy5e50da02006-11-29 17:36:20 -0800275 if (child != &noop_qdisc) {
276 qdisc_tree_decrease_qlen(child, child->q.qlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 qdisc_destroy(child);
Patrick McHardy5e50da02006-11-29 17:36:20 -0800278 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 }
280 sch_tree_unlock(sch);
281
Amnon Aaronsohndd914b42006-01-17 02:24:26 -0800282 for (i=0; i<q->bands; i++) {
283 if (q->queues[i] == &noop_qdisc) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 struct Qdisc *child;
David S. Miller5ce2d482008-07-08 17:06:30 -0700285 child = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
David S. Millerbb949fb2008-07-08 16:55:56 -0700286 &pfifo_qdisc_ops,
Patrick McHardy9f9afec2006-11-29 17:35:18 -0800287 TC_H_MAKE(sch->handle, i + 1));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 if (child) {
289 sch_tree_lock(sch);
Amnon Aaronsohndd914b42006-01-17 02:24:26 -0800290 child = xchg(&q->queues[i], child);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Patrick McHardy5e50da02006-11-29 17:36:20 -0800292 if (child != &noop_qdisc) {
293 qdisc_tree_decrease_qlen(child,
294 child->q.qlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 qdisc_destroy(child);
Patrick McHardy5e50da02006-11-29 17:36:20 -0800296 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 sch_tree_unlock(sch);
298 }
299 }
300 }
301 return 0;
302}
303
Patrick McHardy1e904742008-01-22 22:11:17 -0800304static int prio_init(struct Qdisc *sch, struct nlattr *opt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
306 struct prio_sched_data *q = qdisc_priv(sch);
307 int i;
308
309 for (i=0; i<TCQ_PRIO_BANDS; i++)
310 q->queues[i] = &noop_qdisc;
311
312 if (opt == NULL) {
313 return -EINVAL;
314 } else {
315 int err;
316
317 if ((err= prio_tune(sch, opt)) != 0)
318 return err;
319 }
320 return 0;
321}
322
323static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
324{
325 struct prio_sched_data *q = qdisc_priv(sch);
Arnaldo Carvalho de Melo27a884d2007-04-19 20:29:13 -0700326 unsigned char *b = skb_tail_pointer(skb);
Patrick McHardy1e904742008-01-22 22:11:17 -0800327 struct nlattr *nest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 struct tc_prio_qopt opt;
329
330 opt.bands = q->bands;
331 memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1);
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700332
Patrick McHardy1e904742008-01-22 22:11:17 -0800333 nest = nla_nest_compat_start(skb, TCA_OPTIONS, sizeof(opt), &opt);
334 if (nest == NULL)
335 goto nla_put_failure;
336 if (q->mq) {
337 if (nla_put_flag(skb, TCA_PRIO_MQ) < 0)
338 goto nla_put_failure;
339 }
340 nla_nest_compat_end(skb, nest);
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 return skb->len;
343
Patrick McHardy1e904742008-01-22 22:11:17 -0800344nla_put_failure:
Arnaldo Carvalho de Melodc5fc572007-03-25 23:06:12 -0700345 nlmsg_trim(skb, b);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 return -1;
347}
348
349static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
350 struct Qdisc **old)
351{
352 struct prio_sched_data *q = qdisc_priv(sch);
353 unsigned long band = arg - 1;
354
355 if (band >= q->bands)
356 return -EINVAL;
357
358 if (new == NULL)
359 new = &noop_qdisc;
360
361 sch_tree_lock(sch);
362 *old = q->queues[band];
363 q->queues[band] = new;
Patrick McHardy5e50da02006-11-29 17:36:20 -0800364 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 qdisc_reset(*old);
366 sch_tree_unlock(sch);
367
368 return 0;
369}
370
371static struct Qdisc *
372prio_leaf(struct Qdisc *sch, unsigned long arg)
373{
374 struct prio_sched_data *q = qdisc_priv(sch);
375 unsigned long band = arg - 1;
376
377 if (band >= q->bands)
378 return NULL;
379
380 return q->queues[band];
381}
382
383static unsigned long prio_get(struct Qdisc *sch, u32 classid)
384{
385 struct prio_sched_data *q = qdisc_priv(sch);
386 unsigned long band = TC_H_MIN(classid);
387
388 if (band - 1 >= q->bands)
389 return 0;
390 return band;
391}
392
393static unsigned long prio_bind(struct Qdisc *sch, unsigned long parent, u32 classid)
394{
395 return prio_get(sch, classid);
396}
397
398
399static void prio_put(struct Qdisc *q, unsigned long cl)
400{
401 return;
402}
403
Patrick McHardy1e904742008-01-22 22:11:17 -0800404static int prio_change(struct Qdisc *sch, u32 handle, u32 parent, struct nlattr **tca, unsigned long *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405{
406 unsigned long cl = *arg;
407 struct prio_sched_data *q = qdisc_priv(sch);
408
409 if (cl - 1 > q->bands)
410 return -ENOENT;
411 return 0;
412}
413
414static int prio_delete(struct Qdisc *sch, unsigned long cl)
415{
416 struct prio_sched_data *q = qdisc_priv(sch);
417 if (cl - 1 > q->bands)
418 return -ENOENT;
419 return 0;
420}
421
422
423static int prio_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb,
424 struct tcmsg *tcm)
425{
426 struct prio_sched_data *q = qdisc_priv(sch);
427
428 if (cl - 1 > q->bands)
429 return -ENOENT;
430 tcm->tcm_handle |= TC_H_MIN(cl);
431 if (q->queues[cl-1])
432 tcm->tcm_info = q->queues[cl-1]->handle;
433 return 0;
434}
435
Jarek Poplawski2cf6c362007-01-31 12:21:24 -0800436static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
437 struct gnet_dump *d)
438{
439 struct prio_sched_data *q = qdisc_priv(sch);
440 struct Qdisc *cl_q;
441
442 cl_q = q->queues[cl - 1];
443 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
444 gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
445 return -1;
446
447 return 0;
448}
449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
451{
452 struct prio_sched_data *q = qdisc_priv(sch);
453 int prio;
454
455 if (arg->stop)
456 return;
457
458 for (prio = 0; prio < q->bands; prio++) {
459 if (arg->count < arg->skip) {
460 arg->count++;
461 continue;
462 }
463 if (arg->fn(sch, prio+1, arg) < 0) {
464 arg->stop = 1;
465 break;
466 }
467 arg->count++;
468 }
469}
470
471static struct tcf_proto ** prio_find_tcf(struct Qdisc *sch, unsigned long cl)
472{
473 struct prio_sched_data *q = qdisc_priv(sch);
474
475 if (cl)
476 return NULL;
477 return &q->filter_list;
478}
479
Eric Dumazet20fea082007-11-14 01:44:41 -0800480static const struct Qdisc_class_ops prio_class_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 .graft = prio_graft,
482 .leaf = prio_leaf,
483 .get = prio_get,
484 .put = prio_put,
485 .change = prio_change,
486 .delete = prio_delete,
487 .walk = prio_walk,
488 .tcf_chain = prio_find_tcf,
489 .bind_tcf = prio_bind,
490 .unbind_tcf = prio_put,
491 .dump = prio_dump_class,
Jarek Poplawski2cf6c362007-01-31 12:21:24 -0800492 .dump_stats = prio_dump_class_stats,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493};
494
Eric Dumazet20fea082007-11-14 01:44:41 -0800495static struct Qdisc_ops prio_qdisc_ops __read_mostly = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .next = NULL,
497 .cl_ops = &prio_class_ops,
498 .id = "prio",
499 .priv_size = sizeof(struct prio_sched_data),
500 .enqueue = prio_enqueue,
501 .dequeue = prio_dequeue,
502 .requeue = prio_requeue,
503 .drop = prio_drop,
504 .init = prio_init,
505 .reset = prio_reset,
506 .destroy = prio_destroy,
507 .change = prio_tune,
508 .dump = prio_dump,
509 .owner = THIS_MODULE,
510};
511
Eric Dumazet20fea082007-11-14 01:44:41 -0800512static struct Qdisc_ops rr_qdisc_ops __read_mostly = {
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700513 .next = NULL,
514 .cl_ops = &prio_class_ops,
515 .id = "rr",
516 .priv_size = sizeof(struct prio_sched_data),
517 .enqueue = prio_enqueue,
518 .dequeue = rr_dequeue,
519 .requeue = prio_requeue,
520 .drop = prio_drop,
521 .init = prio_init,
522 .reset = prio_reset,
523 .destroy = prio_destroy,
524 .change = prio_tune,
525 .dump = prio_dump,
526 .owner = THIS_MODULE,
527};
528
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529static int __init prio_module_init(void)
530{
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700531 int err;
532
533 err = register_qdisc(&prio_qdisc_ops);
534 if (err < 0)
535 return err;
536 err = register_qdisc(&rr_qdisc_ops);
537 if (err < 0)
538 unregister_qdisc(&prio_qdisc_ops);
539 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540}
541
YOSHIFUJI Hideaki10297b92007-02-09 23:25:16 +0900542static void __exit prio_module_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
544 unregister_qdisc(&prio_qdisc_ops);
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700545 unregister_qdisc(&rr_qdisc_ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546}
547
548module_init(prio_module_init)
549module_exit(prio_module_exit)
550
551MODULE_LICENSE("GPL");
Peter P Waskiewicz Jrd62733c2007-06-28 21:04:31 -0700552MODULE_ALIAS("sch_rr");