1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_PKT_CLS_H
3 #define __LINUX_PKT_CLS_H
5 #include <linux/types.h>
6 #include <linux/pkt_sched.h>
8 #define TC_COOKIE_MAX_SIZE 16
10 /* Action attributes */
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
32 #define TC_ACT_UNSPEC (-1)
34 #define TC_ACT_RECLASSIFY 1
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 /* For hw path, this means "trap to cpu"
42 * and don't further process the frame
43 * in hardware. For sw path, this is
44 * equivalent of TC_ACT_STOLEN - drop
45 * the skb and act like everything
49 /* There is a special kind of actions called "extended actions",
50 * which need a value parameter. These have a local opcode located in
51 * the highest nibble, starting from 1. The rest of the bits
52 * are used to carry the value. These two parts together make
55 #define __TC_ACT_EXT_SHIFT 28
56 #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT)
57 #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1)
58 #define TC_ACT_EXT_CMP(combined, opcode) \
59 (((combined) & (~TC_ACT_EXT_VAL_MASK)) == opcode)
61 #define TC_ACT_JUMP __TC_ACT_EXT(1)
62 #define TC_ACT_GOTO_CHAIN __TC_ACT_EXT(2)
64 /* Action type identifiers*/
68 /* other actions go here */
72 #define TCA_ID_MAX __TCA_ID_MAX
77 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
78 #define TC_POLICE_OK TC_ACT_OK
79 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
80 #define TC_POLICE_SHOT TC_ACT_SHOT
81 #define TC_POLICE_PIPE TC_ACT_PIPE
86 struct tc_ratespec rate;
87 struct tc_ratespec peakrate;
122 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
125 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
127 /* tca flags definitions */
128 #define TCA_CLS_FLAGS_SKIP_HW (1 << 0) /* don't offload filter to HW */
129 #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */
130 #define TCA_CLS_FLAGS_IN_HW (1 << 2) /* filter is offloaded to HW */
131 #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
132 #define TCA_CLS_FLAGS_VERBOSE (1 << 4) /* verbose logging */
136 #define TC_U32_HTID(h) ((h)&0xFFF00000)
137 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
138 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
139 #define TC_U32_NODE(h) ((h)&0xFFF)
140 #define TC_U32_KEY(h) ((h)&0xFFFFF)
141 #define TC_U32_UNSPEC 0
142 #define TC_U32_ROOT (0xFFF00000)
161 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
172 unsigned char offshift;
181 struct tc_u32_key keys[0];
198 #define TC_U32_TERMINAL 1
199 #define TC_U32_OFFSET 2
200 #define TC_U32_VAROFFSET 4
203 #define TC_U32_MAXDEPTH 8
219 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
227 struct tc_rsvp_pinfo {
228 struct tc_rsvp_gpi dpi;
229 struct tc_rsvp_gpi spi;
249 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
258 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
259 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
264 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
266 /* TC index filter */
273 TCA_TCINDEX_FALL_THROUGH,
280 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
296 FLOW_KEY_NFCT_PROTO_SRC,
297 FLOW_KEY_NFCT_PROTO_DST,
306 #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
330 #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
343 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
346 /* Cgroup classifier */
356 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
360 #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
378 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
380 /* Flower classifier */
387 TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */
388 TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */
389 TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */
390 TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */
391 TCA_FLOWER_KEY_ETH_TYPE, /* be16 */
392 TCA_FLOWER_KEY_IP_PROTO, /* u8 */
393 TCA_FLOWER_KEY_IPV4_SRC, /* be32 */
394 TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */
395 TCA_FLOWER_KEY_IPV4_DST, /* be32 */
396 TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */
397 TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */
398 TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */
399 TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */
400 TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */
401 TCA_FLOWER_KEY_TCP_SRC, /* be16 */
402 TCA_FLOWER_KEY_TCP_DST, /* be16 */
403 TCA_FLOWER_KEY_UDP_SRC, /* be16 */
404 TCA_FLOWER_KEY_UDP_DST, /* be16 */
407 TCA_FLOWER_KEY_VLAN_ID, /* be16 */
408 TCA_FLOWER_KEY_VLAN_PRIO, /* u8 */
409 TCA_FLOWER_KEY_VLAN_ETH_TYPE, /* be16 */
411 TCA_FLOWER_KEY_ENC_KEY_ID, /* be32 */
412 TCA_FLOWER_KEY_ENC_IPV4_SRC, /* be32 */
413 TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */
414 TCA_FLOWER_KEY_ENC_IPV4_DST, /* be32 */
415 TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */
416 TCA_FLOWER_KEY_ENC_IPV6_SRC, /* struct in6_addr */
417 TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */
418 TCA_FLOWER_KEY_ENC_IPV6_DST, /* struct in6_addr */
419 TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */
421 TCA_FLOWER_KEY_TCP_SRC_MASK, /* be16 */
422 TCA_FLOWER_KEY_TCP_DST_MASK, /* be16 */
423 TCA_FLOWER_KEY_UDP_SRC_MASK, /* be16 */
424 TCA_FLOWER_KEY_UDP_DST_MASK, /* be16 */
425 TCA_FLOWER_KEY_SCTP_SRC_MASK, /* be16 */
426 TCA_FLOWER_KEY_SCTP_DST_MASK, /* be16 */
428 TCA_FLOWER_KEY_SCTP_SRC, /* be16 */
429 TCA_FLOWER_KEY_SCTP_DST, /* be16 */
431 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT, /* be16 */
432 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, /* be16 */
433 TCA_FLOWER_KEY_ENC_UDP_DST_PORT, /* be16 */
434 TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, /* be16 */
436 TCA_FLOWER_KEY_FLAGS, /* be32 */
437 TCA_FLOWER_KEY_FLAGS_MASK, /* be32 */
439 TCA_FLOWER_KEY_ICMPV4_CODE, /* u8 */
440 TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */
441 TCA_FLOWER_KEY_ICMPV4_TYPE, /* u8 */
442 TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */
443 TCA_FLOWER_KEY_ICMPV6_CODE, /* u8 */
444 TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */
445 TCA_FLOWER_KEY_ICMPV6_TYPE, /* u8 */
446 TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */
448 TCA_FLOWER_KEY_ARP_SIP, /* be32 */
449 TCA_FLOWER_KEY_ARP_SIP_MASK, /* be32 */
450 TCA_FLOWER_KEY_ARP_TIP, /* be32 */
451 TCA_FLOWER_KEY_ARP_TIP_MASK, /* be32 */
452 TCA_FLOWER_KEY_ARP_OP, /* u8 */
453 TCA_FLOWER_KEY_ARP_OP_MASK, /* u8 */
454 TCA_FLOWER_KEY_ARP_SHA, /* ETH_ALEN */
455 TCA_FLOWER_KEY_ARP_SHA_MASK, /* ETH_ALEN */
456 TCA_FLOWER_KEY_ARP_THA, /* ETH_ALEN */
457 TCA_FLOWER_KEY_ARP_THA_MASK, /* ETH_ALEN */
459 TCA_FLOWER_KEY_MPLS_TTL, /* u8 - 8 bits */
460 TCA_FLOWER_KEY_MPLS_BOS, /* u8 - 1 bit */
461 TCA_FLOWER_KEY_MPLS_TC, /* u8 - 3 bits */
462 TCA_FLOWER_KEY_MPLS_LABEL, /* be32 - 20 bits */
464 TCA_FLOWER_KEY_TCP_FLAGS, /* be16 */
465 TCA_FLOWER_KEY_TCP_FLAGS_MASK, /* be16 */
467 TCA_FLOWER_KEY_IP_TOS, /* u8 */
468 TCA_FLOWER_KEY_IP_TOS_MASK, /* u8 */
469 TCA_FLOWER_KEY_IP_TTL, /* u8 */
470 TCA_FLOWER_KEY_IP_TTL_MASK, /* u8 */
475 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
478 TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
479 TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
482 /* Match-all classifier */
486 TCA_MATCHALL_CLASSID,
492 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
494 /* Extended Matches */
496 struct tcf_ematch_tree_hdr {
502 TCA_EMATCH_TREE_UNSPEC,
504 TCA_EMATCH_TREE_LIST,
505 __TCA_EMATCH_TREE_MAX
507 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
509 struct tcf_ematch_hdr {
513 __u16 pad; /* currently unused */
517 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
518 * +-----------------------+-+-+---+
520 * +-----------------------+-+-+---+
522 * R(2) ::= relation to next ematch
523 * where: 0 0 END (last ematch)
526 * 1 1 Unused (invalid)
527 * I(1) ::= invert result
528 * S(1) ::= simple payload
530 #define TCF_EM_REL_END 0
531 #define TCF_EM_REL_AND (1<<0)
532 #define TCF_EM_REL_OR (1<<1)
533 #define TCF_EM_INVERT (1<<2)
534 #define TCF_EM_SIMPLE (1<<3)
536 #define TCF_EM_REL_MASK 3
537 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
545 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
547 /* Ematch type assignments
548 * 1..32767 Reserved for ematches inside kernel tree
549 * 32768..65535 Free to use, not reliable
551 #define TCF_EM_CONTAINER 0
553 #define TCF_EM_NBYTE 2
555 #define TCF_EM_META 4
556 #define TCF_EM_TEXT 5
557 #define TCF_EM_VLAN 6
558 #define TCF_EM_CANID 7
559 #define TCF_EM_IPSET 8