xref: /openbmc/linux/include/uapi/linux/pkt_cls.h (revision a701d28e)
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_KEY_HASH,		/* u32 */
582 	TCA_FLOWER_KEY_HASH_MASK,	/* u32 */
583 
584 	__TCA_FLOWER_MAX,
585 };
586 
587 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
588 
589 enum {
590 	TCA_FLOWER_KEY_CT_FLAGS_NEW = 1 << 0, /* Beginning of a new connection. */
591 	TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 1 << 1, /* Part of an existing connection. */
592 	TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2, /* Related to an established connection. */
593 	TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3, /* Conntrack has occurred. */
594 };
595 
596 enum {
597 	TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
598 	TCA_FLOWER_KEY_ENC_OPTS_GENEVE, /* Nested
599 					 * TCA_FLOWER_KEY_ENC_OPT_GENEVE_
600 					 * attributes
601 					 */
602 	TCA_FLOWER_KEY_ENC_OPTS_VXLAN,	/* Nested
603 					 * TCA_FLOWER_KEY_ENC_OPT_VXLAN_
604 					 * attributes
605 					 */
606 	TCA_FLOWER_KEY_ENC_OPTS_ERSPAN,	/* Nested
607 					 * TCA_FLOWER_KEY_ENC_OPT_ERSPAN_
608 					 * attributes
609 					 */
610 	__TCA_FLOWER_KEY_ENC_OPTS_MAX,
611 };
612 
613 #define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
614 
615 enum {
616 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC,
617 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS,            /* u16 */
618 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE,             /* u8 */
619 	TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA,             /* 4 to 128 bytes */
620 
621 	__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX,
622 };
623 
624 #define TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX \
625 		(__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)
626 
627 enum {
628 	TCA_FLOWER_KEY_ENC_OPT_VXLAN_UNSPEC,
629 	TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP,		/* u32 */
630 	__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX,
631 };
632 
633 #define TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX \
634 		(__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX - 1)
635 
636 enum {
637 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_UNSPEC,
638 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER,              /* u8 */
639 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX,            /* be32 */
640 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR,              /* u8 */
641 	TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID,             /* u8 */
642 	__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX,
643 };
644 
645 #define TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX \
646 		(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)
647 
648 enum {
649 	TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
650 	TCA_FLOWER_KEY_MPLS_OPTS_LSE,
651 	__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
652 };
653 
654 #define TCA_FLOWER_KEY_MPLS_OPTS_MAX (__TCA_FLOWER_KEY_MPLS_OPTS_MAX - 1)
655 
656 enum {
657 	TCA_FLOWER_KEY_MPLS_OPT_LSE_UNSPEC,
658 	TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH,
659 	TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL,
660 	TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS,
661 	TCA_FLOWER_KEY_MPLS_OPT_LSE_TC,
662 	TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL,
663 	__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX,
664 };
665 
666 #define TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX \
667 		(__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX - 1)
668 
669 enum {
670 	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
671 	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
672 };
673 
674 #define TCA_FLOWER_MASK_FLAGS_RANGE	(1 << 0) /* Range-based match */
675 
676 /* Match-all classifier */
677 
678 struct tc_matchall_pcnt {
679 	__u64 rhit;
680 };
681 
682 enum {
683 	TCA_MATCHALL_UNSPEC,
684 	TCA_MATCHALL_CLASSID,
685 	TCA_MATCHALL_ACT,
686 	TCA_MATCHALL_FLAGS,
687 	TCA_MATCHALL_PCNT,
688 	TCA_MATCHALL_PAD,
689 	__TCA_MATCHALL_MAX,
690 };
691 
692 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
693 
694 /* Extended Matches */
695 
696 struct tcf_ematch_tree_hdr {
697 	__u16		nmatches;
698 	__u16		progid;
699 };
700 
701 enum {
702 	TCA_EMATCH_TREE_UNSPEC,
703 	TCA_EMATCH_TREE_HDR,
704 	TCA_EMATCH_TREE_LIST,
705 	__TCA_EMATCH_TREE_MAX
706 };
707 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
708 
709 struct tcf_ematch_hdr {
710 	__u16		matchid;
711 	__u16		kind;
712 	__u16		flags;
713 	__u16		pad; /* currently unused */
714 };
715 
716 /*  0                   1
717  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
718  * +-----------------------+-+-+---+
719  * |         Unused        |S|I| R |
720  * +-----------------------+-+-+---+
721  *
722  * R(2) ::= relation to next ematch
723  *          where: 0 0 END (last ematch)
724  *                 0 1 AND
725  *                 1 0 OR
726  *                 1 1 Unused (invalid)
727  * I(1) ::= invert result
728  * S(1) ::= simple payload
729  */
730 #define TCF_EM_REL_END	0
731 #define TCF_EM_REL_AND	(1<<0)
732 #define TCF_EM_REL_OR	(1<<1)
733 #define TCF_EM_INVERT	(1<<2)
734 #define TCF_EM_SIMPLE	(1<<3)
735 
736 #define TCF_EM_REL_MASK	3
737 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
738 
739 enum {
740 	TCF_LAYER_LINK,
741 	TCF_LAYER_NETWORK,
742 	TCF_LAYER_TRANSPORT,
743 	__TCF_LAYER_MAX
744 };
745 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
746 
747 /* Ematch type assignments
748  *   1..32767		Reserved for ematches inside kernel tree
749  *   32768..65535	Free to use, not reliable
750  */
751 #define	TCF_EM_CONTAINER	0
752 #define	TCF_EM_CMP		1
753 #define	TCF_EM_NBYTE		2
754 #define	TCF_EM_U32		3
755 #define	TCF_EM_META		4
756 #define	TCF_EM_TEXT		5
757 #define	TCF_EM_VLAN		6
758 #define	TCF_EM_CANID		7
759 #define	TCF_EM_IPSET		8
760 #define	TCF_EM_IPT		9
761 #define	TCF_EM_MAX		9
762 
763 enum {
764 	TCF_EM_PROG_TC
765 };
766 
767 enum {
768 	TCF_EM_OPND_EQ,
769 	TCF_EM_OPND_GT,
770 	TCF_EM_OPND_LT
771 };
772 
773 #endif
774