1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright 2014-2016 6WIND S.A. 4 */ 5 6 #ifndef _RTE_MBUF_PTYPE_H_ 7 #define _RTE_MBUF_PTYPE_H_ 8 9 /** 10 * @file 11 * RTE Mbuf Packet Types 12 * 13 * This file contains declarations for features related to mbuf packet 14 * types. The packet type gives information about the data carried by the 15 * mbuf, and is stored in the mbuf in a 32 bits field. 16 * 17 * The 32 bits are divided into several fields to mark packet types. Note that 18 * each field is indexical. 19 * - Bit 3:0 is for L2 types. 20 * - Bit 7:4 is for L3 or outer L3 (for tunneling case) types. 21 * - Bit 11:8 is for L4 or outer L4 (for tunneling case) types. 22 * - Bit 15:12 is for tunnel types. 23 * - Bit 19:16 is for inner L2 types. 24 * - Bit 23:20 is for inner L3 types. 25 * - Bit 27:24 is for inner L4 types. 26 * - Bit 31:28 is reserved. 27 * 28 * To be compatible with Vector PMD, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV4_EXT, 29 * RTE_PTYPE_L3_IPV6, RTE_PTYPE_L3_IPV6_EXT, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP 30 * and RTE_PTYPE_L4_SCTP should be kept as below in a contiguous 7 bits. 31 * 32 * Note that L3 types values are selected for checking IPV4/IPV6 header from 33 * performance point of view. Reading annotations of RTE_ETH_IS_IPV4_HDR and 34 * RTE_ETH_IS_IPV6_HDR is needed for any future changes of L3 type values. 35 * 36 * Note that the packet types of the same packet recognized by different 37 * hardware may be different, as different hardware may have different 38 * capability of packet type recognition. 39 * 40 * examples: 41 * <'ether type'=0x0800 42 * | 'version'=4, 'protocol'=0x29 43 * | 'version'=6, 'next header'=0x3A 44 * | 'ICMPv6 header'> 45 * will be recognized on i40e hardware as packet type combination of, 46 * RTE_PTYPE_L2_ETHER | 47 * RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | 48 * RTE_PTYPE_TUNNEL_IP | 49 * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | 50 * RTE_PTYPE_INNER_L4_ICMP. 51 * 52 * <'ether type'=0x86DD 53 * | 'version'=6, 'next header'=0x2F 54 * | 'GRE header' 55 * | 'version'=6, 'next header'=0x11 56 * | 'UDP header'> 57 * will be recognized on i40e hardware as packet type combination of, 58 * RTE_PTYPE_L2_ETHER | 59 * RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | 60 * RTE_PTYPE_TUNNEL_GRENAT | 61 * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | 62 * RTE_PTYPE_INNER_L4_UDP. 63 */ 64 65 #include <stddef.h> 66 #include <stdint.h> 67 68 #ifdef __cplusplus 69 extern "C" { 70 #endif 71 72 /** 73 * No packet type information. 74 */ 75 #define RTE_PTYPE_UNKNOWN 0x00000000 76 /** 77 * Ethernet packet type. 78 * It is used for outer packet for tunneling cases. 79 * 80 * Packet format: 81 * <'ether type'=[0x0800|0x86DD]> 82 */ 83 #define RTE_PTYPE_L2_ETHER 0x00000001 84 /** 85 * Ethernet packet type for time sync. 86 * 87 * Packet format: 88 * <'ether type'=0x88F7> 89 */ 90 #define RTE_PTYPE_L2_ETHER_TIMESYNC 0x00000002 91 /** 92 * ARP (Address Resolution Protocol) packet type. 93 * 94 * Packet format: 95 * <'ether type'=0x0806> 96 */ 97 #define RTE_PTYPE_L2_ETHER_ARP 0x00000003 98 /** 99 * LLDP (Link Layer Discovery Protocol) packet type. 100 * 101 * Packet format: 102 * <'ether type'=0x88CC> 103 */ 104 #define RTE_PTYPE_L2_ETHER_LLDP 0x00000004 105 /** 106 * NSH (Network Service Header) packet type. 107 * 108 * Packet format: 109 * <'ether type'=0x894F> 110 */ 111 #define RTE_PTYPE_L2_ETHER_NSH 0x00000005 112 /** 113 * VLAN packet type. 114 * 115 * Packet format: 116 * <'ether type'=[0x8100]> 117 */ 118 #define RTE_PTYPE_L2_ETHER_VLAN 0x00000006 119 /** 120 * QinQ packet type. 121 * 122 * Packet format: 123 * <'ether type'=[0x88A8]> 124 */ 125 #define RTE_PTYPE_L2_ETHER_QINQ 0x00000007 126 /** 127 * PPPOE packet type. 128 * 129 * Packet format: 130 * <'ether type'=[0x8863|0x8864]> 131 */ 132 #define RTE_PTYPE_L2_ETHER_PPPOE 0x00000008 133 /** 134 * FCoE packet type. 135 * 136 * Packet format: 137 * <'ether type'=[0x8906]> 138 */ 139 #define RTE_PTYPE_L2_ETHER_FCOE 0x00000009 140 /** 141 * MPLS packet type. 142 * 143 * Packet format: 144 * <'ether type'=[0x8847|0x8848]> 145 */ 146 #define RTE_PTYPE_L2_ETHER_MPLS 0x0000000a 147 /** 148 * Mask of layer 2 packet types. 149 * It is used for outer packet for tunneling cases. 150 */ 151 #define RTE_PTYPE_L2_MASK 0x0000000f 152 /** 153 * IP (Internet Protocol) version 4 packet type. 154 * It is used for outer packet for tunneling cases, and does not contain any 155 * header option. 156 * 157 * Packet format: 158 * <'ether type'=0x0800 159 * | 'version'=4, 'ihl'=5> 160 */ 161 #define RTE_PTYPE_L3_IPV4 0x00000010 162 /** 163 * IP (Internet Protocol) version 4 packet type. 164 * It is used for outer packet for tunneling cases, and contains header 165 * options. 166 * 167 * Packet format: 168 * <'ether type'=0x0800 169 * | 'version'=4, 'ihl'=[6-15], 'options'> 170 */ 171 #define RTE_PTYPE_L3_IPV4_EXT 0x00000030 172 /** 173 * IP (Internet Protocol) version 6 packet type. 174 * It is used for outer packet for tunneling cases, and does not contain any 175 * extension header. 176 * 177 * Packet format: 178 * <'ether type'=0x86DD 179 * | 'version'=6, 'next header'=0x3B> 180 */ 181 #define RTE_PTYPE_L3_IPV6 0x00000040 182 /** 183 * IP (Internet Protocol) version 4 packet type. 184 * It is used for outer packet for tunneling cases, and may or maynot contain 185 * header options. 186 * 187 * Packet format: 188 * <'ether type'=0x0800 189 * | 'version'=4, 'ihl'=[5-15], <'options'>> 190 */ 191 #define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN 0x00000090 192 /** 193 * IP (Internet Protocol) version 6 packet type. 194 * It is used for outer packet for tunneling cases, and contains extension 195 * headers. 196 * 197 * Packet format: 198 * <'ether type'=0x86DD 199 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 200 * 'extension headers'> 201 */ 202 #define RTE_PTYPE_L3_IPV6_EXT 0x000000c0 203 /** 204 * IP (Internet Protocol) version 6 packet type. 205 * It is used for outer packet for tunneling cases, and may or maynot contain 206 * extension headers. 207 * 208 * Packet format: 209 * <'ether type'=0x86DD 210 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 211 * <'extension headers'>> 212 */ 213 #define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN 0x000000e0 214 /** 215 * Mask of layer 3 packet types. 216 * It is used for outer packet for tunneling cases. 217 */ 218 #define RTE_PTYPE_L3_MASK 0x000000f0 219 /** 220 * TCP (Transmission Control Protocol) packet type. 221 * It is used for outer packet for tunneling cases. 222 * 223 * Packet format: 224 * <'ether type'=0x0800 225 * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0> 226 * or, 227 * <'ether type'=0x86DD 228 * | 'version'=6, 'next header'=6> 229 */ 230 #define RTE_PTYPE_L4_TCP 0x00000100 231 /** 232 * UDP (User Datagram Protocol) packet type. 233 * It is used for outer packet for tunneling cases. 234 * 235 * Packet format: 236 * <'ether type'=0x0800 237 * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0> 238 * or, 239 * <'ether type'=0x86DD 240 * | 'version'=6, 'next header'=17> 241 */ 242 #define RTE_PTYPE_L4_UDP 0x00000200 243 /** 244 * Fragmented IP (Internet Protocol) packet type. 245 * It is used for outer packet for tunneling cases. 246 * 247 * It refers to those packets of any IP types, which can be recognized as 248 * fragmented. A fragmented packet cannot be recognized as any other L4 types 249 * (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP, 250 * RTE_PTYPE_L4_NONFRAG, RTE_PTYPE_L4_IGMP, RTE_PTYPE_L4_ESP). 251 * 252 * Packet format: 253 * <'ether type'=0x0800 254 * | 'version'=4, 'MF'=1> 255 * or, 256 * <'ether type'=0x0800 257 * | 'version'=4, 'frag_offset'!=0> 258 * or, 259 * <'ether type'=0x86DD 260 * | 'version'=6, 'next header'=44> 261 */ 262 #define RTE_PTYPE_L4_FRAG 0x00000300 263 /** 264 * SCTP (Stream Control Transmission Protocol) packet type. 265 * It is used for outer packet for tunneling cases. 266 * 267 * Packet format: 268 * <'ether type'=0x0800 269 * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0> 270 * or, 271 * <'ether type'=0x86DD 272 * | 'version'=6, 'next header'=132> 273 */ 274 #define RTE_PTYPE_L4_SCTP 0x00000400 275 /** 276 * ICMP (Internet Control Message Protocol) packet type. 277 * It is used for outer packet for tunneling cases. 278 * 279 * Packet format: 280 * <'ether type'=0x0800 281 * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0> 282 * or, 283 * <'ether type'=0x86DD 284 * | 'version'=6, 'next header'=1> 285 */ 286 #define RTE_PTYPE_L4_ICMP 0x00000500 287 /** 288 * Non-fragmented IP (Internet Protocol) packet type. 289 * It is used for outer packet for tunneling cases. 290 * 291 * It refers to those packets of any IP types, while cannot be recognized as 292 * any of above L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, 293 * RTE_PTYPE_L4_FRAG (for IPv6), RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP, 294 * RTE_PTYPE_L4_IGMP (for IPv4), RTE_PTYPE_L4_ESP). 295 * 296 * Packet format: 297 * <'ether type'=0x0800 298 * | 'version'=4, 'protocol'!=[1|2|6|17|50|132], 'MF'=0, 'frag_offset'=0> 299 * or, 300 * <'ether type'=0x86DD 301 * | 'version'=6, 'next header'!=[1|6|17|44|50|132]> 302 */ 303 #define RTE_PTYPE_L4_NONFRAG 0x00000600 304 /** 305 * IGMP (Internet Group Management Protocol) packet type. 306 * 307 * Packet format: 308 * <'ether type'=0x0800 309 * | 'version'=4, 'protocol'=2, 'MF'=0, 'frag_offset'=0> 310 */ 311 #define RTE_PTYPE_L4_IGMP 0x00000700 312 /** 313 * ESP (IP Encapsulating Security Payload) transport packet type. 314 * 315 * Packet format: 316 * <'ether type'=0x0800 317 * | 'version'=4, 'protocol'=50, 'MF'=0, 'frag_offset'=0> 318 * or, 319 * <'ether type'=0x86DD 320 * | 'version'=6, 'next header'=50> 321 */ 322 #define RTE_PTYPE_L4_ESP 0x00000800 323 /** 324 * Mask of layer 4 packet types. 325 * It is used for outer packet for tunneling cases. 326 */ 327 #define RTE_PTYPE_L4_MASK 0x00000f00 328 /** 329 * IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type. 330 * 331 * Packet format: 332 * <'ether type'=0x0800 333 * | 'version'=4, 'protocol'=[4|41]> 334 * or, 335 * <'ether type'=0x86DD 336 * | 'version'=6, 'next header'=[4|41]> 337 */ 338 #define RTE_PTYPE_TUNNEL_IP 0x00001000 339 /** 340 * GRE (Generic Routing Encapsulation) tunneling packet type. 341 * 342 * Packet format: 343 * <'ether type'=0x0800 344 * | 'version'=4, 'protocol'=47> 345 * or, 346 * <'ether type'=0x86DD 347 * | 'version'=6, 'next header'=47> 348 */ 349 #define RTE_PTYPE_TUNNEL_GRE 0x00002000 350 /** 351 * VXLAN (Virtual eXtensible Local Area Network) tunneling packet type. 352 * 353 * Packet format: 354 * <'ether type'=0x0800 355 * | 'version'=4, 'protocol'=17 356 * | 'destination port'=4789> 357 * or, 358 * <'ether type'=0x86DD 359 * | 'version'=6, 'next header'=17 360 * | 'destination port'=4789> 361 */ 362 #define RTE_PTYPE_TUNNEL_VXLAN 0x00003000 363 /** 364 * NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling 365 * packet type. 366 * 367 * Packet format: 368 * <'ether type'=0x0800 369 * | 'version'=4, 'protocol'=47 370 * | 'protocol type'=0x6558> 371 * or, 372 * <'ether type'=0x86DD 373 * | 'version'=6, 'next header'=47 374 * | 'protocol type'=0x6558'> 375 */ 376 #define RTE_PTYPE_TUNNEL_NVGRE 0x00004000 377 /** 378 * GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type. 379 * 380 * Packet format: 381 * <'ether type'=0x0800 382 * | 'version'=4, 'protocol'=17 383 * | 'destination port'=6081> 384 * or, 385 * <'ether type'=0x86DD 386 * | 'version'=6, 'next header'=17 387 * | 'destination port'=6081> 388 */ 389 #define RTE_PTYPE_TUNNEL_GENEVE 0x00005000 390 /** 391 * Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area 392 * Network) or GRE (Generic Routing Encapsulation) could be recognized as this 393 * packet type, if they can not be recognized independently as of hardware 394 * capability. 395 */ 396 #define RTE_PTYPE_TUNNEL_GRENAT 0x00006000 397 /** 398 * GTP-C (GPRS Tunnelling Protocol) control tunneling packet type. 399 * Packet format: 400 * <'ether type'=0x0800 401 * | 'version'=4, 'protocol'=17 402 * | 'destination port'=2123> 403 * or, 404 * <'ether type'=0x86DD 405 * | 'version'=6, 'next header'=17 406 * | 'destination port'=2123> 407 * or, 408 * <'ether type'=0x0800 409 * | 'version'=4, 'protocol'=17 410 * | 'source port'=2123> 411 * or, 412 * <'ether type'=0x86DD 413 * | 'version'=6, 'next header'=17 414 * | 'source port'=2123> 415 */ 416 #define RTE_PTYPE_TUNNEL_GTPC 0x00007000 417 /** 418 * GTP-U (GPRS Tunnelling Protocol) user data tunneling packet type. 419 * Packet format: 420 * <'ether type'=0x0800 421 * | 'version'=4, 'protocol'=17 422 * | 'destination port'=2152> 423 * or, 424 * <'ether type'=0x86DD 425 * | 'version'=6, 'next header'=17 426 * | 'destination port'=2152> 427 */ 428 #define RTE_PTYPE_TUNNEL_GTPU 0x00008000 429 /** 430 * ESP (IP Encapsulating Security Payload) tunneling packet type. 431 * 432 * Packet format: 433 * <'ether type'=0x0800 434 * | 'version'=4, 'protocol'=50> 435 * or, 436 * <'ether type'=0x86DD 437 * | 'version'=6, 'next header'=50> 438 */ 439 #define RTE_PTYPE_TUNNEL_ESP 0x00009000 440 /** 441 * L2TP (Layer 2 Tunneling Protocol) tunneling packet type. 442 * 443 * Packet format: 444 * <'ether type'=0x0800 445 * | 'version'=4, 'protocol'=17> 446 * | 'destination port'=1701> 447 * or, 448 * <'ether type'=0x86DD 449 * | 'version'=6, 'next header'=17 450 * | 'destination port'=1701> 451 * or, 452 * <'ether type'=0x0800 453 * | 'version'=4, 'protocol'=115> 454 * or, 455 * <'ether type'=0x86DD 456 * | 'version'=6, 'protocol'=115> 457 */ 458 #define RTE_PTYPE_TUNNEL_L2TP 0x0000a000 459 /** 460 * VXLAN-GPE (VXLAN Generic Protocol Extension) tunneling packet type. 461 * 462 * Packet format: 463 * <'ether type'=0x0800 464 * | 'version'=4, 'protocol'=17 465 * | 'destination port'=4790> 466 * or, 467 * <'ether type'=0x86DD 468 * | 'version'=6, 'next header'=17 469 * | 'destination port'=4790> 470 */ 471 #define RTE_PTYPE_TUNNEL_VXLAN_GPE 0x0000b000 472 /** 473 * MPLS-in-GRE tunneling packet type (RFC 4023). 474 * 475 * Packet format: 476 * <'ether type'=0x0800 477 * | 'version'=4, 'protocol'=47 478 * | 'protocol'=0x8847> 479 * or, 480 * <'ether type'=0x0800 481 * | 'version'=4, 'protocol'=47 482 * | 'protocol'=0x8848> 483 * or, 484 * <'ether type'=0x86DD 485 * | 'version'=6, 'protocol'=47 486 * | 'protocol'=0x8847> 487 * or, 488 * <'ether type'=0x86DD 489 * | 'version'=6, 'next header'=47 490 * | 'protocol'=0x8848> 491 */ 492 #define RTE_PTYPE_TUNNEL_MPLS_IN_GRE 0x0000c000 493 /** 494 * MPLS-in-UDP tunneling packet type (RFC 7510). 495 * 496 * Packet format: 497 * <'ether type'=0x0800 498 * | 'version'=4, 'protocol'=17 499 * | 'destination port'=6635> 500 * or, 501 * <'ether type'=0x86DD 502 * | 'version'=6, 'next header'=17 503 * | 'destination port'=6635> 504 */ 505 #define RTE_PTYPE_TUNNEL_MPLS_IN_UDP 0x0000d000 506 /** 507 * Mask of tunneling packet types. 508 */ 509 #define RTE_PTYPE_TUNNEL_MASK 0x0000f000 510 /** 511 * Ethernet packet type. 512 * It is used for inner packet type only. 513 * 514 * Packet format (inner only): 515 * <'ether type'=[0x800|0x86DD]> 516 */ 517 #define RTE_PTYPE_INNER_L2_ETHER 0x00010000 518 /** 519 * Ethernet packet type with VLAN (Virtual Local Area Network) tag. 520 * 521 * Packet format (inner only): 522 * <'ether type'=[0x800|0x86DD], vlan=[1-4095]> 523 */ 524 #define RTE_PTYPE_INNER_L2_ETHER_VLAN 0x00020000 525 /** 526 * QinQ packet type. 527 * 528 * Packet format: 529 * <'ether type'=[0x88A8]> 530 */ 531 #define RTE_PTYPE_INNER_L2_ETHER_QINQ 0x00030000 532 /** 533 * Mask of inner layer 2 packet types. 534 */ 535 #define RTE_PTYPE_INNER_L2_MASK 0x000f0000 536 /** 537 * IP (Internet Protocol) version 4 packet type. 538 * It is used for inner packet only, and does not contain any header option. 539 * 540 * Packet format (inner only): 541 * <'ether type'=0x0800 542 * | 'version'=4, 'ihl'=5> 543 */ 544 #define RTE_PTYPE_INNER_L3_IPV4 0x00100000 545 /** 546 * IP (Internet Protocol) version 4 packet type. 547 * It is used for inner packet only, and contains header options. 548 * 549 * Packet format (inner only): 550 * <'ether type'=0x0800 551 * | 'version'=4, 'ihl'=[6-15], 'options'> 552 */ 553 #define RTE_PTYPE_INNER_L3_IPV4_EXT 0x00200000 554 /** 555 * IP (Internet Protocol) version 6 packet type. 556 * It is used for inner packet only, and does not contain any extension header. 557 * 558 * Packet format (inner only): 559 * <'ether type'=0x86DD 560 * | 'version'=6, 'next header'=0x3B> 561 */ 562 #define RTE_PTYPE_INNER_L3_IPV6 0x00300000 563 /** 564 * IP (Internet Protocol) version 4 packet type. 565 * It is used for inner packet only, and may or maynot contain header options. 566 * 567 * Packet format (inner only): 568 * <'ether type'=0x0800 569 * | 'version'=4, 'ihl'=[5-15], <'options'>> 570 */ 571 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000 572 /** 573 * IP (Internet Protocol) version 6 packet type. 574 * It is used for inner packet only, and contains extension headers. 575 * 576 * Packet format (inner only): 577 * <'ether type'=0x86DD 578 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 579 * 'extension headers'> 580 */ 581 #define RTE_PTYPE_INNER_L3_IPV6_EXT 0x00500000 582 /** 583 * IP (Internet Protocol) version 6 packet type. 584 * It is used for inner packet only, and may or maynot contain extension 585 * headers. 586 * 587 * Packet format (inner only): 588 * <'ether type'=0x86DD 589 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 590 * <'extension headers'>> 591 */ 592 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000 593 /** 594 * Mask of inner layer 3 packet types. 595 */ 596 #define RTE_PTYPE_INNER_L3_MASK 0x00f00000 597 /** 598 * TCP (Transmission Control Protocol) packet type. 599 * It is used for inner packet only. 600 * 601 * Packet format (inner only): 602 * <'ether type'=0x0800 603 * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0> 604 * or, 605 * <'ether type'=0x86DD 606 * | 'version'=6, 'next header'=6> 607 */ 608 #define RTE_PTYPE_INNER_L4_TCP 0x01000000 609 /** 610 * UDP (User Datagram Protocol) packet type. 611 * It is used for inner packet only. 612 * 613 * Packet format (inner only): 614 * <'ether type'=0x0800 615 * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0> 616 * or, 617 * <'ether type'=0x86DD 618 * | 'version'=6, 'next header'=17> 619 */ 620 #define RTE_PTYPE_INNER_L4_UDP 0x02000000 621 /** 622 * Fragmented IP (Internet Protocol) packet type. 623 * It is used for inner packet only, and may or maynot have layer 4 packet. 624 * 625 * Packet format (inner only): 626 * <'ether type'=0x0800 627 * | 'version'=4, 'MF'=1> 628 * or, 629 * <'ether type'=0x0800 630 * | 'version'=4, 'frag_offset'!=0> 631 * or, 632 * <'ether type'=0x86DD 633 * | 'version'=6, 'next header'=44> 634 */ 635 #define RTE_PTYPE_INNER_L4_FRAG 0x03000000 636 /** 637 * SCTP (Stream Control Transmission Protocol) packet type. 638 * It is used for inner packet only. 639 * 640 * Packet format (inner only): 641 * <'ether type'=0x0800 642 * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0> 643 * or, 644 * <'ether type'=0x86DD 645 * | 'version'=6, 'next header'=132> 646 */ 647 #define RTE_PTYPE_INNER_L4_SCTP 0x04000000 648 /** 649 * ICMP (Internet Control Message Protocol) packet type. 650 * It is used for inner packet only. 651 * 652 * Packet format (inner only): 653 * <'ether type'=0x0800 654 * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0> 655 * or, 656 * <'ether type'=0x86DD 657 * | 'version'=6, 'next header'=1> 658 */ 659 #define RTE_PTYPE_INNER_L4_ICMP 0x05000000 660 /** 661 * Non-fragmented IP (Internet Protocol) packet type. 662 * It is used for inner packet only, and may or maynot have other unknown layer 663 * 4 packet types. 664 * 665 * Packet format (inner only): 666 * <'ether type'=0x0800 667 * | 'version'=4, 'protocol'!=[1|6|17|50|132], 'MF'=0, 'frag_offset'=0> 668 * or, 669 * <'ether type'=0x86DD 670 * | 'version'=6, 'next header'!=[1|6|17|44|50|132]> 671 */ 672 #define RTE_PTYPE_INNER_L4_NONFRAG 0x06000000 673 /** 674 * ESP (IP Encapsulating Security Payload) transport packet type. 675 * It is used for inner packet only. 676 * 677 * Packet format (inner only): 678 * <'ether type'=0x0800 679 * | 'version'=4, 'protocol'=50, 'MF'=0, 'frag_offset'=0> 680 * or, 681 * <'ether type'=0x86DD 682 * | 'version'=6, 'next header'=50> 683 */ 684 #define RTE_PTYPE_INNER_L4_ESP 0x08000000 685 /** 686 * Mask of inner layer 4 packet types. 687 */ 688 #define RTE_PTYPE_INNER_L4_MASK 0x0f000000 689 /** 690 * All valid layer masks. 691 */ 692 #define RTE_PTYPE_ALL_MASK 0x0fffffff 693 694 /** 695 * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by 696 * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can 697 * determine if it is an IPV4 packet. 698 */ 699 #define RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4) 700 701 /** 702 * Check if the (outer) L3 header is IPv6. To avoid comparing IPv6 types one by 703 * one, bit 6 is selected to be used for IPv6 only. Then checking bit 6 can 704 * determine if it is an IPV6 packet. 705 */ 706 #define RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6) 707 708 /* Check if it is a tunneling packet */ 709 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) & \ 710 (RTE_PTYPE_TUNNEL_MASK | \ 711 RTE_PTYPE_INNER_L2_MASK | \ 712 RTE_PTYPE_INNER_L3_MASK | \ 713 RTE_PTYPE_INNER_L4_MASK)) 714 715 /** 716 * Get the name of the l2 packet type 717 * 718 * @param ptype 719 * The packet type value. 720 * @return 721 * A non-null string describing the packet type. 722 */ 723 const char *rte_get_ptype_l2_name(uint32_t ptype); 724 725 /** 726 * Get the name of the l3 packet type 727 * 728 * @param ptype 729 * The packet type value. 730 * @return 731 * A non-null string describing the packet type. 732 */ 733 const char *rte_get_ptype_l3_name(uint32_t ptype); 734 735 /** 736 * Get the name of the l4 packet type 737 * 738 * @param ptype 739 * The packet type value. 740 * @return 741 * A non-null string describing the packet type. 742 */ 743 const char *rte_get_ptype_l4_name(uint32_t ptype); 744 745 /** 746 * Get the name of the tunnel packet type 747 * 748 * @param ptype 749 * The packet type value. 750 * @return 751 * A non-null string describing the packet type. 752 */ 753 const char *rte_get_ptype_tunnel_name(uint32_t ptype); 754 755 /** 756 * Get the name of the inner_l2 packet type 757 * 758 * @param ptype 759 * The packet type value. 760 * @return 761 * A non-null string describing the packet type. 762 */ 763 const char *rte_get_ptype_inner_l2_name(uint32_t ptype); 764 765 /** 766 * Get the name of the inner_l3 packet type 767 * 768 * @param ptype 769 * The packet type value. 770 * @return 771 * A non-null string describing the packet type. 772 */ 773 const char *rte_get_ptype_inner_l3_name(uint32_t ptype); 774 775 /** 776 * Get the name of the inner_l4 packet type 777 * 778 * @param ptype 779 * The packet type value. 780 * @return 781 * A non-null string describing the packet type. 782 */ 783 const char *rte_get_ptype_inner_l4_name(uint32_t ptype); 784 785 /** 786 * Write the packet type name into the buffer 787 * 788 * @param ptype 789 * The packet type value. 790 * @param buf 791 * The buffer where the string is written. 792 * @param buflen 793 * The length of the buffer. 794 * @return 795 * - 0 on success 796 * - (-1) if the buffer is too small 797 */ 798 int rte_get_ptype_name(uint32_t ptype, char *buf, size_t buflen); 799 800 #ifdef __cplusplus 801 } 802 #endif 803 804 #endif /* _RTE_MBUF_PTYPE_H_ */ 805