New upstream version 18.08
[deb_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  * MPLS-in-GRE tunneling packet type (RFC 4023).
440  *
441  * Packet format:
442  * <'ether type'=0x0800
443  * | 'version'=4, 'protocol'=47
444  * | 'protocol'=0x8847>
445  * or,
446  * <'ether type'=0x0800
447  * | 'version'=4, 'protocol'=47
448  * | 'protocol'=0x8848>
449  * or,
450  * <'ether type'=0x86DD
451  * | 'version'=6, 'protocol'=47
452  * | 'protocol'=0x8847>
453  * or,
454  * <'ether type'=0x86DD
455  * | 'version'=6, 'next header'=47
456  * | 'protocol'=0x8848>
457  */
458 #define RTE_PTYPE_TUNNEL_MPLS_IN_GRE       0x0000c000
459 /**
460  * MPLS-in-UDP tunneling packet type (RFC 7510).
461  *
462  * Packet format:
463  * <'ether type'=0x0800
464  * | 'version'=4, 'protocol'=17
465  * | 'destination port'=6635>
466  * or,
467  * <'ether type'=0x86DD
468  * | 'version'=6, 'next header'=17
469  * | 'destination port'=6635>
470  */
471 #define RTE_PTYPE_TUNNEL_MPLS_IN_UDP      0x0000d000
472 /**
473  * Mask of tunneling packet types.
474  */
475 #define RTE_PTYPE_TUNNEL_MASK               0x0000f000
476 /**
477  * Ethernet packet type.
478  * It is used for inner packet type only.
479  *
480  * Packet format (inner only):
481  * <'ether type'=[0x800|0x86DD]>
482  */
483 #define RTE_PTYPE_INNER_L2_ETHER            0x00010000
484 /**
485  * Ethernet packet type with VLAN (Virtual Local Area Network) tag.
486  *
487  * Packet format (inner only):
488  * <'ether type'=[0x800|0x86DD], vlan=[1-4095]>
489  */
490 #define RTE_PTYPE_INNER_L2_ETHER_VLAN       0x00020000
491 /**
492  * QinQ packet type.
493  *
494  * Packet format:
495  * <'ether type'=[0x88A8]>
496  */
497 #define RTE_PTYPE_INNER_L2_ETHER_QINQ       0x00030000
498 /**
499  * Mask of inner layer 2 packet types.
500  */
501 #define RTE_PTYPE_INNER_L2_MASK             0x000f0000
502 /**
503  * IP (Internet Protocol) version 4 packet type.
504  * It is used for inner packet only, and does not contain any header option.
505  *
506  * Packet format (inner only):
507  * <'ether type'=0x0800
508  * | 'version'=4, 'ihl'=5>
509  */
510 #define RTE_PTYPE_INNER_L3_IPV4             0x00100000
511 /**
512  * IP (Internet Protocol) version 4 packet type.
513  * It is used for inner packet only, and contains header options.
514  *
515  * Packet format (inner only):
516  * <'ether type'=0x0800
517  * | 'version'=4, 'ihl'=[6-15], 'options'>
518  */
519 #define RTE_PTYPE_INNER_L3_IPV4_EXT         0x00200000
520 /**
521  * IP (Internet Protocol) version 6 packet type.
522  * It is used for inner packet only, and does not contain any extension header.
523  *
524  * Packet format (inner only):
525  * <'ether type'=0x86DD
526  * | 'version'=6, 'next header'=0x3B>
527  */
528 #define RTE_PTYPE_INNER_L3_IPV6             0x00300000
529 /**
530  * IP (Internet Protocol) version 4 packet type.
531  * It is used for inner packet only, and may or maynot contain header options.
532  *
533  * Packet format (inner only):
534  * <'ether type'=0x0800
535  * | 'version'=4, 'ihl'=[5-15], <'options'>>
536  */
537 #define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
538 /**
539  * IP (Internet Protocol) version 6 packet type.
540  * It is used for inner packet only, and contains extension headers.
541  *
542  * Packet format (inner only):
543  * <'ether type'=0x86DD
544  * | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
545  *   'extension headers'>
546  */
547 #define RTE_PTYPE_INNER_L3_IPV6_EXT         0x00500000
548 /**
549  * IP (Internet Protocol) version 6 packet type.
550  * It is used for inner packet only, and may or maynot contain extension
551  * headers.
552  *
553  * Packet format (inner only):
554  * <'ether type'=0x86DD
555  * | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87],
556  *   <'extension headers'>>
557  */
558 #define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
559 /**
560  * Mask of inner layer 3 packet types.
561  */
562 #define RTE_PTYPE_INNER_L3_MASK             0x00f00000
563 /**
564  * TCP (Transmission Control Protocol) packet type.
565  * It is used for inner packet only.
566  *
567  * Packet format (inner only):
568  * <'ether type'=0x0800
569  * | 'version'=4, 'protocol'=6, 'MF'=0, 'frag_offset'=0>
570  * or,
571  * <'ether type'=0x86DD
572  * | 'version'=6, 'next header'=6>
573  */
574 #define RTE_PTYPE_INNER_L4_TCP              0x01000000
575 /**
576  * UDP (User Datagram Protocol) packet type.
577  * It is used for inner packet only.
578  *
579  * Packet format (inner only):
580  * <'ether type'=0x0800
581  * | 'version'=4, 'protocol'=17, 'MF'=0, 'frag_offset'=0>
582  * or,
583  * <'ether type'=0x86DD
584  * | 'version'=6, 'next header'=17>
585  */
586 #define RTE_PTYPE_INNER_L4_UDP              0x02000000
587 /**
588  * Fragmented IP (Internet Protocol) packet type.
589  * It is used for inner packet only, and may or maynot have layer 4 packet.
590  *
591  * Packet format (inner only):
592  * <'ether type'=0x0800
593  * | 'version'=4, 'MF'=1>
594  * or,
595  * <'ether type'=0x0800
596  * | 'version'=4, 'frag_offset'!=0>
597  * or,
598  * <'ether type'=0x86DD
599  * | 'version'=6, 'next header'=44>
600  */
601 #define RTE_PTYPE_INNER_L4_FRAG             0x03000000
602 /**
603  * SCTP (Stream Control Transmission Protocol) packet type.
604  * It is used for inner packet only.
605  *
606  * Packet format (inner only):
607  * <'ether type'=0x0800
608  * | 'version'=4, 'protocol'=132, 'MF'=0, 'frag_offset'=0>
609  * or,
610  * <'ether type'=0x86DD
611  * | 'version'=6, 'next header'=132>
612  */
613 #define RTE_PTYPE_INNER_L4_SCTP             0x04000000
614 /**
615  * ICMP (Internet Control Message Protocol) packet type.
616  * It is used for inner packet only.
617  *
618  * Packet format (inner only):
619  * <'ether type'=0x0800
620  * | 'version'=4, 'protocol'=1, 'MF'=0, 'frag_offset'=0>
621  * or,
622  * <'ether type'=0x86DD
623  * | 'version'=6, 'next header'=1>
624  */
625 #define RTE_PTYPE_INNER_L4_ICMP             0x05000000
626 /**
627  * Non-fragmented IP (Internet Protocol) packet type.
628  * It is used for inner packet only, and may or maynot have other unknown layer
629  * 4 packet types.
630  *
631  * Packet format (inner only):
632  * <'ether type'=0x0800
633  * | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0, 'frag_offset'=0>
634  * or,
635  * <'ether type'=0x86DD
636  * | 'version'=6, 'next header'!=[6|17|44|132|1]>
637  */
638 #define RTE_PTYPE_INNER_L4_NONFRAG          0x06000000
639 /**
640  * Mask of inner layer 4 packet types.
641  */
642 #define RTE_PTYPE_INNER_L4_MASK             0x0f000000
643 /**
644  * All valid layer masks.
645  */
646 #define RTE_PTYPE_ALL_MASK                  0x0fffffff
647
648 /**
649  * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by
650  * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can
651  * determine if it is an IPV4 packet.
652  */
653 #define  RTE_ETH_IS_IPV4_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV4)
654
655 /**
656  * Check if the (outer) L3 header is IPv6. To avoid comparing IPv6 types one by
657  * one, bit 6 is selected to be used for IPv6 only. Then checking bit 6 can
658  * determine if it is an IPV6 packet.
659  */
660 #define  RTE_ETH_IS_IPV6_HDR(ptype) ((ptype) & RTE_PTYPE_L3_IPV6)
661
662 /* Check if it is a tunneling packet */
663 #define RTE_ETH_IS_TUNNEL_PKT(ptype) ((ptype) &                         \
664         (RTE_PTYPE_TUNNEL_MASK |                                        \
665                 RTE_PTYPE_INNER_L2_MASK |                               \
666                 RTE_PTYPE_INNER_L3_MASK |                               \
667                 RTE_PTYPE_INNER_L4_MASK))
668
669 /**
670  * Get the name of the l2 packet type
671  *
672  * @param ptype
673  *   The packet type value.
674  * @return
675  *   A non-null string describing the packet type.
676  */
677 const char *rte_get_ptype_l2_name(uint32_t ptype);
678
679 /**
680  * Get the name of the l3 packet type
681  *
682  * @param ptype
683  *   The packet type value.
684  * @return
685  *   A non-null string describing the packet type.
686  */
687 const char *rte_get_ptype_l3_name(uint32_t ptype);
688
689 /**
690  * Get the name of the l4 packet type
691  *
692  * @param ptype
693  *   The packet type value.
694  * @return
695  *   A non-null string describing the packet type.
696  */
697 const char *rte_get_ptype_l4_name(uint32_t ptype);
698
699 /**
700  * Get the name of the tunnel packet type
701  *
702  * @param ptype
703  *   The packet type value.
704  * @return
705  *   A non-null string describing the packet type.
706  */
707 const char *rte_get_ptype_tunnel_name(uint32_t ptype);
708
709 /**
710  * Get the name of the inner_l2 packet type
711  *
712  * @param ptype
713  *   The packet type value.
714  * @return
715  *   A non-null string describing the packet type.
716  */
717 const char *rte_get_ptype_inner_l2_name(uint32_t ptype);
718
719 /**
720  * Get the name of the inner_l3 packet type
721  *
722  * @param ptype
723  *   The packet type value.
724  * @return
725  *   A non-null string describing the packet type.
726  */
727 const char *rte_get_ptype_inner_l3_name(uint32_t ptype);
728
729 /**
730  * Get the name of the inner_l4 packet type
731  *
732  * @param ptype
733  *   The packet type value.
734  * @return
735  *   A non-null string describing the packet type.
736  */
737 const char *rte_get_ptype_inner_l4_name(uint32_t ptype);
738
739 /**
740  * Write the packet type name into the buffer
741  *
742  * @param ptype
743  *   The packet type value.
744  * @param buf
745  *   The buffer where the string is written.
746  * @param buflen
747  *   The length of the buffer.
748  * @return
749  *   - 0 on success
750  *   - (-1) if the buffer is too small
751  */
752 int rte_get_ptype_name(uint32_t ptype, char *buf, size_t buflen);
753
754 #ifdef __cplusplus
755 }
756 #endif
757
758 #endif /* _RTE_MBUF_PTYPE_H_ */