---
name: "rte_graph_cluster_stats_create"
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_graph.h"
---

# rte\_graph\_cluster\_stats\_create(3)

Part of [rte\_graph.h(3)](/rte_graph.h/3.md).

## NAME

rte\_graph.h

## SYNOPSIS

`#include <stdbool.h>`\
 `#include <stdio.h>`\
 `#include <rte_common.h>`\

### Data Structures

struct **rte\_graph\_param**\
 struct **rte\_graph\_cluster\_stats\_param**\
 struct **rte\_graph\_cluster\_node\_stats**\
 struct **rte\_node\_xstats**\
 struct **rte\_node\_register**\

### Macros

\#define **RTE\_GRAPH\_NAMESIZE**   64\
 \#define **RTE\_NODE\_NAMESIZE**   64\
 \#define **RTE\_NODE\_XSTAT\_DESC\_SIZE**   64\
 \#define **RTE\_GRAPH\_PCAP\_FILE\_SZ**   64\
 \#define **RTE\_GRAPH\_OFF\_INVALID**   UINT32\_MAX\
 \#define **RTE\_NODE\_ID\_INVALID**   UINT32\_MAX\
 \#define **RTE\_EDGE\_ID\_INVALID**   UINT16\_MAX\
 \#define **RTE\_GRAPH\_ID\_INVALID**   UINT16\_MAX\
 \#define **RTE\_GRAPH\_FENCE**   0xdeadbeef12345678ULL\
 \#define **rte\_graph\_foreach\_node**(count,  off,  graph,  node)\
 \#define **RTE\_NODE\_SOURCE\_F**   (1ULL \<\< 0)\
 \#define **RTE\_NODE\_REGISTER**(node)\

### Typedefs

**typedef** uint32\_t **rte\_graph\_off\_t**\
 **typedef** uint32\_t **rte\_node\_t**\
 **typedef** uint16\_t **rte\_edge\_t**\
 **typedef** uint16\_t **rte\_graph\_t**\
 **typedef** uint16\_t(\* **rte\_node\_process\_t**) (struct rte\_graph \*graph, struct rte\_node \*node, void \*\*objs, uint16\_t nb\_objs)\
 **typedef** int(\* **rte\_node\_init\_t**) (const struct rte\_graph \*graph, struct rte\_node \*node)\
 **typedef** void(\* **rte\_node\_fini\_t**) (const struct rte\_graph \*graph, struct rte\_node \*node)\
 **typedef** int(\* **rte\_graph\_cluster\_stats\_cb\_t**) (bool is\_first, bool is\_last, void \*cookie, const struct **rte\_graph\_cluster\_node\_stats** \*stats)\

### Functions

