rte_graph.h
Contents
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.
Function Documentation
rte_graph_trte_graph_create(constchar*name,structrte_graph_param*prm)
Create Graph.
Create memory reel, detect loops and find isolated nodes.
Parametersname 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.
intrte_graph_destroy(rte_graph_tid)
Destroy Graph.
Free Graph memory reel.
Parametersid id of the graph to destroy.
Returns
0 on success, error otherwise.
rte_graph_trte_graph_clone(rte_graph_tid,constchar*name,structrte_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).
Parametersid 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_trte_graph_from_name(constchar*name)
Get graph id from graph name.
Parametersname 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_tid)
Get graph name from graph id.
Parametersid id of the graph to get name.
Returns
Graph name on success, NULL otherwise.
intrte_graph_export(constchar*name,FILE*f)
Export the graph as graph viz dot file
Parametersname Name of the graph to export.
f File pointer to export the graph.
Returns
0 on success, error otherwise.
intrte_graph_model_mcore_dispatch_core_bind(rte_graph_tid,intlcore)
Bind graph with specific lcore for mcore dispatch model.
Parametersid Graph id to get the pointer of graph object
lcore The lcore where the graph will run on
Returns
0 on success, error otherwise.
voidrte_graph_model_mcore_dispatch_core_unbind(rte_graph_tid)
Unbind graph with lcore for mcore dispatch model
Parametersid Graph id to get the pointer of graph object
structrte_graph*rte_graph_lookup(constchar*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.
Parametersname Name of the graph.
Returns
Graph pointer on success, NULL otherwise.
Seealso
rte_graph_walk()
rte_graph_trte_graph_max_count(void)
Get maximum number of graph available.
Returns
Maximum graph count.
voidrte_graph_dump(FILE*f,rte_graph_tid)
Dump the graph information to file.
Parametersf File pointer to dump graph info.
id Graph id to get graph info.
voidrte_graph_list_dump(FILE*f)
Dump all graphs information to file
Parametersf File pointer to dump graph info.
voidrte_graph_obj_dump(FILE*f,structrte_graph*graph,boolall)
Dump graph information along with node info to file
Parametersf File pointer to dump graph info.
graph Graph pointer to get graph info.
all true to dump nodes in the graph.
structrte_node*rte_graph_node_get(rte_graph_tgraph_id,rte_node_tnode_id)
Get node object with in graph from id.
Parametersgraph_id Graph id to get node pointer from.
node_id Node id to get node pointer.
Returns
Node pointer on success, NULL otherwise.
structrte_node*rte_graph_node_get_by_name(constchar*graph,constchar*name)
Get node pointer with in graph from name.
Parametersgraph Graph name to get node pointer from.
name Node name to get the node pointer.
Returns
Node pointer on success, NULL otherwise.
structrte_graph_cluster_stats*rte_graph_cluster_stats_create(conststructrte_graph_cluster_stats_param*prm)
Create graph stats cluster to aggregate runtime node stats.
Parametersprm Parameters including file pointer to dump stats, Graph pattern to create cluster and callback
function.
Returns
Valid pointer on success, NULL otherwise.
voidrte_graph_cluster_stats_destroy(structrte_graph_cluster_stats*stat)
Destroy cluster stats.
Parametersstat Valid cluster pointer to destroy.
voidrte_graph_cluster_stats_get(structrte_graph_cluster_stats*stat,boolskip_cb)
Get stats to application.
Parametersstat Cluster status.
skip_cb true to skip callback function invocation.
voidrte_graph_cluster_stats_reset(structrte_graph_cluster_stats*stat)
Reset cluster stats to zero.
Parametersstat Valid cluster stats pointer.
rte_node_t__rte_node_register(conststructrte_node_register*node)
Register new packet processing node. Nodes can be registered dynamically via this call or statically via
the RTE_NODE_REGISTER macro.
Parametersnode Valid node pointer with name, process function and next_nodes.
Returns
Valid node id on success, RTE_NODE_ID_INVALID otherwise.
SeealsoRTE_NODE_REGISTER()rte_node_trte_node_clone(rte_node_tid,constchar*name)
Clone a node from static node(node created from RTE_NODE_REGISTER).
Parametersid 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_trte_node_from_name(constchar*name)
Get node id from node name.
Parametersname 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_tid)
Get node name from node id.
Parametersid Valid node id.
Returns
Valid node name on success, NULL otherwise.
rte_edge_trte_node_edge_count(rte_node_tid)
Get the number of edges(next-nodes) for a node from node id.
Parametersid Valid node id.
Returns
Valid edge count on success, RTE_EDGE_ID_INVALID otherwise.
rte_edge_trte_node_edge_update(rte_node_tid,rte_edge_tfrom,constchar**next_nodes,uint16_tnb_edges)
Update the edges for a node from node id.
Parametersid 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_trte_node_edge_shrink(rte_node_tid,rte_edge_tsize)
Shrink the edges to a given size.
Parametersid Valid node id.
size New size to shrink the edges.
Returns
New size on success, RTE_EDGE_ID_INVALID otherwise.
rte_node_trte_node_edge_get(rte_node_tid,char*next_nodes[])
Get the edge names from a given node.
Parametersid 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_trte_node_max_count(void)
Get maximum nodes available.
Returns
Maximum nodes count.
voidrte_node_dump(FILE*f,rte_node_tid)
Dump node info to file.
Parametersf File pointer to dump the node info.
id Node id to get the info.
voidrte_node_list_dump(FILE*f)
Dump all node info to file.
Parametersf File pointer to dump the node info.
static__rte_always_inlineintrte_node_is_invalid(rte_node_tid)[static]
Test the validity of node id.
Parametersid Node id to check.
Returns
1 if valid id, 0 otherwise.
Definition at line 659 of file rte_graph.h.
static__rte_always_inlineintrte_edge_is_invalid(rte_edge_tid)[static]
Test the validity of edge id.
Parametersid Edge node id to check.
Returns
1 if valid id, 0 otherwise.
Definition at line 674 of file rte_graph.h.
static__rte_always_inlineintrte_graph_is_invalid(rte_graph_tid)[static]
Test the validity of graph id.
Parametersid Graph id to check.
Returns
1 if valid id, 0 otherwise.
Definition at line 689 of file rte_graph.h.
static__rte_always_inlineintrte_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.
Macro Definition Documentation
#defineRTE_GRAPH_NAMESIZE64
Max length of graph name.
Definition at line 30 of file rte_graph.h.
#defineRTE_NODE_NAMESIZE64
Max length of node name.
Definition at line 31 of file rte_graph.h.
#defineRTE_NODE_XSTAT_DESC_SIZE64
Max length of node xstat description.
Definition at line 32 of file rte_graph.h.
#defineRTE_GRAPH_PCAP_FILE_SZ64
Max length of pcap file name.
Definition at line 33 of file rte_graph.h.
#defineRTE_GRAPH_OFF_INVALIDUINT32_MAX
Invalid graph offset.
Definition at line 34 of file rte_graph.h.
#defineRTE_NODE_ID_INVALIDUINT32_MAX
Invalid node id.
Definition at line 35 of file rte_graph.h.
#defineRTE_EDGE_ID_INVALIDUINT16_MAX
Invalid edge id.
Definition at line 36 of file rte_graph.h.
#defineRTE_GRAPH_ID_INVALIDUINT16_MAX
Invalid graph id.
Definition at line 37 of file rte_graph.h.
#defineRTE_GRAPH_FENCE0xdeadbeef12345678ULL
Graph fence data.
Definition at line 38 of file rte_graph.h.
#definerte_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.
#defineRTE_NODE_SOURCE_F(1ULL<<0)
Node type is source.
Definition at line 485 of file rte_graph.h.
#defineRTE_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.
Parametersnode Valid node pointer with name, process function, and next_nodes.
Definition at line 520 of file rte_graph.h.
Name
rte_graph.h
Synopsis
#include <stdbool.h>
#include <stdio.h>
#include <rte_common.h>
DataStructures
struct rte_graph_param
struct rte_graph_cluster_stats_param
struct rte_graph_cluster_node_stats
struct rte_node_xstats
struct rte_node_registerMacros
#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)
Typedefstypedef uint32_t rte_graph_off_ttypedef uint32_t rte_node_ttypedef uint16_t rte_edge_ttypedef uint16_t rte_graph_ttypedef 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)
Functionsrte_graph_trte_graph_create (const char *name, struct rte_graph_param *prm)
int rte_graph_destroy (rte_graph_t id)
rte_graph_trte_graph_clone (rte_graph_t id, const char *name, struct rte_graph_param *prm)
rte_graph_trte_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_trte_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_trte_node_clone (rte_node_t id, const char *name)
rte_node_trte_node_from_name (const char *name)
char * rte_node_id_to_name (rte_node_t id)
rte_edge_trte_node_edge_count (rte_node_t id)
rte_edge_trte_node_edge_update (rte_node_t id, rte_edge_t from, const char **next_nodes, uint16_t
nb_edges)
rte_edge_trte_node_edge_shrink (rte_node_t id, rte_edge_t size)
rte_node_trte_node_edge_get (rte_node_t id, char *next_nodes[])
rte_node_trte_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)
Typedef Documentation
typedefuint32_trte_graph_off_t
Graph offset type.
Definition at line 40 of file rte_graph.h.
typedefuint32_trte_node_t
Node id type.
Definition at line 41 of file rte_graph.h.
typedefuint16_trte_edge_t
Edge id type.
Definition at line 42 of file rte_graph.h.
typedefuint16_trte_graph_t
Graph id type.
Definition at line 43 of file rte_graph.h.
typedefuint16_t(*rte_node_process_t)(structrte_graph*graph,structrte_node*node,void**objs,uint16_tnb_objs)
Node stats within cluster of graphs Node process function.
The function invoked when the worker thread walks on nodes using rte_graph_walk().
Parametersgraph 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.
Seealso
rte_graph_walk()
Definition at line 94 of file rte_graph.h.
typedefint(*rte_node_init_t)(conststructrte_graph*graph,structrte_node*node)
Node initialization function.
The function invoked when the user creates the graph using rte_graph_create()Parametersgraph Pointer to the graph object.
node Pointer to the node object.
Returns
• 0: Success. -<0: Failure.
Seealsorte_graph_create()
Definition at line 114 of file rte_graph.h.
typedefvoid(*rte_node_fini_t)(conststructrte_graph*graph,structrte_node*node)
Node finalization function.
The function invoked when the user destroys the graph using rte_graph_destroy().
Parametersgraph Pointer to the graph object.
node Pointer to the node object.
Seealsorte_graph_destroy()
Definition at line 130 of file rte_graph.h.
typedefint(*rte_graph_cluster_stats_cb_t)(boolis_first,boolis_last,void*cookie,conststructrte_graph_cluster_node_stats*stats)
Graph cluster stats callback.
Parametersis_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.
