Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
graph_private.h
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2020 Marvell International Ltd.
3
*/
4
5
#ifndef _CNE_GRAPH_PRIVATE_H_
6
#define _CNE_GRAPH_PRIVATE_H_
7
8
#include <inttypes.h>
9
#include <sys/queue.h>
10
11
#include <
cne_common.h
>
12
13
#include "
cne_graph.h
"
14
#include "
cne_graph_worker.h
"
15
16
#define GRAPH_LOG(level, ...) \
17
cne_log(CNE_LOG_##level, __func__, __LINE__, \
18
CNE_FMT("GRAPH: " CNE_FMT_HEAD(__VA_ARGS__, ) "\n", CNE_FMT_TAIL(__VA_ARGS__, )))
19
20
#define graph_err(...) GRAPH_LOG(ERR, __VA_ARGS__)
21
#define graph_info(...) GRAPH_LOG(INFO, __VA_ARGS__)
22
#define graph_dbg(...) GRAPH_LOG(DEBUG, __VA_ARGS__)
23
24
#define ID_CHECK(id, id_max) \
25
do { \
26
if ((id) >= (id_max)) { \
27
errno = EINVAL; \
28
goto fail; \
29
} \
30
} while (0)
31
32
#define SET_ERR_JMP(err, where, fmt, ...) \
33
do { \
34
graph_err(fmt, ##__VA_ARGS__); \
35
errno = err; \
36
goto where; \
37
} while (0)
38
44
struct
node {
45
STAILQ_ENTRY(node) next;
46
char
name[
CNE_NODE_NAMESIZE
];
47
uint64_t flags;
48
cne_node_process_t
process;
49
cne_node_init_t
init;
50
cne_node_fini_t
fini;
51
cne_node_t
id;
52
cne_node_t
parent_id;
53
cne_edge_t
nb_edges;
54
char
next_nodes[][
CNE_NODE_NAMESIZE
];
55
};
56
62
struct
graph_node {
63
STAILQ_ENTRY(graph_node) next;
64
struct
node *node;
65
bool
visited;
66
struct
graph_node *adjacency_list[];
67
};
68
74
struct
graph {
75
STAILQ_ENTRY(graph) next;
76
char
name[
CNE_GRAPH_NAMESIZE
];
77
cne_graph_off_t
nodes_start;
78
cne_node_t
src_node_count;
79
struct
cne_graph *graph;
80
cne_node_t
node_count;
81
uint32_t cir_start;
82
uint32_t cir_mask;
83
cne_graph_t
id;
84
size_t
mem_sz;
85
STAILQ_HEAD(gnode_list, graph_node) node_list;
86
};
87
88
/* Node functions */
89
90
STAILQ_HEAD(node_head, node);
91
100
struct
node_head *node_list_head_get(
void
);
101
113
struct
node *node_from_name(
const
char
*name);
114
115
/* Graph list functions */
116
117
STAILQ_HEAD(graph_head, graph);
118
127
struct
graph_head *graph_list_head_get(
void
);
128
129
/* Lock functions */
130
136
void
graph_spinlock_lock(
void
);
137
143
void
graph_spinlock_unlock(
void
);
144
145
/* Graph operations */
146
162
int
graph_bfs(
struct
graph *graph,
struct
graph_node *start);
163
176
int
graph_has_isolated_node(
struct
graph *graph);
177
190
int
graph_node_has_edge_to_src_node(
struct
graph *graph);
191
204
int
graph_node_has_loop_edge(
struct
graph *graph);
205
217
cne_node_t
graph_src_nodes_count(
struct
graph *graph);
218
230
cne_node_t
graph_nodes_count(
struct
graph *graph);
231
240
void
graph_mark_nodes_as_not_visited(
struct
graph *graph);
241
242
/* Fast path graph memory populate unctions */
243
257
int
graph_fp_mem_create(
struct
graph *graph);
258
271
int
graph_fp_mem_destroy(
struct
graph *graph);
272
273
/* Lookup functions */
274
288
struct
cne_node *graph_node_id_to_ptr(
const
struct
cne_graph *graph,
cne_node_t
id
);
289
303
struct
cne_node *graph_node_name_to_ptr(
const
struct
cne_graph *graph,
const
char
*node_name);
304
305
/* Debug functions */
306
317
void
graph_dump(FILE *f,
struct
graph *g);
318
331
void
node_dump(FILE *f,
struct
node *n,
bool
hdr);
332
333
#endif
/* _CNE_GRAPH_PRIVATE_H_ */
cne_common.h
cne_graph.h
cne_graph_off_t
uint32_t cne_graph_off_t
Definition
cne_graph.h:39
cne_node_t
uint32_t cne_node_t
Definition
cne_graph.h:40
cne_node_init_t
int(*) cne_node_init_t(const struct cne_graph *graph, struct cne_node *node)
Definition
cne_graph.h:113
cne_node_process_t
uint16_t(*) cne_node_process_t(struct cne_graph *graph, struct cne_node *node, void **objs, uint16_t nb_objs)
Definition
cne_graph.h:94
cne_edge_t
uint16_t cne_edge_t
Definition
cne_graph.h:41
cne_graph_t
uint16_t cne_graph_t
Definition
cne_graph.h:42
cne_node_fini_t
void(*) cne_node_fini_t(const struct cne_graph *graph, struct cne_node *node)
Definition
cne_graph.h:128
CNE_NODE_NAMESIZE
#define CNE_NODE_NAMESIZE
Definition
cne_graph.h:32
CNE_GRAPH_NAMESIZE
#define CNE_GRAPH_NAMESIZE
Definition
cne_graph.h:31
cne_graph_worker.h
lib
usr
clib
graph
graph_private.h
Generated by
1.18.0