rte_mbuf_core.h(3)

โœจ NAME โœจ

okay so bestie, this page is rte_mbuf_core.h, straight out of the Library Functions Manual ๐Ÿ“–๐Ÿ’…. It's a header, it's iconic, and it's about to tell you literally everything about mbuf internals. Buckle up, we're going in ๐Ÿซถ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

first things first, the includes you need to pull in:

#include <stdalign.h>
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_stdatomic.h>

๐ŸŽ€ Data Structures ๐ŸŽ€

these are the structs living in here, no cap:

  • struct rte_mbuf_sched
  • struct rte_mbuf
  • struct rte_mbuf_ext_shared_info

๐ŸŽ€ Macros ๐ŸŽ€

the full flag lineup, every single one, as-is โœจ

#define RTE_MBUF_F_RX_VLAN   (1ULL << 0)
#define RTE_MBUF_F_RX_RSS_HASH   (1ULL << 1)
#define RTE_MBUF_F_RX_FDIR   (1ULL << 2)
#define RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD   (1ULL << 5)
#define RTE_MBUF_F_RX_VLAN_STRIPPED   (1ULL << 6)
#define RTE_MBUF_F_RX_IP_CKSUM_MASK   ((1ULL << 4) | (1ULL << 7))
#define RTE_MBUF_F_RX_L4_CKSUM_MASK   ((1ULL << 3) | (1ULL << 8))
#define RTE_MBUF_F_RX_IEEE1588_PTP   (1ULL << 9)
#define RTE_MBUF_F_RX_IEEE1588_TMST   (1ULL << 10)
#define RTE_MBUF_F_RX_FDIR_ID   (1ULL << 13)
#define RTE_MBUF_F_RX_FDIR_FLX   (1ULL << 14)
#define RTE_MBUF_F_RX_QINQ_STRIPPED   (1ULL << 15)
#define RTE_MBUF_F_RX_LRO   (1ULL << 16)
#define RTE_MBUF_F_RX_SEC_OFFLOAD   (1ULL << 18)
#define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED   (1ULL << 19)
#define RTE_MBUF_F_RX_QINQ   (1ULL << 20)
#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_MASK   ((1ULL << 21) | (1ULL << 22))
#define RTE_MBUF_F_TX_OUTER_UDP_CKSUM   (1ULL << 41)
#define RTE_MBUF_F_TX_UDP_SEG   (1ULL << 42)
#define RTE_MBUF_F_TX_SEC_OFFLOAD   (1ULL << 43)
#define RTE_MBUF_F_TX_MACSEC   (1ULL << 44)
#define RTE_MBUF_F_TX_TUNNEL_VXLAN   (0x1ULL << 45)
#define RTE_MBUF_F_TX_TUNNEL_MPLSINUDP   (0x5ULL << 45)
#define RTE_MBUF_F_TX_TUNNEL_IP   (0xDULL << 45)
#define RTE_MBUF_F_TX_TUNNEL_UDP   (0xEULL << 45)
#define RTE_MBUF_F_TX_QINQ   (1ULL << 49)
#define RTE_MBUF_F_TX_TCP_SEG   (1ULL << 50)
#define RTE_MBUF_F_TX_IEEE1588_TMST   (1ULL << 51)
#define RTE_MBUF_F_TX_L4_NO_CKSUM   (0ULL << 52)
#define RTE_MBUF_F_TX_TCP_CKSUM   (1ULL << 52)
#define RTE_MBUF_F_TX_SCTP_CKSUM   (2ULL << 52)
#define RTE_MBUF_F_TX_UDP_CKSUM   (3ULL << 52)
#define RTE_MBUF_F_TX_L4_MASK   (3ULL << 52)
#define RTE_MBUF_F_TX_IP_CKSUM   (1ULL << 54)
#define RTE_MBUF_F_TX_IPV4   (1ULL << 55)
#define RTE_MBUF_F_TX_IPV6   (1ULL << 56)
#define RTE_MBUF_F_TX_VLAN   (1ULL << 57)
#define RTE_MBUF_F_TX_OUTER_IP_CKSUM   (1ULL << 58)
#define RTE_MBUF_F_TX_OUTER_IPV4   (1ULL << 59)
#define RTE_MBUF_F_TX_OUTER_IPV6   (1ULL << 60)
#define RTE_MBUF_F_TX_OFFLOAD_MASK
#define RTE_MBUF_F_EXTERNAL   (1ULL << 61)
#define RTE_MBUF_F_INDIRECT   (1ULL << 62)
#define RTE_MBUF_PRIV_ALIGN   8
#define RTE_MBUF_DEFAULT_DATAROOM   2048
#define RTE_MBUF_MAX_NB_SEGS   UINT16_MAX
#define RTE_MBUF_CLONED(mb)
#define RTE_MBUF_HAS_EXTBUF(mb)
#define RTE_MBUF_DIRECT(mb)
#define RTE_MBUF_PORT_INVALID   UINT16_MAX
#define MBUF_INVALID_PORT   RTE_MBUF_PORT_INVALID
#define rte_pktmbuf_mtod_offset(m,  t,  o)
#define rte_pktmbuf_mtod(m,  t)
#define rte_pktmbuf_iova_offset(m,  o)
#define rte_pktmbuf_iova(m)

