xref: /openbmc/linux/include/uapi/linux/pkt_cls.h (revision 4a075bd4)
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_MAX
20 };
21 
22 #define TCA_ACT_MAX __TCA_ACT_MAX
23 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
24 #define TCA_ACT_MAX_PRIO 32
25 #define TCA_ACT_BIND	1
26 #define TCA_ACT_NOBIND	0
27 #define TCA_ACT_UNBIND	1
28 #define TCA_ACT_NOUNBIND	0
29 #define TCA_ACT_REPLACE		1
30 #define TCA_ACT_NOREPLACE	0
31 
32 #define TC_ACT_UNSPEC	(-1)
33 #define TC_ACT_OK		0
34 #define TC_ACT_RECLASSIFY	1
35 #define TC_ACT_SHOT		2
36 #define TC_ACT_PIPE		3
37 #define TC_ACT_STOLEN		4
38 #define TC_ACT_QUEUED		5
39 #define TC_ACT_REPEAT		6
40 #define TC_ACT_REDIRECT		7
41 #define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu"
42 				   * and don't further process the frame
43 				   * in hardware. For sw path, this is
44 				   * equivalent of TC_ACT_STOLEN - drop
45 				   * the skb and act like everything
46 				   * is alright.
47 				   */
48 #define TC_ACT_VALUE_MAX	TC_ACT_TRAP
49 
50 /* There is a special kind of actions called "extended actions",
51  * which need a value parameter. These have a local opcode located in
52  * the highest nibble, starting from 1. The rest of the bits
53  * are used to carry the value. These two parts together make
54  * a combined opcode.
55  */
56 #define __TC_ACT_EXT_SHIFT 28
57 #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT)
58 #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1)
59 #define TC_ACT_EXT_OPCODE(combined) ((combined) & (~TC_ACT_EXT_VAL_MASK))
60 #define TC_ACT_EXT_CMP(combined, opcode) (TC_ACT_EXT_OPCODE(combined) == opcode)
61 
62 #define TC_ACT_JUMP __TC_ACT_EXT(1)
63 #define TC_ACT_GOTO_CHAIN __TC_ACT_EXT(2)
64 #define TC_ACT_EXT_OPCODE_MAX	TC_ACT_GOTO_CHAIN
65 
66 /* These macros are put here for binary compatibility with userspace apps that
67  * make use of them. For kernel code and new userspace apps, use the TCA_ID_*
68  * versions.
69  */
70 #define TCA_ACT_GACT 5
71 #define TCA_ACT_IPT 6
72 #define TCA_ACT_PEDIT 7
73 #define TCA_ACT_MIRRED 8
74 #define TCA_ACT_NAT 9
75 #define TCA_ACT_XT 10
76 #define TCA_ACT_SKBEDIT 11
77 #define TCA_ACT_VLAN 12
78 #define TCA_ACT_BPF 13
79 #define TCA_ACT_CONNMARK 14
80 #define TCA_ACT_SKBMOD 15
81 #define TCA_ACT_CSUM 16
82 #define TCA_ACT_TUNNEL_KEY 17
83 #define TCA_ACT_SIMP 22
84 #define TCA_ACT_IFE 25
85 #define TCA_ACT_SAMPLE 26
86 
87 /* Action type identifiers*/
88 enum tca_id {
89 	TCA_ID_UNSPEC = 0,
90 	TCA_ID_POLICE = 1,
91 	TCA_ID_GACT = TCA_ACT_GACT,
92 	TCA_ID_IPT = TCA_ACT_IPT,
93 	TCA_ID_PEDIT = TCA_ACT_PEDIT,
94 	TCA_ID_MIRRED = TCA_ACT_MIRRED,
95 	TCA_ID_NAT = TCA_ACT_NAT,
96 	TCA_ID_XT = TCA_ACT_XT,
97 	TCA_ID_SKBEDIT = TCA_ACT_SKBEDIT,
98 	TCA_ID_VLAN = TCA_ACT_VLAN,
99 	TCA_ID_BPF = TCA_ACT_BPF,
100 	TCA_ID_CONNMARK = TCA_ACT_CONNMARK,
101 	TCA_ID_SKBMOD = TCA_ACT_SKBMOD,
102 	TCA_ID_CSUM = TCA_ACT_CSUM,
103 	TCA_ID_TUNNEL_KEY = TCA_ACT_TUNNEL_KEY,
104 	TCA_ID_SIMP = TCA_ACT_SIMP,
105 	TCA_ID_IFE = TCA_ACT_IFE,
106 	TCA_ID_SAMPLE = TCA_ACT_SAMPLE,
107 	/* other actions go here */
108 	__TCA_ID_MAX = 255
109 };
110 
111 #define TCA_ID_MAX __TCA_ID_MAX
112 
113 struct tc_police {
114 	__u32			index;
115 	int			action;
116 #define TC_POLICE_UNSPEC	TC_ACT_UNSPEC
117 #define TC_POLICE_OK		TC_ACT_OK
118 #define TC_POLICE_RECLASSIFY	TC_ACT_RECLASSIFY
119 #define TC_POLICE_SHOT		TC_ACT_SHOT
120 #define TC_POLICE_PIPE		TC_ACT_PIPE
121 
122 	__u32			limit;
123 	__u32			burst;
124 	__u32			mtu;
125 	struct tc_ratespec	rate;
126 	struct tc_ratespec	peakrate;
127 	int			refcnt;
128 	int			bindcnt;
129 	__u32			capab;
130 };
131 
132 struct tcf_t {
133 	__u64   install;
134 	__u64   lastuse;
135 	__u64   expires;
136 	__u64   firstuse;
137 };
138 
139 struct tc_cnt {
140 	int                   refcnt;
141 	int                   bindcnt;
142 };
143 
144 #define tc_gen \
145 	__u32                 index; \
146 	__u32                 capab; \
147 	int                   action; \
148 	int                   refcnt; \
149 	int                   bindcnt
150 
151 enum {
152 	TCA_POLICE_UNSPEC,
153 	TCA_POLICE_TBF,
154 	TCA_POLICE_RATE,
155 	TCA_POLICE_PEAKRATE,
156 	TCA_POLICE_AVRATE,
157 	TCA_POLICE_RESULT,
158 	TCA_POLICE_TM,
159 	TCA_POLICE_PAD,
160 	__TCA_POLICE_MAX
161 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
162 };
163 
164 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
165 
166 /* tca flags definitions */
167 #define TCA_CLS_FLAGS_SKIP_HW	(1 << 0) /* don't offload filter to HW */
168 #define TCA_CLS_FLAGS_SKIP_SW	(1 << 1) /* don't use filter in SW */
169 #define TCA_CLS_FLAGS_IN_HW	(1 << 2) /* filter is offloaded to HW */
170 #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
171 #define TCA_CLS_FLAGS_VERBOSE	(1 << 4) /* verbose logging */
172 
173 /* U32 filters */
174 
175 #define TC_U32_HTID(h) ((h)&0xFFF00000)
176 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
177 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
178 #define TC_U32_NODE(h) ((h)&0xFFF)
179 #define TC_U32_KEY(h) ((h)&0xFFFFF)
180 #define TC_U32_UNSPEC	0
181 #define TC_U32_ROOT	(0xFFF00000)
182 
183 enum {
184 	TCA_U32_UNSPEC,
185 	TCA_U32_CLASSID,
186 	TCA_U32_HASH,
187 	TCA_U32_LINK,
188 	TCA_U32_DIVISOR,
189 	TCA_U32_SEL,
190 	TCA_U32_POLICE,
191 	TCA_U32_ACT,
192 	TCA_U32_INDEV,
193 	TCA_U32_PCNT,
194 	TCA_U32_MARK,
195 	TCA_U32_FLAGS,
196 	TCA_U32_PAD,
197 	__TCA_U32_MAX
198 };
199 
200 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
201 
202 struct tc_u32_key {
203 	__be32		mask;
204 	__be32		val;
205 	int		off;
206 	int		offmask;
207 };
208 
209 struct tc_u32_sel {
210 	unsigned char		flags;
211 	unsigned char		offshift;
212 	unsigned char		nkeys;
213 
214 	__be16			offmask;
215 	__u16			off;
216 	short			offoff;
217 
218 	short			hoff;
219 	__be32			hmask;
220 	struct tc_u32_key	keys[0];
221 };
222 
223 struct tc_u32_mark {
224 	__u32		val;
225 	__u32		mask;
226 	__u32		success;
227 };
228 
229 struct tc_u32_pcnt {
230 	__u64 rcnt;
231 	__u64 rhit;
232 	__u64 kcnts[0];
233 };
234 
235 /* Flags */
236 
237 #define TC_U32_TERMINAL		1
238 #define TC_U32_OFFSET		2
239 #define TC_U32_VAROFFSET	4
240 #define TC_U32_EAT		8
241 
242 #define TC_U32_MAXDEPTH 8
243 
244 
245 /* RSVP filter */
246 
247 enum {
248 	TCA_RSVP_UNSPEC,
249 	TCA_RSVP_CLASSID,
250 	TCA_RSVP_DST,
251 	TCA_RSVP_SRC,
252 	TCA_RSVP_PINFO,
253 	TCA_RSVP_POLICE,
254 	TCA_RSVP_ACT,
255 	__TCA_RSVP_MAX
256 };
257 
258 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
259 
260 struct tc_rsvp_gpi {
261 	__u32	key;
262 	__u32	mask;
263 	int	offset;
264 };
265 
266 struct tc_rsvp_pinfo {
267 	struct tc_rsvp_gpi dpi;
268 	struct tc_rsvp_gpi spi;
269 	__u8	protocol;
270 	__u8	tunnelid;
271 	__u8	tunnelhdr;
272 	__u8	pad;
273 };
274 
275 /* ROUTE filter */
276 
277 enum {
278 	TCA_ROUTE4_UNSPEC,
279 	TCA_ROUTE4_CLASSID,
280 	TCA_ROUTE4_TO,
281 	TCA_ROUTE4_FROM,
282 	TCA_ROUTE4_IIF,
283 	TCA_ROUTE4_POLICE,
284 	TCA_ROUTE4_ACT,
285 	__TCA_ROUTE4_MAX
286 };
287 
288 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
289 
290 
291 /* FW filter */
292 
293 enum {
294 	TCA_FW_UNSPEC,
295 	TCA_FW_CLASSID,
296 	TCA_FW_POLICE,
297 	TCA_FW_INDEV, /*  used by CONFIG_NET_CLS_IND */
298 	TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
299 	TCA_FW_MASK,
300 	__TCA_FW_MAX
301 };
302 
303 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
304 
305 /* TC index filter */
306 
307 enum {
308 	TCA_TCINDEX_UNSPEC,
309 	TCA_TCINDEX_HASH,
310 	TCA_TCINDEX_MASK,
311 	TCA_TCINDEX_SHIFT,
312 	TCA_TCINDEX_FALL_THROUGH,
313 	TCA_TCINDEX_CLASSID,
314 	TCA_TCINDEX_POLICE,
315 	TCA_TCINDEX_ACT,
316 	__TCA_TCINDEX_MAX
317 };
318 
319 #define TCA_TCINDEX_MAX     (__TCA_TCINDEX_MAX - 1)
320 
321 /* Flow filter */
322 
323 enum {
324 	FLOW_KEY_SRC,
325 	FLOW_KEY_DST,
326 	FLOW_KEY_PROTO,
327 	FLOW_KEY_PROTO_SRC,
328 	FLOW_KEY_PROTO_DST,
329 	FLOW_KEY_IIF,
330 	FLOW_KEY_PRIORITY,
331 	FLOW_KEY_MARK,
332 	FLOW_KEY_NFCT,
333 	FLOW_KEY_NFCT_SRC,
334 	FLOW_KEY_NFCT_DST,
335 	FLOW_KEY_NFCT_PROTO_SRC,
336 	FLOW_KEY_NFCT_PROTO_DST,
337 	FLOW_KEY_RTCLASSID,
338 	FLOW_KEY_SKUID,
339 	FLOW_KEY_SKGID,
340 	FLOW_KEY_VLAN_TAG,
341 	FLOW_KEY_RXHASH,
342 	__FLOW_KEY_MAX,
343 };
344 
345 #define FLOW_KEY_MAX	(__FLOW_KEY_MAX - 1)
346 
347 enum {
348 	FLOW_MODE_MAP,
349 	FLOW_MODE_HASH,
350 };
351 
352 enum {
353 	TCA_FLOW_UNSPEC,
354 	TCA_FLOW_KEYS,
355 	TCA_FLOW_MODE,
356 	TCA_FLOW_BASECLASS,
357 	TCA_FLOW_RSHIFT,
358 	TCA_FLOW_ADDEND,
359 	TCA_FLOW_MASK,
360 	TCA_FLOW_XOR,
361 	TCA_FLOW_DIVISOR,
362 	TCA_FLOW_ACT,
363 	TCA_FLOW_POLICE,
364 	TCA_FLOW_EMATCHES,
365 	TCA_FLOW_PERTURB,
366 	__TCA_FLOW_MAX
367 };
368 
369 #define TCA_FLOW_MAX	(__TCA_FLOW_MAX - 1)
370 
371 /* Basic filter */
372 
373 struct tc_basic_pcnt {
374 	__u64 rcnt;
375 	__u64 rhit;
376 };
377 
378 enum {
379 	TCA_BASIC_UNSPEC,
380 	TCA_BASIC_CLASSID,
381 	TCA_BASIC_EMATCHES,
382 	TCA_BASIC_ACT,
383 	TCA_BASIC_POLICE,
384 	TCA_BASIC_PCNT,
385 	TCA_BASIC_PAD,
386 	__TCA_BASIC_MAX
387 };
388 
389 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
390 
391 
392 /* Cgroup classifier */
393 
394 enum {
395 	TCA_CGROUP_UNSPEC,
396 	TCA_CGROUP_ACT,
397 	TCA_CGROUP_POLICE,
398 	TCA_CGROUP_EMATCHES,
399 	__TCA_CGROUP_MAX,
400 };
401 
402 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
403 
404 /* BPF classifier */
405 
406 #define TCA_BPF_FLAG_ACT_DIRECT		(1 << 0)
407 
408 enum {
409 	TCA_BPF_UNSPEC,
410 	TCA_BPF_ACT,
411 	TCA_BPF_POLICE,
412 	TCA_BPF_CLASSID,
413 	TCA_BPF_OPS_LEN,
414 	TCA_BPF_OPS,
415 	TCA_BPF_FD,
416 	TCA_BPF_NAME,
417 	TCA_BPF_FLAGS,
418 	TCA_BPF_FLAGS_GEN,
419 	TCA_BPF_TAG,
420 	TCA_BPF_ID,
421 	__TCA_BPF_MAX,
422 };
423 
424 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
425 
426 /* Flower classifier */
427 
428 enum {
429 	TCA_FLOWER_UNSPEC,
430 	TCA_FLOWER_CLASSID,
431 	TCA_FLOWER_INDEV,
432 	TCA_FLOWER_ACT,
433 	TCA_FLOWER_KEY_ETH_DST,		/* ETH_ALEN */
434 	TCA_FLOWER_KEY_ETH_DST_MASK,	/* ETH_ALEN */
435 	TCA_FLOWER_KEY_ETH_SRC,		/* ETH_ALEN */
436 	TCA_FLOWER_KEY_ETH_SRC_MASK,	/* ETH_ALEN */
437 	TCA_FLOWER_KEY_ETH_TYPE,	/* be16 */
438 	TCA_FLOWER_KEY_IP_PROTO,	/* u8 */
439 	TCA_FLOWER_KEY_IPV4_SRC,	/* be32 */
440 	TCA_FLOWER_KEY_IPV4_SRC_MASK,	/* be32 */
441 	TCA_FLOWER_KEY_IPV4_DST,	/* be32 */
442 	TCA_FLOWER_KEY_IPV4_DST_MASK,	/* be32 */
443 	TCA_FLOWER_KEY_IPV6_SRC,	/* struct in6_addr */
444 	TCA_FLOWER_KEY_IPV6_SRC_MASK,	/* struct in6_addr */
445 	TCA_FLOWER_KEY_IPV6_DST,	/* struct in6_addr */
446 	TCA_FLOWER_KEY_IPV6_DST_MASK,	/* struct in6_addr */
447 	TCA_FLOWER_KEY_TCP_SRC,		/* be16 */
448 	TCA_FLOWER_KEY_TCP_DST,		/* be16 */
449 	TCA_FLOWER_KEY_UDP_SRC,		/* be16 */
450 	TCA_FLOWER_KEY_UDP_DST,		/* be16 */
451 
452 	TCA_FLOWER_FLAGS,
453 	TCA_FLOWER_KEY_VLAN_ID,		/* be16 */
454 	TCA_FLOWER_KEY_VLAN_PRIO,	/* u8   */
455 	TCA_FLOWER_KEY_VLAN_ETH_TYPE,	/* be16 */
456 
457 	TCA_FLOWER_KEY_ENC_KEY_ID,	/* be32 */
458 	TCA_FLOWER_KEY_ENC_IPV4_SRC,	/* be32 */
459 	TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */
460 	TCA_FLOWER_KEY_ENC_IPV4_DST,	/* be32 */
461 	TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */
462 	TCA_FLOWER_KEY_ENC_IPV6_SRC,	/* struct in6_addr */
463 	TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */
464 	TCA_FLOWER_KEY_ENC_IPV6_DST,	/* struct in6_addr */
465 	TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */
466 
467 	TCA_FLOWER_KEY_TCP_SRC_MASK,	/* be16 */
468 	TCA_FLOWER_KEY_TCP_DST_MASK,	/* be16 */
469 	TCA_FLOWER_KEY_UDP_SRC_MASK,	/* be16 */
470 	TCA_FLOWER_KEY_UDP_DST_MASK,	/* be16 */
471 	TCA_FLOWER_KEY_SCTP_SRC_MASK,	/* be16 */
472 	TCA_FLOWER_KEY_SCTP_DST_MASK,	/* be16 */
473 
474 	TCA_FLOWER_KEY_SCTP_SRC,	/* be16 */
475 	TCA_FLOWER_KEY_SCTP_DST,	/* be16 */
476 
477 	TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,	/* be16 */
478 	TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK,	/* be16 */
479 	TCA_FLOWER_KEY_ENC_UDP_DST_PORT,	/* be16 */
480 	TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK,	/* be16 */
481 
482 	TCA_FLOWER_KEY_FLAGS,		/* be32 */
483 	TCA_FLOWER_KEY_FLAGS_MASK,	/* be32 */
484 
485 	TCA_FLOWER_KEY_ICMPV4_CODE,	/* u8 */
486 	TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */
487 	TCA_FLOWER_KEY_ICMPV4_TYPE,	/* u8 */
488 	TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */
489 	TCA_FLOWER_KEY_ICMPV6_CODE,	/* u8 */
490 	TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */
491 	TCA_FLOWER_KEY_ICMPV6_TYPE,	/* u8 */
492 	TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */
493 
494 	TCA_FLOWER_KEY_ARP_SIP,		/* be32 */
495 	TCA_FLOWER_KEY_ARP_SIP_MASK,	/* be32 */
496 	TCA_FLOWER_KEY_ARP_TIP,		/* be32 */
497 	TCA_FLOWER_KEY_ARP_TIP_MASK,	/* be32 */
498 	TCA_FLOWER_KEY_ARP_OP,		/* u8 */
499 	TCA_FLOWER_KEY_ARP_OP_MASK,	/* u8 */
500 	TCA_FLOWER_KEY_ARP_SHA,		/* ETH_ALEN */
501 	TCA_FLOWER_KEY_ARP_SHA_MASK,	/* ETH_ALEN */
502 	TCA_FLOWER_KEY_ARP_THA,		/* ETH_ALEN */
503 	TCA_FLOWER_KEY_ARP_THA_MASK,	/* ETH_ALEN */
504 
505 	TCA_FLOWER_KEY_MPLS_TTL,	/* u8 - 8 bits */
506 	TCA_FLOWER_KEY_MPLS_BOS,	/* u8 - 1 bit */
507 	TCA_FLOWER_KEY_MPLS_TC,		/* u8 - 3 bits */
508 	TCA_FLOWER_KEY_MPLS_LABEL,	/* be32 - 20 bits */
509 
510 	TCA_FLOWER_KEY_TCP_FLAGS,	/* be16 */
511 	TCA_FLOWER_KEY_TCP_FLAGS_MASK,	/* be16 */
512 
513 	TCA_FLOWER_KEY_IP_TOS,		/* u8 */
514 	TCA_FLOWER_KEY_IP_TOS_MASK,	/* u8 */
515 	TCA_FLOWER_KEY_IP_TTL,		/* u8 */
516 	TCA_FLOWER_KEY_IP_TTL_MASK,	/* u8 */
517 
518 	TCA_FLOWER_KEY_CVLAN_ID,	/* be16 */
519 	TCA_FLOWER_KEY_CVLAN_PRIO,	/* u8   */
520 	TCA_FLOWER_KEY_CVLAN_ETH_TYPE,	/* be16 */
521 
522 	TCA_FLOWER_KEY_ENC_IP_TOS,	/* u8 */
523 	TCA_FLOWER_KEY_ENC_IP_TOS_MASK,	/* u8 */
524 	TCA_FLOWER_KEY_ENC_IP_TTL,	/* u8 */
525 	TCA_FLOWER_KEY_ENC_IP_TTL_MASK,	/* u8 */
526 
527 	TCA_FLOWER_KEY_ENC_OPTS,
528 	TCA_FLOWER_KEY_ENC_OPTS_MASK,
529 
530 	TCA_FLOWER_IN_HW_COUNT,
531 
532 	TCA_FLOWER_KEY_PORT_SRC_MIN,	/* be16 */
533 	TCA_FLOWER_KEY_PORT_SRC_MAX,	/* be16 */
534 	TCA_FLOWER_KEY_PORT_DST_MIN,	/* be16 */
535 	TCA_FLOWER_KEY_PORT_DST_MAX,	/* be16 */
536 
537 	__TCA_FLOWER_MAX,
538 };
539 
540 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
541 
542 enum {
543 	TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
544 	TCA_FLOWER_KEY_ENC_OPTS_GENEVE, /* Nested
545 					 * TCA_FLOWER_KEY_ENC_OPT_GENEVE_
546 					 * attributes
547 					 */
548 	__TCA_FLOWER_KEY_ENC_OPTS_MAX,
549 };
550 
551 #define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
552 
553 enum {
554 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC,
555 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS,            /* u16 */
556 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE,             /* u8 */
557 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA,             /* 4 to 128 bytes */
558 
559 	__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX,
560 };
561 
562 #define TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX \
563 		(__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)
564 
565 enum {
566 	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
567 	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
568 };
569 
570 #define TCA_FLOWER_MASK_FLAGS_RANGE	(1 << 0) /* Range-based match */
571 
572 /* Match-all classifier */
573 
574 struct tc_matchall_pcnt {
575 	__u64 rhit;
576 };
577 
578 enum {
579 	TCA_MATCHALL_UNSPEC,
580 	TCA_MATCHALL_CLASSID,
581 	TCA_MATCHALL_ACT,
582 	TCA_MATCHALL_FLAGS,
583 	TCA_MATCHALL_PCNT,
584 	TCA_MATCHALL_PAD,
585 	__TCA_MATCHALL_MAX,
586 };
587 
588 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
589 
590 /* Extended Matches */
591 
592 struct tcf_ematch_tree_hdr {
593 	__u16		nmatches;
594 	__u16		progid;
595 };
596 
597 enum {
598 	TCA_EMATCH_TREE_UNSPEC,
599 	TCA_EMATCH_TREE_HDR,
600 	TCA_EMATCH_TREE_LIST,
601 	__TCA_EMATCH_TREE_MAX
602 };
603 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
604 
605 struct tcf_ematch_hdr {
606 	__u16		matchid;
607 	__u16		kind;
608 	__u16		flags;
609 	__u16		pad; /* currently unused */
610 };
611 
612 /*  0                   1
613  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
614  * +-----------------------+-+-+---+
615  * |         Unused        |S|I| R |
616  * +-----------------------+-+-+---+
617  *
618  * R(2) ::= relation to next ematch
619  *          where: 0 0 END (last ematch)
620  *                 0 1 AND
621  *                 1 0 OR
622  *                 1 1 Unused (invalid)
623  * I(1) ::= invert result
624  * S(1) ::= simple payload
625  */
626 #define TCF_EM_REL_END	0
627 #define TCF_EM_REL_AND	(1<<0)
628 #define TCF_EM_REL_OR	(1<<1)
629 #define TCF_EM_INVERT	(1<<2)
630 #define TCF_EM_SIMPLE	(1<<3)
631 
632 #define TCF_EM_REL_MASK	3
633 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
634 
635 enum {
636 	TCF_LAYER_LINK,
637 	TCF_LAYER_NETWORK,
638 	TCF_LAYER_TRANSPORT,
639 	__TCF_LAYER_MAX
640 };
641 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
642 
643 /* Ematch type assignments
644  *   1..32767		Reserved for ematches inside kernel tree
645  *   32768..65535	Free to use, not reliable
646  */
647 #define	TCF_EM_CONTAINER	0
648 #define	TCF_EM_CMP		1
649 #define	TCF_EM_NBYTE		2
650 #define	TCF_EM_U32		3
651 #define	TCF_EM_META		4
652 #define	TCF_EM_TEXT		5
653 #define	TCF_EM_VLAN		6
654 #define	TCF_EM_CANID		7
655 #define	TCF_EM_IPSET		8
656 #define	TCF_EM_IPT		9
657 #define	TCF_EM_MAX		9
658 
659 enum {
660 	TCF_EM_PROG_TC
661 };
662 
663 enum {
664 	TCF_EM_OPND_EQ,
665 	TCF_EM_OPND_GT,
666 	TCF_EM_OPND_LT
667 };
668 
669 #endif
670