**rte\_graph\_t** **rte\_graph\_create** (const char \*name, struct **rte\_graph\_param** \*prm)\
 int **rte\_graph\_destroy** (**rte\_graph\_t** id)\
 **rte\_graph\_t** **rte\_graph\_clone** (**rte\_graph\_t** id, const char \*name, struct **rte\_graph\_param** \*prm)\
 **rte\_graph\_t** **rte\_graph\_from\_name** (const char \*name)\
 char \* **rte\_graph\_id\_to\_name** (**rte\_graph\_t** id)\
 int **rte\_graph\_export** (const char \*name, FILE \*f)\
 int **rte\_graph\_model\_mcore\_dispatch\_core\_bind** (**rte\_graph\_t** id, int lcore)\
 void **rte\_graph\_model\_mcore\_dispatch\_core\_unbind** (**rte\_graph\_t** id)\
 struct rte\_graph \* **rte\_graph\_lookup** (const char \*name)\
 **rte\_graph\_t** **rte\_graph\_max\_count** (void)\
 void **rte\_graph\_dump** (FILE \*f, **rte\_graph\_t** id)\
 void **rte\_graph\_list\_dump** (FILE \*f)\
 void **rte\_graph\_obj\_dump** (FILE \*f, struct rte\_graph \*graph, bool all)\
 struct rte\_node \* **rte\_graph\_node\_get** (**rte\_graph\_t** graph\_id, **rte\_node\_t** node\_id)\
 struct rte\_node \* **rte\_graph\_node\_get\_by\_name** (const char \*graph, const char \*name)\
 struct rte\_graph\_cluster\_stats \* **rte\_graph\_cluster\_stats\_create** (const struct **rte\_graph\_cluster\_stats\_param** \*prm)\
 void **rte\_graph\_cluster\_stats\_destroy** (struct rte\_graph\_cluster\_stats \*stat)\
 void **rte\_graph\_cluster\_stats\_get** (struct rte\_graph\_cluster\_stats \*stat, bool skip\_cb)\
 void **rte\_graph\_cluster\_stats\_reset** (struct rte\_graph\_cluster\_stats \*stat)\
 **rte\_node\_t** **\_\_rte\_node\_register** (const struct **rte\_node\_register** \*node)\
 **rte\_node\_t** **rte\_node\_clone** (**rte\_node\_t** id, const char \*name)\
 **rte\_node\_t** **rte\_node\_from\_name** (const char \*name)\
 char \* **rte\_node\_id\_to\_name** (**rte\_node\_t** id)\
 **rte\_edge\_t** **rte\_node\_edge\_count** (**rte\_node\_t** id)\
 **rte\_edge\_t** **rte\_node\_edge\_update** (**rte\_node\_t** id, **rte\_edge\_t** from, const char \*\*next\_nodes, uint16\_t nb\_edges)\
 **rte\_edge\_t** **rte\_node\_edge\_shrink** (**rte\_node\_t** id, **rte\_edge\_t** size)\
 **rte\_node\_t** **rte\_node\_edge\_get** (**rte\_node\_t** id, char \*next\_nodes\[\])\
 **rte\_node\_t** **rte\_node\_max\_count** (void)\
 void **rte\_node\_dump** (FILE \*f, **rte\_node\_t** id)\
 void **rte\_node\_list\_dump** (FILE \*f)\
 static **\_\_rte\_always\_inline** int **rte\_node\_is\_invalid** (**rte\_node\_t** id)\
 static **\_\_rte\_always\_inline** int **rte\_edge\_is\_invalid** (**rte\_edge\_t** id)\
 static **\_\_rte\_always\_inline** int **rte\_graph\_is\_invalid** (**rte\_graph\_t** id)\
 static **\_\_rte\_always\_inline** int **rte\_graph\_has\_stats\_feature** (void)\

## Detailed Description

Graph architecture abstracts the data processing functions as 'node' and 'link' them together to create a complex 'graph' to enable reusable/modular data processing functions.

This API enables graph framework operations such as create, lookup, dump and destroy on graph and node operations such as clone, edge update, and edge shrink, etc. The API also allows to create the stats cluster to monitor per graph and per node stats.

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

## Macro Definition Documentation

### #define RTE\_GRAPH\_NAMESIZE 64

Max length of graph name.

Definition at line **30** of file **rte\_graph.h**.

### #define RTE\_NODE\_NAMESIZE 64

Max length of node name.

Definition at line **31** of file **rte\_graph.h**.

### #define RTE\_NODE\_XSTAT\_DESC\_SIZE 64

Max length of node xstat description.

Definition at line **32** of file **rte\_graph.h**.

### #define RTE\_GRAPH\_PCAP\_FILE\_SZ 64

Max length of pcap file name.

Definition at line **33** of file **rte\_graph.h**.

### #define RTE\_GRAPH\_OFF\_INVALID UINT32\_MAX

Invalid graph offset.

Definition at line **34** of file **rte\_graph.h**.

### #define RTE\_NODE\_ID\_INVALID UINT32\_MAX

Invalid node id.

Definition at line **35** of file **rte\_graph.h**.

### #define RTE\_EDGE\_ID\_INVALID UINT16\_MAX

Invalid edge id.

Definition at line **36** of file **rte\_graph.h**.

### #define RTE\_GRAPH\_ID\_INVALID UINT16\_MAX

Invalid graph id.

Definition at line **37** of file **rte\_graph.h**.

### #define RTE\_GRAPH\_FENCE 0xdeadbeef12345678ULL

Graph fence data.

Definition at line **38** of file **rte\_graph.h**.

### #define rte\_graph\_foreach\_node(count, off, graph, node)

**Value:**.PP

```
    for (count = 0, off = graph->nodes_start,                              \
         node = RTE_PTR_ADD(graph, off);                                   \
         count < graph->nb_nodes;                                          \
         off = node->next, node = RTE_PTR_ADD(graph, off), count++)
```

Macro to browse rte\_node object after the graph creation

Definition at line **395** of file **rte\_graph.h**.

### #define RTE\_NODE\_SOURCE\_F (1ULL \<\< 0)

Node type is source.