๐ŸŽ€ Typedefs ๐ŸŽ€

one little callback type, and it's this:

typedef void(* rte_mbuf_extbuf_free_callback_t) (void *addr, void *opaque)

๐ŸŽ€ Enumerations ๐ŸŽ€

  • enum

๐Ÿ’– Detailed Description ๐Ÿ’–

okay so this file has the definition of the RTE mbuf structure itself, plus the packet offload flags, plus some related macros. That's the whole vibe ๐ŸŒˆ

Important heads-up tho: for the majority of DPDK entities, it is not recommended to include this file directly. Do include <rte_mbuf.h> instead. The way that direct-including this is just doing too much ๐Ÿ™ˆ

And for future contributors: new fields and flags should fit in the "dynamic space" ๐Ÿ’…

Definition in file rte_mbuf_core.h.


๐Ÿ‘‘ Macro Definition Documentation ๐Ÿ‘‘

๐ŸŒธ #define RTE_MBUF_F_RX_VLAN (1ULL << 0)

The RX packet is a 802.1q VLAN packet, and the tci has been saved in mbuf->vlan_tci. If the flag RTE_MBUF_F_RX_VLAN_STRIPPED is also present, the VLAN header has been stripped from mbuf data, else it is still present.

Definition at line 51 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_RSS_HASH (1ULL << 1)

RX packet with RSS hash result.

Definition at line 54 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_FDIR (1ULL << 2)

RX packet with FDIR match indicate.

Definition at line 57 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD (1ULL << 5)

This flag is set when the outermost IP header checksum is detected as wrong by the hardware. bad checksum, bad vibes ๐Ÿ˜ญ

Definition at line 63 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_VLAN_STRIPPED (1ULL << 6)

A vlan has been stripped by the hardware and its tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping is enabled in the RX configuration of the PMD. When RTE_MBUF_F_RX_VLAN_STRIPPED is set, RTE_MBUF_F_RX_VLAN must also be set.

Definition at line 71 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))

Mask of bits used to determine the status of RX IP checksum. Here's the whole roster:

  • RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum
  • RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong
  • RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid
  • RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified.

Definition at line 81 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))

Mask of bits used to determine the status of RX L4 checksum. The lineup:

  • RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN: no information about the RX L4 checksum
  • RTE_MBUF_F_RX_L4_CKSUM_BAD: the L4 checksum in the packet is wrong
  • RTE_MBUF_F_RX_L4_CKSUM_GOOD: the L4 checksum in the packet is valid
  • RTE_MBUF_F_RX_L4_CKSUM_NONE: the L4 checksum is not correct in the packet data, but the integrity of the L4 data is verified.

Definition at line 96 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_IEEE1588_PTP (1ULL << 9)

RX IEEE1588 L2 Ethernet PT Packet.

Definition at line 104 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_IEEE1588_TMST (1ULL << 10)

RX IEEE1588 L2/L4 timestamped packet. โฑ๏ธโœจ

Definition at line 107 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_FDIR_ID (1ULL << 13)

FD id reported if FDIR match.

Definition at line 110 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_FDIR_FLX (1ULL << 14)

Flexible bytes reported if FDIR match.

Definition at line 113 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_QINQ_STRIPPED (1ULL << 15)

