rte_mbuf_dyn.h(3)
β¨ rte_mbuf_dyn.h β¨ β the DPDK dynamic mbuf fields & flags era π
okay bestie, buckle up, this one lives in the Library Functions Manual and it's lowkey one of the most important headers in DPDK for anyone who's ever screamed "WHERE DO I PUT MY CUSTOM DATA IN AN MBUF π". spoiler: here. it's here. you're welcome π«Ά
πΈ NAME πΈ
rte_mbuf_dyn.h β literally just the header itself, no cap π
π SYNOPSIS π
the vibe check first. you pull these in:
#include <stdio.h>
#include <stdint.h>
#include <rte_stdatomic.h>
π¦ Data Structures
struct rte_mbuf_dynfieldstruct rte_mbuf_dynflag
π¦ Macros
#define RTE_MBUF_DYN_NAMESIZE 64
#define RTE_MBUF_DYNFIELD(m, offset, type)
#define RTE_MBUF_DYNFIELD_HISTORY_NAME 'rte_mbuf_dynfield_history'
#define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME 'rte_dynfield_timestamp'
#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME 'rte_dynflag_rx_timestamp'
#define RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME 'rte_dynflag_tx_timestamp'
#define RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME
'rte_dynfield_ip_reassembly'
π¦ Functions
int rte_mbuf_dynfield_register (const struct rte_mbuf_dynfield *params)
int rte_mbuf_dynfield_register_offset (const struct rte_mbuf_dynfield
*params, size_t offset)
int rte_mbuf_dynfield_lookup (const char *name, struct rte_mbuf_dynfield
*params)
int rte_mbuf_dynflag_register (const struct rte_mbuf_dynflag *params)
int rte_mbuf_dynflag_register_bitnum (const struct rte_mbuf_dynflag
*params, unsigned int bitnum)
int rte_mbuf_dynflag_lookup (const char *name, struct rte_mbuf_dynflag
*params)
void rte_mbuf_dyn_dump (FILE *out)
typedef (uint64_t) rte_mbuf_history_t
int rte_mbuf_dyn_rx_timestamp_register (int *field_offset, uint64_t
*rx_flag)
int rte_mbuf_dyn_tx_timestamp_register (int *field_offset, uint64_t
*tx_flag)
π Detailed Description π
RTE Mbuf dynamic fields and flags π
so the whole situation is: so many DPDK features wanna stash some data inside the mbuf. but the room in the mbuf structure is limited, bestie. there's no way to give every single feature its own field β physically impossible, it's giving overbooked flight π. and on top of that, just changing fields in the mbuf structure can break the API or the ABI. nope. not on our watch.
this module fixes that whole mess by letting you dynamically register fields or flags instead:
- a dynamic field is a named area in the
rte_mbufstructure, with a given size (>= 1 byte) and alignment constraint. cute, right? πΈ - a dynamic flag is a named bit in the
rte_mbufstructure, stored inmbuf->ol_flags. tiny but mighty β¨
the placement of the field or flag can be automatic β and when it is, the zones that have the smallest size and alignment constraint get picked in priority (efficient queen behavior π). otherwise, you can request a specific field offset or flag bit number through the API.
the typical use case? a specific offload feature needs to register its own dedicated offload field in the mbuf structure, and adding a static field or flag just isn't justified. that's this. this is it. π¦
Example of use π
- you define a
rte_mbuf_dynfieldstructure containing the params of the dynamic field you're registering:const struct rte_mbuf_dynfield rte_dynfield_my_feature = { ... }; - the application initializes the PMD, and asks for this feature at port initialization by passing
RTE_ETH_RX_OFFLOAD_MY_FEATUREinrxconf. this makes the PMD register the field by callingrte_mbuf_dynfield_register(&rte_dynfield_my_feature). the PMD stores the returned offset. - the application that uses the offload feature also registers the field to retrieve the same offset. teamwork, bestie π€
- when the PMD receives a packet, it can set the field:
*RTE_MBUF_DYNFIELD(m, offset, <type *>) = value; - in the main loop, the application can retrieve the value with the same macro. iconic, consistent, we love her π
real talk: to avoid wasting space, dynamic fields or flags must only be reserved on demand, when an application asks for the related feature. don't just claim land everywhere like it's a group project, okay?
the registration can be done at any moment, but it is not possible to unregister fields or flags for now. no take-backsies π
a dynamic field can be reserved and used by an application only. it can for instance be a packet mark. valid. π
Naming, because collisions are NOT the vibe π
to avoid namespace collisions, dynamic mbuf field or flag names have to be chosen with care. it's advised to use the same conventions than function names in dpdk:
"rte_mbuf_dynfield_<name>"if defined in mbuf library"rte_<libname>_dynfield_<name>"if defined in another library"rte_net_<pmd>_dynfield_<name>"if defined in a PMD- any name that does not start with
"rte_"in an application
π Macro Definition Documentation π
#define RTE_MBUF_DYN_NAMESIZE 64
maximum length of the dynamic field or flag string. that's the cap, bestie, respect it. β
Definition at line 81 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFIELD( m, offset, type)
value:
((type)((uintptr_t)(m) + (offset)))
helper macro to access a dynamic field. it's giving "point me at the right spot in memory and let me in" π
Definition at line 228 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFIELD_HISTORY_NAME 'rte_mbuf_dynfield_history'
the mbuf history dynamic field provides lifecycle tracking for mbuf objects through the system. it records a fixed set of predefined operations for debugging. she's literally keeping receipts on every mbuf, and honestly? slay. π΅οΈπ
Definition at line 249 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME 'rte_dynfield_timestamp'
the timestamp dynamic field provides some timing information. the units and time references (initial phase) are not explicitly defined but are maintained always the same for a given port. some devices allow you to query rte_eth_read_clock() which will return the current device timestamp. the dynamic Tx timestamp flag tells whether the field contains the actual timestamp value for the packets being sent β and this value can be used by the PMD to schedule packet sending. time is fake but the scheduling is real, iykyk β°β¨
Definition at line 280 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME 'rte_dynflag_rx_timestamp'
indicate that the timestamp field in the mbuf was filled by the driver. that's it, that's the flag. the driver did it, and now you know. π
Definition at line 286 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME 'rte_dynflag_tx_timestamp'
when the PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the packet being sent, it tries to synchronize the time of packet appearing on the wire with the specified packet timestamp. if the specified one is in the past, it should be ignored. if one is in the distant future, it should be capped with some reasonable value (in range of seconds). π
heavy caveat incoming, listen up: there is no packet reordering according to timestamps supposed β neither for packets within the burst, nor for the whole bursts. it is an entirely application responsibility to generate packets and their timestamps in the desired order. the timestamps might be put only in the first packet in the burst, providing the entire burst scheduling. so likeβ¦ you did this, bestie, it's your job now π
Definition at line 319 of file <code>rte_mbuf_dyn.h</code>.
#define RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME 'rte_dynfield_ip_reassembly'
for the PMDs which support IP reassembly of packets, the PMD will update the packet with RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME to denote that IP reassembly is incomplete, and the application can retrieve the packets back using RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME. putting the pieces back together, puzzle-style π§©πΈ
Definition at line 345 of file <code>rte_mbuf_dyn.h</code>.
πΈ Function Documentation πΈ
okay so bestie, here's the whole function lineup β every single one, no skips, no cap π
β¨ rte_mbuf_dynfield_register β¨
int rte_mbuf_dynfield_register (const struct rte_mbuf_dynfield * params)
Register space for a dynamic field in the mbuf structure.
If the field is already registered (same name and parameters), its offset is returned.
Parameters
paramsβ A structure containing the requested parameters (name, size, alignment constraint and flags).
Returns
The offset in the mbuf structure, or -1 on error. Possible values for rte_errno:
EINVALβ invalid parameters (size, align, or flags).EEXISTβ this name is already register with different parameters.EPERMβ called from a secondary process.ENOENTβ not enough room in mbuf.ENOMEMβ allocation failure.ENAMETOOLONGβ name does not ends with\0.
π
rte_mbuf_dynfield_register_offset π
int rte_mbuf_dynfield_register_offset (const struct rte_mbuf_dynfield * params, size_t offset)
Register space for a dynamic field in the mbuf structure at offset.
If the field is already registered (same name, parameters and offset), the offset is returned.
Parameters
paramsβ A structure containing the requested parameters (name, size, alignment constraint and flags).offsetβ The requested offset. Ignored ifSIZE_MAXis passed.
Returns
The offset in the mbuf structure, or -1 on error. Possible values for rte_errno:
EINVALβ invalid parameters (size, align, flags, or offset).EEXISTβ this name is already register with different parameters.EBUSYβ the requested offset cannot be used.EPERMβ called from a secondary process.ENOENTβ not enough room in mbuf.ENOMEMβ allocation failure.ENAMETOOLONGβ name does not ends with\0.
π rte_mbuf_dynfield_lookup π
int rte_mbuf_dynfield_lookup (const char * name, struct rte_mbuf_dynfield * params)
Lookup for a registered dynamic mbuf field.
Parameters
nameβ A string identifying the dynamic field.paramsβ If notNULL, and if the lookup is successful, the structure is filled with the parameters of the dynamic field.
Returns
The offset of this field in the mbuf structure, or -1 on error. Possible values for rte_errno:
ENOENTβ no dynamic field matches this name.
π rte_mbuf_dynflag_register π
int rte_mbuf_dynflag_register (const struct rte_mbuf_dynflag * params)
Register a dynamic flag in the mbuf structure.
If the flag is already registered (same name and parameters), its bitnum is returned.
Parameters
paramsβ A structure containing the requested parameters of the dynamic flag (name and options).
Returns
The number of the reserved bit, or -1 on error. Possible values for rte_errno:
EINVALβ invalid parameters (size, align, or flags).EEXISTβ this name is already register with different parameters.EPERMβ called from a secondary process.ENOENTβ no more flag available.ENOMEMβ allocation failure.ENAMETOOLONGβ name is longer thanRTE_MBUF_DYN_NAMESIZE - 1.
π rte_mbuf_dynflag_register_bitnum π
int rte_mbuf_dynflag_register_bitnum (const struct rte_mbuf_dynflag * params, unsigned int bitnum)
Register a dynamic flag in the mbuf structure specifying bitnum.
If the flag is already registered (same name, parameters and bitnum), the bitnum is returned.
Parameters
paramsβ A structure containing the requested parameters of the dynamic flag (name and options).bitnumβ The requested bitnum. Ignored ifUINT_MAXis passed.
Returns
The number of the reserved bit, or -1 on error. Possible values for rte_errno:
EINVALβ invalid parameters (size, align, or flags).EEXISTβ this name is already register with different parameters.EBUSYβ the requested bitnum cannot be used.EPERMβ called from a secondary process.ENOENTβ no more flag available.ENOMEMβ allocation failure.ENAMETOOLONGβ name is longer thanRTE_MBUF_DYN_NAMESIZE - 1.
π¦ rte_mbuf_dynflag_lookup π¦
int rte_mbuf_dynflag_lookup (const char * name, struct rte_mbuf_dynflag * params)
Lookup for a registered dynamic mbuf flag.
Parameters
nameβ A string identifying the dynamic flag.paramsβ If notNULL, and if the lookup is successful, the structure is filled with the parameters of the dynamic flag.
Returns
The offset of this flag in the mbuf structure, or -1 on error. Possible values for rte_errno:
ENOENTβ no dynamic flag matches this name.
π«Ά rte_mbuf_dyn_dump π«Ά
void rte_mbuf_dyn_dump (FILE * out)
Dump the status of dynamic fields and flags.
Parameters
outβ The stream where the status is displayed.
β typedef (uint64_t ) β
Type for mbuf history dynamic field.
Use atomic operations to support cloned mbufs accessed simultaneously by multiple lcores.
The size is 64-bit for better performance on modern systems.
π rte_mbuf_dyn_rx_timestamp_register π
int rte_mbuf_dyn_rx_timestamp_register (int * field_offset, uint64_t * rx_flag)
Register dynamic mbuf field and flag for Rx timestamp.
Parameters
field_offsetβ Pointer to the offset of the registered mbuf field, can beNULL. The same field is shared for Rx and Tx timestamp.rx_flagβ Pointer to the mask of the registered offload flag, can beNULL.
Returns
0 on success, -1 otherwise. Possible values for rte_errno:
EEXISTβ already registered with different parameters.EPERMβ called from a secondary process.ENOENTβ no more field or flag available.ENOMEMβ allocation failure.
π rte_mbuf_dyn_tx_timestamp_register π
int rte_mbuf_dyn_tx_timestamp_register (int * field_offset, uint64_t * tx_flag)
Register dynamic mbuf field and flag for Tx timestamp.
Parameters
field_offsetβ Pointer to the offset of the registered mbuf field, can beNULL. The same field is shared for Rx and Tx timestamp.tx_flagβ Pointer to the mask of the registered offload flag, can beNULL.
Returns
0 on success, -1 otherwise. Possible values for rte_errno:
EEXISTβ already registered with different parameters.EPERMβ called from a secondary process.ENOENTβ no more field or flag available.ENOMEMβ allocation failure.
π Author π
Generated automatically by Doxygen for DPDK from the source code.
and that's the whole vibe bestie β DPDK version 25.11.3, rte_mbuf_dyn.h(3), iconic as always π
β¨
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms