This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / net / act_api.h
1 #ifndef __NET_ACT_API_H
2 #define __NET_ACT_API_H
3
4 /*
5  * Public police action API for classifiers/qdiscs
6  */
7
8 #include <net/sch_generic.h>
9 #include <net/pkt_sched.h>
10
11 #define tca_gen(name) \
12 struct tcf_##name *next; \
13         u32 index; \
14         int refcnt; \
15         int bindcnt; \
16         u32 capab; \
17         int action; \
18         struct tcf_t tm; \
19         struct gnet_stats_basic bstats; \
20         struct gnet_stats_queue qstats; \
21         struct gnet_stats_rate_est rate_est; \
22         spinlock_t *stats_lock; \
23         spinlock_t lock
24
25 struct tcf_police
26 {
27         tca_gen(police);
28         int             result;
29         u32             ewma_rate;
30         u32             burst;
31         u32             mtu;
32         u32             toks;
33         u32             ptoks;
34         psched_time_t   t_c;
35         struct qdisc_rate_table *R_tab;
36         struct qdisc_rate_table *P_tab;
37 };
38
39 #ifdef CONFIG_NET_CLS_ACT
40
41 #define ACT_P_CREATED 1
42 #define ACT_P_DELETED 1
43
44 struct tcf_act_hdr
45 {
46         tca_gen(act_hdr);
47 };
48
49 struct tc_action
50 {
51         void *priv;
52         struct tc_action_ops *ops;
53         __u32   type;   /* for backward compat(TCA_OLD_COMPAT) */
54         __u32   order; 
55         struct tc_action *next;
56 };
57
58 #define TCA_CAP_NONE 0
59 struct tc_action_ops
60 {
61         struct tc_action_ops *next;
62         char    kind[IFNAMSIZ];
63         __u32   type; /* TBD to match kind */
64         __u32   capab;  /* capabilities includes 4 bit version */
65         struct module           *owner;
66         int     (*act)(struct sk_buff **, struct tc_action *);
67         int     (*get_stats)(struct sk_buff *, struct tc_action *);
68         int     (*dump)(struct sk_buff *, struct tc_action *,int , int);
69         int     (*cleanup)(struct tc_action *, int bind);
70         int     (*lookup)(struct tc_action *, u32 );
71         int     (*init)(struct rtattr *,struct rtattr *,struct tc_action *, int , int );
72         int     (*walk)(struct sk_buff *, struct netlink_callback *, int , struct tc_action *);
73 };
74
75 extern int tcf_register_action(struct tc_action_ops *a);
76 extern int tcf_unregister_action(struct tc_action_ops *a);
77 extern void tcf_action_destroy(struct tc_action *a, int bind);
78 extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
79 extern int tcf_action_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
80 extern int tcf_action_init_1(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
81 extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
82 extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
83 extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
84 extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *);
85 extern int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,struct tc_action *,int , int );
86 extern int tcf_act_police_dump(struct sk_buff *, struct tc_action *, int, int);
87 extern int tcf_act_police(struct sk_buff **skb, struct tc_action *a);
88 #endif /* CONFIG_NET_CLS_ACT */
89
90 extern int tcf_police(struct sk_buff *skb, struct tcf_police *p);
91 extern void tcf_police_destroy(struct tcf_police *p);
92 extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est);
93 extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p);
94 extern int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p);
95
96 static inline int
97 tcf_police_release(struct tcf_police *p, int bind)
98 {
99         int ret = 0;
100 #ifdef CONFIG_NET_CLS_ACT
101         if (p) {
102                 if (bind) {
103                          p->bindcnt--;
104                 }
105                 p->refcnt--;
106                 if (p->refcnt <= 0 && !p->bindcnt) {
107                         tcf_police_destroy(p);
108                         ret = 1;
109                 }
110         }
111 #else
112         if (p && --p->refcnt == 0)
113                 tcf_police_destroy(p);
114
115 #endif /* CONFIG_NET_CLS_ACT */
116         return ret;
117 }
118
119 #endif