The outer VLAN has been stripped by the hardware and its TCI is saved in mbuf->vlan_tci_outer. This can only happen if VLAN stripping is enabled in the Rx configuration of the PMD. When RTE_MBUF_F_RX_QINQ_STRIPPED is set, the flags RTE_MBUF_F_RX_VLAN and RTE_MBUF_F_RX_QINQ must also be set.

  • If both RTE_MBUF_F_RX_QINQ_STRIPPED and RTE_MBUF_F_RX_VLAN_STRIPPED are set, the 2 VLANs have been stripped by the hardware and their TCIs are saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
  • If RTE_MBUF_F_RX_QINQ_STRIPPED is set and RTE_MBUF_F_RX_VLAN_STRIPPED is unset, only the outer VLAN is removed from packet data, but both tci are saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).

Definition at line 130 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_LRO (1ULL << 16)

When packets are coalesced by a hardware or virtual driver, this flag can be set in the RX mbuf, meaning that the m->tso_segsz field is valid and is set to the segment size of original packets.

Definition at line 137 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_SEC_OFFLOAD (1ULL << 18)

Indicate that security offload processing was applied on the RX packet. ๐Ÿ”

Definition at line 144 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED (1ULL << 19)

Indicate that security offload processing failed on the RX packet. it did NOT eat ๐Ÿ’€

Definition at line 149 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_QINQ (1ULL << 20)

The RX packet is a double VLAN, and the outer tci has been saved in mbuf->vlan_tci_outer. If this flag is set, RTE_MBUF_F_RX_VLAN must also be set and the inner tci is saved in mbuf->vlan_tci. If the flag RTE_MBUF_F_RX_QINQ_STRIPPED is also present, both VLANs headers have been stripped from mbuf data, else they are still present.

Definition at line 159 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_MASK ((1ULL << 21) | (1ULL << 22))

Mask of bits used to determine the status of outer RX L4 checksum. The states:

  • RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN: no info about the outer RX L4 checksum
  • RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD: the outer L4 checksum in the packet is wrong
  • RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD: the outer L4 checksum in the packet is valid
  • RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID: invalid outer L4 checksum state.

The detection of RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD shall be based on the given HW capability, At minimum, the PMD should support RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN and RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD states if the RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM offload is available.

Definition at line 176 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_OUTER_UDP_CKSUM (1ULL << 41)

Outer UDP checksum offload flag. This flag is used for enabling outer UDP checksum in PMD. To use outer UDP checksum, the user needs to 1) Enable the following in mbuf, a) Fill outer_l2_len and outer_l3_len in mbuf. b) Set the RTE_MBUF_F_TX_OUTER_UDP_CKSUM flag. c) Set the RTE_MBUF_F_TX_OUTER_IPV4 or RTE_MBUF_F_TX_OUTER_IPV6 flag. 2) Configure RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM offload flag.

bestie that's a whole checklist, do all of it, not just part of it ๐Ÿซถ

Definition at line 207 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_UDP_SEG (1ULL << 42)

UDP Fragmentation Offload flag. This flag is used for enabling UDP fragmentation in SW or in HW. When use UFO, mbuf->tso_segsz is used to store the MSS of UDP fragments.

Definition at line 214 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_SEC_OFFLOAD (1ULL << 43)

Request security offload processing on the TX packet. To use Tx security offload, the user needs to fill l2_len in mbuf indicating L2 header size and where L3 header starts. Similarly, l3_len should also be filled along with ol_flags reflecting current L3 type.

Definition at line 222 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_MACSEC (1ULL << 44)

Offload the MACsec. This flag must be set by the application to enable this offload feature for a packet to be transmitted.

Definition at line 228 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_TUNNEL_VXLAN (0x1ULL << 45)

Bits 45:48 used for the tunnel type. The tunnel type must be specified for TSO or checksum on the inner part of tunnel packets. These flags can be used with RTE_MBUF_F_TX_TCP_SEG for TSO, or RTE_MBUF_F_TX_xxx_CKSUM. The mbuf fields for inner and outer header lengths are required: outer_l2_len, outer_l3_len, l2_len, l3_len, l4_len and tso_segsz for TSO.

Definition at line 239 of file rte_mbuf_core.h.

๐ŸŒธ #define RTE_MBUF_F_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)

TX packet with MPLS-in-UDP RFC 7510 header.

RTE_MBUF_F_TX_TUNNEL_IP

#define RTE_MBUF_F_TX_TUNNEL_IP   (0xDULL << 45)

