Blame view
net/sched/sch_ingress.c
4.83 KB
1f211a1b9 net, sched: add c... |
1 2 |
/* net/sched/sch_ingress.c - Ingress and clsact qdisc * |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 8 9 |
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Authors: Jamal Hadi Salim 1999 */ |
1da177e4c Linux-2.6.12-rc2 |
10 11 |
#include <linux/module.h> #include <linux/types.h> |
0ba480538 [NET_SCHED]: Remo... |
12 |
#include <linux/list.h> |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include <linux/skbuff.h> |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <linux/rtnetlink.h> |
d2788d348 net: sched: furth... |
15 |
|
dc5fc579b [NETLINK]: Use nl... |
16 |
#include <net/netlink.h> |
1da177e4c Linux-2.6.12-rc2 |
17 |
#include <net/pkt_sched.h> |
cf1facda2 sched: move tcf_p... |
18 |
#include <net/pkt_cls.h> |
1da177e4c Linux-2.6.12-rc2 |
19 |
|
6529eaba3 net: sched: intro... |
20 21 22 |
struct ingress_sched_data { struct tcf_block *block; }; |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 |
static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) { return NULL; } |
143976ce9 net_sched: remove... |
27 |
static unsigned long ingress_find(struct Qdisc *sch, u32 classid) |
1da177e4c Linux-2.6.12-rc2 |
28 |
{ |
1da177e4c Linux-2.6.12-rc2 |
29 30 |
return TC_H_MIN(classid) + 1; } |
1da177e4c Linux-2.6.12-rc2 |
31 |
static unsigned long ingress_bind_filter(struct Qdisc *sch, |
58f4df423 [NET_SCHED]: sch_... |
32 |
unsigned long parent, u32 classid) |
1da177e4c Linux-2.6.12-rc2 |
33 |
{ |
143976ce9 net_sched: remove... |
34 |
return ingress_find(sch, classid); |
1da177e4c Linux-2.6.12-rc2 |
35 |
} |
143976ce9 net_sched: remove... |
36 |
static void ingress_unbind_filter(struct Qdisc *sch, unsigned long cl) |
1da177e4c Linux-2.6.12-rc2 |
37 38 |
{ } |
58f4df423 [NET_SCHED]: sch_... |
39 |
static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker) |
1da177e4c Linux-2.6.12-rc2 |
40 |
{ |
1da177e4c Linux-2.6.12-rc2 |
41 |
} |
6529eaba3 net: sched: intro... |
42 |
static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl) |
1da177e4c Linux-2.6.12-rc2 |
43 |
{ |
6529eaba3 net: sched: intro... |
44 |
struct ingress_sched_data *q = qdisc_priv(sch); |
1da177e4c Linux-2.6.12-rc2 |
45 |
|
6529eaba3 net: sched: intro... |
46 |
return q->block; |
1da177e4c Linux-2.6.12-rc2 |
47 |
} |
4577139b2 net: use jump lab... |
48 49 |
static int ingress_init(struct Qdisc *sch, struct nlattr *opt) { |
6529eaba3 net: sched: intro... |
50 51 52 |
struct ingress_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); int err; |
112957304 net: sched: fix s... |
53 |
net_inc_ingress_queue(); |
6529eaba3 net: sched: intro... |
54 55 56 |
err = tcf_block_get(&q->block, &dev->ingress_cl_list); if (err) return err; |
087c1a601 net: sched: run i... |
57 |
sch->flags |= TCQ_F_CPUSTATS; |
4577139b2 net: use jump lab... |
58 59 60 |
return 0; } |
1da177e4c Linux-2.6.12-rc2 |
61 62 |
static void ingress_destroy(struct Qdisc *sch) { |
6529eaba3 net: sched: intro... |
63 |
struct ingress_sched_data *q = qdisc_priv(sch); |
1da177e4c Linux-2.6.12-rc2 |
64 |
|
6529eaba3 net: sched: intro... |
65 |
tcf_block_put(q->block); |
4577139b2 net: use jump lab... |
66 |
net_dec_ingress_queue(); |
1da177e4c Linux-2.6.12-rc2 |
67 |
} |
1da177e4c Linux-2.6.12-rc2 |
68 69 |
static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) { |
4b3550ef5 [NET_SCHED]: Use ... |
70 |
struct nlattr *nest; |
1da177e4c Linux-2.6.12-rc2 |
71 |
|
4b3550ef5 [NET_SCHED]: Use ... |
72 73 74 |
nest = nla_nest_start(skb, TCA_OPTIONS); if (nest == NULL) goto nla_put_failure; |
d2788d348 net: sched: furth... |
75 |
|
d59b7d805 net_sched: return... |
76 |
return nla_nest_end(skb, nest); |
1da177e4c Linux-2.6.12-rc2 |
77 |
|
1e90474c3 [NET_SCHED]: Conv... |
78 |
nla_put_failure: |
4b3550ef5 [NET_SCHED]: Use ... |
79 |
nla_nest_cancel(skb, nest); |
1da177e4c Linux-2.6.12-rc2 |
80 81 |
return -1; } |
20fea08b5 [NET]: Move Qdisc... |
82 |
static const struct Qdisc_class_ops ingress_class_ops = { |
1da177e4c Linux-2.6.12-rc2 |
83 |
.leaf = ingress_leaf, |
143976ce9 net_sched: remove... |
84 |
.find = ingress_find, |
1da177e4c Linux-2.6.12-rc2 |
85 |
.walk = ingress_walk, |
6529eaba3 net: sched: intro... |
86 |
.tcf_block = ingress_tcf_block, |
1da177e4c Linux-2.6.12-rc2 |
87 |
.bind_tcf = ingress_bind_filter, |
143976ce9 net_sched: remove... |
88 |
.unbind_tcf = ingress_unbind_filter, |
1da177e4c Linux-2.6.12-rc2 |
89 |
}; |
20fea08b5 [NET]: Move Qdisc... |
90 |
static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { |
1da177e4c Linux-2.6.12-rc2 |
91 92 |
.cl_ops = &ingress_class_ops, .id = "ingress", |
6529eaba3 net: sched: intro... |
93 |
.priv_size = sizeof(struct ingress_sched_data), |
4577139b2 net: use jump lab... |
94 |
.init = ingress_init, |
1da177e4c Linux-2.6.12-rc2 |
95 |
.destroy = ingress_destroy, |
1da177e4c Linux-2.6.12-rc2 |
96 97 98 |
.dump = ingress_dump, .owner = THIS_MODULE, }; |
6529eaba3 net: sched: intro... |
99 100 101 102 |
struct clsact_sched_data { struct tcf_block *ingress_block; struct tcf_block *egress_block; }; |
143976ce9 net_sched: remove... |
103 |
static unsigned long clsact_find(struct Qdisc *sch, u32 classid) |
1f211a1b9 net, sched: add c... |
104 105 106 107 108 109 110 111 112 113 114 115 116 |
{ switch (TC_H_MIN(classid)) { case TC_H_MIN(TC_H_MIN_INGRESS): case TC_H_MIN(TC_H_MIN_EGRESS): return TC_H_MIN(classid); default: return 0; } } static unsigned long clsact_bind_filter(struct Qdisc *sch, unsigned long parent, u32 classid) { |
143976ce9 net_sched: remove... |
117 |
return clsact_find(sch, classid); |
1f211a1b9 net, sched: add c... |
118 |
} |
6529eaba3 net: sched: intro... |
119 |
static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl) |
1f211a1b9 net, sched: add c... |
120 |
{ |
6529eaba3 net: sched: intro... |
121 |
struct clsact_sched_data *q = qdisc_priv(sch); |
1f211a1b9 net, sched: add c... |
122 123 124 |
switch (cl) { case TC_H_MIN(TC_H_MIN_INGRESS): |
6529eaba3 net: sched: intro... |
125 |
return q->ingress_block; |
1f211a1b9 net, sched: add c... |
126 |
case TC_H_MIN(TC_H_MIN_EGRESS): |
6529eaba3 net: sched: intro... |
127 |
return q->egress_block; |
1f211a1b9 net, sched: add c... |
128 129 130 131 132 133 134 |
default: return NULL; } } static int clsact_init(struct Qdisc *sch, struct nlattr *opt) { |
6529eaba3 net: sched: intro... |
135 136 137 |
struct clsact_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); int err; |
112957304 net: sched: fix s... |
138 139 |
net_inc_ingress_queue(); net_inc_egress_queue(); |
6529eaba3 net: sched: intro... |
140 141 142 143 144 145 146 |
err = tcf_block_get(&q->ingress_block, &dev->ingress_cl_list); if (err) return err; err = tcf_block_get(&q->egress_block, &dev->egress_cl_list); if (err) return err; |
1f211a1b9 net, sched: add c... |
147 148 149 150 151 152 153 |
sch->flags |= TCQ_F_CPUSTATS; return 0; } static void clsact_destroy(struct Qdisc *sch) { |
6529eaba3 net: sched: intro... |
154 |
struct clsact_sched_data *q = qdisc_priv(sch); |
1f211a1b9 net, sched: add c... |
155 |
|
6529eaba3 net: sched: intro... |
156 157 |
tcf_block_put(q->egress_block); tcf_block_put(q->ingress_block); |
1f211a1b9 net, sched: add c... |
158 159 160 161 162 163 164 |
net_dec_ingress_queue(); net_dec_egress_queue(); } static const struct Qdisc_class_ops clsact_class_ops = { .leaf = ingress_leaf, |
143976ce9 net_sched: remove... |
165 |
.find = clsact_find, |
1f211a1b9 net, sched: add c... |
166 |
.walk = ingress_walk, |
6529eaba3 net: sched: intro... |
167 |
.tcf_block = clsact_tcf_block, |
1f211a1b9 net, sched: add c... |
168 |
.bind_tcf = clsact_bind_filter, |
143976ce9 net_sched: remove... |
169 |
.unbind_tcf = ingress_unbind_filter, |
1f211a1b9 net, sched: add c... |
170 171 172 173 174 |
}; static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { .cl_ops = &clsact_class_ops, .id = "clsact", |
6529eaba3 net: sched: intro... |
175 |
.priv_size = sizeof(struct clsact_sched_data), |
1f211a1b9 net, sched: add c... |
176 177 178 179 180 |
.init = clsact_init, .destroy = clsact_destroy, .dump = ingress_dump, .owner = THIS_MODULE, }; |
1da177e4c Linux-2.6.12-rc2 |
181 182 |
static int __init ingress_module_init(void) { |
1f211a1b9 net, sched: add c... |
183 184 185 186 187 188 189 190 191 192 |
int ret; ret = register_qdisc(&ingress_qdisc_ops); if (!ret) { ret = register_qdisc(&clsact_qdisc_ops); if (ret) unregister_qdisc(&ingress_qdisc_ops); } return ret; |
1da177e4c Linux-2.6.12-rc2 |
193 |
} |
58f4df423 [NET_SCHED]: sch_... |
194 |
|
10297b993 [NET] SCHED: Fix ... |
195 |
static void __exit ingress_module_exit(void) |
1da177e4c Linux-2.6.12-rc2 |
196 197 |
{ unregister_qdisc(&ingress_qdisc_ops); |
1f211a1b9 net, sched: add c... |
198 |
unregister_qdisc(&clsact_qdisc_ops); |
1da177e4c Linux-2.6.12-rc2 |
199 |
} |
58f4df423 [NET_SCHED]: sch_... |
200 |
|
d2788d348 net: sched: furth... |
201 202 |
module_init(ingress_module_init); module_exit(ingress_module_exit); |
1f211a1b9 net, sched: add c... |
203 |
MODULE_ALIAS("sch_clsact"); |
1da177e4c Linux-2.6.12-rc2 |
204 |
MODULE_LICENSE("GPL"); |