---
name: "rte_latencystats_get"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_latencystats.h"
---

# rte\_latencystats\_get(3)

Part of [rte\_latencystats.h(3)](/rte_latencystats.h/3.md).

## NAME

rte\_latencystats.h

## SYNOPSIS

`#include <stdint.h>`\
 `#include <rte_metrics.h>`\
 `#include <rte_mbuf.h>`\

### Typedefs

**typedef** uint16\_t(\* **rte\_latency\_stats\_flow\_type\_fn**) (struct **rte\_mbuf** \*pkt, void \*user\_param)\

### Functions

int **rte\_latencystats\_init** (uint64\_t samp\_intvl, **rte\_latency\_stats\_flow\_type\_fn** user\_cb)\
 int32\_t **rte\_latencystats\_update** (void)\
 int **rte\_latencystats\_uninit** (void)\
 int **rte\_latencystats\_get\_names** (struct **rte\_metric\_name** \*names, uint16\_t size)\
 int **rte\_latencystats\_get** (struct **rte\_metric\_value** \*values, uint16\_t size)\

## Detailed Description

RTE latency stats

library to provide application and flow based latency stats.

Definition in file **rte\_latencystats.h**.

## Typedef Documentation

### typedef uint16\_t(\* rte\_latency\_stats\_flow\_type\_fn) (struct rte\_mbuf \*pkt, void \*user\_param)

Note: This function pointer is for future flow based latency stats implementation.

Function type used for identifying flow types of a Rx packet.

The callback function is called on Rx for each packet. This function is used for flow based latency calculations.

**Parameters**

*pkt* Packet that has to be identified with its flow types. \
 *user\_param* The arbitrary user parameter passed in by the application when the callback was originally configured.

**Returns**

The flow\_mask, representing the multiple flow types of a packet.

Definition at line **40** of file **rte\_latencystats.h**.

## Function Documentation

### int rte\_latencystats\_init (uint64\_t samp\_intvl, rte\_latency\_stats\_flow\_type\_fn user\_cb)

Registers Rx/Tx callbacks for each active port, queue.

**Parameters**

*samp\_intvl* Sampling time period in nano seconds, at which packet should be marked with time stamp. \
 *user\_cb* Note: This param is for future flow based latency stats implementation. User callback to be called to get flow types of a packet. Used for flow based latency calculation. If the value is NULL, global stats will be calculated, else flow based latency stats will be calculated. For now just pass on the NULL value to this param.

**Returns**

\-1 : On error -ENOMEM: On error 0 : On success

### int32\_t rte\_latencystats\_update (void)

Calculates the latency and jitter values internally, exposing the updated values via *rte\_latencystats\_get* or the rte\_metrics API.

**Returns**

: 0 : on Success \< 0 : Error in updating values.

### int rte\_latencystats\_uninit (void)

Removes registered Rx/Tx callbacks for each active port, queue.

**Returns**

\-1: On error 0: On success

### int rte\_latencystats\_get\_names (struct rte\_metric\_name \* names, uint16\_t size)

Retrieve names of latency statistics

**Parameters**

*names* Block of memory to insert names into. Must be at least size in capacity. If set to NULL, function returns required capacity. \
 *size* Capacity of latency stats names (number of names).

**Returns**

- •

  positive value lower or equal to size: success. The return value is the number of entries filled in the stats table.

- •

  positive value higher than size: error, the given statistics table is too small. The return value corresponds to the size that should be given to succeed. The entries in the table are not valid and shall not be used by the caller.

### int rte\_latencystats\_get (struct rte\_metric\_value \* values, uint16\_t size)

Retrieve latency statistics.

**Parameters**

*values* A pointer to a table of structure of type **rte\_metric\_value to be filled with latency statistics ids and values. This parameter can be set to NULL if size is 0.** \
 *size* **The size of the stats table, which should be large enough to store all the latency stats.**

**Returns**

- •

  **positive value lower or equal to size: success. The return value is the number of entries filled in the stats table.**

- •

  **positive value higher than size: error, the given statistics table is too small. The return value corresponds to the size that should be given to succeed. The entries in the table are not valid and shall not be used by the caller. -ENOMEM: On failure.**

## Author

**Generated automatically by Doxygen for DPDK from the source code.**
