rte_metrics.h(3)
π rte_metrics.h π
okay bestie, welcome to rte_metrics.h β that's the header for the DPDK Metrics module, straight out of the Library Functions Manual. it's giving "statistics that live outside your PMDs" and honestly? iconic. let's get into it π«Ά
β¨ NAME β¨
rte_metrics.h β literally the whole file, that's the name, that's it π
πΈ SYNOPSIS πΈ
#include <stdint.h>
π Data Structures π
struct rte_metric_namestruct rte_metric_value
π¦ Macros π¦
#define RTE_METRICS_MAX_NAME_LEN 64#define RTE_METRICS_GLOBAL -1
β Functions β
int rte_metrics_init (int socket_id)
int rte_metrics_deinit (void)
int rte_metrics_reg_name (const char *name)
int rte_metrics_reg_names (const char *const *names, uint16_t cnt_names)
int rte_metrics_get_names (struct rte_metric_name *names, uint16_t
capacity)
int rte_metrics_get_values (int port_id, struct rte_metric_value
*values, uint16_t capacity)
int rte_metrics_update_value (int port_id, uint16_t key, const uint64_t
value)
int rte_metrics_update_values (int port_id, uint16_t key, const uint64_t
*values, uint32_t count)
π Detailed Description π
DPDK Metrics module β say it with me π£
So here's the tea β: metrics are statistics that are not generated by PMDs. which means they do NOT belong in the ethdev-based extended statistics situation β they get reported through their own independent mechanism instead. it's called having main character energy and refusing to be a side quest, periodt.
- Providers will typically be other libraries.
- Consumers will typically be applications.
how does the info get in there? push model, bestie. the producers update the values held in the metric library by calling an update function on the relevant metrics. no polling, no "hey can you refresh", they just push π«‘
how do consumers get it back out? they query the central metric data, and that data is held in shared memory. and rn β literally right now β only bulk querying of metrics by consumers is supported. that's the vibe check result, no cap.
π Definition in file rte_metrics.h.
π Macro Definition Documentation π
π #define RTE_METRICS_MAX_NAME_LEN 64
Maximum length of metric name (including null-terminator). that's the cap, girl. 64 and don't push it π
π Definition at line 35 of file rte_metrics.h.
π #define RTE_METRICS_GLOBAL -1
Global metric special id. it's the special little guy β¨
When you use it for the port_id parameter when calling rte_metrics_update_metric() or rte_metrics_update_metric(), the global metric gets updated β and global metrics are the ones not associated with any specific port (i.e. device). so no port, no device, just vibes and numbers.
π Definition at line 46 of file rte_metrics.h.
π₯ Function Documentation π₯
π« int rte_metrics_init (int socket_id)
Initializes metric module. π¨ This function must be called from a primary process before metrics are used. no sneaky secondary-process behavior, absolutely not.
Parameters
socket_idβ Socket to use for shared memory allocation.
Returns
0on success- Negative error code (from
rte_errno.h) on error:-EEXISTβ a memzone for metrics already exists but metrics is not initialized-ENOMEMβ cannot allocate metrics memzone-E_RTE_SECONDARYβ function called from secondary process
π« int rte_metrics_deinit (void )
Deinitialize metric module. Must be called from a primary process after all the metrics usage is over, so the shared memory actually gets released. clean up after yourself bestie, it's called closure π§Ήβ¨
Returns
-EINVALβ invalid parameter.-EIO: Error, unable to access metrics shared memory (rte_metrics_init()not called)0β success
π« int rte_metrics_reg_name (const char * name)
Register a metric, making it available as a reporting parameter. π
Registering is literally how producers declare a parameter they wish to be reported. and once it's registered, the associated numeric key can be obtained via rte_metrics_get_names() β and bestie you need that key to update said metric's value. no key, no update, that's the rule π
Parameters
nameβ Metric name. If this exceedsRTE_METRICS_MAX_NAME_LEN(including the NULL terminator), it is truncated. βοΈ
Returns
- Zero or positive: Success (index key of new metric)
-EIO: Error, unable to access metrics shared memory (rte_metrics_init()not called)-EINVAL: Error, invalid parameters-ENOMEM: Error, maximum metrics reached
π« int rte_metrics_reg_names (const char *const * names, uint16_t cnt_names)
Register a set of metrics. it's the bulk version, we love a bulk version π§Ί
This is a bulk version of rte_metrics_reg_names() and aside from handling multiple keys at once is functionally identical.
Parameters
namesβ List of metric namescnt_namesβ Number of metrics in set
Returns
- Zero or positive: Success (index key of start of set)
-EIO: Error, unable to access metrics shared memory (rte_metrics_init()not called)-EINVAL: Error, invalid parameters-ENOMEM: Error, maximum metrics reached
π« int rte_metrics_get_names (struct rte_metric_name * names, uint16_t capacity)
Get metric name-key lookup table. the whole little dictionary of who's who π
Parameters
namesβ Astruct rte_metric_namearray of at leastcapacityin size to receive key names. If this isNULL, function returns the required number of elements for this array.capacityβ Size (number of elements) ofstruct rte_metric_namearray. Disregarded ifnamesisNULL.
Returns
- Positive value above
capacity: error,namesis too small. Return value is required size. - Positive value equal or less than
capacity: Success. Return value is number of elements filled in. - Negative value: error.
π« int rte_metrics_get_values (int port_id, struct rte_metric_value * values, uint16_t capacity)
Get metric value table. the actual numbers, the receipts π§Ύ
Parameters
port_idβ Port id to queryvaluesβ Astruct rte_metric_valuearray of at leastcapacityin size to receive metric ids and values. If this isNULL, function returns the required number of elements for this array.capacityβ Size (number of elements) ofstruct rte_metric_valuearray. Disregarded ifnamesisNULL.
Returns
- Positive value above
capacity: error,valuesis too small. Return value is required size. - Positive value equal or less than
capacity: Success. Return value is number of elements filled in. - Negative value: error.
π« int rte_metrics_update_value (int port_id, uint16_t key, const uint64_t value)
Updates a metric πβ¨
Parameters
port_idβ Port to update metrics forkeyβ Id of metric to updatevalueβ New value
Returns
-EIOif unable to access shared metrics memory- Zero on success
π« int rte_metrics_update_values (int port_id, uint16_t key, const uint64_t * values, uint32_t count)
Updates a metric set. β οΈ Note that it is an error to try to update across a set boundary. don't do it. seriously. the boundary is the boundary ππ§
Parameters
port_idβ Port to update metrics forkeyβ Base id of metrics set to updatevaluesβ Set of new valuescountβ Number of new values
Returns
-ERANGEifcountexceeds metric set size-EIOif unable to access shared metrics memory- Zero on success
π Author π
Generated automatically by Doxygen for DPDK from the source code. (it wrote itself, honestly kind of a slay π€π )
okay that's the whole page bestie, you're officially literate in the DPDK Metrics module, go forth and push your metrics π«Άβ¨
this lil doc was brought to you by DPDK, Version 25.11.3, under the name rte_metrics.h(3) β mwah, bye πππ¦
π¦ 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