xref: /openbmc/linux/include/net/tc_act/tc_pedit.h (revision 5d0e4d78)
1 #ifndef __NET_TC_PED_H
2 #define __NET_TC_PED_H
3 
4 #include <net/act_api.h>
5 #include <linux/tc_act/tc_pedit.h>
6 
7 struct tcf_pedit_key_ex {
8 	enum pedit_header_type htype;
9 	enum pedit_cmd cmd;
10 };
11 
12 struct tcf_pedit {
13 	struct tc_action	common;
14 	unsigned char		tcfp_nkeys;
15 	unsigned char		tcfp_flags;
16 	struct tc_pedit_key	*tcfp_keys;
17 	struct tcf_pedit_key_ex	*tcfp_keys_ex;
18 };
19 #define to_pedit(a) ((struct tcf_pedit *)a)
20 
21 static inline bool is_tcf_pedit(const struct tc_action *a)
22 {
23 #ifdef CONFIG_NET_CLS_ACT
24 	if (a->ops && a->ops->type == TCA_ACT_PEDIT)
25 		return true;
26 #endif
27 	return false;
28 }
29 
30 static inline int tcf_pedit_nkeys(const struct tc_action *a)
31 {
32 	return to_pedit(a)->tcfp_nkeys;
33 }
34 
35 static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
36 {
37 	if (to_pedit(a)->tcfp_keys_ex)
38 		return to_pedit(a)->tcfp_keys_ex[index].htype;
39 
40 	return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
41 }
42 
43 static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
44 {
45 	if (to_pedit(a)->tcfp_keys_ex)
46 		return to_pedit(a)->tcfp_keys_ex[index].cmd;
47 
48 	return __PEDIT_CMD_MAX;
49 }
50 
51 static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
52 {
53 	return to_pedit(a)->tcfp_keys[index].mask;
54 }
55 
56 static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
57 {
58 	return to_pedit(a)->tcfp_keys[index].val;
59 }
60 
61 static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
62 {
63 	return to_pedit(a)->tcfp_keys[index].off;
64 }
65 #endif /* __NET_TC_PED_H */
66