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
142 * <'ether type'=[0x8100]>
144 #define RTE_PTYPE_L2_ETHER_VLAN 0x00000006
149 * <'ether type'=[0x88A8]>
151 #define RTE_PTYPE_L2_ETHER_QINQ 0x00000007
153 * Mask of layer 2 packet types.
154 * It is used for outer packet for tunneling cases.
156 #define RTE_PTYPE_L2_MASK 0x0000000f
158 * IP (Internet Protocol) version 4 packet type.
159 * It is used for outer packet for tunneling cases, and does not contain any
163 * <'ether type'=0x0800
164 * | 'version'=4, 'ihl'=5>
166 #define RTE_PTYPE_L3_IPV4 0x00000010
168 * IP (Internet Protocol) version 4 packet type.
169 * It is used for outer packet for tunneling cases, and contains header
173 * <'ether type'=0x0800
174 * | 'version'=4, 'ihl'=[6-15], 'options'>
176 #define RTE_PTYPE_L3_IPV4_EXT 0x00000030
178 * IP (Internet Protocol) version 6 packet type.
179 * It is used for outer packet for tunneling cases, and does not contain any
183 * <'ether type'=0x86DD
184 * | 'version'=6, 'next header'=0x3B>
186 #define RTE_PTYPE_L3_IPV6 0x00000040
188 * IP (Internet Protocol) version 4 packet type.
189 * It is used for outer packet for tunneling cases, and may or maynot contain
193 * <'ether type'=0x0800
194 * | 'version'=4, 'ihl'=[5-15], <'options'>>
196 #define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN 0x00000090
198 * IP (Internet Protocol) version 6 packet type.
199 * It is used for outer packet for tunneling cases, and contains extension
203 * <'ether type'=0x86DD
204 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
205 * 'extension headers'>
207 #define RTE_PTYPE_L3_IPV6_EXT 0x000000c0
209 * IP (Internet Protocol) version 6 packet type.
210 * It is used for outer packet for tunneling cases, and may or maynot contain
214 * <'ether type'=0x86DD
215 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
216 * <'extension headers'>>
218 #define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN 0x000000e0
220 * Mask of layer 3 packet types.
221 * It is used for outer packet for tunneling cases.
223 #define RTE_PTYPE_L3_MASK 0x000000f0
225 * TCP (Transmission Control Protocol) packet type.
226 * It is used for outer packet for tunneling cases.
229 * <'ether type'=0x0800
230 * | 'version'=4, 'protocol'=6, 'MF'=0>
232 * <'ether type'=0x86DD
233 * | 'version'=6, 'next header'=6>
235 #define RTE_PTYPE_L4_TCP 0x00000100
237 * UDP (User Datagram Protocol) packet type.
238 * It is used for outer packet for tunneling cases.
241 * <'ether type'=0x0800
242 * | 'version'=4, 'protocol'=17, 'MF'=0>
244 * <'ether type'=0x86DD
245 * | 'version'=6, 'next header'=17>
247 #define RTE_PTYPE_L4_UDP 0x00000200
249 * Fragmented IP (Internet Protocol) packet type.
250 * It is used for outer packet for tunneling cases.
252 * It refers to those packets of any IP types, which can be recognized as
253 * fragmented. A fragmented packet cannot be recognized as any other L4 types
254 * (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP,
255 * RTE_PTYPE_L4_NONFRAG).
258 * <'ether type'=0x0800
259 * | 'version'=4, 'MF'=1>
261 * <'ether type'=0x86DD
262 * | 'version'=6, 'next header'=44>
264 #define RTE_PTYPE_L4_FRAG 0x00000300
266 * SCTP (Stream Control Transmission Protocol) packet type.
267 * It is used for outer packet for tunneling cases.
270 * <'ether type'=0x0800
271 * | 'version'=4, 'protocol'=132, 'MF'=0>
273 * <'ether type'=0x86DD
274 * | 'version'=6, 'next header'=132>
276 #define RTE_PTYPE_L4_SCTP 0x00000400
278 * ICMP (Internet Control Message Protocol) packet type.
279 * It is used for outer packet for tunneling cases.
282 * <'ether type'=0x0800
283 * | 'version'=4, 'protocol'=1, 'MF'=0>
285 * <'ether type'=0x86DD
286 * | 'version'=6, 'next header'=1>
288 #define RTE_PTYPE_L4_ICMP 0x00000500
290 * Non-fragmented IP (Internet Protocol) packet type.
291 * It is used for outer packet for tunneling cases.
293 * It refers to those packets of any IP types, while cannot be recognized as
294 * any of above L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP,
295 * RTE_PTYPE_L4_FRAG, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP).
298 * <'ether type'=0x0800
299 * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0>
301 * <'ether type'=0x86DD
302 * | 'version'=6, 'next header'!=[6|17|44|132|1]>
304 #define RTE_PTYPE_L4_NONFRAG 0x00000600
306 * Mask of layer 4 packet types.
307 * It is used for outer packet for tunneling cases.
309 #define RTE_PTYPE_L4_MASK 0x00000f00
311 * IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type.
314 * <'ether type'=0x0800
315 * | 'version'=4, 'protocol'=[4|41]>
317 * <'ether type'=0x86DD
318 * | 'version'=6, 'next header'=[4|41]>
320 #define RTE_PTYPE_TUNNEL_IP 0x00001000
322 * GRE (Generic Routing Encapsulation) tunneling packet type.
325 * <'ether type'=0x0800
326 * | 'version'=4, 'protocol'=47>
328 * <'ether type'=0x86DD
329 * | 'version'=6, 'next header'=47>
331 #define RTE_PTYPE_TUNNEL_GRE 0x00002000
333 * VXLAN (Virtual eXtensible Local Area Network) tunneling packet type.
336 * <'ether type'=0x0800
337 * | 'version'=4, 'protocol'=17
338 * | 'destination port'=4798>
340 * <'ether type'=0x86DD
341 * | 'version'=6, 'next header'=17
342 * | 'destination port'=4798>
344 #define RTE_PTYPE_TUNNEL_VXLAN 0x00003000
346 * NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling
350 * <'ether type'=0x0800
351 * | 'version'=4, 'protocol'=47
352 * | 'protocol type'=0x6558>
354 * <'ether type'=0x86DD
355 * | 'version'=6, 'next header'=47
356 * | 'protocol type'=0x6558'>
358 #define RTE_PTYPE_TUNNEL_NVGRE 0x00004000
360 * GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type.
363 * <'ether type'=0x0800
364 * | 'version'=4, 'protocol'=17
365 * | 'destination port'=6081>
367 * <'ether type'=0x86DD
368 * | 'version'=6, 'next header'=17
369 * | 'destination port'=6081>
371 #define RTE_PTYPE_TUNNEL_GENEVE 0x00005000
373 * Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area
374 * Network) or GRE (Generic Routing Encapsulation) could be recognized as this
375 * packet type, if they can not be recognized independently as of hardware
378 #define RTE_PTYPE_TUNNEL_GRENAT 0x00006000
380 * Mask of tunneling packet types.
382 #define RTE_PTYPE_TUNNEL_MASK 0x0000f000
384 * Ethernet packet type.
385 * It is used for inner packet type only.
387 * Packet format (inner only):
388 * <'ether type'=[0x800|0x86DD]>
390 #define RTE_PTYPE_INNER_L2_ETHER 0x00010000
392 * Ethernet packet type with VLAN (Virtual Local Area Network) tag.
394 * Packet format (inner only):
395 * <'ether type'=[0x800|0x86DD], vlan=[1-4095]>
397 #define RTE_PTYPE_INNER_L2_ETHER_VLAN 0x00020000
399 * Mask of inner layer 2 packet types.
401 #define RTE_PTYPE_INNER_L2_MASK 0x000f0000
403 * IP (Internet Protocol) version 4 packet type.
404 * It is used for inner packet only, and does not contain any header option.
406 * Packet format (inner only):
407 * <'ether type'=0x0800
408 * | 'version'=4, 'ihl'=5>
410 #define RTE_PTYPE_INNER_L3_IPV4 0x00100000
412 * IP (Internet Protocol) version 4 packet type.
413 * It is used for inner packet only, and contains header options.
415 * Packet format (inner only):
416 * <'ether type'=0x0800
417 * | 'version'=4, 'ihl'=[6-15], 'options'>
419 #define RTE_PTYPE_INNER_L3_IPV4_EXT 0x00200000
421 * IP (Internet Protocol) version 6 packet type.
422 * It is used for inner packet only, and does not contain any extension header.
424 * Packet format (inner only):
425 * <'ether type'=0x86DD
426 * | 'version'=6, 'next header'=0x3B>
428 #define RTE_PTYPE_INNER_L3_IPV6 0x00300000
430 * IP (Internet Protocol) version 4 packet type.
431 * It is used for inner packet only, and may or maynot contain header options.
433 * Packet format (inner only):
434 * <'ether type'=0x0800
435 * | 'version'=4, 'ihl'=[5-15], <'options'>>
437 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
439 * IP (Internet Protocol) version 6 packet type.
440 * It is used for inner packet only, and contains extension headers.
442 * Packet format (inner only):
443 * <'ether type'=0x86DD
444 * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
445 * 'extension headers'>
447 #define RTE_PTYPE_INNER_L3_IPV6_EXT 0x00500000
449 * IP (Internet Protocol) version 6 packet type.
450 * It is used for inner packet only, and may or maynot contain extension
453 * Packet format (inner only):
454 * <'ether type'=0x86DD
455 * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
456 * <'extension headers'>>
458 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
460 * Mask of inner layer 3 packet types.
462 #define RTE_PTYPE_INNER_L3_MASK 0x00f00000
464 * TCP (Transmission Control Protocol) packet type.
465 * It is used for inner packet only.
467 * Packet format (inner only):
468 * <'ether type'=0x0800
469 * | 'version'=4, 'protocol'=6, 'MF'=0>
471 * <'ether type'=0x86DD
472 * | 'version'=6, 'next header'=6>
474 #define RTE_PTYPE_INNER_L4_TCP 0x01000000
476 * UDP (User Datagram Protocol) packet type.
477 * It is used for inner packet only.
479 * Packet format (inner only):
480 * <'ether type'=0x0800
481 * | 'version'=4, 'protocol'=17, 'MF'=0>
483 * <'ether type'=0x86DD
484 * | 'version'=6, 'next header'=17>
486 #define RTE_PTYPE_INNER_L4_UDP 0x02000000
488 * Fragmented IP (Internet Protocol) packet type.
489 * It is used for inner packet only, and may or maynot have layer 4 packet.
491 * Packet format (inner only):
492 * <'ether type'=0x0800
493 * | 'version'=4, 'MF'=1>
495 * <'ether type'=0x86DD
496 * | 'version'=6, 'next header'=44>
498 #define RTE_PTYPE_INNER_L4_FRAG 0x03000000
500 * SCTP (Stream Control Transmission Protocol) packet type.
501 * It is used for inner packet only.
503 * Packet format (inner only):
504 * <'ether type'=0x0800
505 * | 'version'=4, 'protocol'=132, 'MF'=0>
507 * <'ether type'=0x86DD
508 * | 'version'=6, 'next header'=132>
510 #define RTE_PTYPE_INNER_L4_SCTP 0x04000000
512 * ICMP (Internet Control Message Protocol) packet type.
513 * It is used for inner packet only.
515 * Packet format (inner only):
516 * <'ether type'=0x0800
517 * | 'version'=4, 'protocol'=1, 'MF'=0>
519 * <'ether type'=0x86DD
520 * | 'version'=6, 'next header'=1>
522 #define RTE_PTYPE_INNER_L4_ICMP 0x05000000
524 * Non-fragmented IP (Internet Protocol) packet type.
525 * It is used for inner packet only, and may or maynot have other unknown layer
528 * Packet format (inner only):
529 * <'ether type'=0x0800
530 * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0>
532 * <'ether type'=0x86DD
533 * | 'version'=6, 'next header'!=[6|17|44|132|1]>
535 #define RTE_PTYPE_INNER_L4_NONFRAG 0x06000000
537 * Mask of inner layer 4 packet types.
539 #define RTE_PTYPE_INNER_L4_MASK 0x0f000000
542 * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
543 * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can
544 * determine if it is an IPV4 packet.
546 #define RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4)
549 * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
550 * one, bit 6 is selected to be used for IPv4 only. Then checking bit 6 can
551 * determine if it is an IPV4 packet.
553 #define RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6)
555 /* Check if it is a tunneling packet */
556 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) & \
557 (RTE_PTYPE_TUNNEL_MASK | \
558 RTE_PTYPE_INNER_L2_MASK | \
559 RTE_PTYPE_INNER_L3_MASK | \
560 RTE_PTYPE_INNER_L4_MASK))
566 #endif /* _RTE_MBUF_PTYPE_H_ */