1 #ifndef __LINUX_PKT_CLS_H
2 #define __LINUX_PKT_CLS_H
4 #include <linux/types.h>
5 #include <linux/pkt_sched.h>
7 #define TC_COOKIE_MAX_SIZE 16
9 /* Action attributes */
21 #define TCA_ACT_MAX __TCA_ACT_MAX
22 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
23 #define TCA_ACT_MAX_PRIO 32
24 #define TCA_ACT_BIND 1
25 #define TCA_ACT_NOBIND 0
26 #define TCA_ACT_UNBIND 1
27 #define TCA_ACT_NOUNBIND 0
28 #define TCA_ACT_REPLACE 1
29 #define TCA_ACT_NOREPLACE 0
31 #define TC_ACT_UNSPEC (-1)
33 #define TC_ACT_RECLASSIFY 1
36 #define TC_ACT_STOLEN 4
37 #define TC_ACT_QUEUED 5
38 #define TC_ACT_REPEAT 6
39 #define TC_ACT_REDIRECT 7
41 /* There is a special kind of actions called "extended actions",
42 * which need a value parameter. These have a local opcode located in
43 * the highest nibble, starting from 1. The rest of the bits
44 * are used to carry the value. These two parts together make
47 #define __TC_ACT_EXT_SHIFT 28
48 #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT)
49 #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1)
50 #define TC_ACT_EXT_CMP(combined, opcode) \
51 (((combined) & (~TC_ACT_EXT_VAL_MASK)) == opcode)
53 #define TC_ACT_JUMP __TC_ACT_EXT(1)
55 /* Action type identifiers*/
59 /* other actions go here */
63 #define TCA_ID_MAX __TCA_ID_MAX
68 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
69 #define TC_POLICE_OK TC_ACT_OK
70 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
71 #define TC_POLICE_SHOT TC_ACT_SHOT
72 #define TC_POLICE_PIPE TC_ACT_PIPE
77 struct tc_ratespec rate;
78 struct tc_ratespec peakrate;
113 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
116 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
118 /* tca flags definitions */
119 #define TCA_CLS_FLAGS_SKIP_HW (1 << 0) /* don't offload filter to HW */
120 #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */
121 #define TCA_CLS_FLAGS_IN_HW (1 << 2) /* filter is offloaded to HW */
122 #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
126 #define TC_U32_HTID(h) ((h)&0xFFF00000)
127 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
128 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
129 #define TC_U32_NODE(h) ((h)&0xFFF)
130 #define TC_U32_KEY(h) ((h)&0xFFFFF)
131 #define TC_U32_UNSPEC 0
132 #define TC_U32_ROOT (0xFFF00000)
151 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
162 unsigned char offshift;
171 struct tc_u32_key keys[0];
188 #define TC_U32_TERMINAL 1
189 #define TC_U32_OFFSET 2
190 #define TC_U32_VAROFFSET 4
193 #define TC_U32_MAXDEPTH 8
209 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
217 struct tc_rsvp_pinfo {
218 struct tc_rsvp_gpi dpi;
219 struct tc_rsvp_gpi spi;
239 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
248 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
249 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
254 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
256 /* TC index filter */
263 TCA_TCINDEX_FALL_THROUGH,
270 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
286 FLOW_KEY_NFCT_PROTO_SRC,
287 FLOW_KEY_NFCT_PROTO_DST,
296 #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
320 #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
333 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
336 /* Cgroup classifier */
346 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
350 #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
367 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
369 /* Flower classifier */
376 TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */
377 TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */
378 TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */
379 TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */
380 TCA_FLOWER_KEY_ETH_TYPE, /* be16 */
381 TCA_FLOWER_KEY_IP_PROTO, /* u8 */
382 TCA_FLOWER_KEY_IPV4_SRC, /* be32 */
383 TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */
384 TCA_FLOWER_KEY_IPV4_DST, /* be32 */
385 TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */
386 TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */
387 TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */
388 TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */
389 TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */
390 TCA_FLOWER_KEY_TCP_SRC, /* be16 */
391 TCA_FLOWER_KEY_TCP_DST, /* be16 */
392 TCA_FLOWER_KEY_UDP_SRC, /* be16 */
393 TCA_FLOWER_KEY_UDP_DST, /* be16 */
396 TCA_FLOWER_KEY_VLAN_ID, /* be16 */
397 TCA_FLOWER_KEY_VLAN_PRIO, /* u8 */
398 TCA_FLOWER_KEY_VLAN_ETH_TYPE, /* be16 */
400 TCA_FLOWER_KEY_ENC_KEY_ID, /* be32 */
401 TCA_FLOWER_KEY_ENC_IPV4_SRC, /* be32 */
402 TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */
403 TCA_FLOWER_KEY_ENC_IPV4_DST, /* be32 */
404 TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */
405 TCA_FLOWER_KEY_ENC_IPV6_SRC, /* struct in6_addr */
406 TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */
407 TCA_FLOWER_KEY_ENC_IPV6_DST, /* struct in6_addr */
408 TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */
410 TCA_FLOWER_KEY_TCP_SRC_MASK, /* be16 */
411 TCA_FLOWER_KEY_TCP_DST_MASK, /* be16 */
412 TCA_FLOWER_KEY_UDP_SRC_MASK, /* be16 */
413 TCA_FLOWER_KEY_UDP_DST_MASK, /* be16 */
414 TCA_FLOWER_KEY_SCTP_SRC_MASK, /* be16 */
415 TCA_FLOWER_KEY_SCTP_DST_MASK, /* be16 */
417 TCA_FLOWER_KEY_SCTP_SRC, /* be16 */
418 TCA_FLOWER_KEY_SCTP_DST, /* be16 */
420 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT, /* be16 */
421 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, /* be16 */
422 TCA_FLOWER_KEY_ENC_UDP_DST_PORT, /* be16 */
423 TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, /* be16 */
425 TCA_FLOWER_KEY_FLAGS, /* be32 */
426 TCA_FLOWER_KEY_FLAGS_MASK, /* be32 */
428 TCA_FLOWER_KEY_ICMPV4_CODE, /* u8 */
429 TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */
430 TCA_FLOWER_KEY_ICMPV4_TYPE, /* u8 */
431 TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */
432 TCA_FLOWER_KEY_ICMPV6_CODE, /* u8 */
433 TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */
434 TCA_FLOWER_KEY_ICMPV6_TYPE, /* u8 */
435 TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */
437 TCA_FLOWER_KEY_ARP_SIP, /* be32 */
438 TCA_FLOWER_KEY_ARP_SIP_MASK, /* be32 */
439 TCA_FLOWER_KEY_ARP_TIP, /* be32 */
440 TCA_FLOWER_KEY_ARP_TIP_MASK, /* be32 */
441 TCA_FLOWER_KEY_ARP_OP, /* u8 */
442 TCA_FLOWER_KEY_ARP_OP_MASK, /* u8 */
443 TCA_FLOWER_KEY_ARP_SHA, /* ETH_ALEN */
444 TCA_FLOWER_KEY_ARP_SHA_MASK, /* ETH_ALEN */
445 TCA_FLOWER_KEY_ARP_THA, /* ETH_ALEN */
446 TCA_FLOWER_KEY_ARP_THA_MASK, /* ETH_ALEN */
448 TCA_FLOWER_KEY_MPLS_TTL, /* u8 - 8 bits */
449 TCA_FLOWER_KEY_MPLS_BOS, /* u8 - 1 bit */
450 TCA_FLOWER_KEY_MPLS_TC, /* u8 - 3 bits */
451 TCA_FLOWER_KEY_MPLS_LABEL, /* be32 - 20 bits */
456 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
459 TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
462 /* Match-all classifier */
466 TCA_MATCHALL_CLASSID,
472 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
474 /* Extended Matches */
476 struct tcf_ematch_tree_hdr {
482 TCA_EMATCH_TREE_UNSPEC,
484 TCA_EMATCH_TREE_LIST,
485 __TCA_EMATCH_TREE_MAX
487 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
489 struct tcf_ematch_hdr {
493 __u16 pad; /* currently unused */
497 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
498 * +-----------------------+-+-+---+
500 * +-----------------------+-+-+---+
502 * R(2) ::= relation to next ematch
503 * where: 0 0 END (last ematch)
506 * 1 1 Unused (invalid)
507 * I(1) ::= invert result
508 * S(1) ::= simple payload
510 #define TCF_EM_REL_END 0
511 #define TCF_EM_REL_AND (1<<0)
512 #define TCF_EM_REL_OR (1<<1)
513 #define TCF_EM_INVERT (1<<2)
514 #define TCF_EM_SIMPLE (1<<3)
516 #define TCF_EM_REL_MASK 3
517 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
525 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
527 /* Ematch type assignments
528 * 1..32767 Reserved for ematches inside kernel tree
529 * 32768..65535 Free to use, not reliable
531 #define TCF_EM_CONTAINER 0
533 #define TCF_EM_NBYTE 2
535 #define TCF_EM_META 4
536 #define TCF_EM_TEXT 5
537 #define TCF_EM_VLAN 6
538 #define TCF_EM_CANID 7
539 #define TCF_EM_IPSET 8