95bc0b5777bc8d788647e45ce7751aa5d3ee494d
[openwrt/svn-archive/archive.git] / openwrt / target / linux / package / ieee80211-dscape / src / fifo_qdisc.c
1 /*
2 * Copyright 2005, Devicescape Software, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * If building without CONFIG_NET_SCHED we need a simple
9 * fifo qdisc to install by default as the sub-qdisc.
10 * This is a simple replacement for sch_fifo.
11 */
12
13 #include <linux/config.h>
14 #include <linux/version.h>
15 #include <linux/netdevice.h>
16 #include <net/ieee80211.h>
17 #include "ieee80211_i.h"
18 #include "wme.h"
19
20 static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* qd)
21 {
22 struct sk_buff_head *q = qdisc_priv(qd);
23
24 if (skb_queue_len(q) > qd->dev->tx_queue_len) {
25 qd->qstats.drops++;
26 kfree_skb(skb);
27 return NET_XMIT_DROP;
28 }
29
30 skb_queue_tail(q, skb);
31 qd->q.qlen++;
32 qd->bstats.bytes += skb->len;
33 qd->bstats.packets++;
34
35 return NET_XMIT_SUCCESS;
36 }
37
38
39 static int pfifo_requeue(struct sk_buff *skb, struct Qdisc* qd)
40 {
41 struct sk_buff_head *q = qdisc_priv(qd);
42
43 skb_queue_head(q, skb);
44 qd->q.qlen++;
45 qd->bstats.bytes += skb->len;
46 qd->bstats.packets++;
47
48 return NET_XMIT_SUCCESS;
49 }
50
51
52 static struct sk_buff *pfifo_dequeue(struct Qdisc* qd)
53 {
54 struct sk_buff_head *q = qdisc_priv(qd);
55
56 return skb_dequeue(q);
57 }
58
59
60 static int pfifo_init(struct Qdisc* qd, struct rtattr *opt)
61 {
62 struct sk_buff_head *q = qdisc_priv(qd);
63
64 skb_queue_head_init(q);
65 return 0;
66 }
67
68
69 static void pfifo_reset(struct Qdisc* qd)
70 {
71 struct sk_buff_head *q = qdisc_priv(qd);
72
73 skb_queue_purge(q);
74 qd->q.qlen = 0;
75 }
76
77
78 static int pfifo_dump(struct Qdisc *qd, struct sk_buff *skb)
79 {
80 return skb->len;
81 }
82
83
84 struct Qdisc_ops pfifo_qdisc_ops =
85 {
86 .next = NULL,
87 .cl_ops = NULL,
88 .id = "ieee80211_pfifo",
89 .priv_size = sizeof(struct sk_buff_head),
90
91 .enqueue = pfifo_enqueue,
92 .dequeue = pfifo_dequeue,
93 .requeue = pfifo_requeue,
94 .drop = NULL,
95
96 .init = pfifo_init,
97 .reset = pfifo_reset,
98 .destroy = NULL,
99 .change = NULL,
100
101 .dump = pfifo_dump,
102 };
103