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