Definition at line **485** of file **rte\_graph.h**.

### #define RTE\_NODE\_REGISTER(node)

**Value:**.PP

```
    RTE_INIT(rte_node_register_##node)                                     \
    {                                                                      \
        node.parent_id = RTE_NODE_ID_INVALID;                          \
        node.id = __rte_node_register(&node);                          \
    }
```

Register a static node.

The static node is registered through the constructor scheme, thereby, it can be used in a multi-process scenario.

**Parameters**

*node* Valid node pointer with name, process function, and next\_nodes.

Definition at line **520** of file **rte\_graph.h**.

## Typedef Documentation

### typedef uint32\_t rte\_graph\_off\_t

Graph offset type.

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

### typedef uint32\_t rte\_node\_t

Node id type.

Definition at line **41** of file **rte\_graph.h**.

### typedef uint16\_t rte\_edge\_t

Edge id type.

Definition at line **42** of file **rte\_graph.h**.

### typedef uint16\_t rte\_graph\_t

Graph id type.

Definition at line **43** of file **rte\_graph.h**.

### typedef uint16\_t(\* rte\_node\_process\_t) (struct rte\_graph \*graph, struct rte\_node \*node, void \*\*objs, uint16\_t nb\_objs)

Node stats within cluster of graphs Node process function.

The function invoked when the worker thread walks on nodes using rte\_graph\_walk().

**Parameters**

*graph* Pointer to the graph object. \
 *node* Pointer to the node object. \
 *objs* Pointer to an array of objects to be processed. \
 *nb\_objs* Number of objects in the array.

**Returns**

Number of objects processed.

**See also**

rte\_graph\_walk()

Definition at line **94** of file **rte\_graph.h**.

### typedef int(\* rte\_node\_init\_t) (const struct rte\_graph \*graph, struct rte\_node \*node)

Node initialization function.

The function invoked when the user creates the graph using **rte\_graph\_create()**

**Parameters**

*graph* Pointer to the graph object. \
 *node* Pointer to the node object.

**Returns**

- •

  0: Success. -\<0: Failure.

**See also**

**rte\_graph\_create()**

Definition at line **114** of file **rte\_graph.h**.

### typedef void(\* rte\_node\_fini\_t) (const struct rte\_graph \*graph, struct rte\_node \*node)

Node finalization function.

The function invoked when the user destroys the graph using **rte\_graph\_destroy()**.

**Parameters**

*graph* Pointer to the graph object. \
 *node* Pointer to the node object.

**See also**

**rte\_graph\_destroy()**

Definition at line **130** of file **rte\_graph.h**.

### typedef int(\* rte\_graph\_cluster\_stats\_cb\_t) (bool is\_first, bool is\_last, void \*cookie, const struct rte\_graph\_cluster\_node\_stats \*stats)

Graph cluster stats callback.

**Parameters**

*is\_first* Flag to denote that stats are of the first node. \
 *is\_last* Flag to denote that stats are of the last node. \
 *cookie* Cookie supplied during stats creation. \
 *stats* Node cluster stats data.

**Returns**

- •

  0: Success. -\<0: Failure.

Definition at line **149** of file **rte\_graph.h**.

## Function Documentation

### rte\_graph\_t rte\_graph\_create (const char \* name, struct rte\_graph\_param \* prm)

Create Graph.

Create memory reel, detect loops and find isolated nodes.

**Parameters**

*name* Unique name for this graph. \
 *prm* Graph parameter, includes node names and count to be included in this graph.

**Returns**

Unique graph id on success, RTE\_GRAPH\_ID\_INVALID otherwise.

### int rte\_graph\_destroy (rte\_graph\_t id)

Destroy Graph.

Free Graph memory reel.

**Parameters**

*id* id of the graph to destroy.

**Returns**

0 on success, error otherwise.

### rte\_graph\_t rte\_graph\_clone (rte\_graph\_t id, const char \* name, struct rte\_graph\_param \* prm)

Clone Graph.

Clone a graph from static graph (graph created from **rte\_graph\_create()**). And all cloned graphs attached to the parent graph MUST be destroyed together for fast schedule design limitation (stop ALL graph walk firstly).

**Parameters**

*id* Static graph id to clone from. \
 *name* Name of the new graph. The library prepends the parent graph name to the user-specified name. The final graph name will be, 'parent graph name' + '-' + name. \
 *prm* Graph parameter, includes model-specific parameters in this graph.

