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 struct tc_pedit_key
*tcfp_keys
;
18 struct tcf_pedit_key_ex
*tcfp_keys_ex
;
21 #define to_pedit(a) ((struct tcf_pedit *)a)
23 static inline bool is_tcf_pedit(const struct tc_action
*a
)
25 #ifdef CONFIG_NET_CLS_ACT
26 if (a
->ops
&& a
->ops
->type
== TCA_ACT_PEDIT
)
32 static inline int tcf_pedit_nkeys(const struct tc_action
*a
)
34 return to_pedit(a
)->tcfp_nkeys
;
37 static inline u32
tcf_pedit_htype(const struct tc_action
*a
, int index
)
39 if (to_pedit(a
)->tcfp_keys_ex
)
40 return to_pedit(a
)->tcfp_keys_ex
[index
].htype
;
42 return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK
;
45 static inline u32
tcf_pedit_cmd(const struct tc_action
*a
, int index
)
47 if (to_pedit(a
)->tcfp_keys_ex
)
48 return to_pedit(a
)->tcfp_keys_ex
[index
].cmd
;
50 return __PEDIT_CMD_MAX
;
53 static inline u32
tcf_pedit_mask(const struct tc_action
*a
, int index
)
55 return to_pedit(a
)->tcfp_keys
[index
].mask
;
58 static inline u32
tcf_pedit_val(const struct tc_action
*a
, int index
)
60 return to_pedit(a
)->tcfp_keys
[index
].val
;
63 static inline u32
tcf_pedit_offset(const struct tc_action
*a
, int index
)
65 return to_pedit(a
)->tcfp_keys
[index
].off
;
67 #endif /* __NET_TC_PED_H */