DPDK 22.11.4
rte_graph.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
3 */
4
5#ifndef _RTE_GRAPH_H_
6#define _RTE_GRAPH_H_
7
26#include <stdbool.h>
27#include <stdio.h>
28
29#include <rte_common.h>
30#include <rte_compat.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define RTE_GRAPH_NAMESIZE 64
37#define RTE_NODE_NAMESIZE 64
38#define RTE_GRAPH_OFF_INVALID UINT32_MAX
39#define RTE_NODE_ID_INVALID UINT32_MAX
40#define RTE_EDGE_ID_INVALID UINT16_MAX
41#define RTE_GRAPH_ID_INVALID UINT16_MAX
42#define RTE_GRAPH_FENCE 0xdeadbeef12345678ULL
44typedef uint32_t rte_graph_off_t;
45typedef uint32_t rte_node_t;
46typedef uint16_t rte_edge_t;
47typedef uint16_t rte_graph_t;
50#if RTE_GRAPH_BURST_SIZE == 1
51#define RTE_GRAPH_BURST_SIZE_LOG2 0
52#elif RTE_GRAPH_BURST_SIZE == 2
53#define RTE_GRAPH_BURST_SIZE_LOG2 1
54#elif RTE_GRAPH_BURST_SIZE == 4
55#define RTE_GRAPH_BURST_SIZE_LOG2 2
56#elif RTE_GRAPH_BURST_SIZE == 8
57#define RTE_GRAPH_BURST_SIZE_LOG2 3
58#elif RTE_GRAPH_BURST_SIZE == 16
59#define RTE_GRAPH_BURST_SIZE_LOG2 4
60#elif RTE_GRAPH_BURST_SIZE == 32
61#define RTE_GRAPH_BURST_SIZE_LOG2 5
62#elif RTE_GRAPH_BURST_SIZE == 64
63#define RTE_GRAPH_BURST_SIZE_LOG2 6
64#elif RTE_GRAPH_BURST_SIZE == 128
65#define RTE_GRAPH_BURST_SIZE_LOG2 7
66#elif RTE_GRAPH_BURST_SIZE == 256
67#define RTE_GRAPH_BURST_SIZE_LOG2 8
68#else
69#error "Unsupported burst size"
70#endif
71
72/* Forward declaration */
73struct rte_node;
74struct rte_graph;
75struct rte_graph_cluster_stats;
99typedef uint16_t (*rte_node_process_t)(struct rte_graph *graph,
100 struct rte_node *node, void **objs,
101 uint16_t nb_objs);
102
119typedef int (*rte_node_init_t)(const struct rte_graph *graph,
120 struct rte_node *node);
121
135typedef void (*rte_node_fini_t)(const struct rte_graph *graph,
136 struct rte_node *node);
137
154typedef int (*rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last,
155 void *cookie, const struct rte_graph_cluster_node_stats *stats);
156
165 const char **node_patterns;
167};
168
182 union {
183 void *cookie;
184 FILE *f;
185 };
187 const char **graph_patterns;
189};
190
197 uint64_t ts;
198 uint64_t calls;
199 uint64_t objs;
200 uint64_t cycles;
202 uint64_t prev_ts;
203 uint64_t prev_calls;
204 uint64_t prev_objs;
205 uint64_t prev_cycles;
207 uint64_t realloc_count;
210 uint64_t hz;
213
228__rte_experimental
229rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm);
230
242__rte_experimental
244
254__rte_experimental
256
266__rte_experimental
268
280__rte_experimental
281int rte_graph_export(const char *name, FILE *f);
282
297__rte_experimental
298struct rte_graph *rte_graph_lookup(const char *name);
299
306__rte_experimental
308
317__rte_experimental
318void rte_graph_dump(FILE *f, rte_graph_t id);
319
326__rte_experimental
328
339__rte_experimental
340void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all);
341
343#define rte_graph_foreach_node(count, off, graph, node) \
344 for (count = 0, off = graph->nodes_start, \
345 node = RTE_PTR_ADD(graph, off); \
346 count < graph->nb_nodes; \
347 off = node->next, node = RTE_PTR_ADD(graph, off), count++)
348
360__rte_experimental
361struct rte_node *rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id);
362
374__rte_experimental
375struct rte_node *rte_graph_node_get_by_name(const char *graph,
376 const char *name);
377
388__rte_experimental
389struct rte_graph_cluster_stats *rte_graph_cluster_stats_create(
390 const struct rte_graph_cluster_stats_param *prm);
391
398__rte_experimental
399void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat);
400
409__rte_experimental
410void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat,
411 bool skip_cb);
412
419__rte_experimental
420void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);
421
429 uint64_t flags;
430#define RTE_NODE_SOURCE_F (1ULL << 0)
437 const char *next_nodes[];
438};
439
453__rte_experimental
455
465#define RTE_NODE_REGISTER(node) \
466 RTE_INIT(rte_node_register_##node) \
467 { \
468 node.parent_id = RTE_NODE_ID_INVALID; \
469 node.id = __rte_node_register(&node); \
470 }
471
485__rte_experimental
487
498__rte_experimental
500
510__rte_experimental
512
522__rte_experimental
524
541__rte_experimental
543 const char **next_nodes, uint16_t nb_edges);
544
556__rte_experimental
558
572__rte_experimental
574
581__rte_experimental
583
592__rte_experimental
593void rte_node_dump(FILE *f, rte_node_t id);
594
601__rte_experimental
602void rte_node_list_dump(FILE *f);
603
613static __rte_always_inline int
615{
616 return (id == RTE_NODE_ID_INVALID);
617}
618
628static __rte_always_inline int
630{
631 return (id == RTE_EDGE_ID_INVALID);
632}
633
643static __rte_always_inline int
645{
646 return (id == RTE_GRAPH_ID_INVALID);
647}
648
655static __rte_always_inline int
657{
658#ifdef RTE_LIBRTE_GRAPH_STATS
659 return RTE_LIBRTE_GRAPH_STATS;
660#else
661 return 0;
662#endif
663}
664
665#ifdef __cplusplus
666}
667#endif
668
669#endif /* _RTE_GRAPH_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:440
#define RTE_STD_C11
Definition: rte_common.h:39
#define __rte_always_inline
Definition: rte_common.h:255
__rte_experimental void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat)
__rte_experimental void rte_graph_list_dump(FILE *f)
static __rte_always_inline int rte_graph_is_invalid(rte_graph_t id)
Definition: rte_graph.h:644
int(* rte_node_init_t)(const struct rte_graph *graph, struct rte_node *node)
Definition: rte_graph.h:119
__rte_experimental void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all)
__rte_experimental rte_node_t rte_node_max_count(void)
__rte_experimental struct rte_graph * rte_graph_lookup(const char *name)
static __rte_always_inline int rte_node_is_invalid(rte_node_t id)
Definition: rte_graph.h:614
__rte_experimental struct rte_node * rte_graph_node_get_by_name(const char *graph, const char *name)
__rte_experimental rte_edge_t rte_node_edge_count(rte_node_t id)
uint16_t(* rte_node_process_t)(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs)
Definition: rte_graph.h:99
__rte_experimental int rte_graph_export(const char *name, FILE *f)
__rte_experimental void rte_node_list_dump(FILE *f)
uint32_t rte_node_t
Definition: rte_graph.h:45
__rte_experimental rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm)
__rte_experimental void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat)
__rte_experimental rte_edge_t rte_node_edge_update(rte_node_t id, rte_edge_t from, const char **next_nodes, uint16_t nb_edges)
__rte_experimental rte_edge_t rte_node_edge_shrink(rte_node_t id, rte_edge_t size)
__rte_experimental rte_graph_t rte_graph_max_count(void)
#define RTE_GRAPH_ID_INVALID
Definition: rte_graph.h:41
__rte_experimental rte_node_t __rte_node_register(const struct rte_node_register *node)
uint16_t rte_edge_t
Definition: rte_graph.h:46
#define RTE_NODE_NAMESIZE
Definition: rte_graph.h:37
__rte_experimental struct rte_graph_cluster_stats * rte_graph_cluster_stats_create(const struct rte_graph_cluster_stats_param *prm)
uint32_t rte_graph_off_t
Definition: rte_graph.h:44
__rte_experimental void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat, bool skip_cb)
__rte_experimental int rte_graph_destroy(rte_graph_t id)
static __rte_always_inline int rte_edge_is_invalid(rte_edge_t id)
Definition: rte_graph.h:629
__rte_experimental void rte_graph_dump(FILE *f, rte_graph_t id)
uint16_t rte_graph_t
Definition: rte_graph.h:47
__rte_experimental rte_node_t rte_node_clone(rte_node_t id, const char *name)
__rte_experimental void rte_node_dump(FILE *f, rte_node_t id)
__rte_experimental rte_node_t rte_node_edge_get(rte_node_t id, char *next_nodes[])
int(* rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last, void *cookie, const struct rte_graph_cluster_node_stats *stats)
Definition: rte_graph.h:154
#define RTE_NODE_ID_INVALID
Definition: rte_graph.h:39
void(* rte_node_fini_t)(const struct rte_graph *graph, struct rte_node *node)
Definition: rte_graph.h:135
#define RTE_EDGE_ID_INVALID
Definition: rte_graph.h:40
__rte_experimental rte_node_t rte_node_from_name(const char *name)
static __rte_always_inline int rte_graph_has_stats_feature(void)
Definition: rte_graph.h:656
__rte_experimental char * rte_graph_id_to_name(rte_graph_t id)
__rte_experimental struct rte_node * rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id)
__rte_experimental rte_graph_t rte_graph_from_name(const char *name)
__rte_experimental char * rte_node_id_to_name(rte_node_t id)
char name[RTE_NODE_NAMESIZE]
Definition: rte_graph.h:211
const char ** graph_patterns
Definition: rte_graph.h:187
rte_graph_cluster_stats_cb_t fn
Definition: rte_graph.h:177
uint16_t nb_node_patterns
Definition: rte_graph.h:164
const char ** node_patterns
Definition: rte_graph.h:165
rte_node_fini_t fini
Definition: rte_graph.h:433
const char * next_nodes[]
Definition: rte_graph.h:437
rte_node_t parent_id
Definition: rte_graph.h:435
rte_node_process_t process
Definition: rte_graph.h:431
char name[RTE_NODE_NAMESIZE]
Definition: rte_graph.h:428
uint64_t flags
Definition: rte_graph.h:429
rte_edge_t nb_edges
Definition: rte_graph.h:436
rte_node_init_t init
Definition: rte_graph.h:432
rte_node_t id
Definition: rte_graph.h:434