1 #ifndef __NET_SCHED_GENERIC_H
2 #define __NET_SCHED_GENERIC_H
4 #include <linux/config.h>
5 #include <linux/netdevice.h>
6 #include <linux/types.h>
7 #include <linux/rcupdate.h>
8 #include <linux/module.h>
9 #include <linux/rtnetlink.h>
10 #include <linux/pkt_sched.h>
11 #include <linux/pkt_cls.h>
12 #include <net/gen_stats.h>
19 struct qdisc_rate_table
21 struct tc_ratespec rate;
23 struct qdisc_rate_table *next;
29 int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
30 struct sk_buff * (*dequeue)(struct Qdisc *dev);
32 #define TCQ_F_BUILTIN 1
33 #define TCQ_F_THROTTLED 2
34 #define TCQ_F_INGRESS 4
36 struct Qdisc_ops *ops;
40 struct sk_buff_head q;
41 struct net_device *dev;
42 struct list_head list;
44 struct gnet_stats_basic bstats;
45 struct gnet_stats_queue qstats;
46 struct gnet_stats_rate_est rate_est;
47 spinlock_t *stats_lock;
48 struct rcu_head q_rcu;
49 int (*reshape_fail)(struct sk_buff *skb,
52 /* This field is deprecated, but it is still used by CBQ
53 * and it will live until better solution will be invented.
55 struct Qdisc *__parent;
58 struct Qdisc_class_ops
60 /* Child qdisc manipulation */
61 int (*graft)(struct Qdisc *, unsigned long cl,
62 struct Qdisc *, struct Qdisc **);
63 struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl);
65 /* Class manipulation routines */
66 unsigned long (*get)(struct Qdisc *, u32 classid);
67 void (*put)(struct Qdisc *, unsigned long);
68 int (*change)(struct Qdisc *, u32, u32,
69 struct rtattr **, unsigned long *);
70 int (*delete)(struct Qdisc *, unsigned long);
71 void (*walk)(struct Qdisc *, struct qdisc_walker * arg);
73 /* Filter manipulation */
74 struct tcf_proto ** (*tcf_chain)(struct Qdisc *, unsigned long);
75 unsigned long (*bind_tcf)(struct Qdisc *, unsigned long,
77 void (*unbind_tcf)(struct Qdisc *, unsigned long);
79 /* rtnetlink specific */
80 int (*dump)(struct Qdisc *, unsigned long,
81 struct sk_buff *skb, struct tcmsg*);
82 int (*dump_stats)(struct Qdisc *, unsigned long,
88 struct Qdisc_ops *next;
89 struct Qdisc_class_ops *cl_ops;
93 int (*enqueue)(struct sk_buff *, struct Qdisc *);
94 struct sk_buff * (*dequeue)(struct Qdisc *);
95 int (*requeue)(struct sk_buff *, struct Qdisc *);
96 unsigned int (*drop)(struct Qdisc *);
98 int (*init)(struct Qdisc *, struct rtattr *arg);
99 void (*reset)(struct Qdisc *);
100 void (*destroy)(struct Qdisc *);
101 int (*change)(struct Qdisc *, struct rtattr *arg);
103 int (*dump)(struct Qdisc *, struct sk_buff *);
104 int (*dump_stats)(struct Qdisc *, struct gnet_dump *);
106 struct module *owner;
118 struct tcf_proto_ops *next;
121 int (*classify)(struct sk_buff*, struct tcf_proto*,
122 struct tcf_result *);
123 int (*init)(struct tcf_proto*);
124 void (*destroy)(struct tcf_proto*);
126 unsigned long (*get)(struct tcf_proto*, u32 handle);
127 void (*put)(struct tcf_proto*, unsigned long);
128 int (*change)(struct tcf_proto*, unsigned long,
129 u32 handle, struct rtattr **,
131 int (*delete)(struct tcf_proto*, unsigned long);
132 void (*walk)(struct tcf_proto*, struct tcf_walker *arg);
134 /* rtnetlink specific */
135 int (*dump)(struct tcf_proto*, unsigned long,
136 struct sk_buff *skb, struct tcmsg*);
138 struct module *owner;
143 /* Fast access part */
144 struct tcf_proto *next;
146 int (*classify)(struct sk_buff*, struct tcf_proto*,
147 struct tcf_result *);
155 struct tcf_proto_ops *ops;
159 extern void qdisc_lock_tree(struct net_device *dev);
160 extern void qdisc_unlock_tree(struct net_device *dev);
162 #define sch_tree_lock(q) qdisc_lock_tree((q)->dev)
163 #define sch_tree_unlock(q) qdisc_unlock_tree((q)->dev)
164 #define tcf_tree_lock(tp) qdisc_lock_tree((tp)->q->dev)
165 #define tcf_tree_unlock(tp) qdisc_unlock_tree((tp)->q->dev)
168 tcf_destroy(struct tcf_proto *tp)
170 tp->ops->destroy(tp);
171 module_put(tp->ops->owner);