graph: implement node debug routines
[dpdk.git] / lib / librte_graph / graph_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2020 Marvell International Ltd.
3  */
4
5 #ifndef _RTE_GRAPH_PRIVATE_H_
6 #define _RTE_GRAPH_PRIVATE_H_
7
8 #include <inttypes.h>
9 #include <sys/queue.h>
10
11 #include <rte_common.h>
12 #include <rte_eal.h>
13
14 #include "rte_graph.h"
15
16
17 #define ID_CHECK(id, id_max)                                                   \
18         do {                                                                   \
19                 if ((id) >= (id_max)) {                                        \
20                         rte_errno = EINVAL;                                    \
21                         goto fail;                                             \
22                 }                                                              \
23         } while (0)
24
25
26 /**
27  * @internal
28  *
29  * Structure that holds node internal data.
30  */
31 struct node {
32         STAILQ_ENTRY(node) next;      /**< Next node in the list. */
33         char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */
34         uint64_t flags;               /**< Node configuration flag. */
35         rte_node_process_t process;   /**< Node process function. */
36         rte_node_init_t init;         /**< Node init function. */
37         rte_node_fini_t fini;         /**< Node fini function. */
38         rte_node_t id;                /**< Allocated identifier for the node. */
39         rte_node_t parent_id;         /**< Parent node identifier. */
40         rte_edge_t nb_edges;          /**< Number of edges from this node. */
41         char next_nodes[][RTE_NODE_NAMESIZE]; /**< Names of next nodes. */
42 };
43
44 /* Node functions */
45 STAILQ_HEAD(node_head, node);
46
47 /**
48  * @internal
49  *
50  * Get the head of the node list.
51  *
52  * @return
53  *   Pointer to the node head.
54  */
55 struct node_head *node_list_head_get(void);
56
57 /**
58  * @internal
59  *
60  * Get node pointer from node name.
61  *
62  * @param name
63  *   Pointer to character string containing the node name.
64  *
65  * @return
66  *   Pointer to the node.
67  */
68 struct node *node_from_name(const char *name);
69
70 /* Lock functions */
71 /**
72  * @internal
73  *
74  * Take a lock on the graph internal spin lock.
75  */
76 void graph_spinlock_lock(void);
77
78 /**
79  * @internal
80  *
81  * Release a lock on the graph internal spin lock.
82  */
83 void graph_spinlock_unlock(void);
84
85 /**
86  * @internal
87  *
88  * Dump internal node object data.
89  *
90  * @param f
91  *   FILE pointer to dump the info.
92  * @param g
93  *   Pointer to the internal node object.
94  */
95 void node_dump(FILE *f, struct node *n);
96
97 #endif /* _RTE_GRAPH_PRIVATE_H_ */