Skip to content

Commit ffe2e21

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/sched: Add accessor functions to pedit keys for offloading drivers
HW drivers will use the header-type and command fields from the extended keys, and some fields (e.g mask, val, offset) from the legacy keys. Signed-off-by: Or Gerlitz <[email protected]> Reviewed-by: Hadar Hen Zion <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2de24fe commit ffe2e21

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

include/net/tc_act/tc_pedit.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __NET_TC_PED_H
33

44
#include <net/act_api.h>
5+
#include <linux/tc_act/tc_pedit.h>
56

67
struct tcf_pedit_key_ex {
78
enum pedit_header_type htype;
@@ -17,4 +18,48 @@ struct tcf_pedit {
1718
};
1819
#define to_pedit(a) ((struct tcf_pedit *)a)
1920

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+
}
2065
#endif /* __NET_TC_PED_H */

0 commit comments

Comments
 (0)