Linux Audio

Check our new training course

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