rte_mbuf.h(3)

๐Ÿ“ฆ version 26.03, in nixos 26.05, nixpkgs unstable

๐Ÿ’– rte_mbuf.h(3) โ€” Library Functions Manual ๐Ÿ’–

okay bestie, this is the RTE Mbuf page and it is literally iconic ๐Ÿ’… it's giving packet-buffer main character energy, and I'm keeping every single name, type, macro, and include exactly where it belongs โ€” no cap. Buckle up ๐Ÿฆ‹


๐ŸŒธ NAME ๐ŸŒธ

rte_mbuf.h โ€” that's the name, periodt ๐Ÿ’–


โœจ SYNOPSIS โœจ

the includes are exactly this, bestie, no edits, no vibes-based renaming:

#include <stdbool.h>
#include <stdint.h>
#include <rte_common.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_prefetch.h>
#include <rte_branch_prediction.h>
#include <rte_mbuf_ptype.h>
#include <rte_mbuf_core.h>
#include <rte_mbuf_history.h>

๐ŸŽ€ Data Structures ๐ŸŽ€

the struct cast is:

  • struct rte_pktmbuf_pool_private
  • struct rte_pktmbuf_extmem

๐Ÿฆ‹ Macros ๐Ÿฆ‹

macro squad, assembled exactly, no skips ๐Ÿซถ

#define RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF   (1 << 0)
#define RTE_MBUF_HAS_PINNED_EXTBUF(mb)
#define __rte_mbuf_raw_sanity_check_mp(m,  mp)
#define __rte_mbuf_sanity_check(m,  is_h)
#define RTE_MBUF_PREFETCH_TO_FREE(m)
#define __rte_mbuf_raw_sanity_check(m)
#define MBUF_RAW_ALLOC_CHECK(m)
#define rte_pktmbuf_detach_extbuf(m)
#define rte_pktmbuf_pkt_len(m)
#define rte_pktmbuf_data_len(m)

๐Ÿ’… Functions ๐Ÿ’…

okay so this is the whole function lineup โ€” every single signature is here, exactly, because we do not ghost a single one ๐Ÿ˜ญโœจ

const char * rte_get_rx_ol_flag_name (uint64_t mask)
int rte_get_rx_ol_flag_list (uint64_t mask, char *buf, size_t buflen)
const char * rte_get_tx_ol_flag_name (uint64_t mask)
int rte_get_tx_ol_flag_list (uint64_t mask, char *buf, size_t buflen)
static void rte_mbuf_prefetch_part1 (struct rte_mbuf *m)
static void rte_mbuf_prefetch_part2 (struct rte_mbuf *m)
static uint16_t rte_pktmbuf_priv_size (struct rte_mempool *mp)
static rte_iova_t rte_mbuf_iova_get (const struct rte_mbuf *m)
static void rte_mbuf_iova_set (struct rte_mbuf *m, rte_iova_t iova)
static rte_iova_t rte_mbuf_data_iova (const struct rte_mbuf *mb)
static rte_iova_t rte_mbuf_data_iova_default (const struct rte_mbuf *mb)
static struct rte_mbuf * rte_mbuf_from_indirect (struct rte_mbuf *mi)
static char * rte_mbuf_buf_addr (struct rte_mbuf *mb, struct rte_mempool *mp)
static char * rte_mbuf_data_addr_default (struct rte_mbuf *mb)
static char * rte_mbuf_to_baddr (struct rte_mbuf *md)
static void * rte_mbuf_to_priv (struct rte_mbuf *m)
static uint32_t rte_pktmbuf_priv_flags (struct rte_mempool *mp)
static uint16_t rte_mbuf_refcnt_update (struct rte_mbuf *m, int16_t value)
static uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m)
static void rte_mbuf_refcnt_set (struct rte_mbuf *m, uint16_t new_value)
static uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo)
static void rte_mbuf_ext_refcnt_set (struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value)
static uint16_t rte_mbuf_ext_refcnt_update (struct rte_mbuf_ext_shared_info *shinfo, int16_t value)
void rte_mbuf_raw_sanity_check (const struct rte_mbuf *m, const struct rte_mempool *mp)
int rte_mbuf_raw_check (const struct rte_mbuf *m, const struct rte_mempool *mp, const char **reason)
void rte_mbuf_sanity_check (const struct rte_mbuf *m, int is_header)
int rte_mbuf_check (const struct rte_mbuf *m, int is_header, const char **reason)
static struct rte_mbuf * rte_mbuf_raw_alloc (struct rte_mempool *mp)
static __rte_always_inline int rte_mbuf_raw_alloc_bulk (struct rte_mempool *mp, struct rte_mbuf **mbufs, unsigned int count)
static __rte_always_inline void rte_mbuf_raw_free (struct rte_mbuf *m)
static __rte_always_inline void rte_mbuf_raw_free_bulk (struct rte_mempool *mp, struct rte_mbuf **mbufs, unsigned int count)
void rte_pktmbuf_init (struct rte_mempool *mp, void *opaque_arg, void *m, unsigned i)
void rte_pktmbuf_pool_init (struct rte_mempool *mp, void *opaque_arg)
struct rte_mempool * rte_pktmbuf_pool_create (const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)
struct rte_mempool * rte_pktmbuf_pool_create_by_ops (const char *name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id, const char *ops_name)
struct rte_mempool * rte_pktmbuf_pool_create_extbuf (const char *name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id, const struct rte_pktmbuf_extmem *ext_mem, unsigned int ext_num)
static uint16_t rte_pktmbuf_data_room_size (struct rte_mempool *mp)
static void rte_pktmbuf_reset_headroom (struct rte_mbuf *m)
static void rte_mbuf_raw_reset_bulk (struct rte_mempool *mp, struct rte_mbuf **mbufs, unsigned int count)
static void rte_pktmbuf_reset (struct rte_mbuf *m)
static struct rte_mbuf * rte_pktmbuf_alloc (struct rte_mempool *mp)
static int rte_pktmbuf_alloc_bulk (struct rte_mempool *pool, struct rte_mbuf **mbufs, unsigned count)
static struct rte_mbuf_ext_shared_info * rte_pktmbuf_ext_shinfo_init_helper (void *buf_addr, uint16_t *buf_len, rte_mbuf_extbuf_free_callback_t free_cb, void *fcb_opaque)
static void rte_pktmbuf_attach_extbuf (struct rte_mbuf *m, void *buf_addr, rte_iova_t buf_iova, uint16_t buf_len, struct rte_mbuf_ext_shared_info *shinfo)
static void rte_mbuf_dynfield_copy (struct rte_mbuf *mdst, const struct rte_mbuf *msrc)
static void rte_pktmbuf_attach (struct rte_mbuf *mi, struct rte_mbuf *m)
static void rte_pktmbuf_detach (struct rte_mbuf *m)
static __rte_always_inline struct rte_mbuf * rte_pktmbuf_prefree_seg (struct rte_mbuf *m)
static __rte_always_inline void rte_pktmbuf_free_seg (struct rte_mbuf *m)
static void rte_pktmbuf_free (struct rte_mbuf *m)
void rte_pktmbuf_free_bulk (struct rte_mbuf **mbufs, unsigned int count)
struct rte_mbuf * rte_pktmbuf_clone (struct rte_mbuf *md, struct rte_mempool *mp)
struct rte_mbuf * rte_pktmbuf_copy (const struct rte_mbuf *m, struct rte_mempool *mp, uint32_t offset, uint32_t length)
static void rte_pktmbuf_refcnt_update (struct rte_mbuf *m, int16_t v)
static uint16_t rte_pktmbuf_headroom (const struct rte_mbuf *m)
static uint16_t rte_pktmbuf_tailroom (const struct rte_mbuf *m)
static struct rte_mbuf * rte_pktmbuf_lastseg (struct rte_mbuf *m)
static char * rte_pktmbuf_prepend (struct rte_mbuf *m, uint16_t len)
static char * rte_pktmbuf_append (struct rte_mbuf *m, uint16_t len)
static char * rte_pktmbuf_adj (struct rte_mbuf *m, uint16_t len)
static int rte_pktmbuf_trim (struct rte_mbuf *m, uint16_t len)
static int rte_pktmbuf_is_contiguous (const struct rte_mbuf *m)
static const void * rte_pktmbuf_read (const struct rte_mbuf *m, uint32_t off, uint32_t len, void *buf)
static int rte_pktmbuf_chain (struct rte_mbuf *head, struct rte_mbuf *tail)
static __rte_always_inline uint64_t rte_mbuf_tx_offload (uint64_t il2, uint64_t il3, uint64_t il4, uint64_t tso, uint64_t ol3, uint64_t ol2, uint64_t unused)
static int rte_validate_tx_offload (const struct rte_mbuf *m)
static int rte_pktmbuf_linearize (struct rte_mbuf *mbuf)
void rte_pktmbuf_dump (FILE *f, const struct rte_mbuf *m, unsigned dump_len)
static uint32_t rte_mbuf_sched_queue_get (const struct rte_mbuf *m)
static uint8_t rte_mbuf_sched_traffic_class_get (const struct rte_mbuf *m)
static uint8_t rte_mbuf_sched_color_get (const struct rte_mbuf *m)
static void rte_mbuf_sched_get (const struct rte_mbuf *m, uint32_t *queue_id, uint8_t *traffic_class, uint8_t *color)
static void rte_mbuf_sched_queue_set (struct rte_mbuf *m, uint32_t queue_id)
static void rte_mbuf_sched_traffic_class_set (struct rte_mbuf *m, uint8_t traffic_class)
static void rte_mbuf_sched_color_set (struct rte_mbuf *m, uint8_t color)
static void rte_mbuf_sched_set (struct rte_mbuf *m, uint32_t queue_id, uint8_t traffic_class, uint8_t color)

