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 <asm/uaccess.h>
14 #include <asm/system.h>
15 #include <asm/bitops.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/string.h>
21 #include <linux/socket.h>
22 #include <linux/sockios.h>
24 #include <linux/errno.h>
25 #include <linux/interrupt.h>
26 #include <linux/if_ether.h>
27 #include <linux/inet.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30 #include <linux/notifier.h>
32 #include <net/route.h>
33 #include <linux/skbuff.h>
35 #include <net/pkt_sched.h>
37 /* 1 band FIFO pseudo-"scheduler" */
39 struct fifo_sched_data
45 bfifo_enqueue(struct sk_buff
*skb
, struct Qdisc
* sch
)
47 struct fifo_sched_data
*q
= (struct fifo_sched_data
*)sch
->data
;
49 if (sch
->stats
.backlog
<= q
->limit
) {
50 __skb_queue_tail(&sch
->q
, skb
);
51 sch
->stats
.backlog
+= skb
->len
;
52 sch
->stats
.bytes
+= skb
->len
;
57 #ifdef CONFIG_NET_CLS_POLICE
58 if (sch
->reshape_fail
==NULL
|| sch
->reshape_fail(skb
, sch
))
65 bfifo_requeue(struct sk_buff
*skb
, struct Qdisc
* sch
)
67 __skb_queue_head(&sch
->q
, skb
);
68 sch
->stats
.backlog
+= skb
->len
;
72 static struct sk_buff
*
73 bfifo_dequeue(struct Qdisc
* sch
)
77 skb
= __skb_dequeue(&sch
->q
);
79 sch
->stats
.backlog
-= skb
->len
;
84 fifo_drop(struct Qdisc
* sch
)
88 skb
= __skb_dequeue_tail(&sch
->q
);
90 sch
->stats
.backlog
-= skb
->len
;
98 fifo_reset(struct Qdisc
* sch
)
100 skb_queue_purge(&sch
->q
);
101 sch
->stats
.backlog
= 0;
105 pfifo_enqueue(struct sk_buff
*skb
, struct Qdisc
* sch
)
107 struct fifo_sched_data
*q
= (struct fifo_sched_data
*)sch
->data
;
109 if (sch
->q
.qlen
<= q
->limit
) {
110 __skb_queue_tail(&sch
->q
, skb
);
111 sch
->stats
.bytes
+= skb
->len
;
112 sch
->stats
.packets
++;
116 #ifdef CONFIG_NET_CLS_POLICE
117 if (sch
->reshape_fail
==NULL
|| sch
->reshape_fail(skb
, sch
))
124 pfifo_requeue(struct sk_buff
*skb
, struct Qdisc
* sch
)
126 __skb_queue_head(&sch
->q
, skb
);
131 static struct sk_buff
*
132 pfifo_dequeue(struct Qdisc
* sch
)
134 return __skb_dequeue(&sch
->q
);
137 static int fifo_init(struct Qdisc
*sch
, struct rtattr
*opt
)
139 struct fifo_sched_data
*q
= (void*)sch
->data
;
142 if (sch
->ops
== &bfifo_qdisc_ops
)
143 q
->limit
= sch
->dev
->tx_queue_len
*sch
->dev
->mtu
;
145 q
->limit
= sch
->dev
->tx_queue_len
;
147 struct tc_fifo_qopt
*ctl
= RTA_DATA(opt
);
148 if (opt
->rta_len
< RTA_LENGTH(sizeof(*ctl
)))
150 q
->limit
= ctl
->limit
;
155 #ifdef CONFIG_RTNETLINK
156 static int fifo_dump(struct Qdisc
*sch
, struct sk_buff
*skb
)
158 struct fifo_sched_data
*q
= (void*)sch
->data
;
159 unsigned char *b
= skb
->tail
;
160 struct tc_fifo_qopt opt
;
162 opt
.limit
= q
->limit
;
163 RTA_PUT(skb
, TCA_OPTIONS
, sizeof(opt
), &opt
);
168 skb_trim(skb
, b
- skb
->data
);
173 struct Qdisc_ops pfifo_qdisc_ops
=
178 sizeof(struct fifo_sched_data
),
190 #ifdef CONFIG_RTNETLINK
195 struct Qdisc_ops bfifo_qdisc_ops
=
200 sizeof(struct fifo_sched_data
),
211 #ifdef CONFIG_RTNETLINK