DPDK  22.07.0
rte_mbuf_core.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright 2014 6WIND S.A.
4  */
5 
6 #ifndef _RTE_MBUF_CORE_H_
7 #define _RTE_MBUF_CORE_H_
8 
19 #include <stdint.h>
20 
21 #include <rte_compat.h>
22 #include <rte_byteorder.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /*
29  * Packet Offload Features Flags. It also carry packet type information.
30  * Critical resources. Both rx/tx shared these bits. Be cautious on any change
31  *
32  * - RX flags start at bit position zero, and get added to the left of previous
33  * flags.
34  * - The most-significant 3 bits are reserved for generic mbuf flags
35  * - TX flags therefore start at bit position 60 (i.e. 63-3), and new flags get
36  * added to the right of the previously defined flags i.e. they should count
37  * downwards, not upwards.
38  *
39  * Keep these flags synchronized with rte_get_rx_ol_flag_name() and
40  * rte_get_tx_ol_flag_name().
41  */
42 
50 #define RTE_MBUF_F_RX_VLAN (1ULL << 0)
51 #define PKT_RX_VLAN RTE_DEPRECATED(PKT_RX_VLAN) RTE_MBUF_F_RX_VLAN
52 
54 #define RTE_MBUF_F_RX_RSS_HASH (1ULL << 1)
55 #define PKT_RX_RSS_HASH RTE_DEPRECATED(PKT_RX_RSS_HASH) RTE_MBUF_F_RX_RSS_HASH
56 
58 #define RTE_MBUF_F_RX_FDIR (1ULL << 2)
59 #define PKT_RX_FDIR RTE_DEPRECATED(PKT_RX_FDIR) RTE_MBUF_F_RX_FDIR
60 
65 #define RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD (1ULL << 5)
66 #define PKT_RX_OUTER_IP_CKSUM_BAD RTE_DEPRECATED(PKT_RX_OUTER_IP_CKSUM_BAD) \
67  RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD
68 
75 #define RTE_MBUF_F_RX_VLAN_STRIPPED (1ULL << 6)
76 #define PKT_RX_VLAN_STRIPPED RTE_DEPRECATED(PKT_RX_VLAN_STRIPPED) \
77  RTE_MBUF_F_RX_VLAN_STRIPPED
78 
87 #define RTE_MBUF_F_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))
88 #define PKT_RX_IP_CKSUM_MASK RTE_DEPRECATED(PKT_RX_IP_CKSUM_MASK) \
89  RTE_MBUF_F_RX_IP_CKSUM_MASK
90 
91 #define RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN 0
92 #define RTE_MBUF_F_RX_IP_CKSUM_BAD (1ULL << 4)
93 #define RTE_MBUF_F_RX_IP_CKSUM_GOOD (1ULL << 7)
94 #define RTE_MBUF_F_RX_IP_CKSUM_NONE ((1ULL << 4) | (1ULL << 7))
95 #define PKT_RX_IP_CKSUM_UNKNOWN RTE_DEPRECATED(PKT_RX_IP_CKSUM_UNKNOWN) \
96  RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN
97 #define PKT_RX_IP_CKSUM_BAD RTE_DEPRECATED(PKT_RX_IP_CKSUM_BAD) \
98  RTE_MBUF_F_RX_IP_CKSUM_BAD
99 #define PKT_RX_IP_CKSUM_GOOD RTE_DEPRECATED(PKT_RX_IP_CKSUM_GOOD) \
100  RTE_MBUF_F_RX_IP_CKSUM_GOOD
101 #define PKT_RX_IP_CKSUM_NONE RTE_DEPRECATED(PKT_RX_IP_CKSUM_NONE) \
102  RTE_MBUF_F_RX_IP_CKSUM_NONE
103 
112 #define RTE_MBUF_F_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))
113 #define PKT_RX_L4_CKSUM_MASK RTE_DEPRECATED(PKT_RX_L4_CKSUM_MASK) \
114  RTE_MBUF_F_RX_L4_CKSUM_MASK
115 
116 #define RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN 0
117 #define RTE_MBUF_F_RX_L4_CKSUM_BAD (1ULL << 3)
118 #define RTE_MBUF_F_RX_L4_CKSUM_GOOD (1ULL << 8)
119 #define RTE_MBUF_F_RX_L4_CKSUM_NONE ((1ULL << 3) | (1ULL << 8))
120 #define PKT_RX_L4_CKSUM_UNKNOWN RTE_DEPRECATED(PKT_RX_L4_CKSUM_UNKNOWN) \
121  RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN
122 #define PKT_RX_L4_CKSUM_BAD RTE_DEPRECATED(PKT_RX_L4_CKSUM_BAD) \
123  RTE_MBUF_F_RX_L4_CKSUM_BAD
124 #define PKT_RX_L4_CKSUM_GOOD RTE_DEPRECATED(PKT_RX_L4_CKSUM_GOOD) \
125  RTE_MBUF_F_RX_L4_CKSUM_GOOD
126 #define PKT_RX_L4_CKSUM_NONE RTE_DEPRECATED(PKT_RX_L4_CKSUM_NONE) \
127  RTE_MBUF_F_RX_L4_CKSUM_NONE
128 
130 #define RTE_MBUF_F_RX_IEEE1588_PTP (1ULL << 9)
131 #define PKT_RX_IEEE1588_PTP RTE_DEPRECATED(PKT_RX_IEEE1588_PTP) \
132  RTE_MBUF_F_RX_IEEE1588_PTP
133 
135 #define RTE_MBUF_F_RX_IEEE1588_TMST (1ULL << 10)
136 #define PKT_RX_IEEE1588_TMST RTE_DEPRECATED(PKT_RX_IEEE1588_TMST) \
137  RTE_MBUF_F_RX_IEEE1588_TMST
138 
140 #define RTE_MBUF_F_RX_FDIR_ID (1ULL << 13)
141 #define PKT_RX_FDIR_ID RTE_DEPRECATED(PKT_RX_FDIR_ID) \
142  RTE_MBUF_F_RX_FDIR_ID
143 
145 #define RTE_MBUF_F_RX_FDIR_FLX (1ULL << 14)
146 #define PKT_RX_FDIR_FLX RTE_DEPRECATED(PKT_RX_FDIR_FLX) \
147  RTE_MBUF_F_RX_FDIR_FLX
148 
164 #define RTE_MBUF_F_RX_QINQ_STRIPPED (1ULL << 15)
165 #define PKT_RX_QINQ_STRIPPED RTE_DEPRECATED(PKT_RX_QINQ_STRIPPED) \
166  RTE_MBUF_F_RX_QINQ_STRIPPED
167 
173 #define RTE_MBUF_F_RX_LRO (1ULL << 16)
174 #define PKT_RX_LRO RTE_DEPRECATED(PKT_RX_LRO) RTE_MBUF_F_RX_LRO
175 
176 /* There is no flag defined at offset 17. It is free for any future use. */
177 
181 #define RTE_MBUF_F_RX_SEC_OFFLOAD (1ULL << 18)
182 #define PKT_RX_SEC_OFFLOAD RTE_DEPRECATED(PKT_RX_SEC_OFFLOAD) \
183  RTE_MBUF_F_RX_SEC_OFFLOAD
184 
188 #define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED (1ULL << 19)
189 #define PKT_RX_SEC_OFFLOAD_FAILED RTE_DEPRECATED(PKT_RX_SEC_OFFLOAD_FAILED) \
190  RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED
191 
200 #define RTE_MBUF_F_RX_QINQ (1ULL << 20)
201 #define PKT_RX_QINQ RTE_DEPRECATED(PKT_RX_QINQ) RTE_MBUF_F_RX_QINQ
202 
218 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_MASK ((1ULL << 21) | (1ULL << 22))
219 #define PKT_RX_OUTER_L4_CKSUM_MASK RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_MASK) \
220  RTE_MBUF_F_RX_OUTER_L4_CKSUM_MASK
221 
222 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN 0
223 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD (1ULL << 21)
224 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)
225 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22))
226 #define PKT_RX_OUTER_L4_CKSUM_UNKNOWN \
227  RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_UNKNOWN) \
228  RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN
229 #define PKT_RX_OUTER_L4_CKSUM_BAD RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_BAD) \
230  RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD
231 #define PKT_RX_OUTER_L4_CKSUM_GOOD RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_GOOD) \
232  RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD
233 #define PKT_RX_OUTER_L4_CKSUM_INVALID \
234  RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_INVALID) \
235  RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID
236 
237 /* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */
238 
239 #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)
240 #define PKT_FIRST_FREE RTE_DEPRECATED(PKT_FIRST_FREE) RTE_MBUF_F_FIRST_FREE
241 #define RTE_MBUF_F_LAST_FREE (1ULL << 40)
242 #define PKT_LAST_FREE RTE_DEPRECATED(PKT_LAST_FREE) RTE_MBUF_F_LAST_FREE
243 
244 /* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */
245 
255 #define RTE_MBUF_F_TX_OUTER_UDP_CKSUM (1ULL << 41)
256 #define PKT_TX_OUTER_UDP_CKSUM RTE_DEPRECATED(PKT_TX_OUTER_UDP_CKSUM) \
257  RTE_MBUF_F_TX_OUTER_UDP_CKSUM
258 
264 #define RTE_MBUF_F_TX_UDP_SEG (1ULL << 42)
265 #define PKT_TX_UDP_SEG RTE_DEPRECATED(PKT_TX_UDP_SEG) RTE_MBUF_F_TX_UDP_SEG
266 
272 #define RTE_MBUF_F_TX_SEC_OFFLOAD (1ULL << 43)
273 #define PKT_TX_SEC_OFFLOAD RTE_DEPRECATED(PKT_TX_SEC_OFFLOAD) \
274  RTE_MBUF_F_TX_SEC_OFFLOAD
275 
280 #define RTE_MBUF_F_TX_MACSEC (1ULL << 44)
281 #define PKT_TX_MACSEC RTE_DEPRECATED(PKT_TX_MACSEC) RTE_MBUF_F_TX_MACSEC
282 
292 #define RTE_MBUF_F_TX_TUNNEL_VXLAN (0x1ULL << 45)
293 #define RTE_MBUF_F_TX_TUNNEL_GRE (0x2ULL << 45)
294 #define RTE_MBUF_F_TX_TUNNEL_IPIP (0x3ULL << 45)
295 #define RTE_MBUF_F_TX_TUNNEL_GENEVE (0x4ULL << 45)
296 
297 #define RTE_MBUF_F_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
298 #define RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE (0x6ULL << 45)
299 #define RTE_MBUF_F_TX_TUNNEL_GTP (0x7ULL << 45)
300 #define RTE_MBUF_F_TX_TUNNEL_ESP (0x8ULL << 45)
301 
312 #define RTE_MBUF_F_TX_TUNNEL_IP (0xDULL << 45)
313 
325 #define RTE_MBUF_F_TX_TUNNEL_UDP (0xEULL << 45)
326 /* add new TX TUNNEL type here */
327 #define RTE_MBUF_F_TX_TUNNEL_MASK (0xFULL << 45)
328 
329 #define PKT_TX_TUNNEL_VXLAN RTE_DEPRECATED(PKT_TX_TUNNEL_VXLAN) \
330  RTE_MBUF_F_TX_TUNNEL_VXLAN
331 #define PKT_TX_TUNNEL_GRE RTE_DEPRECATED(PKT_TX_TUNNEL_GRE) \
332  RTE_MBUF_F_TX_TUNNEL_GRE
333 #define PKT_TX_TUNNEL_IPIP RTE_DEPRECATED(PKT_TX_TUNNEL_IPIP) \
334  RTE_MBUF_F_TX_TUNNEL_IPIP
335 #define PKT_TX_TUNNEL_GENEVE RTE_DEPRECATED(PKT_TX_TUNNEL_GENEVE) \
336  RTE_MBUF_F_TX_TUNNEL_GENEVE
337 #define PKT_TX_TUNNEL_MPLSINUDP RTE_DEPRECATED(PKT_TX_TUNNEL_MPLSINUDP) \
338  RTE_MBUF_F_TX_TUNNEL_MPLSINUDP
339 #define PKT_TX_TUNNEL_VXLAN_GPE RTE_DEPRECATED(PKT_TX_TUNNEL_VXLAN_GPE) \
340  RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE
341 #define PKT_TX_TUNNEL_GTP RTE_DEPRECATED(PKT_TX_TUNNEL_GTP) \
342  RTE_MBUF_F_TX_TUNNEL_GTP
343 #define PKT_TX_TUNNEL_IP RTE_DEPRECATED(PKT_TX_TUNNEL_IP) \
344  RTE_MBUF_F_TX_TUNNEL_IP
345 #define PKT_TX_TUNNEL_UDP RTE_DEPRECATED(PKT_TX_TUNNEL_UDP) \
346  RTE_MBUF_F_TX_TUNNEL_UDP
347 #define PKT_TX_TUNNEL_MASK RTE_DEPRECATED(PKT_TX_TUNNEL_MASK) \
348  RTE_MBUF_F_TX_TUNNEL_MASK
349 
355 #define RTE_MBUF_F_TX_QINQ (1ULL << 49)
356 #define PKT_TX_QINQ RTE_DEPRECATED(PKT_TX_QINQ) RTE_MBUF_F_TX_QINQ
357 #define PKT_TX_QINQ_PKT RTE_DEPRECATED(PKT_TX_QINQ_PKT) RTE_MBUF_F_TX_QINQ
358 
368 #define RTE_MBUF_F_TX_TCP_SEG (1ULL << 50)
369 #define PKT_TX_TCP_SEG RTE_DEPRECATED(PKT_TX_TCP_SEG) RTE_MBUF_F_TX_TCP_SEG
370 
372 #define RTE_MBUF_F_TX_IEEE1588_TMST (1ULL << 51)
373 #define PKT_TX_IEEE1588_TMST RTE_DEPRECATED(PKT_TX_IEEE1588_TMST) \
374  RTE_MBUF_F_TX_IEEE1588_TMST
375 
376 /*
377  * Bits 52+53 used for L4 packet type with checksum enabled: 00: Reserved,
378  * 01: TCP checksum, 10: SCTP checksum, 11: UDP checksum. To use hardware
379  * L4 checksum offload, the user needs to:
380  * - fill l2_len and l3_len in mbuf
381  * - set the flags RTE_MBUF_F_TX_TCP_CKSUM, RTE_MBUF_F_TX_SCTP_CKSUM or
382  * RTE_MBUF_F_TX_UDP_CKSUM
383  * - set the flag RTE_MBUF_F_TX_IPV4 or RTE_MBUF_F_TX_IPV6
384  */
385 
387 #define RTE_MBUF_F_TX_L4_NO_CKSUM (0ULL << 52)
388 
390 #define RTE_MBUF_F_TX_TCP_CKSUM (1ULL << 52)
391 
393 #define RTE_MBUF_F_TX_SCTP_CKSUM (2ULL << 52)
394 
396 #define RTE_MBUF_F_TX_UDP_CKSUM (3ULL << 52)
397 
399 #define RTE_MBUF_F_TX_L4_MASK (3ULL << 52)
400 
401 #define PKT_TX_L4_NO_CKSUM RTE_DEPRECATED(PKT_TX_L4_NO_CKSUM) \
402  RTE_MBUF_F_TX_L4_NO_CKSUM
403 #define PKT_TX_TCP_CKSUM RTE_DEPRECATED(PKT_TX_TCP_CKSUM) \
404  RTE_MBUF_F_TX_TCP_CKSUM
405 #define PKT_TX_SCTP_CKSUM RTE_DEPRECATED(PKT_TX_SCTP_CKSUM) \
406  RTE_MBUF_F_TX_SCTP_CKSUM
407 #define PKT_TX_UDP_CKSUM RTE_DEPRECATED(PKT_TX_UDP_CKSUM) \
408  RTE_MBUF_F_TX_UDP_CKSUM
409 #define PKT_TX_L4_MASK RTE_DEPRECATED(PKT_TX_L4_MASK) RTE_MBUF_F_TX_L4_MASK
410 
417 #define RTE_MBUF_F_TX_IP_CKSUM (1ULL << 54)
418 #define PKT_TX_IP_CKSUM RTE_DEPRECATED(PKT_TX_IP_CKSUM) RTE_MBUF_F_TX_IP_CKSUM
419 
426 #define RTE_MBUF_F_TX_IPV4 (1ULL << 55)
427 #define PKT_TX_IPV4 RTE_DEPRECATED(PKT_TX_IPV4) RTE_MBUF_F_TX_IPV4
428 
435 #define RTE_MBUF_F_TX_IPV6 (1ULL << 56)
436 #define PKT_TX_IPV6 RTE_DEPRECATED(PKT_TX_IPV6) RTE_MBUF_F_TX_IPV6
437 
443 #define RTE_MBUF_F_TX_VLAN (1ULL << 57)
444 #define PKT_TX_VLAN RTE_DEPRECATED(PKT_TX_VLAN) RTE_MBUF_F_TX_VLAN
445 #define PKT_TX_VLAN_PKT RTE_DEPRECATED(PKT_TX_VLAN_PKT) RTE_MBUF_F_TX_VLAN
446 
453 #define RTE_MBUF_F_TX_OUTER_IP_CKSUM (1ULL << 58)
454 #define PKT_TX_OUTER_IP_CKSUM RTE_DEPRECATED(PKT_TX_OUTER_IP_CKSUM) \
455  RTE_MBUF_F_TX_OUTER_IP_CKSUM
456 
462 #define RTE_MBUF_F_TX_OUTER_IPV4 (1ULL << 59)
463 #define PKT_TX_OUTER_IPV4 RTE_DEPRECATED(PKT_TX_OUTER_IPV4) \
464  RTE_MBUF_F_TX_OUTER_IPV4
465 
471 #define RTE_MBUF_F_TX_OUTER_IPV6 (1ULL << 60)
472 #define PKT_TX_OUTER_IPV6 RTE_DEPRECATED(PKT_TX_OUTER_IPV6) \
473  RTE_MBUF_F_TX_OUTER_IPV6
474 
479 #define RTE_MBUF_F_TX_OFFLOAD_MASK ( \
480  RTE_MBUF_F_TX_OUTER_IPV6 | \
481  RTE_MBUF_F_TX_OUTER_IPV4 | \
482  RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
483  RTE_MBUF_F_TX_VLAN | \
484  RTE_MBUF_F_TX_IPV6 | \
485  RTE_MBUF_F_TX_IPV4 | \
486  RTE_MBUF_F_TX_IP_CKSUM | \
487  RTE_MBUF_F_TX_L4_MASK | \
488  RTE_MBUF_F_TX_IEEE1588_TMST | \
489  RTE_MBUF_F_TX_TCP_SEG | \
490  RTE_MBUF_F_TX_QINQ | \
491  RTE_MBUF_F_TX_TUNNEL_MASK | \
492  RTE_MBUF_F_TX_MACSEC | \
493  RTE_MBUF_F_TX_SEC_OFFLOAD | \
494  RTE_MBUF_F_TX_UDP_SEG | \
495  RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
496 #define PKT_TX_OFFLOAD_MASK RTE_DEPRECATED(PKT_TX_OFFLOAD_MASK) RTE_MBUF_F_TX_OFFLOAD_MASK
497 
501 #define RTE_MBUF_F_EXTERNAL (1ULL << 61)
502 #define EXT_ATTACHED_MBUF RTE_DEPRECATED(EXT_ATTACHED_MBUF) RTE_MBUF_F_EXTERNAL
503 
504 #define RTE_MBUF_F_INDIRECT (1ULL << 62)
505 #define IND_ATTACHED_MBUF RTE_DEPRECATED(IND_ATTACHED_MBUF) RTE_MBUF_F_INDIRECT
506 
508 #define RTE_MBUF_PRIV_ALIGN 8
509 
516 #define RTE_MBUF_DEFAULT_DATAROOM 2048
517 #define RTE_MBUF_DEFAULT_BUF_SIZE \
518  (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM)
519 
521  uint32_t queue_id;
522  uint8_t traffic_class;
526  uint8_t color;
528  uint16_t reserved;
529 };
535 enum {
536  RTE_MBUF_L2_LEN_BITS = 7,
537  RTE_MBUF_L3_LEN_BITS = 9,
538  RTE_MBUF_L4_LEN_BITS = 8,
539  RTE_MBUF_TSO_SEGSZ_BITS = 16,
540  RTE_MBUF_OUTL3_LEN_BITS = 9,
541  RTE_MBUF_OUTL2_LEN_BITS = 7,
542  RTE_MBUF_TXOFLD_UNUSED_BITS = sizeof(uint64_t) * CHAR_BIT -
543  RTE_MBUF_L2_LEN_BITS -
544  RTE_MBUF_L3_LEN_BITS -
545  RTE_MBUF_L4_LEN_BITS -
546  RTE_MBUF_TSO_SEGSZ_BITS -
547  RTE_MBUF_OUTL3_LEN_BITS -
548  RTE_MBUF_OUTL2_LEN_BITS,
549 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
550  RTE_MBUF_L2_LEN_OFS =
551  sizeof(uint64_t) * CHAR_BIT - RTE_MBUF_L2_LEN_BITS,
552  RTE_MBUF_L3_LEN_OFS = RTE_MBUF_L2_LEN_OFS - RTE_MBUF_L3_LEN_BITS,
553  RTE_MBUF_L4_LEN_OFS = RTE_MBUF_L3_LEN_OFS - RTE_MBUF_L4_LEN_BITS,
554  RTE_MBUF_TSO_SEGSZ_OFS = RTE_MBUF_L4_LEN_OFS - RTE_MBUF_TSO_SEGSZ_BITS,
555  RTE_MBUF_OUTL3_LEN_OFS =
556  RTE_MBUF_TSO_SEGSZ_OFS - RTE_MBUF_OUTL3_LEN_BITS,
557  RTE_MBUF_OUTL2_LEN_OFS =
558  RTE_MBUF_OUTL3_LEN_OFS - RTE_MBUF_OUTL2_LEN_BITS,
559  RTE_MBUF_TXOFLD_UNUSED_OFS =
560  RTE_MBUF_OUTL2_LEN_OFS - RTE_MBUF_TXOFLD_UNUSED_BITS,
561 #else
562  RTE_MBUF_L2_LEN_OFS = 0,
563  RTE_MBUF_L3_LEN_OFS = RTE_MBUF_L2_LEN_OFS + RTE_MBUF_L2_LEN_BITS,
564  RTE_MBUF_L4_LEN_OFS = RTE_MBUF_L3_LEN_OFS + RTE_MBUF_L3_LEN_BITS,
565  RTE_MBUF_TSO_SEGSZ_OFS = RTE_MBUF_L4_LEN_OFS + RTE_MBUF_L4_LEN_BITS,
566  RTE_MBUF_OUTL3_LEN_OFS =
567  RTE_MBUF_TSO_SEGSZ_OFS + RTE_MBUF_TSO_SEGSZ_BITS,
568  RTE_MBUF_OUTL2_LEN_OFS =
569  RTE_MBUF_OUTL3_LEN_OFS + RTE_MBUF_OUTL3_LEN_BITS,
570  RTE_MBUF_TXOFLD_UNUSED_OFS =
571  RTE_MBUF_OUTL2_LEN_OFS + RTE_MBUF_OUTL2_LEN_BITS,
572 #endif
573 };
574 
578 struct rte_mbuf {
579  RTE_MARKER cacheline0;
580 
581  void *buf_addr;
588  rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t));
589 
590  /* next 8 bytes are initialised on RX descriptor rearm */
591  RTE_MARKER64 rearm_data;
592  uint16_t data_off;
593 
602  uint16_t refcnt;
603 
608  uint16_t nb_segs;
609 
613  uint16_t port;
614 
615  uint64_t ol_flags;
617  /* remaining bytes are set on RX when pulling packet from descriptor */
618  RTE_MARKER rx_descriptor_fields1;
619 
620  /*
621  * The packet type, which is the combination of outer/inner L2, L3, L4
622  * and tunnel types. The packet_type is about data really present in the
623  * mbuf. Example: if vlan stripping is enabled, a received vlan packet
624  * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
625  * vlan is stripped from the data.
626  */
628  union {
629  uint32_t packet_type;
630  __extension__
631  struct {
632  uint8_t l2_type:4;
633  uint8_t l3_type:4;
634  uint8_t l4_type:4;
635  uint8_t tun_type:4;
637  union {
643  __extension__
644  struct {
645  uint8_t inner_l2_type:4;
647  uint8_t inner_l3_type:4;
649  };
650  };
651  uint8_t inner_l4_type:4;
652  };
653  };
654 
655  uint32_t pkt_len;
656  uint16_t data_len;
658  uint16_t vlan_tci;
659 
661  union {
662  union {
663  uint32_t rss;
664  struct {
665  union {
666  struct {
667  uint16_t hash;
668  uint16_t id;
669  };
670  uint32_t lo;
672  };
673  uint32_t hi;
677  } fdir;
678  struct rte_mbuf_sched sched;
680  struct {
681  uint32_t reserved1;
682  uint16_t reserved2;
683  uint16_t txq;
688  } txadapter;
690  uint32_t usr;
691  } hash;
692  };
693 
695  uint16_t vlan_tci_outer;
696 
697  uint16_t buf_len;
699  struct rte_mempool *pool;
701  /* second cache line - fields only used in slow path or on TX */
703 
708  struct rte_mbuf *next;
709 
710  /* fields to support TX offloads */
712  union {
713  uint64_t tx_offload;
714  __extension__
715  struct {
716  uint64_t l2_len:RTE_MBUF_L2_LEN_BITS;
720  uint64_t l3_len:RTE_MBUF_L3_LEN_BITS;
722  uint64_t l4_len:RTE_MBUF_L4_LEN_BITS;
724  uint64_t tso_segsz:RTE_MBUF_TSO_SEGSZ_BITS;
727  /*
728  * Fields for Tx offloading of tunnels.
729  * These are undefined for packets which don't request
730  * any tunnel offloads (outer IP or UDP checksum,
731  * tunnel TSO).
732  *
733  * PMDs should not use these fields unconditionally
734  * when calculating offsets.
735  *
736  * Applications are expected to set appropriate tunnel
737  * offload flags when they fill in these fields.
738  */
739  uint64_t outer_l3_len:RTE_MBUF_OUTL3_LEN_BITS;
741  uint64_t outer_l2_len:RTE_MBUF_OUTL2_LEN_BITS;
744  /* uint64_t unused:RTE_MBUF_TXOFLD_UNUSED_BITS; */
745  };
746  };
747 
752 
756  uint16_t priv_size;
757 
759  uint16_t timesync;
760 
761  uint32_t dynfield1[9];
763 
767 typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);
768 
774  void *fcb_opaque;
775  uint16_t refcnt;
776 };
777 
779 #define RTE_MBUF_MAX_NB_SEGS UINT16_MAX
780 
788 #define RTE_MBUF_CLONED(mb) ((mb)->ol_flags & RTE_MBUF_F_INDIRECT)
789 
795 #define RTE_MBUF_HAS_EXTBUF(mb) ((mb)->ol_flags & RTE_MBUF_F_EXTERNAL)
796 
803 #define RTE_MBUF_DIRECT(mb) \
804  (!((mb)->ol_flags & (RTE_MBUF_F_INDIRECT | RTE_MBUF_F_EXTERNAL)))
805 
807 #define RTE_MBUF_PORT_INVALID UINT16_MAX
808 
809 #define MBUF_INVALID_PORT RTE_MBUF_PORT_INVALID
810 
825 #define rte_pktmbuf_mtod_offset(m, t, o) \
826  ((t)(void *)((char *)(m)->buf_addr + (m)->data_off + (o)))
827 
840 #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
841 
851 #define rte_pktmbuf_iova_offset(m, o) \
852  (rte_iova_t)((m)->buf_iova + (m)->data_off + (o))
853 
861 #define rte_pktmbuf_iova(m) rte_pktmbuf_iova_offset(m, 0)
862 
863 #ifdef __cplusplus
864 }
865 #endif
866 
867 #endif /* _RTE_MBUF_CORE_H_ */
struct rte_mbuf_ext_shared_info * shinfo
struct rte_mbuf * next
uint16_t txq
uint16_t vlan_tci_outer
uint8_t inner_esp_next_proto
uint8_t l2_type
#define __rte_cache_min_aligned
Definition: rte_common.h:448
uint8_t l3_type
uint32_t queue_id
uint64_t l2_len
uint64_t rte_iova_t
Definition: rte_common.h:463
void * buf_addr
uint16_t data_len
uint32_t lo
rte_mbuf_extbuf_free_callback_t free_cb
uint8_t inner_l2_type
uint64_t tso_segsz
uint64_t l4_len
uint16_t nb_segs
uint16_t port
uint64_t outer_l3_len
uint64_t l3_len
__extension__ typedef void * RTE_MARKER[0]
Definition: rte_common.h:469
uint16_t priv_size
uint16_t timesync
uint32_t hi
void(* rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque)
uint8_t inner_l4_type
uint64_t outer_l2_len
uint16_t refcnt
__extension__ typedef uint64_t RTE_MARKER64[0]
Definition: rte_common.h:477
uint64_t ol_flags
uint32_t pkt_len
uint16_t buf_len
uint32_t packet_type
uint8_t inner_l3_type
#define __rte_cache_aligned
Definition: rte_common.h:445
uint8_t l4_type
#define RTE_STD_C11
Definition: rte_common.h:42
struct rte_mempool * pool
uint32_t rss
uint16_t reserved
uint8_t traffic_class
uint64_t tx_offload
uint16_t vlan_tci
uint8_t tun_type
#define __rte_aligned(a)
Definition: rte_common.h:71