๐Ÿ’– Detailed Description ๐Ÿ’–

RTE Mbuf โ€” okay so here's the tea โ˜•

The mbuf library provides the ability to create and destroy buffers that may be used by the RTE application to store message buffers. The message buffers are stored in a mempool, using the RTE mempool library. slay. โœจ

The preferred way to create a mbuf pool is to use rte_pktmbuf_pool_create(). However, in some situations, an application may want to have more control (ex: populate the pool with specific memory), in this case it is possible to use functions from rte_mempool. See how rte_pktmbuf_pool_create() is implemented for details. iykyk ๐Ÿซถ

This library provides an API to allocate/free packet mbufs, which are used to carry network packets. literally the whole point, bestie ๐ŸŒˆ

To understand the concepts of packet buffers or mbufs, you should read "TCP/IP Illustrated, Volume 2: The Implementation,Addison-Wesley, 1995, ISBN 0-201-63354-X from Richard Stevens" http://www.kohala.com/start/tcpipiv2.html ๐Ÿ“š๐Ÿ’–

Definition in file rte_mbuf.h.

๐ŸŽ€ Macro Definition Documentation ๐ŸŽ€

Ok bestie, these are the macros โ€” the little shorthand spells of the mbuf world. Every single one, no skipping ๐Ÿ’…

  • #define RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF (1 << 0) โ€” When this is set, the pktmbuf mempool will hold only mbufs with a pinned external buffer. The external buffer gets attached to the mbuf right at memory pool creation time, and it will never be detached by the mbuf free calls. fr fr, never. Also: the mbuf should not contain any room for data after the mbuf structure. โœจ

Definition at line 330 of file rte_mbuf.h.

  • #define RTE_MBUF_HAS_PINNED_EXTBUF( mb) โ€” the value is:
(rte_pktmbuf_priv_flags(mb->pool) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF)

Returns non-zero if the given mbuf has a pinned external buffer, or zero otherwise. The pinned external buffer is allocated at pool creation time and should not be freed when the mbuf is freed. The external buffer is a user-provided anonymous buffer. ๐Ÿซถ

Definition at line 339 of file rte_mbuf.h.

  • #define __rte_mbuf_raw_sanity_check_mp( m, mp) โ€” the value is:
rte_mbuf_raw_sanity_check(m, mp)

Checks the reinitialized mbuf type in debug mode. ๐Ÿ”

Definition at line 345 of file rte_mbuf.h.

  • #define __rte_mbuf_sanity_check( m, is_h) โ€” the value is:
rte_mbuf_sanity_check(m, is_h)

Checks the mbuf type in debug mode. ๐Ÿ”

Definition at line 347 of file rte_mbuf.h.

  • #define RTE_MBUF_PREFETCH_TO_FREE( m) โ€” mbuf prefetch, and the value is:
do {       \
    if ((m) != NULL)                        \
        rte_prefetch0(m);               \
} while (0)

Definition at line 514 of file rte_mbuf.h.

  • #define __rte_mbuf_raw_sanity_check( m) โ€” the value is:
__rte_mbuf_raw_sanity_check_mp(m, NULL)

This one exists for backwards compatibility. ๐Ÿซก

Definition at line 598 of file rte_mbuf.h.

  • #define MBUF_RAW_ALLOC_CHECK( m) โ€” the value is:
__rte_mbuf_raw_sanity_check_mp(m, NULL)

Also for backwards compatibility. ๐Ÿซก

Definition at line 601 of file rte_mbuf.h.

  • #define rte_pktmbuf_detach_extbuf( m) โ€” the value is:
rte_pktmbuf_detach(m)

Detaches the external buffer attached to a mbuf โ€” same as rte_pktmbuf_detach(), literally the same thing. ๐Ÿฆ‹

Parameters:

  • m โ€” the mbuf having the external buffer.

Definition at line 1219 of file rte_mbuf.h.

  • #define rte_pktmbuf_pkt_len( m) โ€” the value is:
((m)->pkt_len)

