DPDK 25.03.0-rc0
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
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define RTE_GRAPH_NAMESIZE 64
31#define RTE_NODE_NAMESIZE 64
32#define RTE_NODE_XSTAT_DESC_SIZE 64
33#define RTE_GRAPH_PCAP_FILE_SZ 64
34#define RTE_GRAPH_OFF_INVALID UINT32_MAX
35#define RTE_NODE_ID_INVALID UINT32_MAX
36#define RTE_EDGE_ID_INVALID UINT16_MAX
37#define RTE_GRAPH_ID_INVALID UINT16_MAX
38#define RTE_GRAPH_FENCE 0xdeadbeef12345678ULL
40typedef uint32_t rte_graph_off_t;
41typedef uint32_t rte_node_t;
42typedef uint16_t rte_edge_t;
43typedef uint16_t rte_graph_t;
46#if RTE_GRAPH_BURST_SIZE == 1
47#define RTE_GRAPH_BURST_SIZE_LOG2 0
48#elif RTE_GRAPH_BURST_SIZE == 2
49#define RTE_GRAPH_BURST_SIZE_LOG2 1
50#elif RTE_GRAPH_BURST_SIZE == 4
51#define RTE_GRAPH_BURST_SIZE_LOG2 2
52#elif RTE_GRAPH_BURST_SIZE == 8
53#define RTE_GRAPH_BURST_SIZE_LOG2 3
54#elif RTE_GRAPH_BURST_SIZE == 16
55#define RTE_GRAPH_BURST_SIZE_LOG2 4
56#elif RTE_GRAPH_BURST_SIZE == 32
57#define RTE_GRAPH_BURST_SIZE_LOG2 5
58#elif RTE_GRAPH_BURST_SIZE == 64
59#define RTE_GRAPH_BURST_SIZE_LOG2 6
60#elif RTE_GRAPH_BURST_SIZE == 128
61#define RTE_GRAPH_BURST_SIZE_LOG2 7
62#elif RTE_GRAPH_BURST_SIZE == 256
63#define RTE_GRAPH_BURST_SIZE_LOG2 8
64#else
65#error "Unsupported burst size"
66#endif
67
68/* Forward declaration */
69struct rte_node;
70struct rte_graph;
71struct rte_graph_cluster_stats;
94typedef uint16_t (*rte_node_process_t)(struct rte_graph *graph,
95 struct rte_node *node, void **objs,
96 uint16_t nb_objs);
97
114typedef int (*rte_node_init_t)(const struct rte_graph *graph,
115 struct rte_node *node);
116
130typedef void (*rte_node_fini_t)(const struct rte_graph *graph,
131 struct rte_node *node);
132
149typedef int (*rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last,
150 void *cookie, const struct rte_graph_cluster_node_stats *stats);
151
160 const char **node_patterns;
167 union {
168 struct {
169 uint64_t rsvd;
170 } rtc;
171 struct {
172 uint32_t wq_size_max;
173 uint32_t mp_capacity;
174 } dispatch;
175 };
176};
177
190 union {
191 void *cookie;
192 FILE *f;
193 };
195 const char **graph_patterns;
197};
198
205 uint64_t ts;
206 uint64_t calls;
207 uint64_t objs;
208 uint64_t cycles;
210 uint64_t prev_ts;
211 uint64_t prev_calls;
212 uint64_t prev_objs;
213 uint64_t prev_cycles;
215 union {
216 struct {
217 uint64_t sched_objs;
219 uint64_t sched_fail;
221 } dispatch;
222 };
223
224 uint64_t realloc_count;
226 uint8_t xstat_cntrs;
227 char (*xstat_desc)[RTE_NODE_XSTAT_DESC_SIZE];
228 uint64_t *xstat_count;
231 uint64_t hz;
232 char name[RTE_NODE_NAMESIZE];
233};
234
249rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm);
250
263
283rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm);
284
295
306
318int rte_graph_export(const char *name, FILE *f);
319
331
339
354struct rte_graph *rte_graph_lookup(const char *name);
355
363
372void rte_graph_dump(FILE *f, rte_graph_t id);
373
381
392void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all);
393
395#define rte_graph_foreach_node(count, off, graph, node) \
396 for (count = 0, off = graph->nodes_start, \
397 node = RTE_PTR_ADD(graph, off); \
398 count < graph->nb_nodes; \
399 off = node->next, node = RTE_PTR_ADD(graph, off), count++)
400
412struct rte_node *rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id);
413
425struct rte_node *rte_graph_node_get_by_name(const char *graph,
426 const char *name);
427
438struct rte_graph_cluster_stats *rte_graph_cluster_stats_create(
439 const struct rte_graph_cluster_stats_param *prm);
440
447void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat);
448
457void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat,
458 bool skip_cb);
459
466void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);
467
473 uint16_t nb_xstats;
475};
476
484 uint64_t flags;
485#define RTE_NODE_SOURCE_F (1ULL << 0)
493 const char *next_nodes[];
494};
495
510
520#define RTE_NODE_REGISTER(node) \
521 RTE_INIT(rte_node_register_##node) \
522 { \
523 node.parent_id = RTE_NODE_ID_INVALID; \
524 node.id = __rte_node_register(&node); \
525 }
526
541
553
564
575
593 const char **next_nodes, uint16_t nb_edges);
594
607
622
630
639void rte_node_dump(FILE *f, rte_node_t id);
640
647void rte_node_list_dump(FILE *f);
648
658static __rte_always_inline int
660{
661 return (id == RTE_NODE_ID_INVALID);
662}
663
673static __rte_always_inline int
675{
676 return (id == RTE_EDGE_ID_INVALID);
677}
678
688static __rte_always_inline int
690{
691 return (id == RTE_GRAPH_ID_INVALID);
692}
693
700static __rte_always_inline int
702{
703#ifdef RTE_LIBRTE_GRAPH_STATS
704 return RTE_LIBRTE_GRAPH_STATS;
705#else
706 return 0;
707#endif
708}
709
710#ifdef __cplusplus
711}
712#endif
713
714#endif /* _RTE_GRAPH_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:627
#define __rte_always_inline
Definition: rte_common.h:413
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:689
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:114
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:659
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:94
uint32_t rte_node_t
Definition: rte_graph.h:41
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:37
struct rte_graph * rte_graph_lookup(const char *name)
uint16_t rte_edge_t
Definition: rte_graph.h:42
struct rte_node * rte_graph_node_get_by_name(const char *graph, const char *name)
#define RTE_NODE_NAMESIZE
Definition: rte_graph.h:31
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:40
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:674
rte_graph_t rte_graph_from_name(const char *name)
uint16_t rte_graph_t
Definition: rte_graph.h:43
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:149
#define RTE_NODE_ID_INVALID
Definition: rte_graph.h:35
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:130
#define RTE_EDGE_ID_INVALID
Definition: rte_graph.h:36
#define RTE_NODE_XSTAT_DESC_SIZE
Definition: rte_graph.h:32
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:701
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:195
rte_graph_cluster_stats_cb_t fn
Definition: rte_graph.h:186
uint16_t nb_node_patterns
Definition: rte_graph.h:159
uint32_t mp_capacity
Definition: rte_graph.h:173
const char ** node_patterns
Definition: rte_graph.h:160
uint32_t wq_size_max
Definition: rte_graph.h:172
uint64_t rsvd
Definition: rte_graph.h:169
char * pcap_filename
Definition: rte_graph.h:165
uint64_t num_pkt_to_capture
Definition: rte_graph.h:164
rte_node_fini_t fini
Definition: rte_graph.h:488
const char * next_nodes[]
Definition: rte_graph.h:493
rte_node_t parent_id
Definition: rte_graph.h:491
rte_node_process_t process
Definition: rte_graph.h:486
char name[RTE_NODE_NAMESIZE]
Definition: rte_graph.h:483
uint64_t flags
Definition: rte_graph.h:484
rte_edge_t nb_edges
Definition: rte_graph.h:492
struct rte_node_xstats * xstats
Definition: rte_graph.h:489
rte_node_init_t init
Definition: rte_graph.h:487
rte_node_t id
Definition: rte_graph.h:490
uint16_t nb_xstats
Definition: rte_graph.h:473
char xstat_desc[][RTE_NODE_XSTAT_DESC_SIZE]
Definition: rte_graph.h:474