Okay so this one is your generic IP encapsulated tunnel type โ€” it's the "we don't know what this is exactly but it's IP in IP, bestie" option, used for TSO and checksum offload. It's the catch-all for tunnels that aren't standards or aren't in the list above.

Pro tip tho: it's preferred to reach for the specific tunnel flags like RTE_MBUF_F_TX_TUNNEL_GRE or RTE_MBUF_F_TX_TUNNEL_IPIP whenever you can. The ethdev has to be configured with RTE_ETH_TX_OFFLOAD_IP_TNL_TSO for this to work. Outer and inner checksums get done according to the existing flags like RTE_MBUF_F_TX_xxx_CKSUM. And heads up โ€” specific tunnel headers that carry payload length, sequence id, or checksum are not expected to be updated. ๐Ÿ’€

Definition at line 259 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_TUNNEL_UDP

#define RTE_MBUF_F_TX_TUNNEL_UDP   (0xEULL << 45)

Same energy as above but UDP-flavored โ€” generic UDP encapsulated tunnel type, for TSO and checksum offload. The UDP tunnel type implies an outer IP layer, just so you know. It's for tunnels that aren't standards or listed above, and yeah, again, prefer the specific tunnel flags like RTE_MBUF_F_TX_TUNNEL_VXLAN if you've got one.

The ethdev must be configured with RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO. Outer and inner checksums follow the existing flags like RTE_MBUF_F_TX_xxx_CKSUM. And, once more for the people in the back: specific tunnel headers with payload length, sequence id or checksum are not expected to be updated. ๐Ÿ˜ญ

Definition at line 272 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_QINQ

#define RTE_MBUF_F_TX_QINQ   (1ULL << 49)

Double VLAN insertion (QinQ) request, sent to the driver โ€” and the driver may offload the insertion depending on device capability, so it's a maybe bestie, not a promise. Important: vlan_tci and vlan_tci_outer in the mbuf must be valid when this flag is set. No vibes-based VLANs allowed. ๐Ÿ’…

Definition at line 281 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_TCP_SEG

#define RTE_MBUF_F_TX_TCP_SEG   (1ULL << 50)