A macro that returns the length of the packet. The value can be read or assigned (yes, both, it's giving versatile ๐Ÿ‘‘).

Parameters:

  • m โ€” the packet mbuf.

Definition at line 1660 of file rte_mbuf.h.

  • #define rte_pktmbuf_data_len( m) โ€” the value is:
((m)->data_len)

A macro that returns the length of the segment. The value can be read or assigned too ๐Ÿ’–.

Parameters:

  • m โ€” the packet mbuf.

Definition at line 1670 of file rte_mbuf.h.


โœจ Function Documentation โœจ

Now the actual functions, bestie โ€” grab a snack, there's a bunch ๐Ÿ“

const char * rte_get_rx_ol_flag_name (uint64_t mask)

Gets the name of a RX offload flag. iykyk ๐ŸŽ€

Parameters:

  • mask โ€” the mask describing the flag.

Returns: the name of this flag, or NULL if it's not a valid RX flag. ๐Ÿ˜ญ (yes, NULL is the heartbreak here)

int rte_get_rx_ol_flag_list (uint64_t mask, char * buf, size_t buflen)

Dumps the whole list of RX offload flags into a buffer.

Parameters:

  • mask โ€” the mask describing the RX flags.
  • buf โ€” the output buffer.
  • buflen โ€” the length of the buffer.

Returns: 0 on success, (-1) on error. ๐Ÿ’€

const char * rte_get_tx_ol_flag_name (uint64_t mask)

Gets the name of a TX offload flag.

Parameters:

  • mask โ€” the mask describing the flag. Usually only one bit must be set. Several bits can be given if they belong to the same mask. Ex: RTE_MBUF_F_TX_L4_MASK.

Returns: the name of this flag, or NULL if it's not a valid TX flag. ๐Ÿ˜ญ

int rte_get_tx_ol_flag_list (uint64_t mask, char * buf, size_t buflen)

Dumps the list of TX offload flags in a buffer.

Parameters:

  • mask โ€” the mask describing the TX flags.
  • buf โ€” the output buffer.
  • buflen โ€” the length of the buffer.

Returns: 0 on success, (-1) on error. ๐Ÿ’€

void rte_mbuf_prefetch_part1 (struct rte_mbuf * m) [inline], [static]

Prefetches the first part of the mbuf. โšก

The first 64 bytes of the mbuf correspond to fields that are used early in the receive path. If the cache line of the architecture is higher than 64B, the second part will also be prefetched (bonus content, we love ๐Ÿซถ).

Parameters:

  • m โ€” the pointer to the mbuf.

Definition at line 111 of file rte_mbuf.h.

void rte_mbuf_prefetch_part2 (struct rte_mbuf * m) [inline], [static]

Prefetches the second part of the mbuf. โšก

The next 64 bytes of the mbuf correspond to fields that are used in the transmit path. If the cache line of the architecture is higher than 64B, this function does nothing โ€” because it's expected that the full mbuf is already in cache. lucky you ๐Ÿ’…

Parameters:

  • m โ€” the pointer to the mbuf.

Definition at line 128 of file rte_mbuf.h.

uint16_t rte_pktmbuf_priv_size (struct rte_mempool * mp) [inline], [static]

Gets the application private size of mbufs stored in a pktmbuf_pool.

The private size of an mbuf is a zone located between the rte_mbuf structure and the data buffer, where an application can store data associated with a packet. it's the little secret pocket of the mbuf ๐ŸŽ€

Parameters:

  • mp โ€” the packet mbuf pool.

Returns: the private size of mbufs stored in this mempool.

Definition at line 935 of file rte_mbuf.h.

rte_iova_t rte_mbuf_iova_get (const struct rte_mbuf * m) [inline], [static]

Gets the IOVA address of the mbuf data buffer.

Parameters:

  • m โ€” the pointer to the mbuf.

Returns: the IOVA address of the mbuf.

Definition at line 149 of file rte_mbuf.h.

void rte_mbuf_iova_set (struct rte_mbuf * m, rte_iova_t iova) [inline], [static]

Sets the IOVA address of the mbuf data buffer.

Parameters:

  • m โ€” the pointer to the mbuf.
  • iova โ€” value to set as the IOVA address of the mbuf.

Definition at line 167 of file rte_mbuf.h.

rte_iova_t rte_mbuf_data_iova (const struct rte_mbuf * mb) [inline], [static]

Returns the IO address of the beginning of the mbuf data.

Parameters:

  • mb โ€” the pointer to the mbuf.

Returns: the IO address of the beginning of the mbuf data.

Definition at line 186 of file rte_mbuf.h.

rte_iova_t rte_mbuf_data_iova_default (const struct rte_mbuf * mb) [inline], [static]

Returns the default IO address of the beginning of the mbuf data. ๐ŸŒˆ

This function is used by drivers in their receive function, because it returns the location where data should be written by the NIC โ€” taking the default headroom into account. slay, headroom accounted for ๐Ÿ‘‘

Parameters:

  • mb โ€” the pointer to the mbuf.

Returns: the IO address of the beginning of the mbuf data.

Definition at line 204 of file rte_mbuf.h.

struct rte_mbuf * rte_mbuf_from_indirect (struct rte_mbuf * mi) [inline], [static]

Returns the mbuf that owns the data buffer address of an indirect mbuf. it's giving "who's your real parent" energy ๐Ÿ˜ญ

Parameters:

  • mi โ€” the pointer to the indirect mbuf.

Returns: the address of the direct mbuf corresponding to buffer_addr.

Definition at line 218 of file rte_mbuf.h.

char * rte_mbuf_buf_addr (struct rte_mbuf * mb, struct rte_mempool * mp) [inline], [static]

Returns the address of the buffer embedded in the given mbuf.

The return value shall be the same as mb->buf_addr if the mbuf is already initialized and direct. However, this API is useful if the mempool of the mbuf is already known โ€” because it doesn't need to access the mbuf contents in order to get the mempool pointer. efficiency icon ๐Ÿ’…

Parameters:

  • mb โ€” the pointer to the mbuf.
  • mp โ€” the pointer to the mempool of the mbuf.

Returns: the pointer of the mbuf buffer.

Definition at line 239 of file rte_mbuf.h.

char * rte_mbuf_data_addr_default (struct rte_mbuf * mb) [inline], [static]

Returns the default address of the beginning of the mbuf data.

Parameters:

  • mb โ€” the pointer to the mbuf.

Returns: the pointer of the beginning of the mbuf data.

Definition at line 253 of file rte_mbuf.h.

char * rte_mbuf_to_baddr (struct rte_mbuf * md) [inline], [static]

Returns the address of the buffer embedded in the given mbuf.

Note: accessing the mempool pointer of a mbuf is expensive, because the pointer is stored in the 2nd cache line of the mbuf. If the mempool is known, it is better not to reference the mempool pointer in the mbuf, but to call rte_mbuf_buf_addr() instead โ€” that would be more efficient. ๐Ÿงš save your cycles bestie

Parameters:

  • md โ€” the pointer to the mbuf.

Returns: the address of the data buffer owned by the mbuf.

Definition at line 272 of file rte_mbuf.h.

void * rte_mbuf_to_priv (struct rte_mbuf * m) [inline], [static]

Returns the starting address of the private data area embedded in the given mbuf.

โš ๏ธ Note that no check is made to ensure that a private data area actually exists in the supplied mbuf. so like, don't come crying if it's not there ๐Ÿ™ˆ

Parameters:

  • m โ€” the pointer to the mbuf.

Returns: the starting address of the private data area of the given mbuf.

Definition at line 290 of file rte_mbuf.h.

uint32_t rte_pktmbuf_priv_flags (struct rte_mempool * mp) [inline], [static]

Returns the flags from the private data in a mempool structure.

Parameters:

  • mp โ€” a pointer to the mempool structure.

Returns: the flags from the private data structure.

Definition at line 316 of file rte_mbuf.h.

uint16_t rte_mbuf_refcnt_update (struct rte_mbuf * m, int16_t value) [inline], [static]

Adds the given value to an mbuf's refcnt and returns its new value.

Definition at line 434 of file rte_mbuf.h.

uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf * m) [inline], [static]

Reads the value of an mbuf's refcnt. ๐Ÿ‘€

Definition at line 443 of file rte_mbuf.h.

void rte_mbuf_refcnt_set (struct rte_mbuf * m, uint16_t new_value) [inline], [static]

Sets an mbuf's refcnt to the defined value.

Definition at line 452 of file rte_mbuf.h.

uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info * shinfo) [inline], [static]

Reads the refcnt of an external buffer.

Parameters:

  • shinfo โ€” shared data of the external buffer.

Returns: reference count number.

Definition at line 468 of file rte_mbuf.h.

void rte_mbuf_ext_refcnt_set (struct rte_mbuf_ext_shared_info * shinfo, uint16_t new_value) [inline], [static]

Sets the refcnt of an external buffer.

Parameters:

  • shinfo โ€” shared data of the external buffer.
  • new_value โ€” value set.

Definition at line 482 of file rte_mbuf.h.

uint16_t rte_mbuf_ext_refcnt_update (struct rte_mbuf_ext_shared_info * shinfo, int16_t value) [inline], [static]

Adds the given value to the refcnt of an external buffer and returns its new value.

Parameters:

  • shinfo โ€” shared data of the external buffer.
  • value โ€” value to add/subtract.

Returns: updated value.

Definition at line 500 of file rte_mbuf.h.

void rte_mbuf_raw_sanity_check (const struct rte_mbuf * m, const struct rte_mempool * mp)

Sanity checks on a reinitialized mbuf. ๐Ÿ”๐Ÿ’€

