1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
5 #ifndef _RTE_GRAPH_WORKER_H_
6 #define _RTE_GRAPH_WORKER_H_
9 * @file rte_graph_worker.h
12 * @b EXPERIMENTAL: this API may change without prior notice
14 * This API allows a worker thread to walk over a graph and nodes to create,
15 * process, enqueue and move streams of objects to the next nodes.
18 #include <rte_common.h>
19 #include <rte_cycles.h>
20 #include <rte_prefetch.h>
21 #include <rte_memcpy.h>
22 #include <rte_memory.h>
24 #include "rte_graph.h"
33 * Data structure to hold graph data.
36 uint32_t tail; /**< Tail of circular buffer. */
37 uint32_t head; /**< Head of circular buffer. */
38 uint32_t cir_mask; /**< Circular buffer wrap around mask. */
39 rte_node_t nb_nodes; /**< Number of nodes in the graph. */
40 rte_graph_off_t *cir_start; /**< Pointer to circular buffer. */
41 rte_graph_off_t nodes_start; /**< Offset at which node memory starts. */
42 rte_graph_t id; /**< Graph identifier. */
43 int socket; /**< Socket ID where memory is allocated. */
44 char name[RTE_GRAPH_NAMESIZE]; /**< Name of the graph. */
45 uint64_t fence; /**< Fence. */
46 } __rte_cache_aligned;
51 * Data structure to hold node data.
55 uint64_t fence; /**< Fence. */
56 rte_graph_off_t next; /**< Index to next node. */
57 rte_node_t id; /**< Node identifier. */
58 rte_node_t parent_id; /**< Parent Node identifier. */
59 rte_edge_t nb_edges; /**< Number of edges from this node. */
60 uint32_t realloc_count; /**< Number of times realloced. */
62 char parent[RTE_NODE_NAMESIZE]; /**< Parent node name. */
63 char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */
66 #define RTE_NODE_CTX_SZ 16
67 uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */
68 uint16_t size; /**< Total number of objects available. */
69 uint16_t idx; /**< Number of objects used. */
70 rte_graph_off_t off; /**< Offset of node in the graph reel. */
71 uint64_t total_cycles; /**< Cycles spent in this node. */
72 uint64_t total_calls; /**< Calls done to this node. */
73 uint64_t total_objs; /**< Objects processed by this node. */
76 void **objs; /**< Array of object pointers. */
81 rte_node_process_t process; /**< Process function. */
84 struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */
85 } __rte_cache_aligned;
90 * Allocate a stream of objects.
92 * If stream already exists then re-allocate it to a larger size.
95 * Pointer to the graph object.
97 * Pointer to the node object.
100 void __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node);
106 #endif /* _RTE_GRAPH_WORKER_H_ */