DPDK 25.11.0-rc1
Macros | Enumerations | Functions | Variables
rte_mbuf_history.h File Reference
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_mbuf_dyn.h>

Go to the source code of this file.

Macros

#define RTE_MBUF_HISTORY_BITS   4
 
#define RTE_MBUF_HISTORY_MAX   (sizeof(rte_mbuf_history_t) * 8 / RTE_MBUF_HISTORY_BITS)
 

Enumerations

enum  rte_mbuf_history_op {
  RTE_MBUF_HISTORY_OP_NEVER = 0 , RTE_MBUF_HISTORY_OP_LIB_FREE = 1 , RTE_MBUF_HISTORY_OP_PMD_FREE = 2 , RTE_MBUF_HISTORY_OP_APP_FREE = 3 ,
  RTE_MBUF_HISTORY_OP_LIB_ALLOC = 4 , RTE_MBUF_HISTORY_OP_PMD_ALLOC = 5 , RTE_MBUF_HISTORY_OP_APP_ALLOC = 6 , RTE_MBUF_HISTORY_OP_RX = 7 ,
  RTE_MBUF_HISTORY_OP_TX = 8 , RTE_MBUF_HISTORY_OP_TX_PREP = 9 , RTE_MBUF_HISTORY_OP_TX_BUSY = 10 , RTE_MBUF_HISTORY_OP_ENQUEUE = 11 ,
  RTE_MBUF_HISTORY_OP_DEQUEUE = 12 , RTE_MBUF_HISTORY_OP_USR2 = 14 , RTE_MBUF_HISTORY_OP_USR1 = 15 , RTE_MBUF_HISTORY_OP_MAX = 16
}
 

Functions

__rte_experimental void rte_mbuf_history_init (void)
 
static void rte_mbuf_history_mark (struct rte_mbuf *m, enum rte_mbuf_history_op op)
 
static void rte_mbuf_history_mark_bulk (struct rte_mbuf *const *mbufs, unsigned int count, enum rte_mbuf_history_op op)
 
__rte_experimental void rte_mbuf_history_dump (FILE *f, const struct rte_mbuf *m)
 
__rte_experimental void rte_mbuf_history_dump_mempool (FILE *f, struct rte_mempool *mp)
 
__rte_experimental void rte_mbuf_history_dump_all (FILE *f)
 

Variables

int rte_mbuf_history_field_offset
 

Detailed Description

Warning
EXPERIMENTAL: this API may change without prior notice.

These functions allow to track history of mbuf objects using a dynamic field.

It tracks the lifecycle of mbuf objects through the system with a fixed set of predefined events to maintain performance.

The history is stored as an atomic value (64-bit) in a dynamic field of the mbuf, with each event encoded in 4 bits, allowing up to 16 events to be tracked. Atomic operations ensure thread safety for cloned mbufs accessed by multiple lcores.

After dumping the history in a file, the script dpdk-mbuf-history-parser.py can be used for parsing.

Definition in file rte_mbuf_history.h.

Macro Definition Documentation

◆ RTE_MBUF_HISTORY_BITS

#define RTE_MBUF_HISTORY_BITS   4

Number of bits for each history operation.

Definition at line 43 of file rte_mbuf_history.h.

◆ RTE_MBUF_HISTORY_MAX

#define RTE_MBUF_HISTORY_MAX   (sizeof(rte_mbuf_history_t) * 8 / RTE_MBUF_HISTORY_BITS)

Maximum number of history operations that can be stored.

Definition at line 48 of file rte_mbuf_history.h.

Enumeration Type Documentation

◆ rte_mbuf_history_op

History operation types.

Enumerator
RTE_MBUF_HISTORY_OP_NEVER 

Initial state - never allocated

RTE_MBUF_HISTORY_OP_LIB_FREE 

Freed back to pool

RTE_MBUF_HISTORY_OP_PMD_FREE 

Freed by PMD

RTE_MBUF_HISTORY_OP_APP_FREE 

Freed by application

RTE_MBUF_HISTORY_OP_LIB_ALLOC 

Allocation in mbuf library

RTE_MBUF_HISTORY_OP_PMD_ALLOC 

Allocated by PMD for Rx

RTE_MBUF_HISTORY_OP_APP_ALLOC 

Allocated by application

RTE_MBUF_HISTORY_OP_RX 

Received

RTE_MBUF_HISTORY_OP_TX 

Sent

RTE_MBUF_HISTORY_OP_TX_PREP 

Being prepared before Tx

RTE_MBUF_HISTORY_OP_TX_BUSY 

Returned due to Tx busy

RTE_MBUF_HISTORY_OP_ENQUEUE 

Enqueued for processing

RTE_MBUF_HISTORY_OP_DEQUEUE 

Dequeued for processing

RTE_MBUF_HISTORY_OP_USR2 

Application-defined event 2

RTE_MBUF_HISTORY_OP_USR1 

Application-defined event 1

RTE_MBUF_HISTORY_OP_MAX 

Maximum number of operation types

Definition at line 53 of file rte_mbuf_history.h.

Function Documentation

◆ rte_mbuf_history_init()

__rte_experimental void rte_mbuf_history_init ( void  )

Initialize the mbuf history system.

Warning
EXPERIMENTAL: this API may change without prior notice.

This function registers the dynamic field for mbuf history tracking. It should be called once during application initialization.

Note: This function is called by rte_pktmbuf_pool_create, so explicit invocation is usually not required.

◆ rte_mbuf_history_mark()

static void rte_mbuf_history_mark ( struct rte_mbuf m,
enum rte_mbuf_history_op  op 
)
inlinestatic

Mark an mbuf with a history event.

Warning
EXPERIMENTAL: this API may change without prior notice.
Parameters
mPointer to the mbuf.
opThe operation to record.

Definition at line 105 of file rte_mbuf_history.h.

◆ rte_mbuf_history_mark_bulk()

static void rte_mbuf_history_mark_bulk ( struct rte_mbuf *const *  mbufs,
unsigned int  count,
enum rte_mbuf_history_op  op 
)
inlinestatic

Mark multiple mbufs with a history event.

Warning
EXPERIMENTAL: this API may change without prior notice.
Parameters
mbufsArray of mbuf pointers.
countNumber of mbufs to mark.
opThe operation to record.

Definition at line 142 of file rte_mbuf_history.h.

◆ rte_mbuf_history_dump()

__rte_experimental void rte_mbuf_history_dump ( FILE *  f,
const struct rte_mbuf m 
)

Dump mbuf history for a single mbuf to a file.

Warning
EXPERIMENTAL: this API may change without prior notice.
EXPERIMENTAL: this API may change without prior notice.
Parameters
fFile pointer to write the history to.
mPointer to the mbuf to dump history for.

◆ rte_mbuf_history_dump_mempool()

__rte_experimental void rte_mbuf_history_dump_mempool ( FILE *  f,
struct rte_mempool mp 
)

Dump mbuf history statistics for a single mempool to a file.

Warning
EXPERIMENTAL: this API may change without prior notice.
Parameters
fFile pointer to write the history statistics to.
mpPointer to the mempool to dump history for.

◆ rte_mbuf_history_dump_all()

__rte_experimental void rte_mbuf_history_dump_all ( FILE *  f)

Dump mbuf history statistics for all mempools to a file.

Warning
EXPERIMENTAL: this API may change without prior notice.
Parameters
fFile pointer to write the history statistics to.

Variable Documentation

◆ rte_mbuf_history_field_offset

int rte_mbuf_history_field_offset
extern

Global offset for the history dynamic field (set during initialization).