1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <net/act_api.h>
6 #include <linux/tc_act/tc_pedit.h>
7 #include <linux/types.h>
9 struct tcf_pedit_key_ex {
10 enum pedit_header_type htype;
14 struct tcf_pedit_parms {
15 struct tc_pedit_key *tcfp_keys;
16 struct tcf_pedit_key_ex *tcfp_keys_ex;
17 u32 tcfp_off_max_hint;
18 unsigned char tcfp_nkeys;
19 unsigned char tcfp_flags;
24 struct tc_action common;
25 struct tcf_pedit_parms __rcu *parms;
28 #define to_pedit(a) ((struct tcf_pedit *)a)
29 #define to_pedit_parms(a) (rcu_dereference(to_pedit(a)->parms))
31 static inline bool is_tcf_pedit(const struct tc_action *a)
33 #ifdef CONFIG_NET_CLS_ACT
34 if (a->ops && a->ops->id == TCA_ID_PEDIT)
40 static inline int tcf_pedit_nkeys(const struct tc_action *a)
42 struct tcf_pedit_parms *parms;
46 parms = to_pedit_parms(a);
47 nkeys = parms->tcfp_nkeys;
53 static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
55 u32 htype = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
56 struct tcf_pedit_parms *parms;
59 parms = to_pedit_parms(a);
60 if (parms->tcfp_keys_ex)
61 htype = parms->tcfp_keys_ex[index].htype;
67 static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
69 struct tcf_pedit_parms *parms;
70 u32 cmd = __PEDIT_CMD_MAX;
73 parms = to_pedit_parms(a);
74 if (parms->tcfp_keys_ex)
75 cmd = parms->tcfp_keys_ex[index].cmd;
81 static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
83 struct tcf_pedit_parms *parms;
87 parms = to_pedit_parms(a);
88 mask = parms->tcfp_keys[index].mask;
94 static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
96 struct tcf_pedit_parms *parms;
100 parms = to_pedit_parms(a);
101 val = parms->tcfp_keys[index].val;
107 static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
109 struct tcf_pedit_parms *parms;
113 parms = to_pedit_parms(a);
114 off = parms->tcfp_keys[index].off;
119 #endif /* __NET_TC_PED_H */