tridentfb: add imageblit acceleration for Blade3D family
[linux-2.6] / net / sched / sch_ingress.c
1 /* net/sched/sch_ingress.c - Ingress qdisc
2  *              This program is free software; you can redistribute it and/or
3  *              modify it under the terms of the GNU General Public License
4  *              as published by the Free Software Foundation; either version
5  *              2 of the License, or (at your option) any later version.
6  *
7  * Authors:     Jamal Hadi Salim 1999
8  */
9
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/list.h>
13 #include <linux/skbuff.h>
14 #include <linux/rtnetlink.h>
15 #include <net/netlink.h>
16 #include <net/pkt_sched.h>
17
18
19 struct ingress_qdisc_data {
20         struct tcf_proto        *filter_list;
21 };
22
23 /* ------------------------- Class/flow operations ------------------------- */
24
25 static int ingress_graft(struct Qdisc *sch, unsigned long arg,
26                          struct Qdisc *new, struct Qdisc **old)
27 {
28         return -EOPNOTSUPP;
29 }
30
31 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
32 {
33         return NULL;
34 }
35
36 static unsigned long ingress_get(struct Qdisc *sch, u32 classid)
37 {
38         return TC_H_MIN(classid) + 1;
39 }
40
41 static unsigned long ingress_bind_filter(struct Qdisc *sch,
42                                          unsigned long parent, u32 classid)
43 {
44         return ingress_get(sch, classid);
45 }
46
47 static void ingress_put(struct Qdisc *sch, unsigned long cl)
48 {
49 }
50
51 static int ingress_change(struct Qdisc *sch, u32 classid, u32 parent,
52                           struct nlattr **tca, unsigned long *arg)
53 {
54         return 0;
55 }
56
57 static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
58 {
59         return;
60 }
61
62 static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
63 {
64         struct ingress_qdisc_data *p = qdisc_priv(sch);
65
66         return &p->filter_list;
67 }
68
69 /* --------------------------- Qdisc operations ---------------------------- */
70
71 static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
72 {
73         struct ingress_qdisc_data *p = qdisc_priv(sch);
74         struct tcf_result res;
75         int result;
76
77         result = tc_classify(skb, p->filter_list, &res);
78
79         sch->bstats.packets++;
80         sch->bstats.bytes += qdisc_pkt_len(skb);
81         switch (result) {
82         case TC_ACT_SHOT:
83                 result = TC_ACT_SHOT;
84                 sch->qstats.drops++;
85                 break;
86         case TC_ACT_STOLEN:
87         case TC_ACT_QUEUED:
88                 result = TC_ACT_STOLEN;
89                 break;
90         case TC_ACT_RECLASSIFY:
91         case TC_ACT_OK:
92                 skb->tc_index = TC_H_MIN(res.classid);
93         default:
94                 result = TC_ACT_OK;
95                 break;
96         }
97
98         return result;
99 }
100
101 /* ------------------------------------------------------------- */
102
103 static void ingress_destroy(struct Qdisc *sch)
104 {
105         struct ingress_qdisc_data *p = qdisc_priv(sch);
106
107         tcf_destroy_chain(&p->filter_list);
108 }
109
110 static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
111 {
112         struct nlattr *nest;
113
114         nest = nla_nest_start(skb, TCA_OPTIONS);
115         if (nest == NULL)
116                 goto nla_put_failure;
117         nla_nest_end(skb, nest);
118         return skb->len;
119
120 nla_put_failure:
121         nla_nest_cancel(skb, nest);
122         return -1;
123 }
124
125 static const struct Qdisc_class_ops ingress_class_ops = {
126         .graft          =       ingress_graft,
127         .leaf           =       ingress_leaf,
128         .get            =       ingress_get,
129         .put            =       ingress_put,
130         .change         =       ingress_change,
131         .walk           =       ingress_walk,
132         .tcf_chain      =       ingress_find_tcf,
133         .bind_tcf       =       ingress_bind_filter,
134         .unbind_tcf     =       ingress_put,
135 };
136
137 static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
138         .cl_ops         =       &ingress_class_ops,
139         .id             =       "ingress",
140         .priv_size      =       sizeof(struct ingress_qdisc_data),
141         .enqueue        =       ingress_enqueue,
142         .destroy        =       ingress_destroy,
143         .dump           =       ingress_dump,
144         .owner          =       THIS_MODULE,
145 };
146
147 static int __init ingress_module_init(void)
148 {
149         return register_qdisc(&ingress_qdisc_ops);
150 }
151
152 static void __exit ingress_module_exit(void)
153 {
154         unregister_qdisc(&ingress_qdisc_ops);
155 }
156
157 module_init(ingress_module_init)
158 module_exit(ingress_module_exit)
159 MODULE_LICENSE("GPL");