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