1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_TC_PED_H
3 #define __LINUX_TC_PED_H
4 
5 #include <linux/types.h>
6 #include <linux/pkt_cls.h>
7 
8 enum {
9 	TCA_PEDIT_UNSPEC,
10 	TCA_PEDIT_TM,
11 	TCA_PEDIT_PARMS,
12 	TCA_PEDIT_PAD,
13 	TCA_PEDIT_PARMS_EX,
14 	TCA_PEDIT_KEYS_EX,
15 	TCA_PEDIT_KEY_EX,
16 	__TCA_PEDIT_MAX
17 };
18 
19 #define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
20 
21 enum {
22 	TCA_PEDIT_KEY_EX_HTYPE = 1,
23 	TCA_PEDIT_KEY_EX_CMD = 2,
24 	__TCA_PEDIT_KEY_EX_MAX
25 };
26 
27 #define TCA_PEDIT_KEY_EX_MAX (__TCA_PEDIT_KEY_EX_MAX - 1)
28 
29  /* TCA_PEDIT_KEY_EX_HDR_TYPE_NETWROK is a special case for legacy users. It
30   * means no specific header type - offset is relative to the network layer
31   */
32 enum pedit_header_type {
33 	TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK = 0,
34 	TCA_PEDIT_KEY_EX_HDR_TYPE_ETH = 1,
35 	TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 = 2,
36 	TCA_PEDIT_KEY_EX_HDR_TYPE_IP6 = 3,
37 	TCA_PEDIT_KEY_EX_HDR_TYPE_TCP = 4,
38 	TCA_PEDIT_KEY_EX_HDR_TYPE_UDP = 5,
39 	__PEDIT_HDR_TYPE_MAX,
40 };
41 
42 #define TCA_PEDIT_HDR_TYPE_MAX (__PEDIT_HDR_TYPE_MAX - 1)
43 
44 enum pedit_cmd {
45 	TCA_PEDIT_KEY_EX_CMD_SET = 0,
46 	TCA_PEDIT_KEY_EX_CMD_ADD = 1,
47 	__PEDIT_CMD_MAX,
48 };
49 
50 #define TCA_PEDIT_CMD_MAX (__PEDIT_CMD_MAX - 1)
51 
52 struct tc_pedit_key {
53 	__u32           mask;  /* AND */
54 	__u32           val;   /*XOR */
55 	__u32           off;  /*offset */
56 	__u32           at;
57 	__u32           offmask;
58 	__u32           shift;
59 };
60 
61 struct tc_pedit_sel {
62 	tc_gen;
63 	unsigned char           nkeys;
64 	unsigned char           flags;
65 	struct tc_pedit_key     keys[0];
66 };
67 
68 #define tc_pedit tc_pedit_sel
69 
70 #endif
71