Loading...
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 tcf_common 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) \
17 container_of(a->priv, struct tcf_gact, common)
18
19static inline bool is_tcf_gact_shot(const struct tc_action *a)
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 = a->priv;
28 if (gact->tcf_action == TC_ACT_SHOT)
29 return true;
30
31#endif
32 return false;
33}
34#endif /* __NET_TC_GACT_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __NET_TC_GACT_H
3#define __NET_TC_GACT_H
4
5#include <net/act_api.h>
6#include <linux/tc_act/tc_gact.h>
7
8struct tcf_gact {
9 struct tc_action common;
10#ifdef CONFIG_GACT_PROB
11 u16 tcfg_ptype;
12 u16 tcfg_pval;
13 int tcfg_paction;
14 atomic_t packets;
15#endif
16};
17#define to_gact(a) ((struct tcf_gact *)a)
18
19static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
20 bool is_ext)
21{
22#ifdef CONFIG_NET_CLS_ACT
23 struct tcf_gact *gact;
24
25 if (a->ops && a->ops->id != TCA_ID_GACT)
26 return false;
27
28 gact = to_gact(a);
29 if ((!is_ext && gact->tcf_action == act) ||
30 (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
31 return true;
32
33#endif
34 return false;
35}
36
37static inline bool is_tcf_gact_ok(const struct tc_action *a)
38{
39 return __is_tcf_gact_act(a, TC_ACT_OK, false);
40}
41
42static inline bool is_tcf_gact_shot(const struct tc_action *a)
43{
44 return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
45}
46
47static inline bool is_tcf_gact_trap(const struct tc_action *a)
48{
49 return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
50}
51
52static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
53{
54 return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
55}
56
57static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
58{
59 return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
60}
61
62#endif /* __NET_TC_GACT_H */