DPDK  24.07.0
Macros | Functions
rte_graph_worker_common.h File Reference
#include <stdalign.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_memcpy.h>
#include <rte_memory.h>
#include "rte_graph.h"

Go to the source code of this file.

Macros

#define RTE_GRAPH_MODEL_RTC   0
 
#define RTE_GRAPH_MODEL_MCORE_DISPATCH   1
 
#define RTE_GRAPH_MODEL_DEFAULT   RTE_GRAPH_MODEL_RTC
 

Functions

static void rte_node_enqueue (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, void **objs, uint16_t nb_objs)
 
static void rte_node_enqueue_x1 (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, void *obj)
 
static void rte_node_enqueue_x2 (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, void *obj0, void *obj1)
 
static void rte_node_enqueue_x4 (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, void *obj0, void *obj1, void *obj2, void *obj3)
 
static void rte_node_enqueue_next (struct rte_graph *graph, struct rte_node *node, rte_edge_t *nexts, void **objs, uint16_t nb_objs)
 
static void ** rte_node_next_stream_get (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, uint16_t nb_objs)
 
static void rte_node_next_stream_put (struct rte_graph *graph, struct rte_node *node, rte_edge_t next, uint16_t idx)
 
static void rte_node_next_stream_move (struct rte_graph *graph, struct rte_node *src, rte_edge_t next)
 
bool rte_graph_model_is_valid (uint8_t model)
 
int rte_graph_worker_model_set (uint8_t model)
 
uint8_t rte_graph_worker_model_get (struct rte_graph *graph)
 
static __rte_always_inline uint8_t rte_graph_worker_model_no_check_get (struct rte_graph *graph)
 

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 rte_graph_worker_common.h.

Macro Definition Documentation

◆ RTE_GRAPH_MODEL_RTC

#define RTE_GRAPH_MODEL_RTC   0

Graph worker models Run-To-Completion model. It is the default model.

Examples:
examples/l3fwd-graph/main.c.

Definition at line 31 of file rte_graph_worker_common.h.

◆ RTE_GRAPH_MODEL_MCORE_DISPATCH

#define RTE_GRAPH_MODEL_MCORE_DISPATCH   1

Dispatch model to support cross-core dispatching within core affinity.

Examples:
examples/l3fwd-graph/main.c.

Definition at line 32 of file rte_graph_worker_common.h.

◆ RTE_GRAPH_MODEL_DEFAULT

#define RTE_GRAPH_MODEL_DEFAULT   RTE_GRAPH_MODEL_RTC

Default graph model.

Examples:
examples/l3fwd-graph/main.c.

Definition at line 34 of file rte_graph_worker_common.h.

Function Documentation

◆ rte_node_enqueue()

static void rte_node_enqueue ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
objsObjs to enqueue.
nb_objsNumber of objs to enqueue.

Definition at line 289 of file rte_graph_worker_common.h.

◆ rte_node_enqueue_x1()

static void rte_node_enqueue_x1 ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_graph_lookup().
nodeCurrent node pointer.
nextRelative next node index to enqueue objs.
objObj to enqueue.

Definition at line 315 of file rte_graph_worker_common.h.

◆ rte_node_enqueue_x2()

static void rte_node_enqueue_x2 ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_node_enqueue_x1 but enqueue two objs.

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

Definition at line 344 of file rte_graph_worker_common.h.

◆ rte_node_enqueue_x4()

static void rte_node_enqueue_x4 ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_node_enqueue_x1 but enqueue four objs.

Parameters
graphGraph pointer returned from rte_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 378 of file rte_graph_worker_common.h.

◆ rte_node_enqueue_next()

static void rte_node_enqueue_next ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_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 411 of file rte_graph_worker_common.h.

◆ rte_node_next_stream_get()

static void** rte_node_next_stream_get ( struct rte_graph *  graph,
struct rte_node *  node,
rte_edge_t  next,
uint16_t  nb_objs 
)
inlinestatic

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

Parameters
graphGraph pointer returned from rte_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
rte_node_next_stream_put().

Definition at line 440 of file rte_graph_worker_common.h.

◆ rte_node_next_stream_put()

static void rte_node_next_stream_put ( struct rte_graph *  graph,
struct rte_node *  node,
rte_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 rte_node_next_stream_get().

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

Definition at line 470 of file rte_graph_worker_common.h.

◆ rte_node_next_stream_move()

static void rte_node_next_stream_move ( struct rte_graph *  graph,
struct rte_node *  src,
rte_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 already not in pending state. If next node is already in pending state then normal enqueue will be used.

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

Definition at line 498 of file rte_graph_worker_common.h.

◆ rte_graph_model_is_valid()

bool rte_graph_model_is_valid ( uint8_t  model)

Test the validity of model.

Parameters
modelModel to check.
Returns
True if graph model is valid, false otherwise.

◆ rte_graph_worker_model_set()

int rte_graph_worker_model_set ( uint8_t  model)
Note
This function does not perform any locking, and is only safe to call before graph running. It will set all graphs the same model.
Parameters
modelName of the graph worker model.
Returns
0 on success, -1 otherwise.
Examples:
examples/l3fwd-graph/main.c.

◆ rte_graph_worker_model_get()

uint8_t rte_graph_worker_model_get ( struct rte_graph *  graph)

Get the graph worker model

Note
All graph will use the same model and this function will get model from the first one. Used for slow path.
Parameters
graphGraph pointer.
Returns
Graph worker model on success.

◆ rte_graph_worker_model_no_check_get()

static __rte_always_inline uint8_t rte_graph_worker_model_no_check_get ( struct rte_graph *  graph)
static

Get the graph worker model without check

Note
All graph will use the same model and this function will get model from the first one. Used for fast path.
Parameters
graphGraph pointer.
Returns
Graph worker model on success.

Definition at line 569 of file rte_graph_worker_common.h.