rte_mbuf_core.h(3)
πΈ NAME πΈ
rte_mbuf_core.h(3) β straight from the Library Functions Manual, bestie. This is the page for the core mbuf header, and it's giving foundational DPDK energy. π
β¨ SYNOPSIS β¨
okay so first up, the includes are literally:
#include <stdalign.h>
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_stdatomic.h>
π§ Data Structures π§
the structs in question are:
struct rte_mbuf_sched
struct rte_mbuf
struct rte_mbuf_ext_shared_info
π Macros π
every macro, no skips, periodt:
#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 π¦
typedef void(* rte_mbuf_extbuf_free_callback_t) (void *addr, void *opaque)
π Enumerations π
there's literally just this:
enum
π«Ά Detailed Description π«Ά
This file contains definition of RTE mbuf structure itself, packet offload flags and some related macros. For majority of DPDK entities, it is not recommended to include this file directly β use #include <rte_mbuf.h> instead. π
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.
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. the states are:
RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksumRTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrongRTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is validRTE_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 states are:
RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN: no information about the RX L4 checksumRTE_MBUF_F_RX_L4_CKSUM_BAD: the L4 checksum in the packet is wrongRTE_MBUF_F_RX_L4_CKSUM_GOOD: the L4 checksum in the packet is validRTE_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_STRIPPEDandRTE_MBUF_F_RX_VLAN_STRIPPEDare set, the 2 VLANs have been stripped by the hardware and their TCIs are saved inmbuf->vlan_tci(inner) andmbuf->vlan_tci_outer(outer). - If
RTE_MBUF_F_RX_QINQ_STRIPPEDis set andRTE_MBUF_F_RX_VLAN_STRIPPEDis unset, only the outer VLAN is removed from packet data, but both tci are saved inmbuf->vlan_tci(inner) andmbuf->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.
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 are:
RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN: no info about the outer RX L4 checksumRTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD: the outer L4 checksum in the packet is wrongRTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD: the outer L4 checksum in the packet is validRTE_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.
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 the generic IP encapsulated tunnel type, and it exists for TSO and checksum offload bestie β¨ It's the "I'm a tunnel but I'm not gonna tell you which one" flag β you can literally use it for tunnels that aren't standards or that just aren't listed above. But lowkey? Use the specific tunnel flags like RTE_MBUF_F_TX_TUNNEL_GRE or RTE_MBUF_F_TX_TUNNEL_IPIP if you can, it's preferred. The ethdev has to be configured with RTE_ETH_TX_OFFLOAD_IP_TNL_TSO. 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 contain payload length, sequence id or checksum are not expected to be updated.
(defined at line 259... no wait, line 244 of rte_mbuf_core.h π
)
π RTE_MBUF_F_TX_TUNNEL_UDP
#define RTE_MBUF_F_TX_TUNNEL_UDP (0xEULL << 45)
the generic UDP encapsulated tunnel type, same deal β TSO and checksum offload, no cap π The UDP tunnel type implies an outer IP layer, which is the little detail that matters. Again: usable for tunnels that aren't standards or aren't listed above, but please prefer the specific ones like RTE_MBUF_F_TX_TUNNEL_VXLAN when you can. 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 same warning, bestie: specific tunnel headers that contain payload length, sequence id or checksum are not expected to be updated.
(line 272 of rte_mbuf_core.h π)
π RTE_MBUF_F_TX_QINQ
#define RTE_MBUF_F_TX_QINQ (1ULL << 49)
double VLAN insertion request (QinQ) that you hand to the driver β and the driver may offload the insertion based on device capability, so likeβ¦ it's a request, not a promise π₯ When this flag is set, the mbuf's vlan_tci & vlan_tci_outer must be valid. No valid TCI, no insertion, periodt.
(line 281 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_TCP_SEG
#define RTE_MBUF_F_TX_TCP_SEG (1ULL << 50)
TCP segmentation offload!! the icon π To enable this feature for a packet to be transmitted on hardware that supports TSO, you gotta do the whole little ritual:
- set the
RTE_MBUF_F_TX_TCP_SEGflag inmbuf->ol_flags(and yes, this flag impliesRTE_MBUF_F_TX_TCP_CKSUM, it comes as a package deal) - set the flag
RTE_MBUF_F_TX_IPV4orRTE_MBUF_F_TX_IPV6 - if it's IPv4, set the
RTE_MBUF_F_TX_IP_CKSUMflag - fill the mbuf offload information:
l2_len,l3_len,l4_len,tso_segsz
(line 292 of 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 vibe β°β¨
(line 295 of 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. it's the off switch, and it's giving absolutely nothing π (which is the point)
(line 308 of 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 bestie, she's built for it π
(line 311 of 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. yes SCTP gets a lane too, we love inclusivity π
(line 314 of 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. the people's checksum π«Ά
(line 317 of 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. this is the little net that catches all four of the L4 values above (yes, even the 0ULL one) π
(line 320 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_IP_CKSUM
#define RTE_MBUF_F_TX_IP_CKSUM (1ULL << 54)
offload the IP checksum to the hardware β¨ The flag RTE_MBUF_F_TX_IPV4 should also be set by the application β although plot twist, a PMD will only check RTE_MBUF_F_TX_IP_CKSUM, so set both, be a good citizen π
- fill the mbuf offload information:
l2_len,l3_len
(line 328 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_IPV4
#define RTE_MBUF_F_TX_IPV4 (1ULL << 55)
Packet is IPv4. You must set this flag when using any offload feature (TSO, L3 or L4 checksum) so the NIC knows the packet is an IPv4 packet. And if the packet is a tunneled packet? this flag is related to the inner headers, iykyk π
(line 336 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_IPV6
#define RTE_MBUF_F_TX_IPV6 (1ULL << 56)
Packet is IPv6 πΈ Must be set when using an offload feature (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 packet. And if the packet is tunneled, this flag is related to the inner headers. same rule, different address length bestie β¨
(line 344 of 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 the driver may offload the insertion based on device capability (we've been here before, it's a request not a contract π
). The mbuf vlan_tci field must be valid when this flag is set.
(line 351 of 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 π₯ So this is the outer one, the one wearing the trench coat over the tunnel. 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.
- fill the mbuf offload information:
outer_l2_len,outer_l3_len
(line 359 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_OUTER_IPV4
#define RTE_MBUF_F_TX_OUTER_IPV4 (1ULL << 59)
Packet outer header is IPv4. 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 β inner, don't mix them up bestie π
(line 366 of rte_mbuf_core.h)
π RTE_MBUF_F_TX_OUTER_IPV6
#define RTE_MBUF_F_TX_OUTER_IPV6 (1ULL << 60)
Packet outer header is IPv6. Set it 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 list is shorter here β L4 checksum only, no L3 in the parenthetical, that's straight from the source π
(line 373 of 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)
the bitmask of all supported packet Tx offload features flags, which can be set for packet. this is the master list, the VIP section, the whole guest list β if a Tx offload flag exists and is supported, it's in here π
(line 379 of rte_mbuf_core.h π)
π RTE_MBUF_F_EXTERNAL
#define RTE_MBUF_F_EXTERNAL (1ULL << 61)
Mbuf having an external buffer attached π¦ When this is set, shinfo in the mbuf must be filled. no shinfo, no deal.
(line 400 of rte_mbuf_core.h)
π RTE_MBUF_F_INDIRECT
#define RTE_MBUF_F_INDIRECT (1ULL << 62)
Indirect attached mbuf. the mbuf that's like "my data lives at my friend's house" π β¨
(line 402 of rte_mbuf_core.h)
π RTE_MBUF_PRIV_ALIGN
#define RTE_MBUF_PRIV_ALIGN 8
alignment constraint of the mbuf private area. that's 8, memorize it, respect it π
(line 405 of rte_mbuf_core.h)
π RTE_MBUF_DEFAULT_DATAROOM
#define RTE_MBUF_DEFAULT_DATAROOM 2048
okay so some NICs need at least 2KB of 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. write that down bestie, it's a whole formula.
(line 413 of 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 UINT16_MAX, the ceiling, don't go past it fr fr π«
(line 706 of rte_mbuf_core.h)
π RTE_MBUF_CLONED
#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 β¨ And the definition of cloned here: if a mbuf has its data in another mbuf and references it by mbuf indirection, this mbuf can be defined as a cloned mbuf. it's giving "I don't own my data, I'm just borrowing it" π«Ά
(line 715 of rte_mbuf_core.h)
π RTE_MBUF_HAS_EXTBUF
#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. And an external buffer is a user-provided anonymous buffer β like, it came from you, it's got no name, and the mbuf is just holding it π
(line 722 of rte_mbuf_core.h)
π RTE_MBUF_DIRECT
#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. main character mbuf, carries its own stuff, no borrowing.
Note: this macro is optimized for code size. bestie it is so optimized π
The plain macro would be:
#define RTE_MBUF_DIRECT(mb) \
(!((mb)->ol_flags & (RTE_MBUF_F_INDIRECT | RTE_MBUF_F_EXTERNAL)))
So here's the lore: 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. iconic efficiency honestly π
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
17 bytes β 7 bytes. she ate and left no crumbs π₯
(line 757 of rte_mbuf_core.h)
π RTE_MBUF_PORT_INVALID
#define RTE_MBUF_PORT_INVALID UINT16_MAX
uninitialized or unspecified port. it's the "no port yet" placeholder, the blank in your notes app before you remember who you are πΈ
(line 774 of rte_mbuf_core.h)
π MBUF_INVALID_PORT
#define MBUF_INVALID_PORT RTE_MBUF_PORT_INVALID
kept around for backwards compatibility π«Ά same value, older name, we still love her.
(line 776 of rte_mbuf_core.h)
π rte_pktmbuf_mtod_offset
#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. But listen β before using this function, the user must ensure that the first segment is large enough to accommodate its data. no vibes-based bounds checking here, that's on you π
Parameters:
- m β the packet mbuf.
- o β the offset into the mbuf data.
- t β the type to cast the result into.
(line 792 of rte_mbuf_core.h)
π rte_pktmbuf_mtod
#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. And yeah, same rule as her sister: 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.
(line 807 of rte_mbuf_core.h)
π rte_pktmbuf_iova_offset
#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 π same energy as the mtod crew but this one gives you the IO address instead of a pointer.
Parameters:
- m β the packet mbuf.
- o β the offset into the data to calculate address from.
(line 818 of rte_mbuf_core.h)
π rte_pktmbuf_iova
#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 π the offset-zero queen.
Parameters:
- m β the packet mbuf.
(line 828 of rte_mbuf_core.h)
π§ Typedef Documentation π§
typedef void(* rte_mbuf_extbuf_free_callback_t) (void *addr, void *opaque)
function typedef of the callback used to free an externally attached buffer π¦ so when that external buffer (the user-provided anonymous one from RTE_MBUF_HAS_EXTBUF) needs to go away, this is the signature of the function that does the cleanup: it takes a void *addr and a void *opaque, and returns void. that's the whole shape of it bestie β¨
(line 694 of rte_mbuf_core.h)
πΈ Enumeration Type Documentation πΈ
anonymous enum
enum for the tx_offload bit-fields lengths and offsets. it defines the layout of the rte_mbuf tx_offload field π i.e. this is the little map that says which bits of tx_offload mean what β the floor plan of the whole offload situation, no cap π
(line 432 of rte_mbuf_core.h)
β¨ AUTHOR β¨
Ok so plot twist bestie: nobody actually wrote this page by hand π It's literally
Generated automatically by Doxygen for DPDK from the source code.
That's it, that's the author. No mysterious genius, no tortured poet in a hoodie β just Doxygen doing its little robot thing, pulling the docs straight out of the DPDK source code so everything stays in sync with what the code actually says. Honestly? Iconic behavior. Zero ghostwriting scandals, zero "the docs are lying again" energy π
So if you spot something in here, blame the source code β Doxygen is just the messenger π§
and that's a wrap on rte_mbuf_core.h(3)!! π You made it all the way to the end, so proud of you fr fr π«Ά Go forth and slay those mbufs π
Cute little sign-off, courtesy of the footer: this page came to you from DPDK, version 26.03.0, and it's the man page for rte_mbuf_core.h(3). Version number and all, no cap β¨π¦
π¦ where this page comes from
- nixos 26.05: dpdk 26.03
- nixpkgs unstable: dpdk 26.03
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms