Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef __NET_TC_GACT_H |
| 3 | #define __NET_TC_GACT_H |
| 4 | |
| 5 | #include <net/act_api.h> |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 6 | #include <linux/tc_act/tc_gact.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 8 | struct tcf_gact { |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 9 | struct tc_action common; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #ifdef CONFIG_GACT_PROB |
Eric Dumazet | cc6510a | 2015-07-06 05:18:06 -0700 | [diff] [blame] | 11 | u16 tcfg_ptype; |
| 12 | u16 tcfg_pval; |
| 13 | int tcfg_paction; |
| 14 | atomic_t packets; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | }; |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 17 | #define to_gact(a) ((struct tcf_gact *)a) |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 18 | |
Jiri Pirko | e457d86 | 2017-08-23 10:08:19 +0200 | [diff] [blame] | 19 | static inline bool __is_tcf_gact_act(const struct tc_action *a, int act, |
| 20 | bool is_ext) |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 21 | { |
Amir Vadai | 00175ae | 2016-03-08 12:42:31 +0200 | [diff] [blame] | 22 | #ifdef CONFIG_NET_CLS_ACT |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 23 | struct tcf_gact *gact; |
| 24 | |
Eli Cohen | eddd2cf | 2019-02-10 14:25:00 +0200 | [diff] [blame] | 25 | if (a->ops && a->ops->id != TCA_ID_GACT) |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 26 | return false; |
| 27 | |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 28 | gact = to_gact(a); |
Jiri Pirko | e457d86 | 2017-08-23 10:08:19 +0200 | [diff] [blame] | 29 | if ((!is_ext && gact->tcf_action == act) || |
| 30 | (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act))) |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 31 | return true; |
| 32 | |
Amir Vadai | 00175ae | 2016-03-08 12:42:31 +0200 | [diff] [blame] | 33 | #endif |
John Fastabend | 3b01cf5 | 2016-02-16 21:18:03 -0800 | [diff] [blame] | 34 | return false; |
| 35 | } |
Jiri Pirko | 5a4d1fe | 2017-06-06 14:12:03 +0200 | [diff] [blame] | 36 | |
Jiri Pirko | 3b8e923 | 2017-09-25 10:58:21 +0200 | [diff] [blame] | 37 | static 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 | |
Jiri Pirko | 5a4d1fe | 2017-06-06 14:12:03 +0200 | [diff] [blame] | 42 | static inline bool is_tcf_gact_shot(const struct tc_action *a) |
| 43 | { |
Jiri Pirko | e457d86 | 2017-08-23 10:08:19 +0200 | [diff] [blame] | 44 | return __is_tcf_gact_act(a, TC_ACT_SHOT, false); |
Jiri Pirko | 5a4d1fe | 2017-06-06 14:12:03 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static inline bool is_tcf_gact_trap(const struct tc_action *a) |
| 48 | { |
Jiri Pirko | e457d86 | 2017-08-23 10:08:19 +0200 | [diff] [blame] | 49 | return __is_tcf_gact_act(a, TC_ACT_TRAP, false); |
| 50 | } |
| 51 | |
| 52 | static 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 | |
| 57 | static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a) |
| 58 | { |
Davide Caratti | fe384e2 | 2019-03-20 15:00:15 +0100 | [diff] [blame] | 59 | return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK; |
Jiri Pirko | 5a4d1fe | 2017-06-06 14:12:03 +0200 | [diff] [blame] | 60 | } |
| 61 | |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 62 | #endif /* __NET_TC_GACT_H */ |