blob: eb8f01c819e636aca55019cbe791b0e40b612baf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __NET_TC_GACT_H
3#define __NET_TC_GACT_H
4
5#include <net/act_api.h>
John Fastabend3b01cf52016-02-16 21:18:03 -08006#include <linux/tc_act/tc_gact.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
David S. Millere9ce1cd2006-08-21 23:54:55 -07008struct tcf_gact {
WANG Congec0595c2016-07-25 16:09:42 -07009 struct tc_action common;
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#ifdef CONFIG_GACT_PROB
Eric Dumazetcc6510a2015-07-06 05:18:06 -070011 u16 tcfg_ptype;
12 u16 tcfg_pval;
13 int tcfg_paction;
14 atomic_t packets;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070016};
WANG Conga85a9702016-07-25 16:09:41 -070017#define to_gact(a) ((struct tcf_gact *)a)
David S. Millere9ce1cd2006-08-21 23:54:55 -070018
Jiri Pirkoe457d862017-08-23 10:08:19 +020019static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
20 bool is_ext)
John Fastabend3b01cf52016-02-16 21:18:03 -080021{
Amir Vadai00175ae2016-03-08 12:42:31 +020022#ifdef CONFIG_NET_CLS_ACT
John Fastabend3b01cf52016-02-16 21:18:03 -080023 struct tcf_gact *gact;
24
Eli Coheneddd2cf2019-02-10 14:25:00 +020025 if (a->ops && a->ops->id != TCA_ID_GACT)
John Fastabend3b01cf52016-02-16 21:18:03 -080026 return false;
27
WANG Conga85a9702016-07-25 16:09:41 -070028 gact = to_gact(a);
Jiri Pirkoe457d862017-08-23 10:08:19 +020029 if ((!is_ext && gact->tcf_action == act) ||
30 (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
John Fastabend3b01cf52016-02-16 21:18:03 -080031 return true;
32
Amir Vadai00175ae2016-03-08 12:42:31 +020033#endif
John Fastabend3b01cf52016-02-16 21:18:03 -080034 return false;
35}
Jiri Pirko5a4d1fe2017-06-06 14:12:03 +020036
Jiri Pirko3b8e9232017-09-25 10:58:21 +020037static 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 Pirko5a4d1fe2017-06-06 14:12:03 +020042static inline bool is_tcf_gact_shot(const struct tc_action *a)
43{
Jiri Pirkoe457d862017-08-23 10:08:19 +020044 return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
Jiri Pirko5a4d1fe2017-06-06 14:12:03 +020045}
46
47static inline bool is_tcf_gact_trap(const struct tc_action *a)
48{
Jiri Pirkoe457d862017-08-23 10:08:19 +020049 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{
Davide Carattife384e22019-03-20 15:00:15 +010059 return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
Jiri Pirko5a4d1fe2017-06-06 14:12:03 +020060}
61
David S. Millere9ce1cd2006-08-21 23:54:55 -070062#endif /* __NET_TC_GACT_H */