1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2008, Intel Corporation.
5 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
8 #ifndef __NET_TC_SKBEDIT_H
9 #define __NET_TC_SKBEDIT_H
11 #include <net/act_api.h>
12 #include <linux/tc_act/tc_skbedit.h>
14 struct tcf_skbedit_params {
26 struct tc_action common;
27 struct tcf_skbedit_params __rcu *params;
29 #define to_skbedit(a) ((struct tcf_skbedit *)a)
31 /* Return true iff action is the one identified by FLAG. */
32 static inline bool is_tcf_skbedit_with_flag(const struct tc_action *a, u32 flag)
34 #ifdef CONFIG_NET_CLS_ACT
37 if (a->ops && a->ops->id == TCA_ID_SKBEDIT) {
39 flags = rcu_dereference(to_skbedit(a)->params)->flags;
47 /* Return true iff action is mark */
48 static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
50 return is_tcf_skbedit_with_flag(a, SKBEDIT_F_MARK);
53 static inline u32 tcf_skbedit_mark(const struct tc_action *a)
58 mark = rcu_dereference(to_skbedit(a)->params)->mark;
64 /* Return true iff action is ptype */
65 static inline bool is_tcf_skbedit_ptype(const struct tc_action *a)
67 return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PTYPE);
70 static inline u32 tcf_skbedit_ptype(const struct tc_action *a)
75 ptype = rcu_dereference(to_skbedit(a)->params)->ptype;
81 /* Return true iff action is priority */
82 static inline bool is_tcf_skbedit_priority(const struct tc_action *a)
84 return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PRIORITY);
87 static inline u32 tcf_skbedit_priority(const struct tc_action *a)
92 priority = rcu_dereference(to_skbedit(a)->params)->priority;
98 static inline u16 tcf_skbedit_rx_queue_mapping(const struct tc_action *a)
103 rx_queue = rcu_dereference(to_skbedit(a)->params)->queue_mapping;
109 /* Return true iff action is queue_mapping */
110 static inline bool is_tcf_skbedit_queue_mapping(const struct tc_action *a)
112 return is_tcf_skbedit_with_flag(a, SKBEDIT_F_QUEUE_MAPPING);
115 /* Return true if action is on ingress traffic */
116 static inline bool is_tcf_skbedit_ingress(u32 flags)
118 return flags & TCA_ACT_FLAGS_AT_INGRESS;
121 static inline bool is_tcf_skbedit_tx_queue_mapping(const struct tc_action *a)
123 return is_tcf_skbedit_queue_mapping(a) &&
124 !is_tcf_skbedit_ingress(a->tcfa_flags);
127 static inline bool is_tcf_skbedit_rx_queue_mapping(const struct tc_action *a)
129 return is_tcf_skbedit_queue_mapping(a) &&
130 is_tcf_skbedit_ingress(a->tcfa_flags);
133 /* Return true iff action is inheritdsfield */
134 static inline bool is_tcf_skbedit_inheritdsfield(const struct tc_action *a)
136 return is_tcf_skbedit_with_flag(a, SKBEDIT_F_INHERITDSFIELD);
139 #endif /* __NET_TC_SKBEDIT_H */