[WATCHDOG] sa1100_wdt.c sparse clean (2)
[linux-2.6/mini2440.git] / net / sched / sch_fifo.c
blob033083bf0e741e6863a5cb999f58dbda6d3729a1
1 /*
2 * net/sched/sch_fifo.c The simplest FIFO queue.
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.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
12 #include <linux/config.h>
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/netdevice.h>
18 #include <linux/skbuff.h>
19 #include <net/pkt_sched.h>
21 /* 1 band FIFO pseudo-"scheduler" */
23 struct fifo_sched_data
25 u32 limit;
28 static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)
30 struct fifo_sched_data *q = qdisc_priv(sch);
32 if (likely(sch->qstats.backlog + skb->len <= q->limit))
33 return qdisc_enqueue_tail(skb, sch);
35 return qdisc_reshape_fail(skb, sch);
38 static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)
40 struct fifo_sched_data *q = qdisc_priv(sch);
42 if (likely(skb_queue_len(&sch->q) < q->limit))
43 return qdisc_enqueue_tail(skb, sch);
45 return qdisc_reshape_fail(skb, sch);
48 static int fifo_init(struct Qdisc *sch, struct rtattr *opt)
50 struct fifo_sched_data *q = qdisc_priv(sch);
52 if (opt == NULL) {
53 u32 limit = sch->dev->tx_queue_len ? : 1;
55 if (sch->ops == &bfifo_qdisc_ops)
56 limit *= sch->dev->mtu;
58 q->limit = limit;
59 } else {
60 struct tc_fifo_qopt *ctl = RTA_DATA(opt);
62 if (RTA_PAYLOAD(opt) < sizeof(*ctl))
63 return -EINVAL;
65 q->limit = ctl->limit;
68 return 0;
71 static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb)
73 struct fifo_sched_data *q = qdisc_priv(sch);
74 struct tc_fifo_qopt opt = { .limit = q->limit };
76 RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
77 return skb->len;
79 rtattr_failure:
80 return -1;
83 struct Qdisc_ops pfifo_qdisc_ops = {
84 .id = "pfifo",
85 .priv_size = sizeof(struct fifo_sched_data),
86 .enqueue = pfifo_enqueue,
87 .dequeue = qdisc_dequeue_head,
88 .requeue = qdisc_requeue,
89 .drop = qdisc_queue_drop,
90 .init = fifo_init,
91 .reset = qdisc_reset_queue,
92 .change = fifo_init,
93 .dump = fifo_dump,
94 .owner = THIS_MODULE,
97 struct Qdisc_ops bfifo_qdisc_ops = {
98 .id = "bfifo",
99 .priv_size = sizeof(struct fifo_sched_data),
100 .enqueue = bfifo_enqueue,
101 .dequeue = qdisc_dequeue_head,
102 .requeue = qdisc_requeue,
103 .drop = qdisc_queue_drop,
104 .init = fifo_init,
105 .reset = qdisc_reset_queue,
106 .change = fifo_init,
107 .dump = fifo_dump,
108 .owner = THIS_MODULE,
111 EXPORT_SYMBOL(bfifo_qdisc_ops);
112 EXPORT_SYMBOL(pfifo_qdisc_ops);