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