**Returns**

Valid graph id on success, RTE\_GRAPH\_ID\_INVALID otherwise.

### rte\_graph\_t rte\_graph\_from\_name (const char \* name)

Get graph id from graph name.

**Parameters**

*name* Name of the graph to get id.

**Returns**

Graph id on success, RTE\_GRAPH\_ID\_INVALID otherwise.

### char \* rte\_graph\_id\_to\_name (rte\_graph\_t id)

Get graph name from graph id.

**Parameters**

*id* id of the graph to get name.

**Returns**

Graph name on success, NULL otherwise.

### int rte\_graph\_export (const char \* name, FILE \* f)

Export the graph as graph viz dot file

**Parameters**

*name* Name of the graph to export. \
 *f* File pointer to export the graph.

**Returns**

0 on success, error otherwise.

### int rte\_graph\_model\_mcore\_dispatch\_core\_bind (rte\_graph\_t id, int lcore)

Bind graph with specific lcore for mcore dispatch model.

**Parameters**

*id* Graph id to get the pointer of graph object \
 *lcore* The lcore where the graph will run on

**Returns**

0 on success, error otherwise.

### void rte\_graph\_model\_mcore\_dispatch\_core\_unbind (rte\_graph\_t id)

Unbind graph with lcore for mcore dispatch model

**Parameters**

*id* Graph id to get the pointer of graph object

### struct rte\_graph \* rte\_graph\_lookup (const char \* name)

Get graph object from its name.

Typical usage of this API to get graph objects in the worker thread and followed calling rte\_graph\_walk() in a loop.

**Parameters**

*name* Name of the graph.

**Returns**

Graph pointer on success, NULL otherwise.

**See also**

rte\_graph\_walk()

### rte\_graph\_t rte\_graph\_max\_count (void)

Get maximum number of graph available.

**Returns**

Maximum graph count.

### void rte\_graph\_dump (FILE \* f, rte\_graph\_t id)

Dump the graph information to file.

**Parameters**

*f* File pointer to dump graph info. \
 *id* Graph id to get graph info.

### void rte\_graph\_list\_dump (FILE \* f)

Dump all graphs information to file

**Parameters**

*f* File pointer to dump graph info.

### void rte\_graph\_obj\_dump (FILE \* f, struct rte\_graph \* graph, bool all)

Dump graph information along with node info to file

**Parameters**

*f* File pointer to dump graph info. \
 *graph* Graph pointer to get graph info. \
 *all* true to dump nodes in the graph.

### struct rte\_node \* rte\_graph\_node\_get (rte\_graph\_t graph\_id, rte\_node\_t node\_id)

Get node object with in graph from id.

**Parameters**

*graph\_id* Graph id to get node pointer from. \
 *node\_id* Node id to get node pointer.

**Returns**

Node pointer on success, NULL otherwise.

### struct rte\_node \* rte\_graph\_node\_get\_by\_name (const char \* graph, const char \* name)

Get node pointer with in graph from name.

**Parameters**

*graph* Graph name to get node pointer from. \
 *name* Node name to get the node pointer.

**Returns**

Node pointer on success, NULL otherwise.

### struct rte\_graph\_cluster\_stats \* rte\_graph\_cluster\_stats\_create (const struct rte\_graph\_cluster\_stats\_param \* prm)

Create graph stats cluster to aggregate runtime node stats.

**Parameters**

*prm* Parameters including file pointer to dump stats, Graph pattern to create cluster and callback function.

**Returns**

Valid pointer on success, NULL otherwise.

### void rte\_graph\_cluster\_stats\_destroy (struct rte\_graph\_cluster\_stats \* stat)

Destroy cluster stats.

**Parameters**

*stat* Valid cluster pointer to destroy.

### void rte\_graph\_cluster\_stats\_get (struct rte\_graph\_cluster\_stats \* stat, bool skip\_cb)

Get stats to application.

**Parameters**

*stat* Cluster status. \
 *skip\_cb* true to skip callback function invocation.

### void rte\_graph\_cluster\_stats\_reset (struct rte\_graph\_cluster\_stats \* stat)

Reset cluster stats to zero.

**Parameters**

*stat* Valid cluster stats pointer.

### rte\_node\_t \_\_rte\_node\_register (const struct rte\_node\_register \* node)

Register new packet processing node. Nodes can be registered dynamically via this call or statically via the RTE\_NODE\_REGISTER macro.

