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