1
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
11enum {
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
42
43
44
45
46
47
48#define TC_ACT_VALUE_MAX TC_ACT_TRAP
49
50
51
52
53
54
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
67enum {
68 TCA_ID_UNSPEC=0,
69 TCA_ID_POLICE=1,
70
71 __TCA_ID_MAX=255
72};
73
74#define TCA_ID_MAX __TCA_ID_MAX
75
76struct tc_police {
77 __u32 index;
78 int action;
79#define TC_POLICE_UNSPEC TC_ACT_UNSPEC
80#define TC_POLICE_OK TC_ACT_OK
81#define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
82#define TC_POLICE_SHOT TC_ACT_SHOT
83#define TC_POLICE_PIPE TC_ACT_PIPE
84
85 __u32 limit;
86 __u32 burst;
87 __u32 mtu;
88 struct tc_ratespec rate;
89 struct tc_ratespec peakrate;
90 int refcnt;
91 int bindcnt;
92 __u32 capab;
93};
94
95struct tcf_t {
96 __u64 install;
97 __u64 lastuse;
98 __u64 expires;
99 __u64 firstuse;
100};
101
102struct tc_cnt {
103 int refcnt;
104 int bindcnt;
105};
106
107#define tc_gen \
108 __u32 index; \
109 __u32 capab; \
110 int action; \
111 int refcnt; \
112 int bindcnt
113
114enum {
115 TCA_POLICE_UNSPEC,
116 TCA_POLICE_TBF,
117 TCA_POLICE_RATE,
118 TCA_POLICE_PEAKRATE,
119 TCA_POLICE_AVRATE,
120 TCA_POLICE_RESULT,
121 TCA_POLICE_TM,
122 TCA_POLICE_PAD,
123 __TCA_POLICE_MAX
124#define TCA_POLICE_RESULT TCA_POLICE_RESULT
125};
126
127#define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
128
129
130#define TCA_CLS_FLAGS_SKIP_HW (1 << 0)
131#define TCA_CLS_FLAGS_SKIP_SW (1 << 1)
132#define TCA_CLS_FLAGS_IN_HW (1 << 2)
133#define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3)
134#define TCA_CLS_FLAGS_VERBOSE (1 << 4)
135
136
137
138#define TC_U32_HTID(h) ((h)&0xFFF00000)
139#define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
140#define TC_U32_HASH(h) (((h)>>12)&0xFF)
141#define TC_U32_NODE(h) ((h)&0xFFF)
142#define TC_U32_KEY(h) ((h)&0xFFFFF)
143#define TC_U32_UNSPEC 0
144#define TC_U32_ROOT (0xFFF00000)
145
146enum {
147 TCA_U32_UNSPEC,
148 TCA_U32_CLASSID,
149 TCA_U32_HASH,
150 TCA_U32_LINK,
151 TCA_U32_DIVISOR,
152 TCA_U32_SEL,
153 TCA_U32_POLICE,
154 TCA_U32_ACT,
155 TCA_U32_INDEV,
156 TCA_U32_PCNT,
157 TCA_U32_MARK,
158 TCA_U32_FLAGS,
159 TCA_U32_PAD,
160 __TCA_U32_MAX
161};
162
163#define TCA_U32_MAX (__TCA_U32_MAX - 1)
164
165struct tc_u32_key {
166 __be32 mask;
167 __be32 val;
168 int off;
169 int offmask;
170};
171
172struct tc_u32_sel {
173 unsigned char flags;
174 unsigned char offshift;
175 unsigned char nkeys;
176
177 __be16 offmask;
178 __u16 off;
179 short offoff;
180
181 short hoff;
182 __be32 hmask;
183 struct tc_u32_key keys[0];
184};
185
186struct tc_u32_mark {
187 __u32 val;
188 __u32 mask;
189 __u32 success;
190};
191
192struct tc_u32_pcnt {
193 __u64 rcnt;
194 __u64 rhit;
195 __u64 kcnts[0];
196};
197
198
199
200#define TC_U32_TERMINAL 1
201#define TC_U32_OFFSET 2
202#define TC_U32_VAROFFSET 4
203#define TC_U32_EAT 8
204
205#define TC_U32_MAXDEPTH 8
206
207
208
209
210enum {
211 TCA_RSVP_UNSPEC,
212 TCA_RSVP_CLASSID,
213 TCA_RSVP_DST,
214 TCA_RSVP_SRC,
215 TCA_RSVP_PINFO,
216 TCA_RSVP_POLICE,
217 TCA_RSVP_ACT,
218 __TCA_RSVP_MAX
219};
220
221#define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
222
223struct tc_rsvp_gpi {
224 __u32 key;
225 __u32 mask;
226 int offset;
227};
228
229struct tc_rsvp_pinfo {
230 struct tc_rsvp_gpi dpi;
231 struct tc_rsvp_gpi spi;
232 __u8 protocol;
233 __u8 tunnelid;
234 __u8 tunnelhdr;
235 __u8 pad;
236};
237
238
239
240enum {
241 TCA_ROUTE4_UNSPEC,
242 TCA_ROUTE4_CLASSID,
243 TCA_ROUTE4_TO,
244 TCA_ROUTE4_FROM,
245 TCA_ROUTE4_IIF,
246 TCA_ROUTE4_POLICE,
247 TCA_ROUTE4_ACT,
248 __TCA_ROUTE4_MAX
249};
250
251#define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
252
253
254
255
256enum {
257 TCA_FW_UNSPEC,
258 TCA_FW_CLASSID,
259 TCA_FW_POLICE,
260 TCA_FW_INDEV,
261 TCA_FW_ACT,
262 TCA_FW_MASK,
263 __TCA_FW_MAX
264};
265
266#define TCA_FW_MAX (__TCA_FW_MAX - 1)
267
268
269
270enum {
271 TCA_TCINDEX_UNSPEC,
272 TCA_TCINDEX_HASH,
273 TCA_TCINDEX_MASK,
274 TCA_TCINDEX_SHIFT,
275 TCA_TCINDEX_FALL_THROUGH,
276 TCA_TCINDEX_CLASSID,
277 TCA_TCINDEX_POLICE,
278 TCA_TCINDEX_ACT,
279 __TCA_TCINDEX_MAX
280};
281
282#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
283
284
285
286enum {
287 FLOW_KEY_SRC,
288 FLOW_KEY_DST,
289 FLOW_KEY_PROTO,
290 FLOW_KEY_PROTO_SRC,
291 FLOW_KEY_PROTO_DST,
292 FLOW_KEY_IIF,
293 FLOW_KEY_PRIORITY,
294 FLOW_KEY_MARK,
295 FLOW_KEY_NFCT,
296 FLOW_KEY_NFCT_SRC,
297 FLOW_KEY_NFCT_DST,
298 FLOW_KEY_NFCT_PROTO_SRC,
299 FLOW_KEY_NFCT_PROTO_DST,
300 FLOW_KEY_RTCLASSID,
301 FLOW_KEY_SKUID,
302 FLOW_KEY_SKGID,
303 FLOW_KEY_VLAN_TAG,
304 FLOW_KEY_RXHASH,
305 __FLOW_KEY_MAX,
306};
307
308#define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
309
310enum {
311 FLOW_MODE_MAP,
312 FLOW_MODE_HASH,
313};
314
315enum {
316 TCA_FLOW_UNSPEC,
317 TCA_FLOW_KEYS,
318 TCA_FLOW_MODE,
319 TCA_FLOW_BASECLASS,
320 TCA_FLOW_RSHIFT,
321 TCA_FLOW_ADDEND,
322 TCA_FLOW_MASK,
323 TCA_FLOW_XOR,
324 TCA_FLOW_DIVISOR,
325 TCA_FLOW_ACT,
326 TCA_FLOW_POLICE,
327 TCA_FLOW_EMATCHES,
328 TCA_FLOW_PERTURB,
329 __TCA_FLOW_MAX
330};
331
332#define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
333
334
335
336enum {
337 TCA_BASIC_UNSPEC,
338 TCA_BASIC_CLASSID,
339 TCA_BASIC_EMATCHES,
340 TCA_BASIC_ACT,
341 TCA_BASIC_POLICE,
342 __TCA_BASIC_MAX
343};
344
345#define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
346
347
348
349
350enum {
351 TCA_CGROUP_UNSPEC,
352 TCA_CGROUP_ACT,
353 TCA_CGROUP_POLICE,
354 TCA_CGROUP_EMATCHES,
355 __TCA_CGROUP_MAX,
356};
357
358#define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
359
360
361
362#define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
363
364enum {
365 TCA_BPF_UNSPEC,
366 TCA_BPF_ACT,
367 TCA_BPF_POLICE,
368 TCA_BPF_CLASSID,
369 TCA_BPF_OPS_LEN,
370 TCA_BPF_OPS,
371 TCA_BPF_FD,
372 TCA_BPF_NAME,
373 TCA_BPF_FLAGS,
374 TCA_BPF_FLAGS_GEN,
375 TCA_BPF_TAG,
376 TCA_BPF_ID,
377 __TCA_BPF_MAX,
378};
379
380#define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
381
382
383
384enum {
385 TCA_FLOWER_UNSPEC,
386 TCA_FLOWER_CLASSID,
387 TCA_FLOWER_INDEV,
388 TCA_FLOWER_ACT,
389 TCA_FLOWER_KEY_ETH_DST,
390 TCA_FLOWER_KEY_ETH_DST_MASK,
391 TCA_FLOWER_KEY_ETH_SRC,
392 TCA_FLOWER_KEY_ETH_SRC_MASK,
393 TCA_FLOWER_KEY_ETH_TYPE,
394 TCA_FLOWER_KEY_IP_PROTO,
395 TCA_FLOWER_KEY_IPV4_SRC,
396 TCA_FLOWER_KEY_IPV4_SRC_MASK,
397 TCA_FLOWER_KEY_IPV4_DST,
398 TCA_FLOWER_KEY_IPV4_DST_MASK,
399 TCA_FLOWER_KEY_IPV6_SRC,
400 TCA_FLOWER_KEY_IPV6_SRC_MASK,
401 TCA_FLOWER_KEY_IPV6_DST,
402 TCA_FLOWER_KEY_IPV6_DST_MASK,
403 TCA_FLOWER_KEY_TCP_SRC,
404 TCA_FLOWER_KEY_TCP_DST,
405 TCA_FLOWER_KEY_UDP_SRC,
406 TCA_FLOWER_KEY_UDP_DST,
407
408 TCA_FLOWER_FLAGS,
409 TCA_FLOWER_KEY_VLAN_ID,
410 TCA_FLOWER_KEY_VLAN_PRIO,
411 TCA_FLOWER_KEY_VLAN_ETH_TYPE,
412
413 TCA_FLOWER_KEY_ENC_KEY_ID,
414 TCA_FLOWER_KEY_ENC_IPV4_SRC,
415 TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,
416 TCA_FLOWER_KEY_ENC_IPV4_DST,
417 TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,
418 TCA_FLOWER_KEY_ENC_IPV6_SRC,
419 TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,
420 TCA_FLOWER_KEY_ENC_IPV6_DST,
421 TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,
422
423 TCA_FLOWER_KEY_TCP_SRC_MASK,
424 TCA_FLOWER_KEY_TCP_DST_MASK,
425 TCA_FLOWER_KEY_UDP_SRC_MASK,
426 TCA_FLOWER_KEY_UDP_DST_MASK,
427 TCA_FLOWER_KEY_SCTP_SRC_MASK,
428 TCA_FLOWER_KEY_SCTP_DST_MASK,
429
430 TCA_FLOWER_KEY_SCTP_SRC,
431 TCA_FLOWER_KEY_SCTP_DST,
432
433 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,
434 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK,
435 TCA_FLOWER_KEY_ENC_UDP_DST_PORT,
436 TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK,
437
438 TCA_FLOWER_KEY_FLAGS,
439 TCA_FLOWER_KEY_FLAGS_MASK,
440
441 TCA_FLOWER_KEY_ICMPV4_CODE,
442 TCA_FLOWER_KEY_ICMPV4_CODE_MASK,
443 TCA_FLOWER_KEY_ICMPV4_TYPE,
444 TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,
445 TCA_FLOWER_KEY_ICMPV6_CODE,
446 TCA_FLOWER_KEY_ICMPV6_CODE_MASK,
447 TCA_FLOWER_KEY_ICMPV6_TYPE,
448 TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,
449
450 TCA_FLOWER_KEY_ARP_SIP,
451 TCA_FLOWER_KEY_ARP_SIP_MASK,
452 TCA_FLOWER_KEY_ARP_TIP,
453 TCA_FLOWER_KEY_ARP_TIP_MASK,
454 TCA_FLOWER_KEY_ARP_OP,
455 TCA_FLOWER_KEY_ARP_OP_MASK,
456 TCA_FLOWER_KEY_ARP_SHA,
457 TCA_FLOWER_KEY_ARP_SHA_MASK,
458 TCA_FLOWER_KEY_ARP_THA,
459 TCA_FLOWER_KEY_ARP_THA_MASK,
460
461 TCA_FLOWER_KEY_MPLS_TTL,
462 TCA_FLOWER_KEY_MPLS_BOS,
463 TCA_FLOWER_KEY_MPLS_TC,
464 TCA_FLOWER_KEY_MPLS_LABEL,
465
466 TCA_FLOWER_KEY_TCP_FLAGS,
467 TCA_FLOWER_KEY_TCP_FLAGS_MASK,
468
469 TCA_FLOWER_KEY_IP_TOS,
470 TCA_FLOWER_KEY_IP_TOS_MASK,
471 TCA_FLOWER_KEY_IP_TTL,
472 TCA_FLOWER_KEY_IP_TTL_MASK,
473
474 TCA_FLOWER_KEY_CVLAN_ID,
475 TCA_FLOWER_KEY_CVLAN_PRIO,
476 TCA_FLOWER_KEY_CVLAN_ETH_TYPE,
477
478 TCA_FLOWER_KEY_ENC_IP_TOS,
479 TCA_FLOWER_KEY_ENC_IP_TOS_MASK,
480 TCA_FLOWER_KEY_ENC_IP_TTL,
481 TCA_FLOWER_KEY_ENC_IP_TTL_MASK,
482
483 TCA_FLOWER_KEY_ENC_OPTS,
484 TCA_FLOWER_KEY_ENC_OPTS_MASK,
485
486 TCA_FLOWER_IN_HW_COUNT,
487
488 __TCA_FLOWER_MAX,
489};
490
491#define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
492
493enum {
494 TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
495 TCA_FLOWER_KEY_ENC_OPTS_GENEVE,
496
497
498
499 __TCA_FLOWER_KEY_ENC_OPTS_MAX,
500};
501
502#define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
503
504enum {
505 TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC,
506 TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS,
507 TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE,
508 TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA,
509
510 __TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX,
511};
512
513#define TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX \
514 (__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)
515
516enum {
517 TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
518 TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
519};
520
521
522
523enum {
524 TCA_MATCHALL_UNSPEC,
525 TCA_MATCHALL_CLASSID,
526 TCA_MATCHALL_ACT,
527 TCA_MATCHALL_FLAGS,
528 __TCA_MATCHALL_MAX,
529};
530
531#define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
532
533
534
535struct tcf_ematch_tree_hdr {
536 __u16 nmatches;
537 __u16 progid;
538};
539
540enum {
541 TCA_EMATCH_TREE_UNSPEC,
542 TCA_EMATCH_TREE_HDR,
543 TCA_EMATCH_TREE_LIST,
544 __TCA_EMATCH_TREE_MAX
545};
546#define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
547
548struct tcf_ematch_hdr {
549 __u16 matchid;
550 __u16 kind;
551 __u16 flags;
552 __u16 pad;
553};
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569#define TCF_EM_REL_END 0
570#define TCF_EM_REL_AND (1<<0)
571#define TCF_EM_REL_OR (1<<1)
572#define TCF_EM_INVERT (1<<2)
573#define TCF_EM_SIMPLE (1<<3)
574
575#define TCF_EM_REL_MASK 3
576#define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
577
578enum {
579 TCF_LAYER_LINK,
580 TCF_LAYER_NETWORK,
581 TCF_LAYER_TRANSPORT,
582 __TCF_LAYER_MAX
583};
584#define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
585
586
587
588
589
590#define TCF_EM_CONTAINER 0
591#define TCF_EM_CMP 1
592#define TCF_EM_NBYTE 2
593#define TCF_EM_U32 3
594#define TCF_EM_META 4
595#define TCF_EM_TEXT 5
596#define TCF_EM_VLAN 6
597#define TCF_EM_CANID 7
598#define TCF_EM_IPSET 8
599#define TCF_EM_IPT 9
600#define TCF_EM_MAX 9
601
602enum {
603 TCF_EM_PROG_TC
604};
605
606enum {
607 TCF_EM_OPND_EQ,
608 TCF_EM_OPND_GT,
609 TCF_EM_OPND_LT
610};
611
612#endif
613