xref: /linux/include/uapi/linux/pkt_cls.h (revision 216203bd)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_PKT_CLS_H
3 #define __LINUX_PKT_CLS_H
4 
5 #include <linux/types.h>
6 #include <linux/pkt_sched.h>
7 
8 #define TC_COOKIE_MAX_SIZE 16
9 
10 /* Action attributes */
11 enum {
12 	TCA_ACT_UNSPEC,
13 	TCA_ACT_KIND,
14 	TCA_ACT_OPTIONS,
15 	TCA_ACT_INDEX,
16 	TCA_ACT_STATS,
17 	TCA_ACT_PAD,
18 	TCA_ACT_COOKIE,
19 	TCA_ACT_FLAGS,
20 	TCA_ACT_HW_STATS,
21 	TCA_ACT_USED_HW_STATS,
22 	TCA_ACT_IN_HW_COUNT,
23 	__TCA_ACT_MAX
24 };
25 
26 /* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */
27 #define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0) /* Don't use percpu allocator for
28 						* actions stats.
29 						*/
30 #define TCA_ACT_FLAGS_SKIP_HW	(1 << 1) /* don't offload action to HW */
31 #define TCA_ACT_FLAGS_SKIP_SW	(1 << 2) /* don't use action in SW */
32 
33 /* tca HW stats type
34  * When user does not pass the attribute, he does not care.
35  * It is the same as if he would pass the attribute with
36  * all supported bits set.
37  * In case no bits are set, user is not interested in getting any HW statistics.
38  */
39 #define TCA_ACT_HW_STATS_IMMEDIATE (1 << 0) /* Means that in dump, user
40 					     * gets the current HW stats
41 					     * state from the device
42 					     * queried at the dump time.
43 					     */
44 #define TCA_ACT_HW_STATS_DELAYED (1 << 1) /* Means that in dump, user gets
45 					   * HW stats that might be out of date
46 					   * for some time, maybe couple of
47 					   * seconds. This is the case when
48 					   * driver polls stats updates
49 					   * periodically or when it gets async
50 					   * stats update from the device.
51 					   */
52 
53 #define TCA_ACT_MAX __TCA_ACT_MAX
54 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
55 #define TCA_ACT_MAX_PRIO 32
56 #define TCA_ACT_BIND	1
57 #define TCA_ACT_NOBIND	0
58 #define TCA_ACT_UNBIND	1
59 #define TCA_ACT_NOUNBIND	0
60 #define TCA_ACT_REPLACE		1
61 #define TCA_ACT_NOREPLACE	0
62 
63 #define TC_ACT_UNSPEC	(-1)
64 #define TC_ACT_OK		0
65 #define TC_ACT_RECLASSIFY	1
66 #define TC_ACT_SHOT		2
67 #define TC_ACT_PIPE		3
68 #define TC_ACT_STOLEN		4
69 #define TC_ACT_QUEUED		5
70 #define TC_ACT_REPEAT		6
71 #define TC_ACT_REDIRECT		7
72 #define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu"
73 				   * and don't further process the frame
74 				   * in hardware. For sw path, this is
75 				   * equivalent of TC_ACT_STOLEN - drop
76 				   * the skb and act like everything
77 				   * is alright.
78 				   */
79 #define TC_ACT_VALUE_MAX	TC_ACT_TRAP
80 
81 /* There is a special kind of actions called "extended actions",
82  * which need a value parameter. These have a local opcode located in
83  * the highest nibble, starting from 1. The rest of the bits
84  * are used to carry the value. These two parts together make
85  * a combined opcode.
86  */
87 #define __TC_ACT_EXT_SHIFT 28
88 #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT)
89 #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1)
90 #define TC_ACT_EXT_OPCODE(combined) ((combined) & (~TC_ACT_EXT_VAL_MASK))
91 #define TC_ACT_EXT_CMP(combined, opcode) (TC_ACT_EXT_OPCODE(combined) == opcode)
92 
93 #define TC_ACT_JUMP __TC_ACT_EXT(1)
94 #define TC_ACT_GOTO_CHAIN __TC_ACT_EXT(2)
95 #define TC_ACT_EXT_OPCODE_MAX	TC_ACT_GOTO_CHAIN
96 
97 /* These macros are put here for binary compatibility with userspace apps that
98  * make use of them. For kernel code and new userspace apps, use the TCA_ID_*
99  * versions.
100  */
101 #define TCA_ACT_GACT 5
102 #define TCA_ACT_IPT 6 /* obsoleted, can be reused */
103 #define TCA_ACT_PEDIT 7
104 #define TCA_ACT_MIRRED 8
105 #define TCA_ACT_NAT 9
106 #define TCA_ACT_XT 10
107 #define TCA_ACT_SKBEDIT 11
108 #define TCA_ACT_VLAN 12
109 #define TCA_ACT_BPF 13
110 #define TCA_ACT_CONNMARK 14
111 #define TCA_ACT_SKBMOD 15
112 #define TCA_ACT_CSUM 16
113 #define TCA_ACT_TUNNEL_KEY 17
114 #define TCA_ACT_SIMP 22
115 #define TCA_ACT_IFE 25
116 #define TCA_ACT_SAMPLE 26
117 
118 /* Action type identifiers*/
119 enum tca_id {
120 	TCA_ID_UNSPEC = 0,
121 	TCA_ID_POLICE = 1,
122 	TCA_ID_GACT = TCA_ACT_GACT,
123 	TCA_ID_IPT = TCA_ACT_IPT, /* Obsoleted, can be reused */
124 	TCA_ID_PEDIT = TCA_ACT_PEDIT,
125 	TCA_ID_MIRRED = TCA_ACT_MIRRED,
126 	TCA_ID_NAT = TCA_ACT_NAT,
127 	TCA_ID_XT = TCA_ACT_XT,
128 	TCA_ID_SKBEDIT = TCA_ACT_SKBEDIT,
129 	TCA_ID_VLAN = TCA_ACT_VLAN,
130 	TCA_ID_BPF = TCA_ACT_BPF,
131 	TCA_ID_CONNMARK = TCA_ACT_CONNMARK,
132 	TCA_ID_SKBMOD = TCA_ACT_SKBMOD,
133 	TCA_ID_CSUM = TCA_ACT_CSUM,
134 	TCA_ID_TUNNEL_KEY = TCA_ACT_TUNNEL_KEY,
135 	TCA_ID_SIMP = TCA_ACT_SIMP,
136 	TCA_ID_IFE = TCA_ACT_IFE,
137 	TCA_ID_SAMPLE = TCA_ACT_SAMPLE,
138 	TCA_ID_CTINFO,
139 	TCA_ID_MPLS,
140 	TCA_ID_CT,
141 	TCA_ID_GATE,
142 	/* other actions go here */
143 	__TCA_ID_MAX = 255
144 };
145 
146 #define TCA_ID_MAX __TCA_ID_MAX
147 
148 struct tc_police {
149 	__u32			index;
150 	int			action;
151 #define TC_POLICE_UNSPEC	TC_ACT_UNSPEC
152 #define TC_POLICE_OK		TC_ACT_OK
153 #define TC_POLICE_RECLASSIFY	TC_ACT_RECLASSIFY
154 #define TC_POLICE_SHOT		TC_ACT_SHOT
155 #define TC_POLICE_PIPE		TC_ACT_PIPE
156 
157 	__u32			limit;
158 	__u32			burst;
159 	__u32			mtu;
160 	struct tc_ratespec	rate;
161 	struct tc_ratespec	peakrate;
162 	int			refcnt;
163 	int			bindcnt;
164 	__u32			capab;
165 };
166 
167 struct tcf_t {
168 	__u64   install;
169 	__u64   lastuse;
170 	__u64   expires;
171 	__u64   firstuse;
172 };
173 
174 struct tc_cnt {
175 	int                   refcnt;
176 	int                   bindcnt;
177 };
178 
179 #define tc_gen \
180 	__u32                 index; \
181 	__u32                 capab; \
182 	int                   action; \
183 	int                   refcnt; \
184 	int                   bindcnt
185 
186 enum {
187 	TCA_POLICE_UNSPEC,
188 	TCA_POLICE_TBF,
189 	TCA_POLICE_RATE,
190 	TCA_POLICE_PEAKRATE,
191 	TCA_POLICE_AVRATE,
192 	TCA_POLICE_RESULT,
193 	TCA_POLICE_TM,
194 	TCA_POLICE_PAD,
195 	TCA_POLICE_RATE64,
196 	TCA_POLICE_PEAKRATE64,
197 	TCA_POLICE_PKTRATE64,
198 	TCA_POLICE_PKTBURST64,
199 	__TCA_POLICE_MAX
200 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
201 };
202 
203 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
204 
205 /* tca flags definitions */
206 #define TCA_CLS_FLAGS_SKIP_HW	(1 << 0) /* don't offload filter to HW */
207 #define TCA_CLS_FLAGS_SKIP_SW	(1 << 1) /* don't use filter in SW */
208 #define TCA_CLS_FLAGS_IN_HW	(1 << 2) /* filter is offloaded to HW */
209 #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
210 #define TCA_CLS_FLAGS_VERBOSE	(1 << 4) /* verbose logging */
211 
212 /* U32 filters */
213 
214 #define TC_U32_HTID(h) ((h)&0xFFF00000)
215 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
216 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
217 #define TC_U32_NODE(h) ((h)&0xFFF)
218 #define TC_U32_KEY(h) ((h)&0xFFFFF)
219 #define TC_U32_UNSPEC	0
220 #define TC_U32_ROOT	(0xFFF00000)
221 
222 enum {
223 	TCA_U32_UNSPEC,
224 	TCA_U32_CLASSID,
225 	TCA_U32_HASH,
226 	TCA_U32_LINK,
227 	TCA_U32_DIVISOR,
228 	TCA_U32_SEL,
229 	TCA_U32_POLICE,
230 	TCA_U32_ACT,
231 	TCA_U32_INDEV,
232 	TCA_U32_PCNT,
233 	TCA_U32_MARK,
234 	TCA_U32_FLAGS,
235 	TCA_U32_PAD,
236 	__TCA_U32_MAX
237 };
238 
239 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
240 
241 struct tc_u32_key {
242 	__be32		mask;
243 	__be32		val;
244 	int		off;
245 	int		offmask;
246 };
247 
248 struct tc_u32_sel {
249 	/* New members MUST be added within the __struct_group() macro below. */
250 	__struct_group(tc_u32_sel_hdr, hdr, /* no attrs */,
251 		unsigned char		flags;
252 		unsigned char		offshift;
253 		unsigned char		nkeys;
254 
255 		__be16			offmask;
256 		__u16			off;
257 		short			offoff;
258 
259 		short			hoff;
260 		__be32			hmask;
261 	);
262 	struct tc_u32_key	keys[];
263 };
264 
265 struct tc_u32_mark {
266 	__u32		val;
267 	__u32		mask;
268 	__u32		success;
269 };
270 
271 struct tc_u32_pcnt {
272 	__u64 rcnt;
273 	__u64 rhit;
274 	__u64 kcnts[];
275 };
276 
277 /* Flags */
278 
279 #define TC_U32_TERMINAL		1
280 #define TC_U32_OFFSET		2
281 #define TC_U32_VAROFFSET	4
282 #define TC_U32_EAT		8
283 
284 #define TC_U32_MAXDEPTH 8
285 
286 /* ROUTE filter */
287 
288 enum {
289 	TCA_ROUTE4_UNSPEC,
290 	TCA_ROUTE4_CLASSID,
291 	TCA_ROUTE4_TO,
292 	TCA_ROUTE4_FROM,
293 	TCA_ROUTE4_IIF,
294 	TCA_ROUTE4_POLICE,
295 	TCA_ROUTE4_ACT,
296 	__TCA_ROUTE4_MAX
297 };
298 
299 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
300 
301 
302 /* FW filter */
303 
304 enum {
305 	TCA_FW_UNSPEC,
306 	TCA_FW_CLASSID,
307 	TCA_FW_POLICE,
308 	TCA_FW_INDEV,
309 	TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
310 	TCA_FW_MASK,
311 	__TCA_FW_MAX
312 };
313 
314 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
315 
316 /* Flow filter */
317 
318 enum {
319 	FLOW_KEY_SRC,
320 	FLOW_KEY_DST,
321 	FLOW_KEY_PROTO,
322 	FLOW_KEY_PROTO_SRC,
323 	FLOW_KEY_PROTO_DST,
324 	FLOW_KEY_IIF,
325 	FLOW_KEY_PRIORITY,
326 	FLOW_KEY_MARK,
327 	FLOW_KEY_NFCT,
328 	FLOW_KEY_NFCT_SRC,
329 	FLOW_KEY_NFCT_DST,
330 	FLOW_KEY_NFCT_PROTO_SRC,
331 	FLOW_KEY_NFCT_PROTO_DST,
332 	FLOW_KEY_RTCLASSID,
333 	FLOW_KEY_SKUID,
334 	FLOW_KEY_SKGID,
335 	FLOW_KEY_VLAN_TAG,
336 	FLOW_KEY_RXHASH,
337 	__FLOW_KEY_MAX,
338 };
339 
340 #define FLOW_KEY_MAX	(__FLOW_KEY_MAX - 1)
341 
342 enum {
343 	FLOW_MODE_MAP,
344 	FLOW_MODE_HASH,
345 };
346 
347 enum {
348 	TCA_FLOW_UNSPEC,
349 	TCA_FLOW_KEYS,
350 	TCA_FLOW_MODE,
351 	TCA_FLOW_BASECLASS,
352 	TCA_FLOW_RSHIFT,
353 	TCA_FLOW_ADDEND,
354 	TCA_FLOW_MASK,
355 	TCA_FLOW_XOR,
356 	TCA_FLOW_DIVISOR,
357 	TCA_FLOW_ACT,
358 	TCA_FLOW_POLICE,
359 	TCA_FLOW_EMATCHES,
360 	TCA_FLOW_PERTURB,
361 	__TCA_FLOW_MAX
362 };
363 
364 #define TCA_FLOW_MAX	(__TCA_FLOW_MAX - 1)
365 
366 /* Basic filter */
367 
368 struct tc_basic_pcnt {
369 	__u64 rcnt;
370 	__u64 rhit;
371 };
372 
373 enum {
374 	TCA_BASIC_UNSPEC,
375 	TCA_BASIC_CLASSID,
376 	TCA_BASIC_EMATCHES,
377 	TCA_BASIC_ACT,
378 	TCA_BASIC_POLICE,
379 	TCA_BASIC_PCNT,
380 	TCA_BASIC_PAD,
381 	__TCA_BASIC_MAX
382 };
383 
384 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
385 
386 
387 /* Cgroup classifier */
388 
389 enum {
390 	TCA_CGROUP_UNSPEC,
391 	TCA_CGROUP_ACT,
392 	TCA_CGROUP_POLICE,
393 	TCA_CGROUP_EMATCHES,
394 	__TCA_CGROUP_MAX,
395 };
396 
397 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
398 
399 /* BPF classifier */
400 
401 #define TCA_BPF_FLAG_ACT_DIRECT		(1 << 0)
402 
403 enum {
404 	TCA_BPF_UNSPEC,
405 	TCA_BPF_ACT,
406 	TCA_BPF_POLICE,
407 	TCA_BPF_CLASSID,
408 	TCA_BPF_OPS_LEN,
409 	TCA_BPF_OPS,
410 	TCA_BPF_FD,
411 	TCA_BPF_NAME,
412 	TCA_BPF_FLAGS,
413 	TCA_BPF_FLAGS_GEN,
414 	TCA_BPF_TAG,
415 	TCA_BPF_ID,
416 	__TCA_BPF_MAX,
417 };
418 
419 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
420 
421 /* Flower classifier */
422 
423 enum {
424 	TCA_FLOWER_UNSPEC,
425 	TCA_FLOWER_CLASSID,
426 	TCA_FLOWER_INDEV,
427 	TCA_FLOWER_ACT,
428 	TCA_FLOWER_KEY_ETH_DST,		/* ETH_ALEN */
429 	TCA_FLOWER_KEY_ETH_DST_MASK,	/* ETH_ALEN */
430 	TCA_FLOWER_KEY_ETH_SRC,		/* ETH_ALEN */
431 	TCA_FLOWER_KEY_ETH_SRC_MASK,	/* ETH_ALEN */
432 	TCA_FLOWER_KEY_ETH_TYPE,	/* be16 */
433 	TCA_FLOWER_KEY_IP_PROTO,	/* u8 */
434 	TCA_FLOWER_KEY_IPV4_SRC,	/* be32 */
435 	TCA_FLOWER_KEY_IPV4_SRC_MASK,	/* be32 */
436 	TCA_FLOWER_KEY_IPV4_DST,	/* be32 */
437 	TCA_FLOWER_KEY_IPV4_DST_MASK,	/* be32 */
438 	TCA_FLOWER_KEY_IPV6_SRC,	/* struct in6_addr */
439 	TCA_FLOWER_KEY_IPV6_SRC_MASK,	/* struct in6_addr */
440 	TCA_FLOWER_KEY_IPV6_DST,	/* struct in6_addr */
441 	TCA_FLOWER_KEY_IPV6_DST_MASK,	/* struct in6_addr */
442 	TCA_FLOWER_KEY_TCP_SRC,		/* be16 */
443 	TCA_FLOWER_KEY_TCP_DST,		/* be16 */
444 	TCA_FLOWER_KEY_UDP_SRC,		/* be16 */
445 	TCA_FLOWER_KEY_UDP_DST,		/* be16 */
446 
447 	TCA_FLOWER_FLAGS,
448 	TCA_FLOWER_KEY_VLAN_ID,		/* be16 */
449 	TCA_FLOWER_KEY_VLAN_PRIO,	/* u8   */
450 	TCA_FLOWER_KEY_VLAN_ETH_TYPE,	/* be16 */
451 
452 	TCA_FLOWER_KEY_ENC_KEY_ID,	/* be32 */
453 	TCA_FLOWER_KEY_ENC_IPV4_SRC,	/* be32 */
454 	TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */
455 	TCA_FLOWER_KEY_ENC_IPV4_DST,	/* be32 */
456 	TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */
457 	TCA_FLOWER_KEY_ENC_IPV6_SRC,	/* struct in6_addr */
458 	TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */
459 	TCA_FLOWER_KEY_ENC_IPV6_DST,	/* struct in6_addr */
460 	TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */
461 
462 	TCA_FLOWER_KEY_TCP_SRC_MASK,	/* be16 */
463 	TCA_FLOWER_KEY_TCP_DST_MASK,	/* be16 */
464 	TCA_FLOWER_KEY_UDP_SRC_MASK,	/* be16 */
465 	TCA_FLOWER_KEY_UDP_DST_MASK,	/* be16 */
466 	TCA_FLOWER_KEY_SCTP_SRC_MASK,	/* be16 */
467 	TCA_FLOWER_KEY_SCTP_DST_MASK,	/* be16 */
468 
469 	TCA_FLOWER_KEY_SCTP_SRC,	/* be16 */
470 	TCA_FLOWER_KEY_SCTP_DST,	/* be16 */
471 
472 	TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,	/* be16 */
473 	TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK,	/* be16 */
474 	TCA_FLOWER_KEY_ENC_UDP_DST_PORT,	/* be16 */
475 	TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK,	/* be16 */
476 
477 	TCA_FLOWER_KEY_FLAGS,		/* be32 */
478 	TCA_FLOWER_KEY_FLAGS_MASK,	/* be32 */
479 
480 	TCA_FLOWER_KEY_ICMPV4_CODE,	/* u8 */
481 	TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */
482 	TCA_FLOWER_KEY_ICMPV4_TYPE,	/* u8 */
483 	TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */
484 	TCA_FLOWER_KEY_ICMPV6_CODE,	/* u8 */
485 	TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */
486 	TCA_FLOWER_KEY_ICMPV6_TYPE,	/* u8 */
487 	TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */
488 
489 	TCA_FLOWER_KEY_ARP_SIP,		/* be32 */
490 	TCA_FLOWER_KEY_ARP_SIP_MASK,	/* be32 */
491 	TCA_FLOWER_KEY_ARP_TIP,		/* be32 */
492 	TCA_FLOWER_KEY_ARP_TIP_MASK,	/* be32 */
493 	TCA_FLOWER_KEY_ARP_OP,		/* u8 */
494 	TCA_FLOWER_KEY_ARP_OP_MASK,	/* u8 */
495 	TCA_FLOWER_KEY_ARP_SHA,		/* ETH_ALEN */
496 	TCA_FLOWER_KEY_ARP_SHA_MASK,	/* ETH_ALEN */
497 	TCA_FLOWER_KEY_ARP_THA,		/* ETH_ALEN */
498 	TCA_FLOWER_KEY_ARP_THA_MASK,	/* ETH_ALEN */
499 
500 	TCA_FLOWER_KEY_MPLS_TTL,	/* u8 - 8 bits */
501 	TCA_FLOWER_KEY_MPLS_BOS,	/* u8 - 1 bit */
502 	TCA_FLOWER_KEY_MPLS_TC,		/* u8 - 3 bits */
503 	TCA_FLOWER_KEY_MPLS_LABEL,	/* be32 - 20 bits */
504 
505 	TCA_FLOWER_KEY_TCP_FLAGS,	/* be16 */
506 	TCA_FLOWER_KEY_TCP_FLAGS_MASK,	/* be16 */
507 
508 	TCA_FLOWER_KEY_IP_TOS,		/* u8 */
509 	TCA_FLOWER_KEY_IP_TOS_MASK,	/* u8 */
510 	TCA_FLOWER_KEY_IP_TTL,		/* u8 */
511 	TCA_FLOWER_KEY_IP_TTL_MASK,	/* u8 */
512 
513 	TCA_FLOWER_KEY_CVLAN_ID,	/* be16 */
514 	TCA_FLOWER_KEY_CVLAN_PRIO,	/* u8   */
515 	TCA_FLOWER_KEY_CVLAN_ETH_TYPE,	/* be16 */
516 
517 	TCA_FLOWER_KEY_ENC_IP_TOS,	/* u8 */
518 	TCA_FLOWER_KEY_ENC_IP_TOS_MASK,	/* u8 */
519 	TCA_FLOWER_KEY_ENC_IP_TTL,	/* u8 */
520 	TCA_FLOWER_KEY_ENC_IP_TTL_MASK,	/* u8 */
521 
522 	TCA_FLOWER_KEY_ENC_OPTS,
523 	TCA_FLOWER_KEY_ENC_OPTS_MASK,
524 
525 	TCA_FLOWER_IN_HW_COUNT,
526 
527 	TCA_FLOWER_KEY_PORT_SRC_MIN,	/* be16 */
528 	TCA_FLOWER_KEY_PORT_SRC_MAX,	/* be16 */
529 	TCA_FLOWER_KEY_PORT_DST_MIN,	/* be16 */
530 	TCA_FLOWER_KEY_PORT_DST_MAX,	/* be16 */
531 
532 	TCA_FLOWER_KEY_CT_STATE,	/* u16 */
533 	TCA_FLOWER_KEY_CT_STATE_MASK,	/* u16 */
534 	TCA_FLOWER_KEY_CT_ZONE,		/* u16 */
535 	TCA_FLOWER_KEY_CT_ZONE_MASK,	/* u16 */
536 	TCA_FLOWER_KEY_CT_MARK,		/* u32 */
537 	TCA_FLOWER_KEY_CT_MARK_MASK,	/* u32 */
538 	TCA_FLOWER_KEY_CT_LABELS,	/* u128 */
539 	TCA_FLOWER_KEY_CT_LABELS_MASK,	/* u128 */
540 
541 	TCA_FLOWER_KEY_MPLS_OPTS,
542 
543 	TCA_FLOWER_KEY_HASH,		/* u32 */
544 	TCA_FLOWER_KEY_HASH_MASK,	/* u32 */
545 
546 	TCA_FLOWER_KEY_NUM_OF_VLANS,    /* u8 */
547 
548 	TCA_FLOWER_KEY_PPPOE_SID,	/* be16 */
549 	TCA_FLOWER_KEY_PPP_PROTO,	/* be16 */
550 
551 	TCA_FLOWER_KEY_L2TPV3_SID,	/* be32 */
552 
553 	TCA_FLOWER_L2_MISS,		/* u8 */
554 
555 	TCA_FLOWER_KEY_CFM,		/* nested */
556 
557 	TCA_FLOWER_KEY_SPI,		/* be32 */
558 	TCA_FLOWER_KEY_SPI_MASK,	/* be32 */
559 
560 	TCA_FLOWER_KEY_ENC_FLAGS,	/* be32 */
561 	TCA_FLOWER_KEY_ENC_FLAGS_MASK,	/* be32 */
562 
563 	__TCA_FLOWER_MAX,
564 };
565 
566 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
567 
568 enum {
569 	TCA_FLOWER_KEY_CT_FLAGS_NEW = 1 << 0, /* Beginning of a new connection. */
570 	TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 1 << 1, /* Part of an existing connection. */
571 	TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2, /* Related to an established connection. */
572 	TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3, /* Conntrack has occurred. */
573 	TCA_FLOWER_KEY_CT_FLAGS_INVALID = 1 << 4, /* Conntrack is invalid. */
574 	TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5, /* Packet is in the reply direction. */
575 	__TCA_FLOWER_KEY_CT_FLAGS_MAX,
576 };
577 
578 enum {
579 	TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
580 	TCA_FLOWER_KEY_ENC_OPTS_GENEVE, /* Nested
581 					 * TCA_FLOWER_KEY_ENC_OPT_GENEVE_
582 					 * attributes
583 					 */
584 	TCA_FLOWER_KEY_ENC_OPTS_VXLAN,	/* Nested
585 					 * TCA_FLOWER_KEY_ENC_OPT_VXLAN_
586 					 * attributes
587 					 */
588 	TCA_FLOWER_KEY_ENC_OPTS_ERSPAN,	/* Nested
589 					 * TCA_FLOWER_KEY_ENC_OPT_ERSPAN_
590 					 * attributes
591 					 */
592 	TCA_FLOWER_KEY_ENC_OPTS_GTP,	/* Nested
593 					 * TCA_FLOWER_KEY_ENC_OPT_GTP_
594 					 * attributes
595 					 */
596 	TCA_FLOWER_KEY_ENC_OPTS_PFCP,	/* Nested
597 					 * TCA_FLOWER_KEY_ENC_IPT_PFCP
598 					 * attributes
599 					 */
600 	__TCA_FLOWER_KEY_ENC_OPTS_MAX,
601 };
602 
603 #define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
604 
605 enum {
606 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC,
607 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS,            /* u16 */
608 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE,             /* u8 */
609 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA,             /* 4 to 128 bytes */
610 
611 	__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX,
612 };
613 
614 #define TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX \
615 		(__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)
616 
617 enum {
618 	TCA_FLOWER_KEY_ENC_OPT_VXLAN_UNSPEC,
619 	TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP,		/* u32 */
620 	__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX,
621 };
622 
623 #define TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX \
624 		(__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX - 1)
625 
626 enum {
627 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_UNSPEC,
628 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER,              /* u8 */
629 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX,            /* be32 */
630 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR,              /* u8 */
631 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID,             /* u8 */
632 	__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX,
633 };
634 
635 #define TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX \
636 		(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)
637 
638 enum {
639 	TCA_FLOWER_KEY_ENC_OPT_GTP_UNSPEC,
640 	TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE,		/* u8 */
641 	TCA_FLOWER_KEY_ENC_OPT_GTP_QFI,			/* u8 */
642 
643 	__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX,
644 };
645 
646 #define TCA_FLOWER_KEY_ENC_OPT_GTP_MAX \
647 		(__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX - 1)
648 
649 enum {
650 	TCA_FLOWER_KEY_ENC_OPT_PFCP_UNSPEC,
651 	TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE,		/* u8 */
652 	TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID,		/* be64 */
653 	__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX,
654 };
655 
656 #define TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX \
657 		(__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX - 1)
658 
659 enum {
660 	TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
661 	TCA_FLOWER_KEY_MPLS_OPTS_LSE,
662 	__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
663 };
664 
665 #define TCA_FLOWER_KEY_MPLS_OPTS_MAX (__TCA_FLOWER_KEY_MPLS_OPTS_MAX - 1)
666 
667 enum {
668 	TCA_FLOWER_KEY_MPLS_OPT_LSE_UNSPEC,
669 	TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH,
670 	TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL,
671 	TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS,
672 	TCA_FLOWER_KEY_MPLS_OPT_LSE_TC,
673 	TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL,
674 	__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX,
675 };
676 
677 #define TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX \
678 		(__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX - 1)
679 
680 enum {
681 	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
682 	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
683 	TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM = (1 << 2),
684 	TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT = (1 << 3),
685 	TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM = (1 << 4),
686 	TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT = (1 << 5),
687 	__TCA_FLOWER_KEY_FLAGS_MAX,
688 };
689 
690 #define TCA_FLOWER_KEY_FLAGS_MAX (__TCA_FLOWER_KEY_FLAGS_MAX - 1)
691 
692 enum {
693 	TCA_FLOWER_KEY_CFM_OPT_UNSPEC,
694 	TCA_FLOWER_KEY_CFM_MD_LEVEL,
695 	TCA_FLOWER_KEY_CFM_OPCODE,
696 	__TCA_FLOWER_KEY_CFM_OPT_MAX,
697 };
698 
699 #define TCA_FLOWER_KEY_CFM_OPT_MAX (__TCA_FLOWER_KEY_CFM_OPT_MAX - 1)
700 
701 #define TCA_FLOWER_MASK_FLAGS_RANGE	(1 << 0) /* Range-based match */
702 
703 /* Match-all classifier */
704 
705 struct tc_matchall_pcnt {
706 	__u64 rhit;
707 };
708 
709 enum {
710 	TCA_MATCHALL_UNSPEC,
711 	TCA_MATCHALL_CLASSID,
712 	TCA_MATCHALL_ACT,
713 	TCA_MATCHALL_FLAGS,
714 	TCA_MATCHALL_PCNT,
715 	TCA_MATCHALL_PAD,
716 	__TCA_MATCHALL_MAX,
717 };
718 
719 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
720 
721 /* Extended Matches */
722 
723 struct tcf_ematch_tree_hdr {
724 	__u16		nmatches;
725 	__u16		progid;
726 };
727 
728 enum {
729 	TCA_EMATCH_TREE_UNSPEC,
730 	TCA_EMATCH_TREE_HDR,
731 	TCA_EMATCH_TREE_LIST,
732 	__TCA_EMATCH_TREE_MAX
733 };
734 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
735 
736 struct tcf_ematch_hdr {
737 	__u16		matchid;
738 	__u16		kind;
739 	__u16		flags;
740 	__u16		pad; /* currently unused */
741 };
742 
743 /*  0                   1
744  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
745  * +-----------------------+-+-+---+
746  * |         Unused        |S|I| R |
747  * +-----------------------+-+-+---+
748  *
749  * R(2) ::= relation to next ematch
750  *          where: 0 0 END (last ematch)
751  *                 0 1 AND
752  *                 1 0 OR
753  *                 1 1 Unused (invalid)
754  * I(1) ::= invert result
755  * S(1) ::= simple payload
756  */
757 #define TCF_EM_REL_END	0
758 #define TCF_EM_REL_AND	(1<<0)
759 #define TCF_EM_REL_OR	(1<<1)
760 #define TCF_EM_INVERT	(1<<2)
761 #define TCF_EM_SIMPLE	(1<<3)
762 
763 #define TCF_EM_REL_MASK	3
764 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
765 
766 enum {
767 	TCF_LAYER_LINK,
768 	TCF_LAYER_NETWORK,
769 	TCF_LAYER_TRANSPORT,
770 	__TCF_LAYER_MAX
771 };
772 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
773 
774 /* Ematch type assignments
775  *   1..32767		Reserved for ematches inside kernel tree
776  *   32768..65535	Free to use, not reliable
777  */
778 #define	TCF_EM_CONTAINER	0
779 #define	TCF_EM_CMP		1
780 #define	TCF_EM_NBYTE		2
781 #define	TCF_EM_U32		3
782 #define	TCF_EM_META		4
783 #define	TCF_EM_TEXT		5
784 #define	TCF_EM_VLAN		6
785 #define	TCF_EM_CANID		7
786 #define	TCF_EM_IPSET		8
787 #define	TCF_EM_IPT		9
788 #define	TCF_EM_MAX		9
789 
790 enum {
791 	TCF_EM_PROG_TC
792 };
793 
794 enum {
795 	TCF_EM_OPND_EQ,
796 	TCF_EM_OPND_GT,
797 	TCF_EM_OPND_LT
798 };
799 
800 #endif
801