mbuf: add MPLS packet type
[dpdk.git] / lib / librte_mbuf / rte_mbuf_ptype.h
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).
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, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP).
294  *
295  * Packet format:
296  * <'ether type'=0x0800
297  * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0, 'frag_offset'=0>
298  * or,
299  * <'ether type'=0x86DD
300  * | 'version'=6, 'next header'!=[6|17|44|132|1]>
301  */
302 #define RTE_PTYPE_L4_NONFRAG                0x00000600
303 /**
304  * Mask of layer 4 packet types.
305  * It is used for outer packet for tunneling cases.
306  */
307 #define RTE_PTYPE_L4_MASK                   0x00000f00
308 /**
309  * IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type.
310  *
311  * Packet format:
312  * <'ether type'=0x0800
313  * | 'version'=4, 'protocol'=[4|41]>
314  * or,
315  * <'ether type'=0x86DD
316  * | 'version'=6, 'next header'=[4|41]>
317  */
318 #define RTE_PTYPE_TUNNEL_IP                 0x00001000
319 /**
320  * GRE (Generic Routing Encapsulation) tunneling packet type.
321  *
322  * Packet format:
323  * <'ether type'=0x0800
324  * | 'version'=4, 'protocol'=47>
325  * or,
326  * <'ether type'=0x86DD
327  * | 'version'=6, 'next header'=47>
328  */
329 #define RTE_PTYPE_TUNNEL_GRE                0x00002000
330 /**
331  * VXLAN (Virtual eXtensible Local Area Network) tunneling packet type.
332  *
333  * Packet format:
334  * <'ether type'=0x0800
335  * | 'version'=4, 'protocol'=17
336  * | 'destination port'=4789>
337  * or,
338  * <'ether type'=0x86DD
339  * | 'version'=6, 'next header'=17
340  * | 'destination port'=4789>
341  */
342 #define RTE_PTYPE_TUNNEL_VXLAN              0x00003000
343 /**
344  * NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling
345  * packet type.
346  *
347  * Packet format:
348  * <'ether type'=0x0800
349  * | 'version'=4, 'protocol'=47
350  * | 'protocol type'=0x6558>
351  * or,
352  * <'ether type'=0x86DD
353  * | 'version'=6, 'next header'=47
354  * | 'protocol type'=0x6558'>
355  */
356 #define RTE_PTYPE_TUNNEL_NVGRE              0x00004000
357 /**
358  * GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type.
359  *
360  * Packet format:
361  * <'ether type'=0x0800
362  * | 'version'=4, 'protocol'=17
363  * | 'destination port'=6081>
364  * or,
365  * <'ether type'=0x86DD
366  * | 'version'=6, 'next header'=17
367  * | 'destination port'=6081>
368  */
369 #define RTE_PTYPE_TUNNEL_GENEVE             0x00005000
370 /**
371  * Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area
372  * Network) or GRE (Generic Routing Encapsulation) could be recognized as this
373  * packet type, if they can not be recognized independently as of hardware
374  * capability.
375  */
376 #define RTE_PTYPE_TUNNEL_GRENAT             0x00006000
377 /**
378  * GTP-C (GPRS Tunnelling Protocol) control tunneling packet type.
379  * Packet format:
380  * <'ether type'=0x0800
381  * | 'version'=4, 'protocol'=17
382  * | 'destination port'=2123>
383  * or,
384  * <'ether type'=0x86DD
385  * | 'version'=6, 'next header'=17
386  * | 'destination port'=2123>
387  * or,
388  * <'ether type'=0x0800
389  * | 'version'=4, 'protocol'=17
390  * | 'source port'=2123>
391  * or,
392  * <'ether type'=0x86DD
393  * | 'version'=6, 'next header'=17
394  * | 'source port'=2123>
395  */
396 #define RTE_PTYPE_TUNNEL_GTPC               0x00007000
397 /**
398  * GTP-U (GPRS Tunnelling Protocol) user data tunneling packet type.
399  * Packet format:
400  * <'ether type'=0x0800
401  * | 'version'=4, 'protocol'=17
402  * | 'destination port'=2152>
403  * or,
404  * <'ether type'=0x86DD
405  * | 'version'=6, 'next header'=17
406  * | 'destination port'=2152>
407  */
408 #define RTE_PTYPE_TUNNEL_GTPU               0x00008000
409 /**
410  * ESP (IP Encapsulating Security Payload) tunneling packet type.
411  *
412  * Packet format:
413  * <'ether type'=0x0800
414  * | 'version'=4, 'protocol'=51>
415  * or,
416  * <'ether type'=0x86DD
417  * | 'version'=6, 'next header'=51>
418  */
419 #define RTE_PTYPE_TUNNEL_ESP                0x00009000
420 /**
421  * L2TP (Layer 2 Tunneling Protocol) tunnleing packet type.
422  *
423  * Packet format:
424  * <'ether type'=0x0800
425  * | 'version'=4, 'protocol'=17>
426  * | 'destination port'=1701>
427  * or,
428  * <'ether type'=0x86DD
429  * | 'version'=6, 'next header'=17
430  * | 'destination port'=1701>
431  * or,
432  * <'ether type'=0x0800
433  * | 'version'=4, 'protocol'=115>
434  * or,
435  * <'ether type'=0x86DD
436  * | 'version'=6, 'protocol'=115>
437  */
438 #define RTE_PTYPE_TUNNEL_L2TP               0x0000a000
439 /**
440  * VXLAN-GPE (VXLAN Generic Protocol Extension) tunneling packet type.
441  *
442  * Packet format:
443  * <'ether type'=0x0800
444  * | 'version'=4, 'protocol'=17
445  * | 'destination port'=4790>
446  * or,
447  * <'ether type'=0x86DD
448  * | 'version'=6, 'next header'=17
449  * | 'destination port'=4790>
450  */
451 #define RTE_PTYPE_TUNNEL_VXLAN_GPE          0x0000b000
452 /**
453  * MPLS-in-GRE tunneling packet type (RFC 4023).
454  *
455  * Packet format:
456  * <'ether type'=0x0800
457  * | 'version'=4, 'protocol'=47
458  * | 'protocol'=0x8847>
459  * or,
460  * <'ether type'=0x0800
461  * | 'version'=4, 'protocol'=47
462  * | 'protocol'=0x8848>
463  * or,
464  * <'ether type'=0x86DD
465  * | 'version'=6, 'protocol'=47
466  * | 'protocol'=0x8847>
467  * or,
468  * <'ether type'=0x86DD
469  * | 'version'=6, 'next header'=47
470  * | 'protocol'=0x8848>
471  */
472 #define RTE_PTYPE_TUNNEL_MPLS_IN_GRE       0x0000c000
473 /**
474  * MPLS-in-UDP tunneling packet type (RFC 7510).
475  *
476  * Packet format:
477  * <'ether type'=0x0800
478  * | 'version'=4, 'protocol'=17
479  * | 'destination port'=6635>
480  * or,
481  * <'ether type'=0x86DD
482  * | 'version'=6, 'next header'=17
483  * | 'destination port'=6635>
484  */
485 #define RTE_PTYPE_TUNNEL_MPLS_IN_UDP      0x0000d000
486 /**
487  * Mask of tunneling packet types.
488  */
489 #define RTE_PTYPE_TUNNEL_MASK               0x0000f000
490 /**
491  * Ethernet packet type.
492  * It is used for inner packet type only.
493  *
494  * Packet format (inner only):
495  * <'ether type'=[0x800|0x86DD]>
496  */
497 #define RTE_PTYPE_INNER_L2_ETHER            0x00010000
498 /**
499  * Ethernet packet type with VLAN (Virtual Local Area Network) tag.
500  *
501  * Packet format (inner only):
502  * <'ether type'=[0x800|0x86DD], vlan=[1-4095]>
503  */
504 #define RTE_PTYPE_INNER_L2_ETHER_VLAN       0x00020000
505 /**
506  * QinQ packet type.
507  *
508  * Packet format:
509  * <'ether type'=[0x88A8]>
510  */
511 #define RTE_PTYPE_INNER_L2_ETHER_QINQ       0x00030000
512 /**
513  * Mask of inner layer 2 packet types.
514  */
515 #define RTE_PTYPE_INNER_L2_MASK             0x000f0000
516 /**
517  * IP (Internet Protocol) version 4 packet type.
518  * It is used for inner packet only, and does not contain any header option.
519  *
520  * Packet format (inner only):
521  * <'ether type'=0x0800
522  * | 'version'=4, 'ihl'=5>
523  */
524 #define RTE_PTYPE_INNER_L3_IPV4             0x00100000
525 /**
526  * IP (Internet Protocol) version 4 packet type.
527  * It is used for inner packet only, and contains header options.
528  *
529  * Packet format (inner only):
530  * <'ether type'=0x0800
531  * | 'version'=4, 'ihl'=[6-15], 'options'>
532  */
533 #define RTE_PTYPE_INNER_L3_IPV4_EXT         0x00200000
534 /**
535  * IP (Internet Protocol) version 6 packet type.
536  * It is used for inner packet only, and does not contain any extension header.
537  *
538  * Packet format (inner only):
539  * <'ether type'=0x86DD
540  * | 'version'=6, 'next header'=0x3B>
541  */
542 #define RTE_PTYPE_INNER_L3_IPV6             0x00300000
543 /**
544  * IP (Internet Protocol) version 4 packet type.
545  * It is used for inner packet only, and may or maynot contain header options.
546  *
547  * Packet format (inner only):
548  * <'ether type'=0x0800
549  * | 'version'=4, 'ihl'=[5-15], <'options'>>
550  */
551 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
552 /**
553  * IP (Internet Protocol) version 6 packet type.
554  * It is used for inner packet only, and contains extension headers.
555  *
556  * Packet format (inner only):
557  * <'ether type'=0x86DD
558  * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
559  *   'extension headers'>
560  */
561 #define RTE_PTYPE_INNER_L3_IPV6_EXT         0x00500000
562 /**
563  * IP (Internet Protocol) version 6 packet type.
564  * It is used for inner packet only, and may or maynot contain extension
565  * headers.
566  *
567  * Packet format (inner only):
568  * <'ether type'=0x86DD
569  * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
570  *   <'extension headers'>>
571  */
572 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
573 /**
574  * Mask of inner layer 3 packet types.
575  */
576 #define RTE_PTYPE_INNER_L3_MASK             0x00f00000
577 /**
578  * TCP (Transmission Control Protocol) packet type.
579  * It is used for inner packet only.
580  *
581  * Packet format (inner only):
582  * <'ether type'=0x0800
583  * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0>
584  * or,
585  * <'ether type'=0x86DD
586  * | 'version'=6, 'next header'=6>
587  */
588 #define RTE_PTYPE_INNER_L4_TCP              0x01000000
589 /**
590  * UDP (User Datagram Protocol) packet type.
591  * It is used for inner packet only.
592  *
593  * Packet format (inner only):
594  * <'ether type'=0x0800
595  * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0>
596  * or,
597  * <'ether type'=0x86DD
598  * | 'version'=6, 'next header'=17>
599  */
600 #define RTE_PTYPE_INNER_L4_UDP              0x02000000
601 /**
602  * Fragmented IP (Internet Protocol) packet type.
603  * It is used for inner packet only, and may or maynot have layer 4 packet.
604  *
605  * Packet format (inner only):
606  * <'ether type'=0x0800
607  * | 'version'=4, 'MF'=1>
608  * or,
609  * <'ether type'=0x0800
610  * | 'version'=4, 'frag_offset'!=0>
611  * or,
612  * <'ether type'=0x86DD
613  * | 'version'=6, 'next header'=44>
614  */
615 #define RTE_PTYPE_INNER_L4_FRAG             0x03000000
616 /**
617  * SCTP (Stream Control Transmission Protocol) packet type.
618  * It is used for inner packet only.
619  *
620  * Packet format (inner only):
621  * <'ether type'=0x0800
622  * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0>
623  * or,
624  * <'ether type'=0x86DD
625  * | 'version'=6, 'next header'=132>
626  */
627 #define RTE_PTYPE_INNER_L4_SCTP             0x04000000
628 /**
629  * ICMP (Internet Control Message Protocol) packet type.
630  * It is used for inner packet only.
631  *
632  * Packet format (inner only):
633  * <'ether type'=0x0800
634  * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0>
635  * or,
636  * <'ether type'=0x86DD
637  * | 'version'=6, 'next header'=1>
638  */
639 #define RTE_PTYPE_INNER_L4_ICMP             0x05000000
640 /**
641  * Non-fragmented IP (Internet Protocol) packet type.
642  * It is used for inner packet only, and may or maynot have other unknown layer
643  * 4 packet types.
644  *
645  * Packet format (inner only):
646  * <'ether type'=0x0800
647  * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0, 'frag_offset'=0>
648  * or,
649  * <'ether type'=0x86DD
650  * | 'version'=6, 'next header'!=[6|17|44|132|1]>
651  */
652 #define RTE_PTYPE_INNER_L4_NONFRAG          0x06000000
653 /**
654  * Mask of inner layer 4 packet types.
655  */
656 #define RTE_PTYPE_INNER_L4_MASK             0x0f000000
657 /**
658  * All valid layer masks.
659  */
660 #define RTE_PTYPE_ALL_MASK                  0x0fffffff
661
662 /**
663  * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
664  * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can
665  * determine if it is an IPV4 packet.
666  */
667 #define  RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4)
668
669 /**
670  * Check if the (outer) L3 header is IPv6. To avoid comparing IPv6 types one by
671  * one, bit 6 is selected to be used for IPv6 only. Then checking bit 6 can
672  * determine if it is an IPV6 packet.
673  */
674 #define  RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6)
675
676 /* Check if it is a tunneling packet */
677 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) &                         \
678         (RTE_PTYPE_TUNNEL_MASK |                                        \
679                 RTE_PTYPE_INNER_L2_MASK |                               \
680                 RTE_PTYPE_INNER_L3_MASK |                               \
681                 RTE_PTYPE_INNER_L4_MASK))
682
683 /**
684  * Get the name of the l2 packet type
685  *
686  * @param ptype
687  *   The packet type value.
688  * @return
689  *   A non-null string describing the packet type.
690  */
691 const char *rte_get_ptype_l2_name(uint32_t ptype);
692
693 /**
694  * Get the name of the l3 packet type
695  *
696  * @param ptype
697  *   The packet type value.
698  * @return
699  *   A non-null string describing the packet type.
700  */
701 const char *rte_get_ptype_l3_name(uint32_t ptype);
702
703 /**
704  * Get the name of the l4 packet type
705  *
706  * @param ptype
707  *   The packet type value.
708  * @return
709  *   A non-null string describing the packet type.
710  */
711 const char *rte_get_ptype_l4_name(uint32_t ptype);
712
713 /**
714  * Get the name of the tunnel packet type
715  *
716  * @param ptype
717  *   The packet type value.
718  * @return
719  *   A non-null string describing the packet type.
720  */
721 const char *rte_get_ptype_tunnel_name(uint32_t ptype);
722
723 /**
724  * Get the name of the inner_l2 packet type
725  *
726  * @param ptype
727  *   The packet type value.
728  * @return
729  *   A non-null string describing the packet type.
730  */
731 const char *rte_get_ptype_inner_l2_name(uint32_t ptype);
732
733 /**
734  * Get the name of the inner_l3 packet type
735  *
736  * @param ptype
737  *   The packet type value.
738  * @return
739  *   A non-null string describing the packet type.
740  */
741 const char *rte_get_ptype_inner_l3_name(uint32_t ptype);
742
743 /**
744  * Get the name of the inner_l4 packet type
745  *
746  * @param ptype
747  *   The packet type value.
748  * @return
749  *   A non-null string describing the packet type.
750  */
751 const char *rte_get_ptype_inner_l4_name(uint32_t ptype);
752
753 /**
754  * Write the packet type name into the buffer
755  *
756  * @param ptype
757  *   The packet type value.
758  * @param buf
759  *   The buffer where the string is written.
760  * @param buflen
761  *   The length of the buffer.
762  * @return
763  *   - 0 on success
764  *   - (-1) if the buffer is too small
765  */
766 int rte_get_ptype_name(uint32_t ptype, char *buf, size_t buflen);
767
768 #ifdef __cplusplus
769 }
770 #endif
771
772 #endif /* _RTE_MBUF_PTYPE_H_ */