This checks the consistency of the given reinitialized mbuf. The function will cause a panic if corruption is detected. not a cute panic, a real one ๐Ÿ˜ญ

Check that the mbuf is properly reinitialized (refcnt=1, next=NULL, nb_segs=1), as done by rte_pktmbuf_prefree_seg().

Parameters

  • m โ€” the mbuf you're checking, bestie ๐Ÿ’…
  • mp โ€” the mempool the mbuf belongs to. Pass NULL if you don't know which pool it is, and it just won't be checked โœจ

int rte_mbuf_raw_check (const struct rte_mbuf * m, const struct rte_mempool * mp, const char ** reason)

Sanity checks on a reinitialized mbuf ๐Ÿซถ

Pretty much the same vibe as rte_mbuf_raw_sanity_check(), except this one is actually chill about it โ€” instead of panicking, it hands you the reason when it catches corruption. No cap, way more useful for debugging.

Parameters

  • m โ€” the mbuf to be checked
  • mp โ€” the mempool the mbuf belongs to. NULL if unknown, not to be checked
  • reason โ€” a reference to a string pointer where the reason gets stored, so you know why the mbuf is considered invalid ๐Ÿ‘‘

Returns

  • 0 if no issue has been found โ€” and reason is left totally untouched, she stays in her lane ๐Ÿ’–
  • -1 if a problem is detected โ€” and then reason points to a string describing why the mbuf is deemed invalid ๐Ÿ˜ญ

void rte_mbuf_sanity_check (const struct rte_mbuf * m, int is_header)

Sanity checks on an mbuf ๐Ÿ”

Checks the consistency of the given mbuf. Heads up though: this function will cause a panic if corruption is detected. Like, it does not play. ๐Ÿ’€

Parameters

  • m โ€” the mbuf to be checked
  • is_header โ€” true if the mbuf is a packet header, false if it's a sub-segment of a packet (in which case, some fields like nb_segs are not checked)

int rte_mbuf_check (const struct rte_mbuf * m, int is_header, const char ** reason)

Sanity checks on a mbuf โœจ

Almost identical to rte_mbuf_sanity_check(), but this one gives you the reason when corruption is detected rather than panicking. So basically the same energy, minus the screaming ๐ŸŒธ

Parameters

  • m โ€” the mbuf to be checked
  • is_header โ€” true if the mbuf is a packet header, false if it's a sub-segment of a packet (in which case, some fields like nb_segs are not checked)
  • reason โ€” a reference to a string pointer where to store the reason why a mbuf is considered invalid

Returns

  • 0 if no issue has been found โ€” reason is left untouched ๐ŸŽ€
  • -1 if a problem is detected โ€” reason then points to a string describing the reason why the mbuf is deemed invalid

struct rte_mbuf * rte_mbuf_raw_alloc (struct rte_mempool * mp) [inline], [static]

Allocate an uninitialized mbuf from mempool mp ๐Ÿฆ‹

So PMDs (especially in RX functions) can use this to allocate an uninitialized mbuf. Lowkey important: the driver is responsible for initializing all the required fields. See rte_pktmbuf_reset(). For standard needs though, prefer rte_pktmbuf_alloc() โ€” that's the main character here, this one's more of a supporting role ๐Ÿ’…

The caller can expect that the following fields of the mbuf structure are initialized: buf_addr, buf_iova, buf_len, refcnt=1, nb_segs=1, next=NULL, pool, priv_size. Everything else? That's on you, bestie โ€” the caller must initialize the other fields ๐Ÿ˜Œ

Parameters

  • mp โ€” the mempool from which mbuf is allocated

Returns

  • The pointer to the new mbuf on success ๐Ÿ‘‘
  • NULL if allocation failed ๐Ÿ˜ญ

Definition at line 622 of file rte_mbuf.h.


__rte_always_inline int rte_mbuf_raw_alloc_bulk (struct rte_mempool * mp, struct rte_mbuf ** mbufs, unsigned int count) [static]

Allocate a bulk of uninitialized mbufs from mempool mp ๐ŸŒˆ

PMDs (especially in Rx functions) use this to allocate a bulk of uninitialized mbufs. Same deal as before: the driver is responsible for initializing all the required fields. See rte_pktmbuf_reset(). And again, for standard needs, prefer rte_pktmbuf_alloc_bulk() ๐Ÿ’–

The caller can expect that the following fields of the mbuf structure are initialized: buf_addr, buf_iova, buf_len, refcnt=1, nb_segs=1, next=NULL, pool, priv_size. The other fields must be initialized by the caller, no exceptions โœจ

Parameters

  • mp โ€” the mempool from which mbufs are allocated
  • mbufs โ€” array of pointers to mbufs
  • count โ€” array size

Returns

  • 0: Success ๐ŸŽ‰
  • -ENOENT: Not enough entries in the mempool; no mbufs are retrieved ๐Ÿ’€

Definition at line 663 of file rte_mbuf.h.


__rte_always_inline void rte_mbuf_raw_free (struct rte_mbuf * m) [static]

Put mbuf back into its original mempool ๐ŸŽ€

Bestie, read this twice: the caller must ensure that the mbuf is direct and properly reinitialized (refcnt=1, next=NULL, nb_segs=1), exactly as done by rte_pktmbuf_prefree_seg(). Don't skip this check, fr fr ๐Ÿ˜ญ

This function should be used with care, when optimization is required. For standard needs, prefer rte_pktmbuf_free() or rte_pktmbuf_free_seg() ๐Ÿ’…

Parameters

  • m โ€” the mbuf to be freed

Definition at line 691 of file rte_mbuf.h.


__rte_always_inline void rte_mbuf_raw_free_bulk (struct rte_mempool * mp, struct rte_mbuf ** mbufs, unsigned int count) [static]

Put a bulk of mbufs allocated from the same mempool back into the mempool ๐ŸŒธ

The caller must ensure that the mbufs come from the specified mempool, are direct and properly reinitialized (refcnt=1, next=NULL, nb_segs=1), as done by rte_pktmbuf_prefree_seg(). This is the vibe check you cannot fail ๐Ÿ™ˆ

This function should be used with care, when optimization is required. For standard needs, prefer rte_pktmbuf_free_bulk() โœจ

See also: RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE

Parameters

  • mp โ€” the mempool to which the mbufs belong
  • mbufs โ€” array of pointers to packet mbufs. The array must not contain NULL pointers โš ๏ธ
  • count โ€” array size

Definition at line 719 of file rte_mbuf.h.


void rte_pktmbuf_init (struct rte_mempool * mp, void * opaque_arg, void * m, unsigned i)

The packet mbuf constructor ๐Ÿงš

This function initializes some fields in the mbuf structure that are not modified by the user once created (origin pool, buffer start address, and so on). It's given as a callback function to rte_mempool_obj_iter() or rte_mempool_create() at pool creation time ๐Ÿ’–

This function expects that the mempool private area was previously initialized with rte_pktmbuf_pool_init() โ€” so do that first, okay? ๐Ÿ˜Œ

Parameters

  • mp โ€” the mempool from which mbufs originate
  • opaque_arg โ€” a pointer that can be used by the user to retrieve useful information for mbuf initialization. This pointer is the opaque argument passed to rte_mempool_obj_iter() or rte_mempool_create()
  • m โ€” the mbuf to initialize
  • i โ€” the index of the mbuf in the pool table

void rte_pktmbuf_pool_init (struct rte_mempool * mp, void * opaque_arg)

A packet mbuf pool constructor โœจ

This one initializes the mempool private data in the case of a pktmbuf pool. That private data is needed by the driver. The function must be called on the mempool before it is used, or it can be given as a callback function to rte_mempool_create() at pool creation. It can be extended by the user โ€” for example, to provide another packet size ๐Ÿ‘‘

