4 * Copyright(c) 2010-2016 Intel Corporation.
5 * Copyright 2014-2016 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _RTE_MBUF_PTYPE_H_
36 #define _RTE_MBUF_PTYPE_H_
40 * RTE Mbuf Packet Types
42 * This file contains declarations for features related to mbuf packet
43 * types. The packet type gives information about the data carried by the
44 * mbuf, and is stored in the mbuf in a 32 bits field.
46 * The 32 bits are divided into several fields to mark packet types. Note that
47 * each field is indexical.
48 * - Bit 3:0 is for L2 types.
49 * - Bit 7:4 is for L3 or outer L3 (for tunneling case) types.
50 * - Bit 11:8 is for L4 or outer L4 (for tunneling case) types.
51 * - Bit 15:12 is for tunnel types.
52 * - Bit 19:16 is for inner L2 types.
53 * - Bit 23:20 is for inner L3 types.
54 * - Bit 27:24 is for inner L4 types.
55 * - Bit 31:28 is reserved.
57 * To be compatible with Vector PMD, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV4_EXT,
58 * RTE_PTYPE_L3_IPV6, RTE_PTYPE_L3_IPV6_EXT, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP
59 * and RTE_PTYPE_L4_SCTP should be kept as below in a contiguous 7 bits.
61 * Note that L3 types values are selected for checking IPV4/IPV6 header from
62 * performance point of view. Reading annotations of RTE_ETH_IS_IPV4_HDR and
63 * RTE_ETH_IS_IPV6_HDR is needed for any future changes of L3 type values.
65 * Note that the packet types of the same packet recognized by different
66 * hardware may be different, as different hardware may have different
67 * capability of packet type recognition.
70 * <'ether type'=0x0800
71 * | 'version'=4, 'protocol'=0x29
72 * | 'version'=6, 'next header'=0x3A
74 * will be recognized on i40e hardware as packet type combination of,
75 * RTE_PTYPE_L2_ETHER |
76 * RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
77 * RTE_PTYPE_TUNNEL_IP |
78 * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
79 * RTE_PTYPE_INNER_L4_ICMP.
81 * <'ether type'=0x86DD
82 * | 'version'=6, 'next header'=0x2F
84 * | 'version'=6, 'next header'=0x11
86 * will be recognized on i40e hardware as packet type combination of,
87 * RTE_PTYPE_L2_ETHER |
88 * RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
89 * RTE_PTYPE_TUNNEL_GRENAT |
90 * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
91 * RTE_PTYPE_INNER_L4_UDP.
99 * No packet type information.
101 #define RTE_PTYPE_UNKNOWN 0x00000000
103 * Ethernet packet type.
104 * It is used for outer packet for tunneling cases.
107 * <'ether type'=[0x0800|0x86DD]>
109 #define RTE_PTYPE_L2_ETHER 0x00000001
111 * Ethernet packet type for time sync.
114 * <'ether type'=0x88F7>
116 #define RTE_PTYPE_L2_ETHER_TIMESYNC 0x00000002
118 * ARP (Address Resolution Protocol) packet type.
121 * <'ether type'=0x0806>
123 #define RTE_PTYPE_L2_ETHER_ARP 0x00000003
125 * LLDP (Link Layer Discovery Protocol) packet type.
128 * <'ether type'=0x88CC>
130 #define RTE_PTYPE_L2_ETHER_LLDP 0x00000004
132 * NSH (Network Service Header) packet type.
135 * <'ether type'=0x894F>
137 #define RTE_PTYPE_L2_ETHER_NSH 0x00000005
139 * Mask of layer 2 packet types.
140 * It is used for outer packet for tunneling cases.
142 #define RTE_PTYPE_L2_MASK 0x0000000f
144 * IP (Internet Protocol) version 4 packet type.
145 * It is used for outer packet for tunneling cases, and does not contain any
149 * <'ether type'=0x0800
150 * | 'version'=4, 'ihl'=5>
152 #define RTE_PTYPE_L3_IPV4 0x00000010
154 * IP (Internet Protocol) version 4 packet type.
155 * It is used for outer packet for tunneling cases, and contains header
159 * <'ether type'=0x0800
160 * | 'version'=4, 'ihl'=[6-15], 'options'>
162 #define RTE_PTYPE_L3_IPV4_EXT 0x00000030
164 * IP (Internet Protocol) version 6 packet type.
165 * It is used for outer packet for tunneling cases, and does not contain any
169 * <'ether type'=0x86DD
170 * | 'version'=6, 'next header'=0x3B>
172 #define RTE_PTYPE_L3_IPV6 0x00000040
174 * IP (Internet Protocol) version 4 packet type.
175 * It is used for outer packet for tunneling cases, and may or maynot contain
179 * <'ether type'=0x0800
180 * | 'version'=4, 'ihl'=[5-15], <'options'>>
182 #define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN 0x00000090
184 * IP (Internet Protocol) version 6 packet type.
185 * It is used for outer packet for tunneling cases, and contains extension
189 * <'ether type'=0x86DD
190 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
191 * 'extension headers'>
193 #define RTE_PTYPE_L3_IPV6_EXT 0x000000c0
195 * IP (Internet Protocol) version 6 packet type.
196 * It is used for outer packet for tunneling cases, and may or maynot contain
200 * <'ether type'=0x86DD
201 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
202 * <'extension headers'>>
204 #define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN 0x000000e0
206 * Mask of layer 3 packet types.
207 * It is used for outer packet for tunneling cases.
209 #define RTE_PTYPE_L3_MASK 0x000000f0
211 * TCP (Transmission Control Protocol) packet type.
212 * It is used for outer packet for tunneling cases.
215 * <'ether type'=0x0800
216 * | 'version'=4, 'protocol'=6, 'MF'=0>
218 * <'ether type'=0x86DD
219 * | 'version'=6, 'next header'=6>
221 #define RTE_PTYPE_L4_TCP 0x00000100
223 * UDP (User Datagram Protocol) packet type.
224 * It is used for outer packet for tunneling cases.
227 * <'ether type'=0x0800
228 * | 'version'=4, 'protocol'=17, 'MF'=0>
230 * <'ether type'=0x86DD
231 * | 'version'=6, 'next header'=17>
233 #define RTE_PTYPE_L4_UDP 0x00000200
235 * Fragmented IP (Internet Protocol) packet type.
236 * It is used for outer packet for tunneling cases.
238 * It refers to those packets of any IP types, which can be recognized as
239 * fragmented. A fragmented packet cannot be recognized as any other L4 types
240 * (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP,
241 * RTE_PTYPE_L4_NONFRAG).
244 * <'ether type'=0x0800
245 * | 'version'=4, 'MF'=1>
247 * <'ether type'=0x86DD
248 * | 'version'=6, 'next header'=44>
250 #define RTE_PTYPE_L4_FRAG 0x00000300
252 * SCTP (Stream Control Transmission Protocol) packet type.
253 * It is used for outer packet for tunneling cases.
256 * <'ether type'=0x0800
257 * | 'version'=4, 'protocol'=132, 'MF'=0>
259 * <'ether type'=0x86DD
260 * | 'version'=6, 'next header'=132>
262 #define RTE_PTYPE_L4_SCTP 0x00000400
264 * ICMP (Internet Control Message Protocol) packet type.
265 * It is used for outer packet for tunneling cases.
268 * <'ether type'=0x0800
269 * | 'version'=4, 'protocol'=1, 'MF'=0>
271 * <'ether type'=0x86DD
272 * | 'version'=6, 'next header'=1>
274 #define RTE_PTYPE_L4_ICMP 0x00000500
276 * Non-fragmented IP (Internet Protocol) packet type.
277 * It is used for outer packet for tunneling cases.
279 * It refers to those packets of any IP types, while cannot be recognized as
280 * any of above L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP,
281 * RTE_PTYPE_L4_FRAG, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP).
284 * <'ether type'=0x0800
285 * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0>
287 * <'ether type'=0x86DD
288 * | 'version'=6, 'next header'!=[6|17|44|132|1]>
290 #define RTE_PTYPE_L4_NONFRAG 0x00000600
292 * Mask of layer 4 packet types.
293 * It is used for outer packet for tunneling cases.
295 #define RTE_PTYPE_L4_MASK 0x00000f00
297 * IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type.
300 * <'ether type'=0x0800
301 * | 'version'=4, 'protocol'=[4|41]>
303 * <'ether type'=0x86DD
304 * | 'version'=6, 'next header'=[4|41]>
306 #define RTE_PTYPE_TUNNEL_IP 0x00001000
308 * GRE (Generic Routing Encapsulation) tunneling packet type.
311 * <'ether type'=0x0800
312 * | 'version'=4, 'protocol'=47>
314 * <'ether type'=0x86DD
315 * | 'version'=6, 'next header'=47>
317 #define RTE_PTYPE_TUNNEL_GRE 0x00002000
319 * VXLAN (Virtual eXtensible Local Area Network) tunneling packet type.
322 * <'ether type'=0x0800
323 * | 'version'=4, 'protocol'=17
324 * | 'destination port'=4798>
326 * <'ether type'=0x86DD
327 * | 'version'=6, 'next header'=17
328 * | 'destination port'=4798>
330 #define RTE_PTYPE_TUNNEL_VXLAN 0x00003000
332 * NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling
336 * <'ether type'=0x0800
337 * | 'version'=4, 'protocol'=47
338 * | 'protocol type'=0x6558>
340 * <'ether type'=0x86DD
341 * | 'version'=6, 'next header'=47
342 * | 'protocol type'=0x6558'>
344 #define RTE_PTYPE_TUNNEL_NVGRE 0x00004000
346 * GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type.
349 * <'ether type'=0x0800
350 * | 'version'=4, 'protocol'=17
351 * | 'destination port'=6081>
353 * <'ether type'=0x86DD
354 * | 'version'=6, 'next header'=17
355 * | 'destination port'=6081>
357 #define RTE_PTYPE_TUNNEL_GENEVE 0x00005000
359 * Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area
360 * Network) or GRE (Generic Routing Encapsulation) could be recognized as this
361 * packet type, if they can not be recognized independently as of hardware
364 #define RTE_PTYPE_TUNNEL_GRENAT 0x00006000
366 * Mask of tunneling packet types.
368 #define RTE_PTYPE_TUNNEL_MASK 0x0000f000
370 * Ethernet packet type.
371 * It is used for inner packet type only.
373 * Packet format (inner only):
374 * <'ether type'=[0x800|0x86DD]>
376 #define RTE_PTYPE_INNER_L2_ETHER 0x00010000
378 * Ethernet packet type with VLAN (Virtual Local Area Network) tag.
380 * Packet format (inner only):
381 * <'ether type'=[0x800|0x86DD], vlan=[1-4095]>
383 #define RTE_PTYPE_INNER_L2_ETHER_VLAN 0x00020000
385 * Mask of inner layer 2 packet types.
387 #define RTE_PTYPE_INNER_L2_MASK 0x000f0000
389 * IP (Internet Protocol) version 4 packet type.
390 * It is used for inner packet only, and does not contain any header option.
392 * Packet format (inner only):
393 * <'ether type'=0x0800
394 * | 'version'=4, 'ihl'=5>
396 #define RTE_PTYPE_INNER_L3_IPV4 0x00100000
398 * IP (Internet Protocol) version 4 packet type.
399 * It is used for inner packet only, and contains header options.
401 * Packet format (inner only):
402 * <'ether type'=0x0800
403 * | 'version'=4, 'ihl'=[6-15], 'options'>
405 #define RTE_PTYPE_INNER_L3_IPV4_EXT 0x00200000
407 * IP (Internet Protocol) version 6 packet type.
408 * It is used for inner packet only, and does not contain any extension header.
410 * Packet format (inner only):
411 * <'ether type'=0x86DD
412 * | 'version'=6, 'next header'=0x3B>
414 #define RTE_PTYPE_INNER_L3_IPV6 0x00300000
416 * IP (Internet Protocol) version 4 packet type.
417 * It is used for inner packet only, and may or maynot contain header options.
419 * Packet format (inner only):
420 * <'ether type'=0x0800
421 * | 'version'=4, 'ihl'=[5-15], <'options'>>
423 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
425 * IP (Internet Protocol) version 6 packet type.
426 * It is used for inner packet only, and contains extension headers.
428 * Packet format (inner only):
429 * <'ether type'=0x86DD
430 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
431 * 'extension headers'>
433 #define RTE_PTYPE_INNER_L3_IPV6_EXT 0x00500000
435 * IP (Internet Protocol) version 6 packet type.
436 * It is used for inner packet only, and may or maynot contain extension
439 * Packet format (inner only):
440 * <'ether type'=0x86DD
441 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
442 * <'extension headers'>>
444 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
446 * Mask of inner layer 3 packet types.
448 #define RTE_PTYPE_INNER_L3_MASK 0x00f00000
450 * TCP (Transmission Control Protocol) packet type.
451 * It is used for inner packet only.
453 * Packet format (inner only):
454 * <'ether type'=0x0800
455 * | 'version'=4, 'protocol'=6, 'MF'=0>
457 * <'ether type'=0x86DD
458 * | 'version'=6, 'next header'=6>
460 #define RTE_PTYPE_INNER_L4_TCP 0x01000000
462 * UDP (User Datagram Protocol) packet type.
463 * It is used for inner packet only.
465 * Packet format (inner only):
466 * <'ether type'=0x0800
467 * | 'version'=4, 'protocol'=17, 'MF'=0>
469 * <'ether type'=0x86DD
470 * | 'version'=6, 'next header'=17>
472 #define RTE_PTYPE_INNER_L4_UDP 0x02000000
474 * Fragmented IP (Internet Protocol) packet type.
475 * It is used for inner packet only, and may or maynot have layer 4 packet.
477 * Packet format (inner only):
478 * <'ether type'=0x0800
479 * | 'version'=4, 'MF'=1>
481 * <'ether type'=0x86DD
482 * | 'version'=6, 'next header'=44>
484 #define RTE_PTYPE_INNER_L4_FRAG 0x03000000
486 * SCTP (Stream Control Transmission Protocol) packet type.
487 * It is used for inner packet only.
489 * Packet format (inner only):
490 * <'ether type'=0x0800
491 * | 'version'=4, 'protocol'=132, 'MF'=0>
493 * <'ether type'=0x86DD
494 * | 'version'=6, 'next header'=132>
496 #define RTE_PTYPE_INNER_L4_SCTP 0x04000000
498 * ICMP (Internet Control Message Protocol) packet type.
499 * It is used for inner packet only.
501 * Packet format (inner only):
502 * <'ether type'=0x0800
503 * | 'version'=4, 'protocol'=1, 'MF'=0>
505 * <'ether type'=0x86DD
506 * | 'version'=6, 'next header'=1>
508 #define RTE_PTYPE_INNER_L4_ICMP 0x05000000
510 * Non-fragmented IP (Internet Protocol) packet type.
511 * It is used for inner packet only, and may or maynot have other unknown layer
514 * Packet format (inner only):
515 * <'ether type'=0x0800
516 * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0>
518 * <'ether type'=0x86DD
519 * | 'version'=6, 'next header'!=[6|17|44|132|1]>
521 #define RTE_PTYPE_INNER_L4_NONFRAG 0x06000000
523 * Mask of inner layer 4 packet types.
525 #define RTE_PTYPE_INNER_L4_MASK 0x0f000000
528 * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
529 * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can
530 * determine if it is an IPV4 packet.
532 #define RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4)
535 * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
536 * one, bit 6 is selected to be used for IPv4 only. Then checking bit 6 can
537 * determine if it is an IPV4 packet.
539 #define RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6)
541 /* Check if it is a tunneling packet */
542 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) & \
543 (RTE_PTYPE_TUNNEL_MASK | \
544 RTE_PTYPE_INNER_L2_MASK | \
545 RTE_PTYPE_INNER_L3_MASK | \
546 RTE_PTYPE_INNER_L4_MASK))
552 #endif /* _RTE_MBUF_PTYPE_H_ */