Merge branch 'for-4.14/block-postmerge' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / include / net / tc_act / tc_gact.h
1 #ifndef __NET_TC_GACT_H
2 #define __NET_TC_GACT_H
3
4 #include <net/act_api.h>
5 #include <linux/tc_act/tc_gact.h>
6
7 struct tcf_gact {
8         struct tc_action        common;
9 #ifdef CONFIG_GACT_PROB
10         u16                     tcfg_ptype;
11         u16                     tcfg_pval;
12         int                     tcfg_paction;
13         atomic_t                packets;
14 #endif
15 };
16 #define to_gact(a) ((struct tcf_gact *)a)
17
18 static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
19                                      bool is_ext)
20 {
21 #ifdef CONFIG_NET_CLS_ACT
22         struct tcf_gact *gact;
23
24         if (a->ops && a->ops->type != TCA_ACT_GACT)
25                 return false;
26
27         gact = to_gact(a);
28         if ((!is_ext && gact->tcf_action == act) ||
29             (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
30                 return true;
31
32 #endif
33         return false;
34 }
35
36 static inline bool is_tcf_gact_shot(const struct tc_action *a)
37 {
38         return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
39 }
40
41 static inline bool is_tcf_gact_trap(const struct tc_action *a)
42 {
43         return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
44 }
45
46 static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
47 {
48         return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
49 }
50
51 static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
52 {
53         return a->goto_chain->index;
54 }
55
56 #endif /* __NET_TC_GACT_H */