1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <net/act_api.h>
6 #include <linux/tc_act/tc_pedit.h>
8 struct tcf_pedit_key_ex {
9 enum pedit_header_type htype;
14 struct tc_action common;
15 unsigned char tcfp_nkeys;
16 unsigned char tcfp_flags;
17 u32 tcfp_off_max_hint;
18 struct tc_pedit_key *tcfp_keys;
19 struct tcf_pedit_key_ex *tcfp_keys_ex;
22 #define to_pedit(a) ((struct tcf_pedit *)a)
24 static inline bool is_tcf_pedit(const struct tc_action *a)
26 #ifdef CONFIG_NET_CLS_ACT
27 if (a->ops && a->ops->id == TCA_ID_PEDIT)
33 static inline int tcf_pedit_nkeys(const struct tc_action *a)
35 return to_pedit(a)->tcfp_nkeys;
38 static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
40 if (to_pedit(a)->tcfp_keys_ex)
41 return to_pedit(a)->tcfp_keys_ex[index].htype;
43 return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
46 static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
48 if (to_pedit(a)->tcfp_keys_ex)
49 return to_pedit(a)->tcfp_keys_ex[index].cmd;
51 return __PEDIT_CMD_MAX;
54 static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
56 return to_pedit(a)->tcfp_keys[index].mask;
59 static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
61 return to_pedit(a)->tcfp_keys[index].val;
64 static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
66 return to_pedit(a)->tcfp_keys[index].off;
68 #endif /* __NET_TC_PED_H */