CNDP
22.08.0
|
Go to the source code of this file.
Data Structures | |
struct | cne_graph_cluster_stats_param |
struct | cne_graph_cluster_node_stats |
struct | cne_node_register |
Macros | |
#define | CNE_GRAPH_NAMESIZE 64 |
#define | CNE_NODE_NAMESIZE 64 |
#define | CNE_GRAPH_OFF_INVALID UINT32_MAX |
#define | CNE_NODE_ID_INVALID UINT32_MAX |
#define | CNE_EDGE_ID_INVALID UINT16_MAX |
#define | CNE_GRAPH_ID_INVALID UINT16_MAX |
#define | CNE_GRAPH_FENCE 0xdeadbeef12345678ULL |
#define | CNE_GRAPH_BURST_SIZE_LOG2 8 |
#define | cne_graph_foreach_node(count, off, graph, node) |
#define | CNE_NODE_SOURCE_F (1ULL << 0) |
#define | CNE_NODE_INPUT_F (1ULL << 1) |
#define | CNE_NODE_MASK_F (CNE_NODE_SOURCE_F | CNE_NODE_INPUT_F) |
#define | CNE_NODE_REGISTER(node) |
Typedefs | |
typedef uint32_t | cne_graph_off_t |
typedef uint32_t | cne_node_t |
typedef uint16_t | cne_edge_t |
typedef uint16_t | cne_graph_t |
typedef uint16_t(* | cne_node_process_t) (struct cne_graph *graph, struct cne_node *node, void **objs, uint16_t nb_objs) |
typedef int(* | cne_node_init_t) (const struct cne_graph *graph, struct cne_node *node) |
typedef void(* | cne_node_fini_t) (const struct cne_graph *graph, struct cne_node *node) |
typedef int(* | cne_graph_cluster_stats_cb_t) (bool is_first, bool is_last, const struct cne_graph_cluster_node_stats *stats) |
Functions | |
CNDP_API cne_graph_t | cne_graph_create (const char *name, const char **patterns) |
CNDP_API int | cne_graph_destroy (cne_graph_t id) |
CNDP_API cne_graph_t | cne_graph_from_name (const char *name) |
CNDP_API char * | cne_graph_id_to_name (cne_graph_t id) |
CNDP_API int | cne_graph_export (const char *name, FILE *f) |
CNDP_API int | cne_graph_export_cb (const char *name, FILE *f, cne_graph_export_t *exp) |
CNDP_API cne_graph_t | cne_graph_max_count (void) |
CNDP_API struct cne_graph * | cne_graph_lookup (const char *name) |
CNDP_API void | cne_graph_dump (FILE *f, cne_graph_t id) |
CNDP_API void | cne_graph_list_dump (FILE *f) |
CNDP_API void | cne_graph_obj_dump (FILE *f, struct cne_graph *graph, bool all) |
CNDP_API struct cne_node * | cne_graph_node_get (cne_graph_t graph_id, cne_node_t node_id) |
CNDP_API struct cne_node * | cne_graph_node_get_by_name (const char *graph, const char *name) |
CNDP_API struct cne_node * | cne_graph_get_node_by_name (const struct cne_graph *graph, const char *node_name) |
CNDP_API struct cne_graph_cluster_stats * | cne_graph_cluster_stats_create (const struct cne_graph_cluster_stats_param *prm) |
CNDP_API void | cne_graph_cluster_stats_destroy (struct cne_graph_cluster_stats *stat) |
CNDP_API void | cne_graph_cluster_stats_get (struct cne_graph_cluster_stats *stat, bool skip_cb) |
CNDP_API void | cne_graph_cluster_stats_reset (struct cne_graph_cluster_stats *stat) |
CNDP_API int | cne_graph_stats_node_count (struct cne_graph_cluster_stats *stat) |
cne_node_t | __cne_node_register (const struct cne_node_register *node) |
CNDP_API cne_node_t | cne_node_clone (cne_node_t id, const char *name) |
CNDP_API cne_node_t | cne_node_from_name (const char *name) |
CNDP_API char * | cne_node_id_to_name (cne_node_t id) |
CNDP_API cne_edge_t | cne_node_edge_count (cne_node_t id) |
CNDP_API cne_edge_t | cne_node_edge_update (cne_node_t id, cne_edge_t from, const char **next_nodes, uint16_t nb_edges) |
CNDP_API cne_edge_t | cne_node_edge_shrink (cne_node_t id, cne_edge_t size) |
CNDP_API cne_node_t | cne_node_edge_get (cne_node_t id, char *next_nodes[]) |
CNDP_API cne_node_t | cne_node_max_count (void) |
CNDP_API void | cne_node_dump (FILE *f, cne_node_t id) |
CNDP_API void | cne_node_list_dump (FILE *f) |
static __cne_always_inline int | cne_node_is_invalid (cne_node_t id) |
static __cne_always_inline int | cne_edge_is_invalid (cne_edge_t id) |
static __cne_always_inline int | cne_graph_is_invalid (cne_graph_t id) |
static __cne_always_inline int | cne_graph_has_stats_feature (void) |
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 creation of the stats cluster to monitor per graph and per node stats.
Definition in file cne_graph.h.
#define CNE_GRAPH_NAMESIZE 64 |
Max length of graph name.
Definition at line 31 of file cne_graph.h.
#define CNE_NODE_NAMESIZE 64 |
Max length of node name.
Definition at line 32 of file cne_graph.h.
#define CNE_GRAPH_OFF_INVALID UINT32_MAX |
Invalid graph offset.
Definition at line 33 of file cne_graph.h.
#define CNE_NODE_ID_INVALID UINT32_MAX |
Invalid node id.
Definition at line 34 of file cne_graph.h.
#define CNE_EDGE_ID_INVALID UINT16_MAX |
Invalid edge id.
Definition at line 35 of file cne_graph.h.
#define CNE_GRAPH_ID_INVALID UINT16_MAX |
Invalid graph id.
Definition at line 36 of file cne_graph.h.
#define CNE_GRAPH_FENCE 0xdeadbeef12345678ULL |
Graph fence data.
Definition at line 37 of file cne_graph.h.
#define CNE_GRAPH_BURST_SIZE_LOG2 8 |
Burst size in terms of log2 Object burst size of 256.
Definition at line 62 of file cne_graph.h.
#define cne_graph_foreach_node | ( | count, | |
off, | |||
graph, | |||
node | |||
) |
Macro to browse cne_node object after the graph creation
Definition at line 329 of file cne_graph.h.
#define CNE_NODE_SOURCE_F (1ULL << 0) |
Flag bits for cne_node_register.flags field Node type is source.
Definition at line 440 of file cne_graph.h.
#define CNE_NODE_INPUT_F (1ULL << 1) |
Node type is a input node not a source node
Definition at line 441 of file cne_graph.h.
#define CNE_NODE_MASK_F (CNE_NODE_SOURCE_F | CNE_NODE_INPUT_F) |
Flag Mask value
Definition at line 442 of file cne_graph.h.
#define CNE_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.
node | Valid node pointer with name, process function, and next_nodes. |
Definition at line 468 of file cne_graph.h.
typedef uint32_t cne_graph_off_t |
Graph offset type.
Definition at line 39 of file cne_graph.h.
typedef uint32_t cne_node_t |
Node id type.
Definition at line 40 of file cne_graph.h.
typedef uint16_t cne_edge_t |
Edge id type.
Definition at line 41 of file cne_graph.h.
typedef uint16_t cne_graph_t |
Graph id type.
Definition at line 42 of file cne_graph.h.
typedef uint16_t(* cne_node_process_t) (struct cne_graph *graph, struct cne_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 cne_graph_walk().
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. |
Definition at line 94 of file cne_graph.h.
typedef int(* cne_node_init_t) (const struct cne_graph *graph, struct cne_node *node) |
Node initialization function.
The function invoked when the user creates the graph using cne_graph_create()
graph | Pointer to the graph object. |
node | Pointer to the node object. |
Definition at line 113 of file cne_graph.h.
typedef void(* cne_node_fini_t) (const struct cne_graph *graph, struct cne_node *node) |
Node finalization function.
The function invoked when the user destroys the graph using cne_graph_destroy().
graph | Pointer to the graph object. |
node | Pointer to the node object. |
Definition at line 128 of file cne_graph.h.
typedef int(* cne_graph_cluster_stats_cb_t) (bool is_first, bool is_last, const struct cne_graph_cluster_node_stats *stats) |
Graph cluster stats callback.
is_first | Flag to denote that stats are of the first node. |
is_last | Flag to denote that stats are of the last node. |
stats | Node cluster stats data. |
Definition at line 144 of file cne_graph.h.
CNDP_API cne_graph_t cne_graph_create | ( | const char * | name, |
const char ** | patterns | ||
) |
Create Graph.
Create memory reel, detect loops and find isolated nodes.
name | Unique name for this graph. |
patterns | Graph node patterns, must be NULL terminated. |
CNDP_API int cne_graph_destroy | ( | cne_graph_t | id | ) |
Destroy Graph.
Free Graph memory reel.
id | id of the graph to destroy. |
CNDP_API cne_graph_t cne_graph_from_name | ( | const char * | name | ) |
Get graph id from graph name.
name | Name of the graph to get id. |
CNDP_API char* cne_graph_id_to_name | ( | cne_graph_t | id | ) |
Get graph name from graph id.
id | id of the graph to get name. |
CNDP_API int cne_graph_export | ( | const char * | name, |
FILE * | f | ||
) |
Export the graph as graphviz dot file
name | Name of the graph to export. |
f | File pointer to export the graph. |
CNDP_API int cne_graph_export_cb | ( | const char * | name, |
FILE * | f, | ||
cne_graph_export_t * | exp | ||
) |
Export the graph information to a file and use the export functions to help build the data.
name | The name of the graph to export. |
f | The file pointer to write the exported data, can be NULL and will use stdout. |
exp | The export function structure pointer. |
EBADF - exp function return an error. EINVAL - exp function or name is NULL. ENOENT - Did not find the graph named.
CNDP_API cne_graph_t cne_graph_max_count | ( | void | ) |
Get maximum number of graph available.
CNDP_API struct cne_graph* cne_graph_lookup | ( | const char * | name | ) |
Get graph object from its name.
Typical usage of this API is to get graph objects in the worker thread and call cne_graph_walk() in a loop.
name | Name of the graph. |
CNDP_API void cne_graph_dump | ( | FILE * | f, |
cne_graph_t | id | ||
) |
Dump the graph information to file.
f | File pointer to dump graph info. |
id | Graph id to get graph info. |
CNDP_API void cne_graph_list_dump | ( | FILE * | f | ) |
Dump all graph information to file
f | File pointer to dump graph info. |
CNDP_API void cne_graph_obj_dump | ( | FILE * | f, |
struct cne_graph * | graph, | ||
bool | all | ||
) |
Dump graph information along with node info to file
f | File pointer to dump graph info. |
graph | Graph pointer to get graph info. |
all | true to dump nodes in the graph. |
CNDP_API struct cne_node* cne_graph_node_get | ( | cne_graph_t | graph_id, |
cne_node_t | node_id | ||
) |
Get node object with in graph from id.
graph_id | Graph id to get node pointer from. |
node_id | Node id to get node pointer. |
CNDP_API struct cne_node* cne_graph_node_get_by_name | ( | const char * | graph, |
const char * | name | ||
) |
Get node pointer with in graph from name.
graph | Graph name to get node pointer from. |
name | Node name to get the node pointer. |
CNDP_API struct cne_node* cne_graph_get_node_by_name | ( | const struct cne_graph * | graph, |
const char * | node_name | ||
) |
Get node pointer within graph.
graph | Pointer to the graph to locate the node. |
node_name | Node name to get the node pointer. |
CNDP_API struct cne_graph_cluster_stats* cne_graph_cluster_stats_create | ( | const struct cne_graph_cluster_stats_param * | prm | ) |
Create graph stats cluster to aggregate runtime node stats.
prm | Parameters including file pointer to dump stats, Graph pattern to create cluster and callback function. |
CNDP_API void cne_graph_cluster_stats_destroy | ( | struct cne_graph_cluster_stats * | stat | ) |
Destroy cluster stats.
stat | Valid cluster pointer to destroy. |
CNDP_API void cne_graph_cluster_stats_get | ( | struct cne_graph_cluster_stats * | stat, |
bool | skip_cb | ||
) |
Get stats to application.
[out] | stat | Cluster status. |
skip_cb | true to skip callback function invocation. |
CNDP_API void cne_graph_cluster_stats_reset | ( | struct cne_graph_cluster_stats * | stat | ) |
Reset cluster stats to zero.
stat | Valid cluster stats pointer. |
CNDP_API int cne_graph_stats_node_count | ( | struct cne_graph_cluster_stats * | stat | ) |
Return the number of nodes in cluster.
stat | Valid cluster stats pointer. |
cne_node_t __cne_node_register | ( | const struct cne_node_register * | node | ) |
Register new packet processing node. Nodes can be registered dynamically via this call or statically via the CNE_NODE_REGISTER macro.
node | Valid node pointer with name, process function and next_nodes. |
CNDP_API cne_node_t cne_node_clone | ( | cne_node_t | id, |
const char * | name | ||
) |
Clone a node from static node(node created from CNE_NODE_REGISTER).
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. |
CNDP_API cne_node_t cne_node_from_name | ( | const char * | name | ) |
Get node id from node name.
name | Valid node name. In the case of the cloned node, the name will be "parent node name" + "-" + name. |
CNDP_API char* cne_node_id_to_name | ( | cne_node_t | id | ) |
Get node name from node id.
id | Valid node id. |
CNDP_API cne_edge_t cne_node_edge_count | ( | cne_node_t | id | ) |
Get the number of edges(next-nodes) for a node from node id.
id | Valid node id. |
CNDP_API cne_edge_t cne_node_edge_update | ( | cne_node_t | id, |
cne_edge_t | from, | ||
const char ** | next_nodes, | ||
uint16_t | nb_edges | ||
) |
Update the edges for a node from node id.
id | Valid node id. |
from | Index to update the edges from. CNE_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. |
CNDP_API cne_edge_t cne_node_edge_shrink | ( | cne_node_t | id, |
cne_edge_t | size | ||
) |
Shrink the edges to a given size.
id | Valid node id. |
size | New size to shrink the edges. |
CNDP_API cne_node_t cne_node_edge_get | ( | cne_node_t | id, |
char * | next_nodes[] | ||
) |
Get the edge names from a given node.
id | Valid node id. | |
[out] | 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. |
CNDP_API cne_node_t cne_node_max_count | ( | void | ) |
Get maximum nodes available.
CNDP_API void cne_node_dump | ( | FILE * | f, |
cne_node_t | id | ||
) |
Dump node info to file.
f | File pointer to dump the node info. |
id | Node id to get the info. |
CNDP_API void cne_node_list_dump | ( | FILE * | f | ) |
Dump all node info to file.
f | File pointer to dump the node info. |
|
static |
Test the validity of node id.
id | Node id to check. |
Definition at line 607 of file cne_graph.h.
|
static |
Test the validity of edge id.
id | Edge node id to check. |
Definition at line 622 of file cne_graph.h.
|
static |
Test the validity of graph id.
id | Graph id to check. |
Definition at line 637 of file cne_graph.h.
|
static |
Test stats feature support.
Definition at line 649 of file cne_graph.h.