The mempool private area size must be at least equal to sizeof(struct rte_pktmbuf_pool_private). Respect the size, bestie ๐Ÿ’…

Parameters

  • mp โ€” the mempool from which mbufs originate
  • opaque_arg โ€” a pointer that can be used by the user to retrieve useful information for mbuf initialization. This pointer is the opaque argument passed to rte_mempool_create()

struct rte_mempool * rte_pktmbuf_pool_create (const char * name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)

Create a mbuf pool ๐Ÿฆ‹

This function creates and initializes a packet mbuf pool. It's a wrapper to rte_mempool functions โ€” think of it as the friendly face on top of all that machinery ๐ŸŒธ

Parameters

  • name โ€” the name of the mbuf pool
  • n โ€” the number of elements in the mbuf pool
  • cache_size โ€” size of the per-core object cache. See rte_mempool_create() for details
  • priv_size โ€” size of application private area between the rte_mbuf structure and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN โš ๏ธ
  • data_room_size โ€” size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM
  • socket_id โ€” the socket identifier where the memory should be allocated. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone

Returns

The pointer to the new allocated mempool, on success ๐ŸŽ‰ NULL on error with rte_errno set appropriately. Possible rte_errno values include:

  • E_RTE_NO_CONFIG โ€” function could not get pointer to rte_config structure
  • EINVAL โ€” cache size provided is too large, or priv_size is not aligned
  • ENOSPC โ€” the maximum number of memzones has already been allocated
  • EEXIST โ€” a memzone with the same name already exists
  • ENOMEM โ€” no appropriate memory area found in which to create memzone

struct rte_mempool * rte_pktmbuf_pool_create_by_ops (const char * name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id, const char * ops_name)

Create a mbuf pool with a given mempool ops name ๐Ÿ’œ

This function creates and initializes a packet mbuf pool. It's a wrapper to rte_mempool functions. Basically the same as the one above but you get to pick the ops, iykyk ๐Ÿ˜Œ

Parameters

  • name โ€” the name of the mbuf pool
  • n โ€” the number of elements in the mbuf pool
  • cache_size โ€” size of the per-core object cache. See rte_mempool_create() for details
  • priv_size โ€” size of application private area between the rte_mbuf structure and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN
  • data_room_size โ€” size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM
  • socket_id โ€” the socket identifier where the memory should be allocated. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone
  • ops_name โ€” the mempool ops name to be used for this mempool instead of the default mempool. The value can be NULL to use the default mempool ๐ŸŽ€

Returns

The pointer to the new allocated mempool, on success โœจ NULL on error with rte_errno set appropriately. Possible rte_errno values include:

  • E_RTE_NO_CONFIG โ€” function could not get pointer to rte_config structure
  • EINVAL โ€” cache size provided is too large, or priv_size is not aligned
  • ENOSPC โ€” the maximum number of memzones has already been allocated
  • EEXIST โ€” a memzone with the same name already exists
  • ENOMEM โ€” no appropriate memory area found in which to create memzone

struct rte_mempool * rte_pktmbuf_pool_create_extbuf (const char * name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id, const struct rte_pktmbuf_extmem * ext_mem, unsigned int ext_num)

Create a mbuf pool with external pinned data buffers ๐Ÿ”ฅ

This function creates and initializes a packet mbuf pool that contains only mbufs with external buffer. It is a wrapper to rte_mempool functions ๐ŸŒˆ

๐ŸŒธ Parameters

  • name โ€” what you're naming the mbuf pool, bestie. Pick something cute, it's gonna live in a memzone ๐ŸŽ€
  • n โ€” how many elements are in the mbuf pool.
  • cache_size โ€” the size of the per-core object cache, k? Peep rte_mempool_create() for the deets.
  • priv_size โ€” the size of the application private area, sittin' right between the rte_mbuf structure and the data buffer. Heads up: this value must be aligned to RTE_MBUF_PRIV_ALIGN.
  • data_room_size โ€” the size of the data buffer in each mbuf, RTE_PKTMBUF_HEADROOM included, no cap.
  • socket_id โ€” the socket identifier for where the memory should be allocated. It can be SOCKET_ID_ANY if there's no NUMA constraint on the reserved zone, no stress โœจ
  • ext_mem โ€” pointer to the array of structures describing the external memory for data buffers. It is caller responsibility to register this memory with rte_extmem_register() (if needed), map this memory to the appropriate physical device, etc. So likeโ€ฆ that's on you, not me ๐Ÿ’…
  • ext_num โ€” the number of elements in the ext_mem array.

๐Ÿ’– Returns

The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately. Possible rte_errno values include:

  • E_RTE_NO_CONFIG โ€” function could not get pointer to rte_config structure
  • EINVAL โ€” cache size provided is too large, or priv_size is not aligned.
  • ENOSPC โ€” the maximum number of memzones has already been allocated
  • EEXIST โ€” a memzone with the same name already exists
  • ENOMEM โ€” no appropriate memory area found in which to create memzone

๐Ÿฆ‹ rte_pktmbuf_data_room_size

uint16_t rte_pktmbuf_data_room_size (struct rte_mempool * mp) [inline], [static]

Grab the data room size of the mbufs chillin' inside a pktmbuf_pool ๐Ÿ‘‘

The data room size is likeโ€ฆ the amount of data that can actually be stored in a mbuf, and yes, that includes the headroom (RTE_PKTMBUF_HEADROOM). It's giving "how much room do we actually have" energy.

Parameters

  • mp โ€” the packet mbuf pool.

Returns

The data room size of mbufs stored in this mempool. Slay.

Definition at line 914 of file rte_mbuf.h.


๐ŸŒˆ rte_pktmbuf_reset_headroom

void rte_pktmbuf_reset_headroom (struct rte_mbuf * m) [inline], [static]

Resets the data_off field of a packet mbuf back to its default value ๐Ÿ”„

Real talk though: the given mbuf must have only one segment, and that segment should be empty. One segment only, bestie, that's the vibe check.

Parameters

  • m โ€” the packet mbuf whose data_off field has to be reset.

Definition at line 951 of file rte_mbuf.h.


๐Ÿงš rte_mbuf_raw_reset_bulk

void rte_mbuf_raw_reset_bulk (struct rte_mempool * mp, struct rte_mbuf ** mbufs, unsigned int count) [inline], [static]

Resets the fields of a whole bulk of packet mbufs to their default values โ€” group reset, periodt ๐Ÿ’ซ

The caller must ensure that the mbufs come from the specified mempool, are direct, and are properly reinitialized (refcnt=1, next=NULL, nb_segs=1), exactly like rte_pktmbuf_prefree_seg() does.

โš ๏ธ Use this function with care, okay? Like, when optimization is actually required. For standard needs, prefer rte_pktmbuf_reset() โ€” it's the safe, icon behavior.

Parameters

  • mp โ€” the mempool to which the mbuf belongs.
  • mbufs โ€” array of pointers to packet mbufs. The array must not contain NULL pointers, fr fr.
  • count โ€” array size.

Definition at line 976 of file rte_mbuf.h.


๐ŸŽ€ rte_pktmbuf_reset

void rte_pktmbuf_reset (struct rte_mbuf * m) [inline], [static]

Puts the fields of a packet mbuf back to their default values โœจ

The given mbuf must have only one segment. That's the whole rule, don't fight it.

Parameters

  • m โ€” the packet mbuf to be reset.

Definition at line 1009 of file rte_mbuf.h.


๐Ÿ’œ rte_pktmbuf_alloc

struct rte_mbuf * rte_pktmbuf_alloc (struct rte_mempool * mp) [inline], [static]

Allocates a brand new mbuf from a mempool ๐ŸŽ

This new mbuf contains one segment, which has a length of 0. The pointer to data is initialized to have some bytes of headroom in the buffer (if the buffer size allows, ofc).

