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