**Parameters**

*node* Valid node pointer with name, process function and next\_nodes.

**Returns**

Valid node id on success, RTE\_NODE\_ID\_INVALID otherwise.

**See also**

**RTE\_NODE\_REGISTER()**

### rte\_node\_t rte\_node\_clone (rte\_node\_t id, const char \* name)

Clone a node from static node(node created from RTE\_NODE\_REGISTER).

**Parameters**

*id* Static node id to clone from. \
 *name* Name of the new node. The library prepends the parent node name to the user-specified name. The final node name will be, 'parent node name' + '-' + name.

**Returns**

Valid node id on success, RTE\_NODE\_ID\_INVALID otherwise.

### rte\_node\_t rte\_node\_from\_name (const char \* name)

Get node id from node name.

**Parameters**

*name* Valid node name. In the case of the cloned node, the name will be 'parent node name' + '-' + name.

**Returns**

Valid node id on success, RTE\_NODE\_ID\_INVALID otherwise.

### char \* rte\_node\_id\_to\_name (rte\_node\_t id)

Get node name from node id.

**Parameters**

*id* Valid node id.

**Returns**

Valid node name on success, NULL otherwise.

### rte\_edge\_t rte\_node\_edge\_count (rte\_node\_t id)

Get the number of edges(next-nodes) for a node from node id.

**Parameters**

*id* Valid node id.

**Returns**

Valid edge count on success, RTE\_EDGE\_ID\_INVALID otherwise.

### rte\_edge\_t rte\_node\_edge\_update (rte\_node\_t id, rte\_edge\_t from, const char \*\* next\_nodes, uint16\_t nb\_edges)

Update the edges for a node from node id.

**Parameters**

*id* Valid node id. \
 *from* Index to update the edges from. RTE\_EDGE\_ID\_INVALID is valid, in that case, it will be added to the end of the list. \
 *next\_nodes* Name of the edges to update. \
 *nb\_edges* Number of edges to update.

**Returns**

Valid edge count on success, 0 otherwise.

### rte\_edge\_t rte\_node\_edge\_shrink (rte\_node\_t id, rte\_edge\_t size)

Shrink the edges to a given size.

**Parameters**

*id* Valid node id. \
 *size* New size to shrink the edges.

**Returns**

New size on success, RTE\_EDGE\_ID\_INVALID otherwise.

### rte\_node\_t rte\_node\_edge\_get (rte\_node\_t id, char \* next\_nodes\[\])

Get the edge names from a given node.

**Parameters**

*id* Valid node id. \
 *next\_nodes* Buffer to copy the edge names. The NULL value is allowed in that case, the function returns the size of the array that needs to be allocated.

**Returns**

When next\_nodes == NULL, it returns the size of the array else number of item copied.

### rte\_node\_t rte\_node\_max\_count (void)

Get maximum nodes available.

**Returns**

Maximum nodes count.

### void rte\_node\_dump (FILE \* f, rte\_node\_t id)

Dump node info to file.

**Parameters**

*f* File pointer to dump the node info. \
 *id* Node id to get the info.

### void rte\_node\_list\_dump (FILE \* f)

Dump all node info to file.

**Parameters**

*f* File pointer to dump the node info.

### static \_\_rte\_always\_inline int rte\_node\_is\_invalid (rte\_node\_t id)` [static]`

Test the validity of node id.

**Parameters**

*id* Node id to check.

**Returns**

1 if valid id, 0 otherwise.

Definition at line **659** of file **rte\_graph.h**.

### static \_\_rte\_always\_inline int rte\_edge\_is\_invalid (rte\_edge\_t id)` [static]`

Test the validity of edge id.

**Parameters**

*id* Edge node id to check.

**Returns**

1 if valid id, 0 otherwise.

Definition at line **674** of file **rte\_graph.h**.

### static \_\_rte\_always\_inline int rte\_graph\_is\_invalid (rte\_graph\_t id)` [static]`

Test the validity of graph id.

**Parameters**

*id* Graph id to check.

**Returns**

1 if valid id, 0 otherwise.

Definition at line **689** of file **rte\_graph.h**.

### static \_\_rte\_always\_inline int rte\_graph\_has\_stats\_feature (void)` [static]`

Test stats feature support.

**Returns**

1 if stats enabled, 0 otherwise.

Definition at line **701** of file **rte\_graph.h**.

## Author

Generated automatically by Doxygen for DPDK from the source code.