Parameters

  • mp โ€” the mempool from which the mbuf is allocated.

Returns

  • The pointer to the new mbuf on success.
  • NULL if allocation failed ๐Ÿ˜ญ

Definition at line 1040 of file rte_mbuf.h.


โญ rte_pktmbuf_alloc_bulk

int rte_pktmbuf_alloc_bulk (struct rte_mempool * pool, struct rte_mbuf ** mbufs, unsigned count) [inline], [static]

Allocates a bulk of mbufs, initializes refcnt and resets the fields to default values. Bulk girl summer ๐ŸŒธ

Parameters

  • pool โ€” the mempool from which mbufs are allocated.
  • mbufs โ€” array of pointers to mbufs.
  • count โ€” array size.

Returns

  • 0: Success ๐Ÿ‘‘
  • -ENOENT: Not enough entries in the mempool; no mbufs are retrieved. Nothing came through, bestie ๐Ÿ’€

Definition at line 1062 of file rte_mbuf.h.


๐Ÿซถ rte_pktmbuf_ext_shinfo_init_helper

struct rte_mbuf_ext_shared_info * rte_pktmbuf_ext_shinfo_init_helper (void * buf_addr, uint16_t * buf_len, rte_mbuf_extbuf_free_callback_t free_cb, void * fcb_opaque) [inline], [static]

Initializes shared data at the end of an external buffer before you attach it to a mbuf with rte_pktmbuf_attach_extbuf(). Ngl this isn't mandatory โ€” it's a little helper function that simply spares a few bytes at the end of the buffer for shared data. If your shared data is allocated separately, don't call this; instead the application has to properly initialize the shared data according to its own needs.

The free callback and its argument get saved, and refcnt is set to 1. Cute, tidy, done ๐Ÿ’…

โš ๏ธ Warning: the value of buf_len will be reduced to RTE_PTR_DIFF(shinfo, buf_addr) after this initialization. That value shall be used for rte_pktmbuf_attach_extbuf().

Parameters

  • buf_addr โ€” the pointer to the external buffer.
  • buf_len โ€” the pointer to the length of the external buffer. The input value must be larger than the size of struct rte_mbuf_ext_shared_info and the padding for alignment. If it's not enough, this function returns NULL. The adjusted buffer length comes back out through this pointer.
  • free_cb โ€” free callback function to call when the external buffer needs to be freed.
  • fcb_opaque โ€” argument for the free callback function.

Returns

A pointer to the initialized shared data on success, NULL otherwise.

Definition at line 1111 of file rte_mbuf.h.


๐Ÿฆ„ rte_pktmbuf_attach_extbuf

void rte_pktmbuf_attach_extbuf (struct rte_mbuf * m, void * buf_addr, rte_iova_t buf_iova, uint16_t buf_len, struct rte_mbuf_ext_shared_info * shinfo) [inline], [static]

Attaches an external buffer to a mbuf ๐Ÿ”—

User-managed anonymous buffer can be attached to a mbuf. When you attach it, the corresponding free callback function and its argument should be provided via shinfo. That callback function will be called once all the mbufs are detached from the buffer (i.e. refcnt becomes zero).

The headroom length of the attaching mbuf gets set to zero, and that can be properly adjusted after attachment. For example, rte_pktmbuf_adj() or rte_pktmbuf_reset_headroom() might be used.

Same deal with the packet length โ€” it's initialized to 0. If the buffer contains data, the user has to adjust data_len and the pkt_len field of the mbuf accordingly.

More mbufs can be attached to the same external buffer with rte_pktmbuf_attach() once the external buffer has been attached by this API.

Detachment can be done by either rte_pktmbuf_detach_extbuf() or rte_pktmbuf_detach().

Memory for shared data must be provided, and the user must initialize all of the content properly โ€” especially the free callback and refcnt. The pointer of shared data will be stored in m->shinfo. rte_pktmbuf_ext_shinfo_init_helper can help by simply sparing a few bytes at the end of the buffer for the shared data, storing the free callback and its argument, and setting refcnt to 1. Example time, bestie:

struct rte_mbuf_ext_shared_info *shinfo =
rte_pktmbuf_ext_shinfo_init_helper(buf_addr, &buf_len,
                                            free_cb, fcb_arg);
rte_pktmbuf_attach_extbuf(m, buf_addr, buf_iova, buf_len, shinfo);
rte_pktmbuf_reset_headroom(m); rte_pktmbuf_adj(m, data_len);

Attaching an external buffer is quite similar to mbuf indirection when it comes to replacing buffer addresses and length of a mbuf, but there are a few differences:

  • When an indirect mbuf is attached, refcnt of the direct mbuf would be 2 as long as the direct mbuf itself isn't freed after the attachment. In such cases, the buffer area of a direct mbuf must be read-only. But an external buffer has its own refcnt and it starts from 1. Unless multiple mbufs are attached to a mbuf having an external buffer, the external buffer is writable ๐Ÿ‘€
  • There's no need to allocate the buffer from a mempool. Any buffer can be attached with an appropriate free callback and its IO address. Iconic.
  • Smaller metadata is required to maintain shared data such as refcnt.

Parameters

  • m โ€” the pointer to the mbuf.
  • buf_addr โ€” the pointer to the external buffer.
  • buf_iova โ€” IO address of the external buffer.
  • buf_len โ€” the size of the external buffer.
  • shinfo โ€” user-provided memory for shared data of the external buffer.

Definition at line 1193 of file rte_mbuf.h.


๐Ÿ“ rte_mbuf_dynfield_copy

void rte_mbuf_dynfield_copy (struct rte_mbuf * mdst, const struct rte_mbuf * msrc) [inline], [static]

Copies the dynamic fields from msrc to mdst. Passing notes in class, but make it C ๐Ÿ’Œ

Parameters

  • mdst โ€” the destination mbuf.
  • msrc โ€” the source mbuf.

Definition at line 1230 of file rte_mbuf.h.


๐Ÿ”ฅ rte_pktmbuf_attach

void rte_pktmbuf_attach (struct rte_mbuf * mi, struct rte_mbuf * m) [inline], [static]

Attaches one packet mbuf to another packet mbuf ๐Ÿซ‚

If the mbuf we're attaching to isn't a direct buffer and is attached to an external buffer, then the mbuf being attached will be attached to the external buffer instead of doing mbuf indirection.

Otherwise, the mbuf will be indirectly attached. After attachment we refer to the mbuf we attached as 'indirect', while the mbuf we attached to is the 'direct' one. The direct mbuf's reference counter is incremented.

Right now, not supported โ€” read carefully, bestie:

  • attachment for an already indirect mbuf (e.g. mi has to be direct).
  • mbuf we're trying to attach (mi) is used by someone else, e.g. its reference counter is greater than 1.

Parameters

  • mi โ€” the indirect packet mbuf.
  • m โ€” the packet mbuf we're attaching to.

Definition at line 1272 of file rte_mbuf.h.


๐Ÿ’ซ rte_pktmbuf_detach

void rte_pktmbuf_detach (struct rte_mbuf * m) [inline], [static]

Detaches a packet mbuf from an external buffer or a direct buffer. Breaking up, but make it graceful ๐Ÿฆ‹

  • decrement refcnt and free the external/direct buffer if refcnt becomes zero.
  • restore original mbuf address and length values.
  • reset pktmbuf data and data_len to their default values.

All other fields of the given packet mbuf will be left intact โ€” untouched, unbothered, living their best life โœจ

If the packet mbuf was allocated from the pool with pinned external buffers, rte_pktmbuf_detach does nothing with a mbuf of this kind, because pinned buffers are not supposed to be detached. That's the rule, no exceptions ๐Ÿ’…

Parameters

  • m โ€” the indirect attached packet mbuf.

Definition at line 1368 of file rte_mbuf.h.


