[PATCH] make tty_insert_flip_string_flags() a non gpl export
[linux-2.6.22.y-op.git] / include / net / act_api.h
blob11e9eaf79f5ab37f49f1a895f90156a58db0d6ba
1 #ifndef __NET_ACT_API_H
2 #define __NET_ACT_API_H
4 /*
5 * Public police action API for classifiers/qdiscs
6 */
8 #include <net/sch_generic.h>
9 #include <net/pkt_sched.h>
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
25 struct tcf_police
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;
39 #ifdef CONFIG_NET_CLS_ACT
41 #define ACT_P_CREATED 1
42 #define ACT_P_DELETED 1
44 struct tcf_act_hdr
46 tca_gen(act_hdr);
49 struct tc_action
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;
58 #define TCA_CAP_NONE 0
59 struct tc_action_ops
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 *, struct tcf_result *);
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 *);
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 struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err);
80 extern struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err);
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 *, int);
85 #endif /* CONFIG_NET_CLS_ACT */
87 extern int tcf_police(struct sk_buff *skb, struct tcf_police *p);
88 extern void tcf_police_destroy(struct tcf_police *p);
89 extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est);
90 extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p);
91 extern int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p);
93 static inline int
94 tcf_police_release(struct tcf_police *p, int bind)
96 int ret = 0;
97 #ifdef CONFIG_NET_CLS_ACT
98 if (p) {
99 if (bind) {
100 p->bindcnt--;
102 p->refcnt--;
103 if (p->refcnt <= 0 && !p->bindcnt) {
104 tcf_police_destroy(p);
105 ret = 1;
108 #else
109 if (p && --p->refcnt == 0)
110 tcf_police_destroy(p);
112 #endif /* CONFIG_NET_CLS_ACT */
113 return ret;
116 #endif