File Index
Files and directories
Sign in
FILE

tc_pedit.h

File preview with syntax highlighting.

linux-6.19.14/include/net/tc_act/tc_pedit.h C
  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#include <linux/types.h>
  8
  9struct tcf_pedit_key_ex {
 10	enum pedit_header_type htype;
 11	enum pedit_cmd cmd;
 12};
 13
 14struct tcf_pedit_parms {
 15	struct tc_pedit_key	*tcfp_keys;
 16	struct tcf_pedit_key_ex	*tcfp_keys_ex;
 17	int action;
 18	u32 tcfp_off_max_hint;
 19	unsigned char tcfp_nkeys;
 20	unsigned char tcfp_flags;
 21	struct rcu_head rcu;
 22};
 23
 24struct tcf_pedit {
 25	struct tc_action common;
 26	struct tcf_pedit_parms __rcu *parms;
 27};
 28
 29#define to_pedit(a) ((struct tcf_pedit *)a)
 30#define to_pedit_parms(a) (rcu_dereference(to_pedit(a)->parms))
 31
 32static inline bool is_tcf_pedit(const struct tc_action *a)
 33{
 34#ifdef CONFIG_NET_CLS_ACT
 35	if (a->ops && a->ops->id == TCA_ID_PEDIT)
 36		return true;
 37#endif
 38	return false;
 39}
 40
 41static inline int tcf_pedit_nkeys(const struct tc_action *a)
 42{
 43	struct tcf_pedit_parms *parms;
 44	int nkeys;
 45
 46	rcu_read_lock();
 47	parms = to_pedit_parms(a);
 48	nkeys = parms->tcfp_nkeys;
 49	rcu_read_unlock();
 50
 51	return nkeys;
 52}
 53
 54static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
 55{
 56	u32 htype = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
 57	struct tcf_pedit_parms *parms;
 58
 59	rcu_read_lock();
 60	parms = to_pedit_parms(a);
 61	if (parms->tcfp_keys_ex)
 62		htype = parms->tcfp_keys_ex[index].htype;
 63	rcu_read_unlock();
 64
 65	return htype;
 66}
 67
 68static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
 69{
 70	struct tcf_pedit_parms *parms;
 71	u32 cmd = __PEDIT_CMD_MAX;
 72
 73	rcu_read_lock();
 74	parms = to_pedit_parms(a);
 75	if (parms->tcfp_keys_ex)
 76		cmd = parms->tcfp_keys_ex[index].cmd;
 77	rcu_read_unlock();
 78
 79	return cmd;
 80}
 81
 82static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
 83{
 84	struct tcf_pedit_parms *parms;
 85	u32 mask;
 86
 87	rcu_read_lock();
 88	parms = to_pedit_parms(a);
 89	mask = parms->tcfp_keys[index].mask;
 90	rcu_read_unlock();
 91
 92	return mask;
 93}
 94
 95static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
 96{
 97	struct tcf_pedit_parms *parms;
 98	u32 val;
 99
100	rcu_read_lock();
101	parms = to_pedit_parms(a);
102	val = parms->tcfp_keys[index].val;
103	rcu_read_unlock();
104
105	return val;
106}
107
108static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
109{
110	struct tcf_pedit_parms *parms;
111	u32 off;
112
113	rcu_read_lock();
114	parms = to_pedit_parms(a);
115	off = parms->tcfp_keys[index].off;
116	rcu_read_unlock();
117
118	return off;
119}
120#endif /* __NET_TC_PED_H */
~/ Read-only file preview.