1 #ifndef __LINUX_PKT_CLS_H 2 #define __LINUX_PKT_CLS_H 3 4 #include <linux/types.h> 5 #include <linux/pkt_sched.h> 6 7 #define TC_COOKIE_MAX_SIZE 16 8 9 /* Action attributes */ 10 enum { 11 TCA_ACT_UNSPEC, 12 TCA_ACT_KIND, 13 TCA_ACT_OPTIONS, 14 TCA_ACT_INDEX, 15 TCA_ACT_STATS, 16 TCA_ACT_PAD, 17 TCA_ACT_COOKIE, 18 __TCA_ACT_MAX 19 }; 20 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 30 31 #define TC_ACT_UNSPEC (-1) 32 #define TC_ACT_OK 0 33 #define TC_ACT_RECLASSIFY 1 34 #define TC_ACT_SHOT 2 35 #define TC_ACT_PIPE 3 36 #define TC_ACT_STOLEN 4 37 #define TC_ACT_QUEUED 5 38 #define TC_ACT_REPEAT 6 39 #define TC_ACT_REDIRECT 7 40 #define TC_ACT_JUMP 0x10000000 41 42 /* Action type identifiers*/ 43 enum { 44 TCA_ID_UNSPEC=0, 45 TCA_ID_POLICE=1, 46 /* other actions go here */ 47 __TCA_ID_MAX=255 48 }; 49 50 #define TCA_ID_MAX __TCA_ID_MAX 51 52 struct tc_police { 53 __u32 index; 54 int action; 55 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC 56 #define TC_POLICE_OK TC_ACT_OK 57 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY 58 #define TC_POLICE_SHOT TC_ACT_SHOT 59 #define TC_POLICE_PIPE TC_ACT_PIPE 60 61 __u32 limit; 62 __u32 burst; 63 __u32 mtu; 64 struct tc_ratespec rate; 65 struct tc_ratespec peakrate; 66 int refcnt; 67 int bindcnt; 68 __u32 capab; 69 }; 70 71 struct tcf_t { 72 __u64 install; 73 __u64 lastuse; 74 __u64 expires; 75 __u64 firstuse; 76 }; 77 78 struct tc_cnt { 79 int refcnt; 80 int bindcnt; 81 }; 82 83 #define tc_gen \ 84 __u32 index; \ 85 __u32 capab; \ 86 int action; \ 87 int refcnt; \ 88 int bindcnt 89 90 enum { 91 TCA_POLICE_UNSPEC, 92 TCA_POLICE_TBF, 93 TCA_POLICE_RATE, 94 TCA_POLICE_PEAKRATE, 95 TCA_POLICE_AVRATE, 96 TCA_POLICE_RESULT, 97 TCA_POLICE_TM, 98 TCA_POLICE_PAD, 99 __TCA_POLICE_MAX 100 #define TCA_POLICE_RESULT TCA_POLICE_RESULT 101 }; 102 103 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1) 104 105 /* tca flags definitions */ 106 #define TCA_CLS_FLAGS_SKIP_HW (1 << 0) /* don't offload filter to HW */ 107 #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */ 108 #define TCA_CLS_FLAGS_IN_HW (1 << 2) /* filter is offloaded to HW */ 109 #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */ 110 111 /* U32 filters */ 112 113 #define TC_U32_HTID(h) ((h)&0xFFF00000) 114 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20) 115 #define TC_U32_HASH(h) (((h)>>12)&0xFF) 116 #define TC_U32_NODE(h) ((h)&0xFFF) 117 #define TC_U32_KEY(h) ((h)&0xFFFFF) 118 #define TC_U32_UNSPEC 0 119 #define TC_U32_ROOT (0xFFF00000) 120 121 enum { 122 TCA_U32_UNSPEC, 123 TCA_U32_CLASSID, 124 TCA_U32_HASH, 125 TCA_U32_LINK, 126 TCA_U32_DIVISOR, 127 TCA_U32_SEL, 128 TCA_U32_POLICE, 129 TCA_U32_ACT, 130 TCA_U32_INDEV, 131 TCA_U32_PCNT, 132 TCA_U32_MARK, 133 TCA_U32_FLAGS, 134 TCA_U32_PAD, 135 __TCA_U32_MAX 136 }; 137 138 #define TCA_U32_MAX (__TCA_U32_MAX - 1) 139 140 struct tc_u32_key { 141 __be32 mask; 142 __be32 val; 143 int off; 144 int offmask; 145 }; 146 147 struct tc_u32_sel { 148 unsigned char flags; 149 unsigned char offshift; 150 unsigned char nkeys; 151 152 __be16 offmask; 153 __u16 off; 154 short offoff; 155 156 short hoff; 157 __be32 hmask; 158 struct tc_u32_key keys[0]; 159 }; 160 161 struct tc_u32_mark { 162 __u32 val; 163 __u32 mask; 164 __u32 success; 165 }; 166 167 struct tc_u32_pcnt { 168 __u64 rcnt; 169 __u64 rhit; 170 __u64 kcnts[0]; 171 }; 172 173 /* Flags */ 174 175 #define TC_U32_TERMINAL 1 176 #define TC_U32_OFFSET 2 177 #define TC_U32_VAROFFSET 4 178 #define TC_U32_EAT 8 179 180 #define TC_U32_MAXDEPTH 8 181 182 183 /* RSVP filter */ 184 185 enum { 186 TCA_RSVP_UNSPEC, 187 TCA_RSVP_CLASSID, 188 TCA_RSVP_DST, 189 TCA_RSVP_SRC, 190 TCA_RSVP_PINFO, 191 TCA_RSVP_POLICE, 192 TCA_RSVP_ACT, 193 __TCA_RSVP_MAX 194 }; 195 196 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 ) 197 198 struct tc_rsvp_gpi { 199 __u32 key; 200 __u32 mask; 201 int offset; 202 }; 203 204 struct tc_rsvp_pinfo { 205 struct tc_rsvp_gpi dpi; 206 struct tc_rsvp_gpi spi; 207 __u8 protocol; 208 __u8 tunnelid; 209 __u8 tunnelhdr; 210 __u8 pad; 211 }; 212 213 /* ROUTE filter */ 214 215 enum { 216 TCA_ROUTE4_UNSPEC, 217 TCA_ROUTE4_CLASSID, 218 TCA_ROUTE4_TO, 219 TCA_ROUTE4_FROM, 220 TCA_ROUTE4_IIF, 221 TCA_ROUTE4_POLICE, 222 TCA_ROUTE4_ACT, 223 __TCA_ROUTE4_MAX 224 }; 225 226 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1) 227 228 229 /* FW filter */ 230 231 enum { 232 TCA_FW_UNSPEC, 233 TCA_FW_CLASSID, 234 TCA_FW_POLICE, 235 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */ 236 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */ 237 TCA_FW_MASK, 238 __TCA_FW_MAX 239 }; 240 241 #define TCA_FW_MAX (__TCA_FW_MAX - 1) 242 243 /* TC index filter */ 244 245 enum { 246 TCA_TCINDEX_UNSPEC, 247 TCA_TCINDEX_HASH, 248 TCA_TCINDEX_MASK, 249 TCA_TCINDEX_SHIFT, 250 TCA_TCINDEX_FALL_THROUGH, 251 TCA_TCINDEX_CLASSID, 252 TCA_TCINDEX_POLICE, 253 TCA_TCINDEX_ACT, 254 __TCA_TCINDEX_MAX 255 }; 256 257 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1) 258 259 /* Flow filter */ 260 261 enum { 262 FLOW_KEY_SRC, 263 FLOW_KEY_DST, 264 FLOW_KEY_PROTO, 265 FLOW_KEY_PROTO_SRC, 266 FLOW_KEY_PROTO_DST, 267 FLOW_KEY_IIF, 268 FLOW_KEY_PRIORITY, 269 FLOW_KEY_MARK, 270 FLOW_KEY_NFCT, 271 FLOW_KEY_NFCT_SRC, 272 FLOW_KEY_NFCT_DST, 273 FLOW_KEY_NFCT_PROTO_SRC, 274 FLOW_KEY_NFCT_PROTO_DST, 275 FLOW_KEY_RTCLASSID, 276 FLOW_KEY_SKUID, 277 FLOW_KEY_SKGID, 278 FLOW_KEY_VLAN_TAG, 279 FLOW_KEY_RXHASH, 280 __FLOW_KEY_MAX, 281 }; 282 283 #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1) 284 285 enum { 286 FLOW_MODE_MAP, 287 FLOW_MODE_HASH, 288 }; 289 290 enum { 291 TCA_FLOW_UNSPEC, 292 TCA_FLOW_KEYS, 293 TCA_FLOW_MODE, 294 TCA_FLOW_BASECLASS, 295 TCA_FLOW_RSHIFT, 296 TCA_FLOW_ADDEND, 297 TCA_FLOW_MASK, 298 TCA_FLOW_XOR, 299 TCA_FLOW_DIVISOR, 300 TCA_FLOW_ACT, 301 TCA_FLOW_POLICE, 302 TCA_FLOW_EMATCHES, 303 TCA_FLOW_PERTURB, 304 __TCA_FLOW_MAX 305 }; 306 307 #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1) 308 309 /* Basic filter */ 310 311 enum { 312 TCA_BASIC_UNSPEC, 313 TCA_BASIC_CLASSID, 314 TCA_BASIC_EMATCHES, 315 TCA_BASIC_ACT, 316 TCA_BASIC_POLICE, 317 __TCA_BASIC_MAX 318 }; 319 320 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1) 321 322 323 /* Cgroup classifier */ 324 325 enum { 326 TCA_CGROUP_UNSPEC, 327 TCA_CGROUP_ACT, 328 TCA_CGROUP_POLICE, 329 TCA_CGROUP_EMATCHES, 330 __TCA_CGROUP_MAX, 331 }; 332 333 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1) 334 335 /* BPF classifier */ 336 337 #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0) 338 339 enum { 340 TCA_BPF_UNSPEC, 341 TCA_BPF_ACT, 342 TCA_BPF_POLICE, 343 TCA_BPF_CLASSID, 344 TCA_BPF_OPS_LEN, 345 TCA_BPF_OPS, 346 TCA_BPF_FD, 347 TCA_BPF_NAME, 348 TCA_BPF_FLAGS, 349 TCA_BPF_FLAGS_GEN, 350 TCA_BPF_TAG, 351 __TCA_BPF_MAX, 352 }; 353 354 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1) 355 356 /* Flower classifier */ 357 358 enum { 359 TCA_FLOWER_UNSPEC, 360 TCA_FLOWER_CLASSID, 361 TCA_FLOWER_INDEV, 362 TCA_FLOWER_ACT, 363 TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */ 364 TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */ 365 TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */ 366 TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */ 367 TCA_FLOWER_KEY_ETH_TYPE, /* be16 */ 368 TCA_FLOWER_KEY_IP_PROTO, /* u8 */ 369 TCA_FLOWER_KEY_IPV4_SRC, /* be32 */ 370 TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */ 371 TCA_FLOWER_KEY_IPV4_DST, /* be32 */ 372 TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */ 373 TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */ 374 TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */ 375 TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */ 376 TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */ 377 TCA_FLOWER_KEY_TCP_SRC, /* be16 */ 378 TCA_FLOWER_KEY_TCP_DST, /* be16 */ 379 TCA_FLOWER_KEY_UDP_SRC, /* be16 */ 380 TCA_FLOWER_KEY_UDP_DST, /* be16 */ 381 382 TCA_FLOWER_FLAGS, 383 TCA_FLOWER_KEY_VLAN_ID, /* be16 */ 384 TCA_FLOWER_KEY_VLAN_PRIO, /* u8 */ 385 TCA_FLOWER_KEY_VLAN_ETH_TYPE, /* be16 */ 386 387 TCA_FLOWER_KEY_ENC_KEY_ID, /* be32 */ 388 TCA_FLOWER_KEY_ENC_IPV4_SRC, /* be32 */ 389 TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */ 390 TCA_FLOWER_KEY_ENC_IPV4_DST, /* be32 */ 391 TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */ 392 TCA_FLOWER_KEY_ENC_IPV6_SRC, /* struct in6_addr */ 393 TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */ 394 TCA_FLOWER_KEY_ENC_IPV6_DST, /* struct in6_addr */ 395 TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */ 396 397 TCA_FLOWER_KEY_TCP_SRC_MASK, /* be16 */ 398 TCA_FLOWER_KEY_TCP_DST_MASK, /* be16 */ 399 TCA_FLOWER_KEY_UDP_SRC_MASK, /* be16 */ 400 TCA_FLOWER_KEY_UDP_DST_MASK, /* be16 */ 401 TCA_FLOWER_KEY_SCTP_SRC_MASK, /* be16 */ 402 TCA_FLOWER_KEY_SCTP_DST_MASK, /* be16 */ 403 404 TCA_FLOWER_KEY_SCTP_SRC, /* be16 */ 405 TCA_FLOWER_KEY_SCTP_DST, /* be16 */ 406 407 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT, /* be16 */ 408 TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, /* be16 */ 409 TCA_FLOWER_KEY_ENC_UDP_DST_PORT, /* be16 */ 410 TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, /* be16 */ 411 412 TCA_FLOWER_KEY_FLAGS, /* be32 */ 413 TCA_FLOWER_KEY_FLAGS_MASK, /* be32 */ 414 415 TCA_FLOWER_KEY_ICMPV4_CODE, /* u8 */ 416 TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */ 417 TCA_FLOWER_KEY_ICMPV4_TYPE, /* u8 */ 418 TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */ 419 TCA_FLOWER_KEY_ICMPV6_CODE, /* u8 */ 420 TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */ 421 TCA_FLOWER_KEY_ICMPV6_TYPE, /* u8 */ 422 TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */ 423 424 TCA_FLOWER_KEY_ARP_SIP, /* be32 */ 425 TCA_FLOWER_KEY_ARP_SIP_MASK, /* be32 */ 426 TCA_FLOWER_KEY_ARP_TIP, /* be32 */ 427 TCA_FLOWER_KEY_ARP_TIP_MASK, /* be32 */ 428 TCA_FLOWER_KEY_ARP_OP, /* u8 */ 429 TCA_FLOWER_KEY_ARP_OP_MASK, /* u8 */ 430 TCA_FLOWER_KEY_ARP_SHA, /* ETH_ALEN */ 431 TCA_FLOWER_KEY_ARP_SHA_MASK, /* ETH_ALEN */ 432 TCA_FLOWER_KEY_ARP_THA, /* ETH_ALEN */ 433 TCA_FLOWER_KEY_ARP_THA_MASK, /* ETH_ALEN */ 434 435 __TCA_FLOWER_MAX, 436 }; 437 438 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1) 439 440 enum { 441 TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0), 442 }; 443 444 /* Match-all classifier */ 445 446 enum { 447 TCA_MATCHALL_UNSPEC, 448 TCA_MATCHALL_CLASSID, 449 TCA_MATCHALL_ACT, 450 TCA_MATCHALL_FLAGS, 451 __TCA_MATCHALL_MAX, 452 }; 453 454 #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1) 455 456 /* Extended Matches */ 457 458 struct tcf_ematch_tree_hdr { 459 __u16 nmatches; 460 __u16 progid; 461 }; 462 463 enum { 464 TCA_EMATCH_TREE_UNSPEC, 465 TCA_EMATCH_TREE_HDR, 466 TCA_EMATCH_TREE_LIST, 467 __TCA_EMATCH_TREE_MAX 468 }; 469 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1) 470 471 struct tcf_ematch_hdr { 472 __u16 matchid; 473 __u16 kind; 474 __u16 flags; 475 __u16 pad; /* currently unused */ 476 }; 477 478 /* 0 1 479 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 480 * +-----------------------+-+-+---+ 481 * | Unused |S|I| R | 482 * +-----------------------+-+-+---+ 483 * 484 * R(2) ::= relation to next ematch 485 * where: 0 0 END (last ematch) 486 * 0 1 AND 487 * 1 0 OR 488 * 1 1 Unused (invalid) 489 * I(1) ::= invert result 490 * S(1) ::= simple payload 491 */ 492 #define TCF_EM_REL_END 0 493 #define TCF_EM_REL_AND (1<<0) 494 #define TCF_EM_REL_OR (1<<1) 495 #define TCF_EM_INVERT (1<<2) 496 #define TCF_EM_SIMPLE (1<<3) 497 498 #define TCF_EM_REL_MASK 3 499 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK) 500 501 enum { 502 TCF_LAYER_LINK, 503 TCF_LAYER_NETWORK, 504 TCF_LAYER_TRANSPORT, 505 __TCF_LAYER_MAX 506 }; 507 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1) 508 509 /* Ematch type assignments 510 * 1..32767 Reserved for ematches inside kernel tree 511 * 32768..65535 Free to use, not reliable 512 */ 513 #define TCF_EM_CONTAINER 0 514 #define TCF_EM_CMP 1 515 #define TCF_EM_NBYTE 2 516 #define TCF_EM_U32 3 517 #define TCF_EM_META 4 518 #define TCF_EM_TEXT 5 519 #define TCF_EM_VLAN 6 520 #define TCF_EM_CANID 7 521 #define TCF_EM_IPSET 8 522 #define TCF_EM_MAX 8 523 524 enum { 525 TCF_EM_PROG_TC 526 }; 527 528 enum { 529 TCF_EM_OPND_EQ, 530 TCF_EM_OPND_GT, 531 TCF_EM_OPND_LT 532 }; 533 534 #endif 535