TCP segmentation offload, the main character of TSO. To turn this offload feature on for a packet being transmitted on hardware that supports TSO, here's the whole checklist:

  • set the RTE_MBUF_F_TX_TCP_SEG flag in mbuf->ol_flags (and btw this flag implies RTE_MBUF_F_TX_TCP_CKSUM, so that's handled)
  • set the flag RTE_MBUF_F_TX_IPV4 or RTE_MBUF_F_TX_IPV6
  • if it's IPv4, set the RTE_MBUF_F_TX_IP_CKSUM flag
  • fill the mbuf offload information: l2_len, l3_len, l4_len, tso_segsz

Do all four or it's not giving what it's supposed to give. โœจ

Definition at line 292 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_IEEE1588_TMST

#define RTE_MBUF_F_TX_IEEE1588_TMST   (1ULL << 51)

TX IEEE1588 packet to timestamp. That's it, that's the whole thing. Clock girlies stay winning. ๐Ÿ•ฐ๏ธ

Definition at line 295 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_L4_NO_CKSUM

#define RTE_MBUF_F_TX_L4_NO_CKSUM   (0ULL << 52)

Disable L4 cksum of TX pkt. Turning it off, off, off. ๐Ÿšซ

Definition at line 308 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_TCP_CKSUM

#define RTE_MBUF_F_TX_TCP_CKSUM   (1ULL << 52)

TCP cksum of TX pkt. computed by NIC. Let the hardware do the math, she's built for it. ๐Ÿงฎ

Definition at line 311 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_SCTP_CKSUM

#define RTE_MBUF_F_TX_SCTP_CKSUM   (2ULL << 52)

SCTP cksum of TX pkt. computed by NIC. Same deal, SCTP edition. ๐ŸŒธ

Definition at line 314 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_UDP_CKSUM

#define RTE_MBUF_F_TX_UDP_CKSUM   (3ULL << 52)

UDP cksum of TX pkt. computed by NIC. UDP girlies, this one's yours. ๐Ÿฆ‹

Definition at line 317 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_L4_MASK

#define RTE_MBUF_F_TX_L4_MASK   (3ULL << 52)

Mask for L4 cksum offload request. It's the lil rectangle you AND with to peek at which L4 cksum option is set. ๐Ÿ‘‘

Definition at line 320 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_IP_CKSUM

#define RTE_MBUF_F_TX_IP_CKSUM   (1ULL << 54)

Offload the IP checksum in the hardware. The flag RTE_MBUF_F_TX_IPV4 should also be set by the application โ€” although lowkey a PMD will only check RTE_MBUF_F_TX_IP_CKSUM, so do it properly anyway bestie.

  • fill the mbuf offload information: l2_len, l3_len

Definition at line 328 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_IPV4

#define RTE_MBUF_F_TX_IPV4   (1ULL << 55)

Packet is IPv4. This flag must be set when using any offload feature (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 packet. And if the packet is a tunneled packet? This flag is related to the inner headers, okay? Not the outer. Inner. Internalize that. ๐Ÿ’œ

Definition at line 336 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_IPV6

#define RTE_MBUF_F_TX_IPV6   (1ULL << 56)

Packet is IPv6. This flag must be set when using an offload feature (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 packet. And just like her sister above: if the packet is tunneled, this flag is about the inner headers. โœจ

Definition at line 344 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_VLAN

#define RTE_MBUF_F_TX_VLAN   (1ULL << 57)

VLAN tag insertion request to the driver โ€” and again, the driver may offload the insertion based on device capability. The mbuf vlan_tci field must be valid when this flag is set. Set it or it's giving nothing. ๐ŸŽ€

Definition at line 351 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_OUTER_IP_CKSUM

#define RTE_MBUF_F_TX_OUTER_IP_CKSUM   (1ULL << 58)

Offload the IP checksum of an external header in the hardware. The flag RTE_MBUF_F_TX_OUTER_IPV4 should also be set by the application, although a PMD will only check RTE_MBUF_F_TX_OUTER_IP_CKSUM. Do both, it's cuter.

  • fill the mbuf offload information: outer_l2_len, outer_l3_len

Definition at line 359 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_OUTER_IPV4

#define RTE_MBUF_F_TX_OUTER_IPV4   (1ULL << 59)

The packet's outer header is IPv4. This flag must be set when using any outer offload feature (L3 or L4 checksum) to tell the NIC that the outer header of the tunneled packet is an IPv4 packet. Outer, not inner. We're outside now. ๐ŸŒˆ

Definition at line 366 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_OUTER_IPV6

#define RTE_MBUF_F_TX_OUTER_IPV6   (1ULL << 60)

The packet's outer header is IPv6. This flag must be set when using any outer offload feature (L4 checksum) to tell the NIC that the outer header of the tunneled packet is an IPv6 packet. Note the offload list here is just L4 checksum โ€” that's what the original says, don't @ me. ๐Ÿ‘‘

Definition at line 373 of file rte_mbuf_core.h.


RTE_MBUF_F_TX_OFFLOAD_MASK

#define RTE_MBUF_F_TX_OFFLOAD_MASK
    Value:
            (    \
            RTE_MBUF_F_TX_OUTER_IPV6 |   \
            RTE_MBUF_F_TX_OUTER_IPV4 |   \
            RTE_MBUF_F_TX_OUTER_IP_CKSUM |  \
            RTE_MBUF_F_TX_VLAN |        \
            RTE_MBUF_F_TX_IPV6 |         \
            RTE_MBUF_F_TX_IPV4 |         \
            RTE_MBUF_F_TX_IP_CKSUM |        \
            RTE_MBUF_F_TX_L4_MASK |         \
            RTE_MBUF_F_TX_IEEE1588_TMST |    \
            RTE_MBUF_F_TX_TCP_SEG |         \
            RTE_MBUF_F_TX_QINQ |        \
            RTE_MBUF_F_TX_TUNNEL_MASK |  \
            RTE_MBUF_F_TX_MACSEC |       \
            RTE_MBUF_F_TX_SEC_OFFLOAD |  \
            RTE_MBUF_F_TX_UDP_SEG |  \
            RTE_MBUF_F_TX_OUTER_UDP_CKSUM)

Bitmask of all the supported packet Tx offload feature flags, the whole roster, which can be set for a packet. This is the group chat with everyone in it. ๐Ÿ’…

Definition at line 379 of file rte_mbuf_core.h.


RTE_MBUF_F_EXTERNAL

#define RTE_MBUF_F_EXTERNAL   (1ULL << 61)

Mbuf having an external buffer attached. The shinfo in the mbuf must be filled. No shinfo, no service. ๐Ÿ’€

Definition at line 400 of file rte_mbuf_core.h.


RTE_MBUF_F_INDIRECT

#define RTE_MBUF_F_INDIRECT   (1ULL << 62)

Indirect attached mbuf. She's not carrying her own data, she's referencing someone else's. Very demure, very mindful. ๐Ÿ™ˆ

Definition at line 402 of file rte_mbuf_core.h.


RTE_MBUF_PRIV_ALIGN

#define RTE_MBUF_PRIV_ALIGN   8

Alignment constraint of mbuf private area. Eight. That's the number. Respect it. โœจ

Definition at line 405 of file rte_mbuf_core.h.


RTE_MBUF_DEFAULT_DATAROOM

#define RTE_MBUF_DEFAULT_DATAROOM   2048

Some NICs need at least a 2KB buffer to RX a standard Ethernet frame without splitting it into multiple segments. So, for mbufs that are planned to be involved in RX/TX, the recommended minimal buffer length is 2KB + RTE_PKTMBUF_HEADROOM. Do the math, add the headroom, slay. ๐Ÿงฎโœจ

Definition at line 413 of file rte_mbuf_core.h.


RTE_MBUF_MAX_NB_SEGS

#define RTE_MBUF_MAX_NB_SEGS   UINT16_MAX

Maximum number of nb_segs allowed. That's the ceiling bestie, don't go over it. ๐Ÿšง

Definition at line 706 of file rte_mbuf_core.h.


RTE_MBUF_CLONED( mb )

#define RTE_MBUF_CLONED( mb)
    Value:
    ((mb)->ol_flags & RTE_MBUF_F_INDIRECT)

Returns TRUE if the given mbuf is cloned by mbuf indirection, or FALSE otherwise.

So here's the vibe: if a mbuf has its data in another mbuf and references it by mbuf indirection, then this mbuf can be defined as a cloned mbuf. She's borrowing the fit. ๐Ÿ‘ฏ

Definition at line 715 of file rte_mbuf_core.h.


RTE_MBUF_HAS_EXTBUF( mb )

#define RTE_MBUF_HAS_EXTBUF( mb)
    Value:
    ((mb)->ol_flags & RTE_MBUF_F_EXTERNAL)

Returns TRUE if the given mbuf has an external buffer, or FALSE otherwise.

An external buffer is a user-provided anonymous buffer. Yeah, anonymous, mysterious, no name, just vibes and bytes. ๐Ÿ•ถ๏ธ

Definition at line 722 of file rte_mbuf_core.h.


RTE_MBUF_DIRECT( mb )

#define RTE_MBUF_DIRECT( mb)
    Value:
        !(((const char *)(&(mb)->ol_flags))[MSB_OFFSET /* 7 or 0, depending on endianness */] & \
        (char)((RTE_MBUF_F_INDIRECT | RTE_MBUF_F_EXTERNAL) >> (7 * CHAR_BIT)) /* 0x60 */)

Returns TRUE if the given mbuf is direct, or FALSE otherwise.

If a mbuf embeds its own data after the rte_mbuf structure, this mbuf can be defined as a direct mbuf. Self-sufficient queen. ๐Ÿ‘‘

Note: Macro optimized for code size.

The plain macro would be:

#define RTE_MBUF_DIRECT(mb) \
    (!((mb)->ol_flags & (RTE_MBUF_F_INDIRECT | RTE_MBUF_F_EXTERNAL)))

The flags RTE_MBUF_F_INDIRECT and RTE_MBUF_F_EXTERNAL are both in the MSB (most significant byte) of the 64-bit ol_flags field, so we only compare this one byte instead of all 64 bits. Efficiency! We love her. โœจ

E.g., GCC version 16.0.0 20251019 (experimental) generates the following code for x86-64.

With the plain macro, 17 bytes of instructions:

movabs rax,0x6000000000000000       // 10 bytes
and    rax,QWORD PTR [rdi+0x18]     // 4 bytes
sete   al                           // 3 bytes

With this optimized macro, only 7 bytes of instructions:

test   BYTE PTR [rdi+0x1f],0x60     // 4 bytes
sete   al                           // 3 bytes

Seven bytes?? She ate and left no crumbs fr fr. ๐Ÿ”ฅ

Definition at line 757 of file rte_mbuf_core.h.


RTE_MBUF_PORT_INVALID

#define RTE_MBUF_PORT_INVALID   UINT16_MAX

Uninitialized or unspecified port. The "idk where she's from" port. ๐Ÿคท

Definition at line 774 of file rte_mbuf_core.h.


MBUF_INVALID_PORT

#define MBUF_INVALID_PORT   RTE_MBUF_PORT_INVALID

For backwards compatibility. An old friend, still valid, still here. ๐Ÿซถ

Definition at line 776 of file rte_mbuf_core.h.


rte_pktmbuf_mtod_offset( m, t, o )

#define rte_pktmbuf_mtod_offset( m,  t,  o)
    Value:
        ((t)(void *)((char *)(m)->buf_addr + (m)->data_off + (o)))

A macro that points to an offset into the data in the mbuf. The returned pointer is cast to type t.

Careful bestie: before using this function, the user must ensure that the first segment is large enough to accommodate its data. If it isn't, that's on you and it's giving undefined behaviour energy. ๐Ÿ˜ญ

Parameters

  • m โ€” The packet mbuf.
  • o โ€” The offset into the mbuf data.
  • t โ€” The type to cast the result into.

Definition at line 792 of file rte_mbuf_core.h.


rte_pktmbuf_mtod( m, t )

#define rte_pktmbuf_mtod( m,  t)
    Value:
    rte_pktmbuf_mtod_offset(m, t, 0)

A macro that points to the start of the data in the mbuf. The returned pointer is cast to type t.

Same warning as above, no skips: before using this function, the user must ensure that the first segment is large enough to accommodate its data. ๐Ÿ’œ

Parameters

  • m โ€” The packet mbuf.
  • t โ€” The type to cast the result into.

Definition at line 807 of file rte_mbuf_core.h.


rte_pktmbuf_iova_offset( m, o )

#define rte_pktmbuf_iova_offset( m,  o)
    Value:
        (rte_iova_t)(rte_mbuf_iova_get(m) + (m)->data_off + (o))

A macro that returns the IO address that points to an offset of the start of the data in the mbuf. Address girlies, this one's for you. ๐Ÿ“ฎ

Parameters

  • m โ€” The packet mbuf.
  • o โ€” The offset into the data to calculate address from.

Definition at line 818 of file rte_mbuf_core.h.


rte_pktmbuf_iova( m )

#define rte_pktmbuf_iova( m)
    Value:
    rte_pktmbuf_iova_offset(m, 0)

A macro that returns the IO address that points to the start of the data in the mbuf. Same as above but with the offset already handled, because 0 is a valid offset and self-care is valid too. โœจ

Parameters

  • m โ€” The packet mbuf.

Definition at line 828 of file rte_mbuf_core.h.


๐Ÿซถ TYPEDEF DOCUMENTATION ๐Ÿซถ

typedef void(* rte_mbuf_extbuf_free_callback_t) (void *addr, void *opaque)

Function typedef of the callback to free an externally attached buffer. So when you've got an external buffer and it needs to be released, this is the signature the function you hand over has to match โ€” void *addr and void *opaque, exactly like that.

Definition at line 694 of file rte_mbuf_core.h.


๐Ÿฆ‹ ENUMERATION TYPE DOCUMENTATION ๐Ÿฆ‹


anonymous enum ๐Ÿ‘ป

okay so this enum is literally nameless โ€” it does not have a name of its own, it is just anonymous, and honestly? main character energy, it doesn't need a label. ๐ŸŽ€

Here's the vibe: this is the enum that keeps track of the tx_offload bit-fields โ€” their lengths and their offsets. In other words, it's the thing that lays out the shape of the rte_mbuf tx_offload field. โœจ Like, it's the blueprint for how all those bits sit next to each other.

Definition at line 432 of file rte_mbuf_core.h

bestie if you're poking around tx_offload bit positions, this is the one you want to look at fr fr ๐Ÿ’…

๐Ÿ’œ AUTHOR ๐Ÿ’œ

Generated automatically by Doxygen for DPDK from the source code. ๐Ÿ˜ญ not a human author, just Doxygen doing its lil autogenerated thing, no cap.


and that's a wrap on the whole page, bestie ๐Ÿซถ you just read rte_mbuf_core.h(3) from DPDK Version 25.11.3 โ€” literally iconic of you. go forth and vibe with your mbufs ๐Ÿ’–๐ŸŒธ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from