CNDP  22.08.0
cne_graph_worker.h File Reference
#include <string.h>
#include <cne_common.h>
#include <cne_cycles.h>
#include <cne_prefetch.h>
#include <cne_branch_prediction.h>
#include <cne_log.h>
#include "cne_graph.h"

Go to the source code of this file.

Functions

static void cne_graph_walk (struct cne_graph *graph)
 
static void cne_node_add_objects_to_source (struct cne_graph *graph, struct cne_node *node, void **objs, uint16_t nb_objs)
 
static void cne_node_add_objects_to_input (struct cne_graph *graph, struct cne_node *node, void **objs, uint16_t nb_objs)
 
static void cne_node_enqueue (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, void **objs, uint16_t nb_objs)
 
static void cne_node_enqueue_x1 (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, void *obj)
 
static void cne_node_enqueue_x2 (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, void *obj0, void *obj1)
 
static void cne_node_enqueue_x4 (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, void *obj0, void *obj1, void *obj2, void *obj3)
 
static void cne_node_enqueue_next (struct cne_graph *graph, struct cne_node *node, cne_edge_t *nexts, void **objs, uint16_t nb_objs)
 
static void ** cne_node_next_stream_get (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, uint16_t nb_objs)
 
static void cne_node_next_stream_put (struct cne_graph *graph, struct cne_node *node, cne_edge_t next, uint16_t idx)
 
static void cne_node_next_stream_move (struct cne_graph *graph, struct cne_node *src, cne_edge_t next)
 

Detailed Description

This API allows a worker thread to walk over a graph and nodes to create, process, enqueue and move streams of objects to the next nodes.

Definition in file cne_graph_worker.h.

Function Documentation

◆ cne_graph_walk()

static void cne_graph_walk ( struct cne_graph *  graph)
inlinestatic

Perform graph walk on the circular buffer and invoke the process function of the nodes and collect the stats.

Parameters
graphGraph pointer returned from cne_graph_lookup function.
See also
cne_graph_lookup()
Examples
examples/cnet-graph/cnet-graph.c, examples/cnet-quic/cnet-quic.c, and examples/l3fwd-graph/fwd.c.

Definition at line 125 of file cne_graph_worker.h.

◆ cne_node_add_objects_to_source()

static void cne_node_add_objects_to_source ( struct cne_graph *  graph,
struct cne_node *  node,
void **  objs,
uint16_t  nb_objs 
)
inlinestatic

Add the objs to node for further processing but do not set the node to pending state in the circular buffer. The node should already be a source so it will already be processed.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
objsObjs to enqueue.
nb_objsNumber of objs to enqueue.

Definition at line 260 of file cne_graph_worker.h.

◆ cne_node_add_objects_to_input()

static void cne_node_add_objects_to_input ( struct cne_graph *  graph,
struct cne_node *  node,
void **  objs,
uint16_t  nb_objs 
)
inlinestatic

Enqueue the objs to a input node type and set the node to pending state in the circular buffer.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeNode to add objects to.
objsObjs to enqueue.
nb_objsNumber of objs to enqueue.

Definition at line 284 of file cne_graph_worker.h.

◆ cne_node_enqueue()

static void cne_node_enqueue ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
void **  objs,
uint16_t  nb_objs 
)
inlinestatic

Enqueue the objs to next node for further processing and set the next node to pending state in the circular buffer.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
objsObjs to enqueue.
nb_objsNumber of objs to enqueue.

Definition at line 311 of file cne_graph_worker.h.

◆ cne_node_enqueue_x1()

static void cne_node_enqueue_x1 ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
void *  obj 
)
inlinestatic

Enqueue only one obj to next node for further processing and set the next node to pending state in the circular buffer.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
objObj to enqueue.

Definition at line 337 of file cne_graph_worker.h.

◆ cne_node_enqueue_x2()

static void cne_node_enqueue_x2 ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
void *  obj0,
void *  obj1 
)
inlinestatic

Enqueue only two objs to next node for further processing and set the next node to pending state in the circular buffer. Same as cne_node_enqueue_x1 but enqueue two objs.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
obj0Obj to enqueue.
obj1Obj to enqueue.

Definition at line 365 of file cne_graph_worker.h.

◆ cne_node_enqueue_x4()

static void cne_node_enqueue_x4 ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
void *  obj0,
void *  obj1,
void *  obj2,
void *  obj3 
)
inlinestatic

Enqueue only four objs to next node for further processing and set the next node to pending state in the circular buffer. Same as cne_node_enqueue_x1 but enqueue four objs.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
obj01st obj to enqueue.
obj12nd obj to enqueue.
obj23rd obj to enqueue.
obj34th obj to enqueue.

Definition at line 399 of file cne_graph_worker.h.

◆ cne_node_enqueue_next()

static void cne_node_enqueue_next ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t nexts,
void **  objs,
uint16_t  nb_objs 
)
inlinestatic

Enqueue objs to multiple next nodes for further processing and set the next nodes to pending state in the circular buffer. objs[i] will be enqueued to nexts[i].

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextsList of relative next node indices to enqueue objs.
objsList of objs to enqueue.
nb_objsNumber of objs to enqueue.

Definition at line 431 of file cne_graph_worker.h.

◆ cne_node_next_stream_get()

static void** cne_node_next_stream_get ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
uint16_t  nb_objs 
)
inlinestatic

Get the stream of next node to enqueue the objs. Once done with the updating objs, needs to call cne_node_next_stream_put to put the next node to pending state.

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to get stream.
nb_objsRequested free size of the next stream.
Returns
Valid next stream on success.
See also
cne_node_next_stream_put().

Definition at line 460 of file cne_graph_worker.h.

◆ cne_node_next_stream_put()

static void cne_node_next_stream_put ( struct cne_graph *  graph,
struct cne_node *  node,
cne_edge_t  next,
uint16_t  idx 
)
inlinestatic

Put the next stream to pending state in the circular buffer for further processing. Should be invoked after cne_node_next_stream_get().

Parameters
graphGraph pointer returned from cne_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index.
idxNumber of objs updated in the stream after getting the stream using cne_node_next_stream_get.
See also
cne_node_next_stream_get().

Definition at line 490 of file cne_graph_worker.h.

◆ cne_node_next_stream_move()

static void cne_node_next_stream_move ( struct cne_graph *  graph,
struct cne_node *  src,
cne_edge_t  next 
)
inlinestatic

Home run scenario, Enqueue all the objs of current node to next node in optimized way by swapping the streams of both nodes. Performs good when next node is not already in pending state. If next node is already in pending state then normal enqueue will be used.

Parameters
graphGraph pointer returned from cne_graph_lookup().
srcCurrent node pointer.
nextRelative next node index.

Definition at line 519 of file cne_graph_worker.h.