DPDK 25.07.0
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
21#include <stdbool.h>
22#include <stdio.h>
23
24#include <rte_common.h>
25#include <rte_compat.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define RTE_GRAPH_NAMESIZE 64
32#define RTE_NODE_NAMESIZE 64
33#define RTE_NODE_XSTAT_DESC_SIZE 64
34#define RTE_GRAPH_PCAP_FILE_SZ 64
35#define RTE_GRAPH_OFF_INVALID UINT32_MAX
36#define RTE_NODE_ID_INVALID UINT32_MAX
37#define RTE_EDGE_ID_INVALID UINT16_MAX
38#define RTE_GRAPH_ID_INVALID UINT16_MAX
39#define RTE_GRAPH_FENCE 0xdeadbeef12345678ULL
41typedef uint32_t rte_graph_off_t;
42typedef uint32_t rte_node_t;
43typedef uint16_t rte_edge_t;
44typedef uint16_t rte_graph_t;
47#if RTE_GRAPH_BURST_SIZE == 1
48#define RTE_GRAPH_BURST_SIZE_LOG2 0
49#elif RTE_GRAPH_BURST_SIZE == 2
50#define RTE_GRAPH_BURST_SIZE_LOG2 1
51#elif RTE_GRAPH_BURST_SIZE == 4
52#define RTE_GRAPH_BURST_SIZE_LOG2 2
53#elif RTE_GRAPH_BURST_SIZE == 8
54#define RTE_GRAPH_BURST_SIZE_LOG2 3
55#elif RTE_GRAPH_BURST_SIZE == 16
56#define RTE_GRAPH_BURST_SIZE_LOG2 4
57#elif RTE_GRAPH_BURST_SIZE == 32
58#define RTE_GRAPH_BURST_SIZE_LOG2 5
59#elif RTE_GRAPH_BURST_SIZE == 64
60#define RTE_GRAPH_BURST_SIZE_LOG2 6
61#elif RTE_GRAPH_BURST_SIZE == 128
62#define RTE_GRAPH_BURST_SIZE_LOG2 7
63#elif RTE_GRAPH_BURST_SIZE == 256
64#define RTE_GRAPH_BURST_SIZE_LOG2 8
65#else
66#error "Unsupported burst size"
67#endif
68
69/* Forward declaration */
70struct rte_node;
71struct rte_graph;
72struct rte_graph_cluster_stats;
95typedef uint16_t (*rte_node_process_t)(struct rte_graph *graph,
96 struct rte_node *node, void **objs,
97 uint16_t nb_objs);
98
115typedef int (*rte_node_init_t)(const struct rte_graph *graph,
116 struct rte_node *node);
117
131typedef void (*rte_node_fini_t)(const struct rte_graph *graph,
132 struct rte_node *node);
133
150typedef int (*rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last,
151 void *cookie, const struct rte_graph_cluster_node_stats *stats);
152
161 const char **node_patterns;
168 union {
169 struct {
170 uint64_t rsvd;
171 } rtc;
172 struct {
173 uint32_t wq_size_max;
174 uint32_t mp_capacity;
175 } dispatch;
176 };
177};
178
191 union {
192 void *cookie;
193 FILE *f;
194 };
196 const char **graph_patterns;
198};
199
206 uint64_t ts;
207 uint64_t calls;
208 uint64_t objs;
209 uint64_t cycles;
211 uint64_t prev_ts;
212 uint64_t prev_calls;
213 uint64_t prev_objs;
214 uint64_t prev_cycles;
216 union {
217 struct {
218 uint64_t sched_objs;
220 uint64_t sched_fail;
222 } dispatch;
223 };
224
225 uint64_t realloc_count;
227 uint8_t xstat_cntrs;
228 char (*xstat_desc)[RTE_NODE_XSTAT_DESC_SIZE];
229 uint64_t *xstat_count;
232 uint64_t hz;
233 char name[RTE_NODE_NAMESIZE];
234};
235
250rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm);
251
264
284rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm);
285
296
307
319int rte_graph_export(const char *name, FILE *f);
320
332
340
355struct rte_graph *rte_graph_lookup(const char *name);
356
364
373void rte_graph_dump(FILE *f, rte_graph_t id);
374
382
393void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all);
394
396#define rte_graph_foreach_node(count, off, graph, node) \
397 for (count = 0, off = graph->nodes_start, \
398 node = RTE_PTR_ADD(graph, off); \
399 count < graph->nb_nodes; \
400 off = node->next, node = RTE_PTR_ADD(graph, off), count++)
401
413struct rte_node *rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id);
414
426struct rte_node *rte_graph_node_get_by_name(const char *graph,
427 const char *name);
428
439struct rte_graph_cluster_stats *rte_graph_cluster_stats_create(
440 const struct rte_graph_cluster_stats_param *prm);
441
448void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat);
449
458void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat,
459 bool skip_cb);
460
467void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);
468
474 uint16_t nb_xstats;
476};
477
485 uint64_t flags;
486#define RTE_NODE_SOURCE_F (1ULL << 0)
494 const char *next_nodes[];
495};
496
511
521#define RTE_NODE_REGISTER(node) \
522 RTE_INIT(rte_node_register_##node) \
523 { \
524 node.parent_id = RTE_NODE_ID_INVALID; \
525 node.id = __rte_node_register(&node); \
526 }
527
542
554
565
576
594 const char **next_nodes, uint16_t nb_edges);
595
608
623
631
640void rte_node_dump(FILE *f, rte_node_t id);
641
648void rte_node_list_dump(FILE *f);
649
659static __rte_always_inline int
661{
662 return (id == RTE_NODE_ID_INVALID);
663}
664
676__rte_experimental
678
688static __rte_always_inline int
690{
691 return (id == RTE_EDGE_ID_INVALID);
692}
693
703static __rte_always_inline int
705{
706 return (id == RTE_GRAPH_ID_INVALID);
707}
708
715static __rte_always_inline int
717{
718#ifdef RTE_LIBRTE_GRAPH_STATS
719 return RTE_LIBRTE_GRAPH_STATS;
720#else
721 return 0;
722#endif
723}
724
725#ifdef __cplusplus
726}
727#endif
728
729#endif /* _RTE_GRAPH_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:739
#define __rte_always_inline
Definition: rte_common.h:490
void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all)
static __rte_always_inline int rte_graph_is_invalid(rte_graph_t id)
Definition: rte_graph.h:704
void rte_graph_list_dump(FILE *f)
int(* rte_node_init_t)(const struct rte_graph *graph, struct rte_node *node)
Definition: rte_graph.h:115
void rte_graph_model_mcore_dispatch_core_unbind(rte_graph_t id)
char * rte_node_id_to_name(rte_node_t id)
rte_graph_t rte_graph_max_count(void)
static __rte_always_inline int rte_node_is_invalid(rte_node_t id)
Definition: rte_graph.h:660
char * rte_graph_id_to_name(rte_graph_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:95
uint32_t rte_node_t
Definition: rte_graph.h:42
rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm)
#define RTE_GRAPH_ID_INVALID
Definition: rte_graph.h:38
__rte_experimental int rte_node_free(rte_node_t id)
struct rte_graph * rte_graph_lookup(const char *name)
uint16_t rte_edge_t
Definition: rte_graph.h:43
struct rte_node * rte_graph_node_get_by_name(const char *graph, const char *name)
#define RTE_NODE_NAMESIZE
Definition: rte_graph.h:32
rte_node_t rte_node_clone(rte_node_t id, const char *name)
int rte_graph_destroy(rte_graph_t id)
rte_node_t rte_node_edge_get(rte_node_t id, char *next_nodes[])
uint32_t rte_graph_off_t
Definition: rte_graph.h:41
rte_edge_t rte_node_edge_shrink(rte_node_t id, rte_edge_t size)
struct rte_graph_cluster_stats * rte_graph_cluster_stats_create(const struct rte_graph_cluster_stats_param *prm)
rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm)
rte_edge_t rte_node_edge_count(rte_node_t id)
int rte_graph_model_mcore_dispatch_core_bind(rte_graph_t id, int lcore)
static __rte_always_inline int rte_edge_is_invalid(rte_edge_t id)
Definition: rte_graph.h:689
rte_graph_t rte_graph_from_name(const char *name)
uint16_t rte_graph_t
Definition: rte_graph.h:44
void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat)
int rte_graph_export(const char *name, FILE *f)
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:150
#define RTE_NODE_ID_INVALID
Definition: rte_graph.h:36
void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat, bool skip_cb)
void rte_node_list_dump(FILE *f)
struct rte_node * rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id)
void(* rte_node_fini_t)(const struct rte_graph *graph, struct rte_node *node)
Definition: rte_graph.h:131
#define RTE_EDGE_ID_INVALID
Definition: rte_graph.h:37
#define RTE_NODE_XSTAT_DESC_SIZE
Definition: rte_graph.h:33
void rte_node_dump(FILE *f, rte_node_t id)
void rte_graph_dump(FILE *f, rte_graph_t id)
rte_node_t __rte_node_register(const struct rte_node_register *node)
static __rte_always_inline int rte_graph_has_stats_feature(void)
Definition: rte_graph.h:716
void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat)
rte_edge_t rte_node_edge_update(rte_node_t id, rte_edge_t from, const char **next_nodes, uint16_t nb_edges)
rte_node_t rte_node_max_count(void)
rte_node_t rte_node_from_name(const char *name)
const char ** graph_patterns
Definition: rte_graph.h:196
rte_graph_cluster_stats_cb_t fn
Definition: rte_graph.h:187
uint16_t nb_node_patterns
Definition: rte_graph.h:160
uint32_t mp_capacity
Definition: rte_graph.h:174
const char ** node_patterns
Definition: rte_graph.h:161
uint32_t wq_size_max
Definition: rte_graph.h:173
uint64_t rsvd
Definition: rte_graph.h:170
char * pcap_filename
Definition: rte_graph.h:166
uint64_t num_pkt_to_capture
Definition: rte_graph.h:165
rte_node_fini_t fini
Definition: rte_graph.h:489
const char * next_nodes[]
Definition: rte_graph.h:494
rte_node_t parent_id
Definition: rte_graph.h:492
rte_node_process_t process
Definition: rte_graph.h:487
char name[RTE_NODE_NAMESIZE]
Definition: rte_graph.h:484
uint64_t flags
Definition: rte_graph.h:485
rte_edge_t nb_edges
Definition: rte_graph.h:493
struct rte_node_xstats * xstats
Definition: rte_graph.h:490
rte_node_init_t init
Definition: rte_graph.h:488
rte_node_t id
Definition: rte_graph.h:491
uint16_t nb_xstats
Definition: rte_graph.h:474
char xstat_desc[][RTE_NODE_XSTAT_DESC_SIZE]
Definition: rte_graph.h:475