DPDK 23.11.0
Loading...
Searching...
No Matches
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_GRAPH_PCAP_FILE_SZ 64
33#define RTE_GRAPH_OFF_INVALID UINT32_MAX
34#define RTE_NODE_ID_INVALID UINT32_MAX
35#define RTE_EDGE_ID_INVALID UINT16_MAX
36#define RTE_GRAPH_ID_INVALID UINT16_MAX
37#define RTE_GRAPH_FENCE 0xdeadbeef12345678ULL
39typedef uint32_t rte_graph_off_t;
40typedef uint32_t rte_node_t;
41typedef uint16_t rte_edge_t;
42typedef uint16_t rte_graph_t;
45#if RTE_GRAPH_BURST_SIZE == 1
46#define RTE_GRAPH_BURST_SIZE_LOG2 0
47#elif RTE_GRAPH_BURST_SIZE == 2
48#define RTE_GRAPH_BURST_SIZE_LOG2 1
49#elif RTE_GRAPH_BURST_SIZE == 4
50#define RTE_GRAPH_BURST_SIZE_LOG2 2
51#elif RTE_GRAPH_BURST_SIZE == 8
52#define RTE_GRAPH_BURST_SIZE_LOG2 3
53#elif RTE_GRAPH_BURST_SIZE == 16
54#define RTE_GRAPH_BURST_SIZE_LOG2 4
55#elif RTE_GRAPH_BURST_SIZE == 32
56#define RTE_GRAPH_BURST_SIZE_LOG2 5
57#elif RTE_GRAPH_BURST_SIZE == 64
58#define RTE_GRAPH_BURST_SIZE_LOG2 6
59#elif RTE_GRAPH_BURST_SIZE == 128
60#define RTE_GRAPH_BURST_SIZE_LOG2 7
61#elif RTE_GRAPH_BURST_SIZE == 256
62#define RTE_GRAPH_BURST_SIZE_LOG2 8
63#else
64#error "Unsupported burst size"
65#endif
66
67/* Forward declaration */
68struct rte_node;
69struct rte_graph;
70struct rte_graph_cluster_stats;
93typedef uint16_t (*rte_node_process_t)(struct rte_graph *graph,
94 struct rte_node *node, void **objs,
95 uint16_t nb_objs);
96
113typedef int (*rte_node_init_t)(const struct rte_graph *graph,
114 struct rte_node *node);
115
129typedef void (*rte_node_fini_t)(const struct rte_graph *graph,
130 struct rte_node *node);
131
148typedef int (*rte_graph_cluster_stats_cb_t)(bool is_first, bool is_last,
149 void *cookie, const struct rte_graph_cluster_node_stats *stats);
150
159 const char **node_patterns;
166 union {
167 struct {
168 uint64_t rsvd;
169 } rtc;
170 struct {
171 uint32_t wq_size_max;
172 uint32_t mp_capacity;
173 } dispatch;
174 };
175};
176
189 union {
190 void *cookie;
191 FILE *f;
192 };
194 const char **graph_patterns;
196};
197
204 uint64_t ts;
205 uint64_t calls;
206 uint64_t objs;
207 uint64_t cycles;
209 uint64_t prev_ts;
210 uint64_t prev_calls;
211 uint64_t prev_objs;
212 uint64_t prev_cycles;
214 union {
215 struct {
216 uint64_t sched_objs;
218 uint64_t sched_fail;
220 } dispatch;
221 };
222
223 uint64_t realloc_count;
226 uint64_t hz;
229
244rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm);
245
258
278rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm);
279
290
301
313int rte_graph_export(const char *name, FILE *f);
314
326
334
349struct rte_graph *rte_graph_lookup(const char *name);
350
358
367void rte_graph_dump(FILE *f, rte_graph_t id);
368
376
387void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all);
388
390#define rte_graph_foreach_node(count, off, graph, node) \
391 for (count = 0, off = graph->nodes_start, \
392 node = RTE_PTR_ADD(graph, off); \
393 count < graph->nb_nodes; \
394 off = node->next, node = RTE_PTR_ADD(graph, off), count++)
395
407struct rte_node *rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id);
408
420struct rte_node *rte_graph_node_get_by_name(const char *graph,
421 const char *name);
422
433struct rte_graph_cluster_stats *rte_graph_cluster_stats_create(
434 const struct rte_graph_cluster_stats_param *prm);
435
442void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat);
443
452void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat,
453 bool skip_cb);
454
461void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);
462
480
495
505#define RTE_NODE_REGISTER(node) \
506 RTE_INIT(rte_node_register_##node) \
507 { \
508 node.parent_id = RTE_NODE_ID_INVALID; \
509 node.id = __rte_node_register(&node); \
510 }
511
526
538
549
560
578 const char **next_nodes, uint16_t nb_edges);
579
592
607
615
624void rte_node_dump(FILE *f, rte_node_t id);
625
632void rte_node_list_dump(FILE *f);
633
643static __rte_always_inline int
645{
646 return (id == RTE_NODE_ID_INVALID);
647}
648
658static __rte_always_inline int
660{
661 return (id == RTE_EDGE_ID_INVALID);
662}
663
673static __rte_always_inline int
675{
676 return (id == RTE_GRAPH_ID_INVALID);
677}
678
685static __rte_always_inline int
687{
688#ifdef RTE_LIBRTE_GRAPH_STATS
689 return RTE_LIBRTE_GRAPH_STATS;
690#else
691 return 0;
692#endif
693}
694
695#ifdef __cplusplus
696}
697#endif
698
699#endif /* _RTE_GRAPH_H_ */
#define __rte_cache_aligned
Definition rte_common.h:524
#define __rte_always_inline
Definition rte_common.h:331
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:674
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:113
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:644
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:93
uint32_t rte_node_t
Definition rte_graph.h:40
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:36
struct rte_graph * rte_graph_lookup(const char *name)
uint16_t rte_edge_t
Definition rte_graph.h:41
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:39
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:659
rte_graph_t rte_graph_from_name(const char *name)
uint16_t rte_graph_t
Definition rte_graph.h:42
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:148
#define RTE_NODE_ID_INVALID
Definition rte_graph.h:34
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:129
#define RTE_EDGE_ID_INVALID
Definition rte_graph.h:35
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:686
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)
char name[RTE_NODE_NAMESIZE]
Definition rte_graph.h:227
rte_graph_cluster_stats_cb_t fn
Definition rte_graph.h:185
uint16_t nb_node_patterns
Definition rte_graph.h:158
uint32_t mp_capacity
Definition rte_graph.h:172
const char ** node_patterns
Definition rte_graph.h:159
uint32_t wq_size_max
Definition rte_graph.h:171
uint64_t rsvd
Definition rte_graph.h:168
char * pcap_filename
Definition rte_graph.h:164
uint64_t num_pkt_to_capture
Definition rte_graph.h:163
rte_node_fini_t fini
Definition rte_graph.h:474
const char * next_nodes[]
Definition rte_graph.h:478
rte_node_t parent_id
Definition rte_graph.h:476
rte_node_process_t process
Definition rte_graph.h:472
char name[RTE_NODE_NAMESIZE]
Definition rte_graph.h:469
rte_edge_t nb_edges
Definition rte_graph.h:477
rte_node_init_t init
Definition rte_graph.h:473
rte_node_t id
Definition rte_graph.h:475