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
7struct 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
18static 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
36static inline bool is_tcf_gact_ok(const struct tc_action *a)
37{
38 return __is_tcf_gact_act(a, TC_ACT_OK, false);
39}
40
41static inline bool is_tcf_gact_shot(const struct tc_action *a)
42{
43 return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
44}
45
46static inline bool is_tcf_gact_trap(const struct tc_action *a)
47{
48 return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
49}
50
51static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
52{
53 return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
54}
55
56static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
57{
58 return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
59}
60
61#endif
62