๐ŸŒŸ rte_pktmbuf_prefree_seg

__rte_always_inline struct rte_mbuf * rte_pktmbuf_prefree_seg (struct rte_mbuf * m) [static]

Decreases the reference counter and unlinks a mbuf segment โ›“๏ธโ€๐Ÿ’ฅ

This function does the same thing as a free, except that it does not return the segment to its pool. It decreases the reference counter, and if that reaches 0, the segment is detached from its parent (for an indirect mbuf). So close to letting go, but not quite ๐Ÿ˜ญ

Parameters

  • m โ€” the mbuf to be unlinked.

Returns

  • m โ€” if it's the last reference. It can be recycled or freed. ๐ŸŽ‰
    • NULL โ€” if the mbuf still has remaining references on it. ๐Ÿ˜ฌ

Definition at line 1460 of file rte_mbuf.h.


๐Ÿ—‘๏ธ __rte_always_inline void rte_pktmbuf_free_seg (struct rte_mbuf * m) [static]

Frees one segment of a packet mbuf back into its original mempool.

It frees an mbuf without parsing the other segments โ€” so if you're dealing with chained buffers, it only yeets the single one you handed it, no chain-walking. ๐Ÿซถ

Parameters

  • m โ€” The packet mbuf segment to be freed.

Definition at line 1498 of file rte_mbuf.h.


๐Ÿ—‘๏ธโœจ void rte_pktmbuf_free (struct rte_mbuf * m) [inline], [static]

Frees a packet mbuf back into its original mempool.

This one frees an mbuf and all its segments if it's chained. Each segment goes back into its original mempool. Iconic cleanup behaviour, honestly. ๐Ÿงน

Parameters

  • m โ€” The packet mbuf to be freed. If NULL, the function does nothing โ€” no drama, no crash. ๐Ÿ˜Œ

Definition at line 1514 of file rte_mbuf.h.


๐Ÿ—‘๏ธ๐Ÿซง void rte_pktmbuf_free_bulk (struct rte_mbuf ** mbufs, unsigned int count)

Frees a whole bulk of packet mbufs back into their original mempools.

It frees a bulk of mbufs, and all their segments if they're chained buffers. Each segment is added back into its original mempool. Bulk freeing is the vibe when you've got a mountain of packets. ๐Ÿ’…

Parameters

  • mbufs โ€” Array of pointers to packet mbufs. The array may contain NULL pointers.
  • count โ€” Array size.

๐Ÿงฌ struct rte_mbuf * rte_pktmbuf_clone (struct rte_mbuf * md, struct rte_mempool * mp)

Makes a "clone" of the given packet mbuf. Copy-paste but make it โœจfashionโœจ.

It walks through all segments of the given packet mbuf, and for each one:

  • Creates a new packet mbuf from the given pool.
  • Attaches the newly created mbuf to the segment. Then it updates pkt_len and nb_segs of the "clone" packet mbuf to match the values from the original packet mbuf.

Parameters

  • md โ€” The packet mbuf to be cloned.
  • mp โ€” The mempool from which the "clone" mbufs are allocated.

Returns

  • The pointer to the new "clone" mbuf on success. ๐ŸŽ€
  • NULL if allocation fails. ๐Ÿ˜ญ

๐Ÿ“‹ struct rte_mbuf * rte_pktmbuf_copy (const struct rte_mbuf * m, struct rte_mempool * mp, uint32_t offset, uint32_t length)

Makes a full copy of a given packet mbuf โ€” like, a real copy, not a clone.

It copies all the data from a given packet mbuf to a newly allocated set of mbufs. The private data are is not copied. (Yes that's exactly how the original says it, I'm not touching it. ๐Ÿ™ˆ)

Parameters

  • m โ€” The packet mbuf to be copied.
  • mp โ€” The mempool from which the "clone" mbufs are allocated.
  • offset โ€” The number of bytes to skip before copying. If the mbuf does not have that many bytes, it is an error and NULL is returned.
  • length โ€” The upper limit on bytes to copy. Passing UINT32_MAX means all data (after offset).

Returns

  • The pointer to the new "clone" mbuf on success. โœจ
  • NULL if allocation fails.

๐Ÿ”ข void rte_pktmbuf_refcnt_update (struct rte_mbuf * m, int16_t v) [inline], [static]

Adds the given value to the refcnt of all packet mbuf segments.

It walks through all segments of the given packet mbuf and for each of them invokes rte_mbuf_refcnt_update(). Chain-wide refcount updates, no cap. ๐Ÿงฎ

Parameters

  • m โ€” The packet mbuf whose refcnt to be updated.
  • v โ€” The value to add to the mbuf's segments refcnt.

Definition at line 1598 of file rte_mbuf.h.


๐Ÿ“ uint16_t rte_pktmbuf_headroom (const struct rte_mbuf * m) [inline], [static]

Gets the headroom in a packet mbuf.

Parameters

  • m โ€” The packet mbuf.

Returns

The length of the headroom.

Definition at line 1615 of file rte_mbuf.h.


๐Ÿ“ uint16_t rte_pktmbuf_tailroom (const struct rte_mbuf * m) [inline], [static]

Gets the tailroom of a packet mbuf.

Parameters

  • m โ€” The packet mbuf.

Returns

The length of the tailroom.

Definition at line 1629 of file rte_mbuf.h.


๐Ÿ struct rte_mbuf * rte_pktmbuf_lastseg (struct rte_mbuf * m) [inline], [static]

Gets the last segment of the packet. The final girl of the chain, literally. ๐Ÿ‘‘

Parameters

  • m โ€” The packet mbuf.

Returns

The last segment of the given mbuf.

Definition at line 1644 of file rte_mbuf.h.


โฌ…๏ธ char * rte_pktmbuf_prepend (struct rte_mbuf * m, uint16_t len) [inline], [static]

Prepends len bytes to an mbuf data area.

Returns a pointer to the new data start address. If there is not enough headroom in the first segment, the function will return NULL without modifying the mbuf. Nothing happens, no half-done nonsense. ๐Ÿ™…

Parameters

  • m โ€” The pkt mbuf.
  • len โ€” The amount of data to prepend (in bytes).

Returns

A pointer to the start of the newly prepended data, or NULL if there is not enough headroom space in the first segment.

Definition at line 1687 of file rte_mbuf.h.


โžก๏ธ char * rte_pktmbuf_append (struct rte_mbuf * m, uint16_t len) [inline], [static]

Appends len bytes to an mbuf.

Appends len bytes to an mbuf and returns a pointer to the start address of the added data. If there is not enough tailroom in the last segment, the function will return NULL without modifying the mbuf.

Parameters

  • m โ€” The packet mbuf.
  • len โ€” The amount of data to append (in bytes).

Returns

A pointer to the start of the newly appended data, or NULL if there is not enough tailroom space in the last segment.

Definition at line 1720 of file rte_mbuf.h.


โœ‚๏ธ char * rte_pktmbuf_adj (struct rte_mbuf * m, uint16_t len) [inline], [static]

Removes len bytes at the beginning of an mbuf.

Returns a pointer to the start address of the new data area. If the length is greater than the length of the first segment, then the function will fail and return NULL, without modifying the mbuf. ๐Ÿ˜ค

Parameters

  • m โ€” The packet mbuf.
  • len โ€” The amount of data to remove (in bytes).

Returns

A pointer to the new start of the data.

Definition at line 1751 of file rte_mbuf.h.


๐Ÿชš int rte_pktmbuf_trim (struct rte_mbuf * m, uint16_t len) [inline], [static]

Removes len bytes of data at the end of the mbuf.

If the length is greater than the length of the last segment, the function will fail and return -1 without modifying the mbuf.

Parameters

  • m โ€” The packet mbuf.
  • len โ€” The amount of data to remove (in bytes).

