thinkpad-acpi: name event constants
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / sched / sch_ingress.c
blob4a2b773743589733533d7ca48ca902f44b5980fa
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.
7 * Authors: Jamal Hadi Salim 1999
8 */
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>
19 struct ingress_qdisc_data {
20 struct tcf_proto *filter_list;
23 /* ------------------------- Class/flow operations ------------------------- */
25 static int ingress_graft(struct Qdisc *sch, unsigned long arg,
26 struct Qdisc *new, struct Qdisc **old)
28 return -EOPNOTSUPP;
31 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
33 return NULL;
36 static unsigned long ingress_get(struct Qdisc *sch, u32 classid)
38 return TC_H_MIN(classid) + 1;
41 static unsigned long ingress_bind_filter(struct Qdisc *sch,
42 unsigned long parent, u32 classid)
44 return ingress_get(sch, classid);
47 static void ingress_put(struct Qdisc *sch, unsigned long cl)
51 static int ingress_change(struct Qdisc *sch, u32 classid, u32 parent,
52 struct nlattr **tca, unsigned long *arg)
54 return 0;
57 static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
59 return;
62 static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
64 struct ingress_qdisc_data *p = qdisc_priv(sch);
66 return &p->filter_list;
69 /* --------------------------- Qdisc operations ---------------------------- */
71 static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
73 struct ingress_qdisc_data *p = qdisc_priv(sch);
74 struct tcf_result res;
75 int result;
77 result = tc_classify(skb, p->filter_list, &res);
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;
98 return result;
101 /* ------------------------------------------------------------- */
103 static void ingress_destroy(struct Qdisc *sch)
105 struct ingress_qdisc_data *p = qdisc_priv(sch);
107 tcf_destroy_chain(&p->filter_list);
110 static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
112 struct nlattr *nest;
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;
120 nla_put_failure:
121 nla_nest_cancel(skb, nest);
122 return -1;
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,
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,
147 static int __init ingress_module_init(void)
149 return register_qdisc(&ingress_qdisc_ops);
152 static void __exit ingress_module_exit(void)
154 unregister_qdisc(&ingress_qdisc_ops);
157 module_init(ingress_module_init)
158 module_exit(ingress_module_exit)
159 MODULE_LICENSE("GPL");