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