Returns

  • 0: On success. โœ…
  • -1: On error. โŒ

Definition at line 1781 of file rte_mbuf.h.


๐Ÿ”— int rte_pktmbuf_is_contiguous (const struct rte_mbuf * m) [inline], [static]

Tests if mbuf data is contiguous.

Parameters

  • m โ€” The packet mbuf.

Returns

  • 1, if all data is contiguous (one segment). ๐ŸŽฏ
  • 0, if there is several segments.

Definition at line 1805 of file rte_mbuf.h.


๐Ÿ‘€ const void * rte_pktmbuf_read (const struct rte_mbuf * m, uint32_t off, uint32_t len, void * buf) [inline], [static]

Reads len data bytes in a mbuf at a specified offset.

If the data is contiguous, it returns the pointer in the mbuf data; otherwise it copies the data into the buffer provided by the user and returns its pointer. Bestie it literally hands you the data whichever way it can. ๐Ÿซด

Parameters

  • m โ€” The pointer to the mbuf.
  • off โ€” The offset of the data in the mbuf.
  • len โ€” The amount of bytes to read.
  • buf โ€” The buffer where data is copied if it is not contiguous in mbuf data. Its length should be at least equal to the len parameter.

Returns

The pointer to the data, either in the mbuf if it is contiguous, or in the user buffer. If mbuf is too small, NULL is returned.

Definition at line 1837 of file rte_mbuf.h.


โ›“๏ธ int rte_pktmbuf_chain (struct rte_mbuf * head, struct rte_mbuf * tail) [inline], [static]

Chains an mbuf to another, thereby creating a segmented packet.

Heads up bestie: the implementation will do a linear walk over the segments to find the tail entry. For cases when there are many segments, it's better to chain the entries manually. Don't make it do all that walking for nothing. ๐Ÿšถโ€โ™€๏ธ

Parameters

  • head โ€” The head of the mbuf chain (the first packet)
  • tail โ€” The mbuf to put last in the chain

Returns

  • 0, on success. โœ…
  • -EOVERFLOW, if the chain segment limit exceeded. ๐Ÿ’€

Definition at line 1862 of file rte_mbuf.h.


๐Ÿงพ __rte_always_inline uint64_t rte_mbuf_tx_offload (uint64_t il2, uint64_t il3, uint64_t il4, uint64_t tso, uint64_t ol3, uint64_t ol2, uint64_t unused) [static]

For the given input values, generates a raw tx_offload value. Note that it is the caller's responsibility to make sure that the input parameters don't exceed maximum bit-field values. Like, don't blame the function, okay? ๐Ÿ™

Parameters

  • il2 โ€” l2_len value.
  • il3 โ€” l3_len value.
  • il4 โ€” l4_len value.
  • tso โ€” tso_segsz value.
  • ol3 โ€” outer_l3_len value.
  • ol2 โ€” outer_l2_len value.
  • unused โ€” unused value.

Returns

raw tx_offload value.

Definition at line 1909 of file rte_mbuf.h.


๐Ÿ” int rte_validate_tx_offload (const struct rte_mbuf * m) [inline], [static]

Validates general requirements for Tx offload in an mbuf.

This function checks correctness and completeness of Tx offload settings. It's giving "quality control supervisor". ๐Ÿ’…

Parameters

  • m โ€” The packet mbuf to be validated.

Returns

0 if packet is valid.

Definition at line 1932 of file rte_mbuf.h.


๐Ÿงต int rte_pktmbuf_linearize (struct rte_mbuf * mbuf) [inline], [static]

Linearizes data in an mbuf.

This function moves the mbuf data into the first segment if there is enough tailroom. The subsequent segments are unchained and freed. Say bye to the chain bestie, it's one big blob now. ๐Ÿซถ

Parameters

  • mbuf โ€” mbuf to linearize

Returns

  • 0, on success
  • -1, on error

Definition at line 1982 of file rte_mbuf.h.


๐Ÿ–จ๏ธ void rte_pktmbuf_dump (FILE * f, const struct rte_mbuf * m, unsigned dump_len)

Dumps an mbuf structure to a file. Debug time, bestie, get the receipts. ๐Ÿงพ

It dumps all fields for the given packet mbuf and all its associated segments (in the case of a chained buffer).

Parameters

  • f โ€” A pointer to a file for output
  • m โ€” The packet mbuf.
  • dump_len โ€” If dump_len != 0, also dump the "dump_len" first data bytes of the packet.

๐ŸŽซ uint32_t rte_mbuf_sched_queue_get (const struct rte_mbuf * m) [inline], [static]

Gets the value of the mbuf sched queue_id field.

Definition at line 2009 of file rte_mbuf.h.


๐ŸŽŸ๏ธ uint8_t rte_mbuf_sched_traffic_class_get (const struct rte_mbuf * m) [inline], [static]

Gets the value of the mbuf sched traffic_class field.

Definition at line 2018 of file rte_mbuf.h.


๐ŸŽจ uint8_t rte_mbuf_sched_color_get (const struct rte_mbuf * m) [inline], [static]

Gets the value of the mbuf sched color field.

Definition at line 2027 of file rte_mbuf.h.


๐Ÿ“ฆ void rte_mbuf_sched_get (const struct rte_mbuf * m, uint32_t * queue_id, uint8_t * traffic_class, uint8_t * color) [inline], [static]

Gets the values of the mbuf sched queue_id, traffic_class and color โ€” all three at once, efficiency queen. ๐Ÿ‘‘

Parameters

  • m โ€” Mbuf to read
  • queue_id โ€” Returns the queue id
  • traffic_class โ€” Returns the traffic class id
  • color โ€” Returns the colour id

Definition at line 2045 of file rte_mbuf.h.


๐Ÿ–Š๏ธ void rte_mbuf_sched_queue_set (struct rte_mbuf * m, uint32_t queue_id) [inline], [static]

Sets the mbuf sched queue_id to the defined value.

Definition at line 2060 of file rte_mbuf.h.


๐Ÿ–๏ธ void rte_mbuf_sched_traffic_class_set (struct rte_mbuf * m, uint8_t traffic_class) [inline], [static]

Sets the mbuf sched traffic_class id to the defined value.

Okay so first, this little leftover from the entry above โ€” don't skip it, bestie, it's part of the record:

Definition at line 2069 of file rte_mbuf.h.


๐ŸŽ€ rte_mbuf_sched_color_set ๐ŸŽ€

void rte_mbuf_sched_color_set (struct rte_mbuf * m, uint8_t color) [inline],
    [static]

This one sets the mbuf sched color id to the defined value. That's literally the whole vibe โ€” color id goes in, sched color gets set. Slay. โœจ

Definition at line 2078 of file rte_mbuf.h.


๐Ÿฆ‹ rte_mbuf_sched_set ๐Ÿฆ‹

void rte_mbuf_sched_set (struct rte_mbuf * m, uint32_t queue_id, uint8_t
    traffic_class, uint8_t color) [inline],  [static]

This icon sets the mbuf sched queue_id, traffic_class, and color all in one go. Main character energy, honestly. ๐Ÿ’…

๐ŸŒธ Parameters ๐ŸŒธ

  • m โ€” Mbuf to set
  • queue_id โ€” Queue id value to be set
  • traffic_class โ€” Traffic class id value to be set
  • color โ€” Color id to be set

Definition at line 2096 of file rte_mbuf.h.


๐Ÿ‘‘ Author ๐Ÿ‘‘

The page literally says: "Generated automatically by Doxygen for DPDK from the source code." No cap, that's the whole author section. ๐Ÿซถ


And that's the end of the page, bestie โ€” shoutout to DPDK Version 26.03.0 and the rte_mbuf.h(3) page. You ate this whole manual. Periodt. ๐Ÿ’–๐ŸŽ€

๐Ÿ“ฆ where this page comes from