ethdev: introduce new tunnel VXLAN-GPE
[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  * Mask of layer 2 packet types.
135  * It is used for outer packet for tunneling cases.
136  */
137 #define RTE_PTYPE_L2_MASK                   0x0000000f
138 /**
139  * IP (Internet Protocol) version 4 packet type.
140  * It is used for outer packet for tunneling cases, and does not contain any
141  * header option.
142  *
143  * Packet format:
144  * <'ether type'=0x0800
145  * | 'version'=4, 'ihl'=5>
146  */
147 #define RTE_PTYPE_L3_IPV4                   0x00000010
148 /**
149  * IP (Internet Protocol) version 4 packet type.
150  * It is used for outer packet for tunneling cases, and contains header
151  * options.
152  *
153  * Packet format:
154  * <'ether type'=0x0800
155  * | 'version'=4, 'ihl'=[6-15], 'options'>
156  */
157 #define RTE_PTYPE_L3_IPV4_EXT               0x00000030
158 /**
159  * IP (Internet Protocol) version 6 packet type.
160  * It is used for outer packet for tunneling cases, and does not contain any
161  * extension header.
162  *
163  * Packet format:
164  * <'ether type'=0x86DD
165  * | 'version'=6, 'next header'=0x3B>
166  */
167 #define RTE_PTYPE_L3_IPV6                   0x00000040
168 /**
169  * IP (Internet Protocol) version 4 packet type.
170  * It is used for outer packet for tunneling cases, and may or maynot contain
171  * header options.
172  *
173  * Packet format:
174  * <'ether type'=0x0800
175  * | 'version'=4, 'ihl'=[5-15], <'options'>>
176  */
177 #define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN       0x00000090
178 /**
179  * IP (Internet Protocol) version 6 packet type.
180  * It is used for outer packet for tunneling cases, and contains extension
181  * headers.
182  *
183  * Packet format:
184  * <'ether type'=0x86DD
185  * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
186  *   'extension headers'>
187  */
188 #define RTE_PTYPE_L3_IPV6_EXT               0x000000c0
189 /**
190  * IP (Internet Protocol) version 6 packet type.
191  * It is used for outer packet for tunneling cases, and may or maynot contain
192  * extension headers.
193  *
194  * Packet format:
195  * <'ether type'=0x86DD
196  * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
197  *   <'extension headers'>>
198  */
199 #define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN       0x000000e0
200 /**
201  * Mask of layer 3 packet types.
202  * It is used for outer packet for tunneling cases.
203  */
204 #define RTE_PTYPE_L3_MASK                   0x000000f0
205 /**
206  * TCP (Transmission Control Protocol) packet type.
207  * It is used for outer packet for tunneling cases.
208  *
209  * Packet format:
210  * <'ether type'=0x0800
211  * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0>
212  * or,
213  * <'ether type'=0x86DD
214  * | 'version'=6, 'next header'=6>
215  */
216 #define RTE_PTYPE_L4_TCP                    0x00000100
217 /**
218  * UDP (User Datagram Protocol) packet type.
219  * It is used for outer packet for tunneling cases.
220  *
221  * Packet format:
222  * <'ether type'=0x0800
223  * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0>
224  * or,
225  * <'ether type'=0x86DD
226  * | 'version'=6, 'next header'=17>
227  */
228 #define RTE_PTYPE_L4_UDP                    0x00000200
229 /**
230  * Fragmented IP (Internet Protocol) packet type.
231  * It is used for outer packet for tunneling cases.
232  *
233  * It refers to those packets of any IP types, which can be recognized as
234  * fragmented. A fragmented packet cannot be recognized as any other L4 types
235  * (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP,
236  * RTE_PTYPE_L4_NONFRAG).
237  *
238  * Packet format:
239  * <'ether type'=0x0800
240  * | 'version'=4, 'MF'=1>
241  * or,
242  * <'ether type'=0x0800
243  * | 'version'=4, 'frag_offset'!=0>
244  * or,
245  * <'ether type'=0x86DD
246  * | 'version'=6, 'next header'=44>
247  */
248 #define RTE_PTYPE_L4_FRAG                   0x00000300
249 /**
250  * SCTP (Stream Control Transmission Protocol) packet type.
251  * It is used for outer packet for tunneling cases.
252  *
253  * Packet format:
254  * <'ether type'=0x0800
255  * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0>
256  * or,
257  * <'ether type'=0x86DD
258  * | 'version'=6, 'next header'=132>
259  */
260 #define RTE_PTYPE_L4_SCTP                   0x00000400
261 /**
262  * ICMP (Internet Control Message Protocol) packet type.
263  * It is used for outer packet for tunneling cases.
264  *
265  * Packet format:
266  * <'ether type'=0x0800
267  * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0>
268  * or,
269  * <'ether type'=0x86DD
270  * | 'version'=6, 'next header'=1>
271  */
272 #define RTE_PTYPE_L4_ICMP                   0x00000500
273 /**
274  * Non-fragmented IP (Internet Protocol) packet type.
275  * It is used for outer packet for tunneling cases.
276  *
277  * It refers to those packets of any IP types, while cannot be recognized as
278  * any of above L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP,
279  * RTE_PTYPE_L4_FRAG, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP).
280  *
281  * Packet format:
282  * <'ether type'=0x0800
283  * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0, 'frag_offset'=0>
284  * or,
285  * <'ether type'=0x86DD
286  * | 'version'=6, 'next header'!=[6|17|44|132|1]>
287  */
288 #define RTE_PTYPE_L4_NONFRAG                0x00000600
289 /**
290  * Mask of layer 4 packet types.
291  * It is used for outer packet for tunneling cases.
292  */
293 #define RTE_PTYPE_L4_MASK                   0x00000f00
294 /**
295  * IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type.
296  *
297  * Packet format:
298  * <'ether type'=0x0800
299  * | 'version'=4, 'protocol'=[4|41]>
300  * or,
301  * <'ether type'=0x86DD
302  * | 'version'=6, 'next header'=[4|41]>
303  */
304 #define RTE_PTYPE_TUNNEL_IP                 0x00001000
305 /**
306  * GRE (Generic Routing Encapsulation) tunneling packet type.
307  *
308  * Packet format:
309  * <'ether type'=0x0800
310  * | 'version'=4, 'protocol'=47>
311  * or,
312  * <'ether type'=0x86DD
313  * | 'version'=6, 'next header'=47>
314  */
315 #define RTE_PTYPE_TUNNEL_GRE                0x00002000
316 /**
317  * VXLAN (Virtual eXtensible Local Area Network) tunneling packet type.
318  *
319  * Packet format:
320  * <'ether type'=0x0800
321  * | 'version'=4, 'protocol'=17
322  * | 'destination port'=4789>
323  * or,
324  * <'ether type'=0x86DD
325  * | 'version'=6, 'next header'=17
326  * | 'destination port'=4789>
327  */
328 #define RTE_PTYPE_TUNNEL_VXLAN              0x00003000
329 /**
330  * NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling
331  * packet type.
332  *
333  * Packet format:
334  * <'ether type'=0x0800
335  * | 'version'=4, 'protocol'=47
336  * | 'protocol type'=0x6558>
337  * or,
338  * <'ether type'=0x86DD
339  * | 'version'=6, 'next header'=47
340  * | 'protocol type'=0x6558'>
341  */
342 #define RTE_PTYPE_TUNNEL_NVGRE              0x00004000
343 /**
344  * GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type.
345  *
346  * Packet format:
347  * <'ether type'=0x0800
348  * | 'version'=4, 'protocol'=17
349  * | 'destination port'=6081>
350  * or,
351  * <'ether type'=0x86DD
352  * | 'version'=6, 'next header'=17
353  * | 'destination port'=6081>
354  */
355 #define RTE_PTYPE_TUNNEL_GENEVE             0x00005000
356 /**
357  * Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area
358  * Network) or GRE (Generic Routing Encapsulation) could be recognized as this
359  * packet type, if they can not be recognized independently as of hardware
360  * capability.
361  */
362 #define RTE_PTYPE_TUNNEL_GRENAT             0x00006000
363 /**
364  * GTP-C (GPRS Tunnelling Protocol) control tunneling packet type.
365  * Packet format:
366  * <'ether type'=0x0800
367  * | 'version'=4, 'protocol'=17
368  * | 'destination port'=2123>
369  * or,
370  * <'ether type'=0x86DD
371  * | 'version'=6, 'next header'=17
372  * | 'destination port'=2123>
373  * or,
374  * <'ether type'=0x0800
375  * | 'version'=4, 'protocol'=17
376  * | 'source port'=2123>
377  * or,
378  * <'ether type'=0x86DD
379  * | 'version'=6, 'next header'=17
380  * | 'source port'=2123>
381  */
382 #define RTE_PTYPE_TUNNEL_GTPC               0x00007000
383 /**
384  * GTP-U (GPRS Tunnelling Protocol) user data tunneling packet type.
385  * Packet format:
386  * <'ether type'=0x0800
387  * | 'version'=4, 'protocol'=17
388  * | 'destination port'=2152>
389  * or,
390  * <'ether type'=0x86DD
391  * | 'version'=6, 'next header'=17
392  * | 'destination port'=2152>
393  */
394 #define RTE_PTYPE_TUNNEL_GTPU               0x00008000
395 /**
396  * ESP (IP Encapsulating Security Payload) tunneling packet type.
397  *
398  * Packet format:
399  * <'ether type'=0x0800
400  * | 'version'=4, 'protocol'=51>
401  * or,
402  * <'ether type'=0x86DD
403  * | 'version'=6, 'next header'=51>
404  */
405 #define RTE_PTYPE_TUNNEL_ESP                0x00009000
406 /**
407  * L2TP (Layer 2 Tunneling Protocol) tunnleing packet type.
408  *
409  * Packet format:
410  * <'ether type'=0x0800
411  * | 'version'=4, 'protocol'=17>
412  * | 'destination port'=1701>
413  * or,
414  * <'ether type'=0x86DD
415  * | 'version'=6, 'next header'=17
416  * | 'destination port'=1701>
417  * or,
418  * <'ether type'=0x0800
419  * | 'version'=4, 'protocol'=115>
420  * or,
421  * <'ether type'=0x86DD
422  * | 'version'=6, 'protocol'=115>
423  */
424 #define RTE_PTYPE_TUNNEL_L2TP               0x0000a000
425 /**
426  * VXLAN-GPE (VXLAN Generic Protocol Extension) tunneling packet type.
427  *
428  * Packet format:
429  * <'ether type'=0x0800
430  * | 'version'=4, 'protocol'=17
431  * | 'destination port'=4790>
432  * or,
433  * <'ether type'=0x86DD
434  * | 'version'=6, 'next header'=17
435  * | 'destination port'=4790>
436  */
437 #define RTE_PTYPE_TUNNEL_VXLAN_GPE          0x0000b000
438 /**
439  * Mask of tunneling packet types.
440  */
441 #define RTE_PTYPE_TUNNEL_MASK               0x0000f000
442 /**
443  * Ethernet packet type.
444  * It is used for inner packet type only.
445  *
446  * Packet format (inner only):
447  * <'ether type'=[0x800|0x86DD]>
448  */
449 #define RTE_PTYPE_INNER_L2_ETHER            0x00010000
450 /**
451  * Ethernet packet type with VLAN (Virtual Local Area Network) tag.
452  *
453  * Packet format (inner only):
454  * <'ether type'=[0x800|0x86DD], vlan=[1-4095]>
455  */
456 #define RTE_PTYPE_INNER_L2_ETHER_VLAN       0x00020000
457 /**
458  * QinQ packet type.
459  *
460  * Packet format:
461  * <'ether type'=[0x88A8]>
462  */
463 #define RTE_PTYPE_INNER_L2_ETHER_QINQ       0x00030000
464 /**
465  * Mask of inner layer 2 packet types.
466  */
467 #define RTE_PTYPE_INNER_L2_MASK             0x000f0000
468 /**
469  * IP (Internet Protocol) version 4 packet type.
470  * It is used for inner packet only, and does not contain any header option.
471  *
472  * Packet format (inner only):
473  * <'ether type'=0x0800
474  * | 'version'=4, 'ihl'=5>
475  */
476 #define RTE_PTYPE_INNER_L3_IPV4             0x00100000
477 /**
478  * IP (Internet Protocol) version 4 packet type.
479  * It is used for inner packet only, and contains header options.
480  *
481  * Packet format (inner only):
482  * <'ether type'=0x0800
483  * | 'version'=4, 'ihl'=[6-15], 'options'>
484  */
485 #define RTE_PTYPE_INNER_L3_IPV4_EXT         0x00200000
486 /**
487  * IP (Internet Protocol) version 6 packet type.
488  * It is used for inner packet only, and does not contain any extension header.
489  *
490  * Packet format (inner only):
491  * <'ether type'=0x86DD
492  * | 'version'=6, 'next header'=0x3B>
493  */
494 #define RTE_PTYPE_INNER_L3_IPV6             0x00300000
495 /**
496  * IP (Internet Protocol) version 4 packet type.
497  * It is used for inner packet only, and may or maynot contain header options.
498  *
499  * Packet format (inner only):
500  * <'ether type'=0x0800
501  * | 'version'=4, 'ihl'=[5-15], <'options'>>
502  */
503 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
504 /**
505  * IP (Internet Protocol) version 6 packet type.
506  * It is used for inner packet only, and contains extension headers.
507  *
508  * Packet format (inner only):
509  * <'ether type'=0x86DD
510  * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
511  *   'extension headers'>
512  */
513 #define RTE_PTYPE_INNER_L3_IPV6_EXT         0x00500000
514 /**
515  * IP (Internet Protocol) version 6 packet type.
516  * It is used for inner packet only, and may or maynot contain extension
517  * headers.
518  *
519  * Packet format (inner only):
520  * <'ether type'=0x86DD
521  * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
522  *   <'extension headers'>>
523  */
524 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
525 /**
526  * Mask of inner layer 3 packet types.
527  */
528 #define RTE_PTYPE_INNER_L3_MASK             0x00f00000
529 /**
530  * TCP (Transmission Control Protocol) packet type.
531  * It is used for inner packet only.
532  *
533  * Packet format (inner only):
534  * <'ether type'=0x0800
535  * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0>
536  * or,
537  * <'ether type'=0x86DD
538  * | 'version'=6, 'next header'=6>
539  */
540 #define RTE_PTYPE_INNER_L4_TCP              0x01000000
541 /**
542  * UDP (User Datagram Protocol) packet type.
543  * It is used for inner packet only.
544  *
545  * Packet format (inner only):
546  * <'ether type'=0x0800
547  * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0>
548  * or,
549  * <'ether type'=0x86DD
550  * | 'version'=6, 'next header'=17>
551  */
552 #define RTE_PTYPE_INNER_L4_UDP              0x02000000
553 /**
554  * Fragmented IP (Internet Protocol) packet type.
555  * It is used for inner packet only, and may or maynot have layer 4 packet.
556  *
557  * Packet format (inner only):
558  * <'ether type'=0x0800
559  * | 'version'=4, 'MF'=1>
560  * or,
561  * <'ether type'=0x0800
562  * | 'version'=4, 'frag_offset'!=0>
563  * or,
564  * <'ether type'=0x86DD
565  * | 'version'=6, 'next header'=44>
566  */
567 #define RTE_PTYPE_INNER_L4_FRAG             0x03000000
568 /**
569  * SCTP (Stream Control Transmission Protocol) packet type.
570  * It is used for inner packet only.
571  *
572  * Packet format (inner only):
573  * <'ether type'=0x0800
574  * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0>
575  * or,
576  * <'ether type'=0x86DD
577  * | 'version'=6, 'next header'=132>
578  */
579 #define RTE_PTYPE_INNER_L4_SCTP             0x04000000
580 /**
581  * ICMP (Internet Control Message Protocol) packet type.
582  * It is used for inner packet only.
583  *
584  * Packet format (inner only):
585  * <'ether type'=0x0800
586  * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0>
587  * or,
588  * <'ether type'=0x86DD
589  * | 'version'=6, 'next header'=1>
590  */
591 #define RTE_PTYPE_INNER_L4_ICMP             0x05000000
592 /**
593  * Non-fragmented IP (Internet Protocol) packet type.
594  * It is used for inner packet only, and may or maynot have other unknown layer
595  * 4 packet types.
596  *
597  * Packet format (inner only):
598  * <'ether type'=0x0800
599  * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0, 'frag_offset'=0>
600  * or,
601  * <'ether type'=0x86DD
602  * | 'version'=6, 'next header'!=[6|17|44|132|1]>
603  */
604 #define RTE_PTYPE_INNER_L4_NONFRAG          0x06000000
605 /**
606  * Mask of inner layer 4 packet types.
607  */
608 #define RTE_PTYPE_INNER_L4_MASK             0x0f000000
609 /**
610  * All valid layer masks.
611  */
612 #define RTE_PTYPE_ALL_MASK                  0x0fffffff
613
614 /**
615  * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
616  * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can
617  * determine if it is an IPV4 packet.
618  */
619 #define  RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4)
620
621 /**
622  * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
623  * one, bit 6 is selected to be used for IPv4 only. Then checking bit 6 can
624  * determine if it is an IPV4 packet.
625  */
626 #define  RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6)
627
628 /* Check if it is a tunneling packet */
629 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) &                         \
630         (RTE_PTYPE_TUNNEL_MASK |                                        \
631                 RTE_PTYPE_INNER_L2_MASK |                               \
632                 RTE_PTYPE_INNER_L3_MASK |                               \
633                 RTE_PTYPE_INNER_L4_MASK))
634
635 /**
636  * Get the name of the l2 packet type
637  *
638  * @param ptype
639  *   The packet type value.
640  * @return
641  *   A non-null string describing the packet type.
642  */
643 const char *rte_get_ptype_l2_name(uint32_t ptype);
644
645 /**
646  * Get the name of the l3 packet type
647  *
648  * @param ptype
649  *   The packet type value.
650  * @return
651  *   A non-null string describing the packet type.
652  */
653 const char *rte_get_ptype_l3_name(uint32_t ptype);
654
655 /**
656  * Get the name of the l4 packet type
657  *
658  * @param ptype
659  *   The packet type value.
660  * @return
661  *   A non-null string describing the packet type.
662  */
663 const char *rte_get_ptype_l4_name(uint32_t ptype);
664
665 /**
666  * Get the name of the tunnel packet type
667  *
668  * @param ptype
669  *   The packet type value.
670  * @return
671  *   A non-null string describing the packet type.
672  */
673 const char *rte_get_ptype_tunnel_name(uint32_t ptype);
674
675 /**
676  * Get the name of the inner_l2 packet type
677  *
678  * @param ptype
679  *   The packet type value.
680  * @return
681  *   A non-null string describing the packet type.
682  */
683 const char *rte_get_ptype_inner_l2_name(uint32_t ptype);
684
685 /**
686  * Get the name of the inner_l3 packet type
687  *
688  * @param ptype
689  *   The packet type value.
690  * @return
691  *   A non-null string describing the packet type.
692  */
693 const char *rte_get_ptype_inner_l3_name(uint32_t ptype);
694
695 /**
696  * Get the name of the inner_l4 packet type
697  *
698  * @param ptype
699  *   The packet type value.
700  * @return
701  *   A non-null string describing the packet type.
702  */
703 const char *rte_get_ptype_inner_l4_name(uint32_t ptype);
704
705 /**
706  * Write the packet type name into the buffer
707  *
708  * @param ptype
709  *   The packet type value.
710  * @param buf
711  *   The buffer where the string is written.
712  * @param buflen
713  *   The length of the buffer.
714  * @return
715  *   - 0 on success
716  *   - (-1) if the buffer is too small
717  */
718 int rte_get_ptype_name(uint32_t ptype, char *buf, size_t buflen);
719
720 #ifdef __cplusplus
721 }
722 #endif
723
724 #endif /* _RTE_MBUF_PTYPE_H_ */