DPDK 25.11.0-rc1
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
161typedef void (*packets_enqueued_cb)(struct rte_graph *graph, uint64_t cb_priv);
162
171 const char **node_patterns;
178 union {
179 struct {
180 uint64_t rsvd;
181 } rtc;
182 struct {
183 uint32_t wq_size_max;
184 uint32_t mp_capacity;
185 packets_enqueued_cb notify_cb;
186 uint64_t cb_priv;
187 } dispatch;
188 };
189};
190
203 union {
204 void *cookie;
205 FILE *f;
206 };
208 const char **graph_patterns;
210};
211
218 uint64_t ts;
219 uint64_t calls;
220 uint64_t objs;
221 uint64_t cycles;
223 uint64_t prev_ts;
224 uint64_t prev_calls;
225 uint64_t prev_objs;
226 uint64_t prev_cycles;
228 union {
229 struct {
230 uint64_t sched_objs;
232 uint64_t sched_fail;
234 } dispatch;
235 };
236
237 uint64_t realloc_count;
239 uint8_t xstat_cntrs;
240 char (*xstat_desc)[RTE_NODE_XSTAT_DESC_SIZE];
241 uint64_t *xstat_count;
244 uint64_t hz;
245 char name[RTE_NODE_NAMESIZE];
246};
247
262rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm);
263
276
296rte_graph_t rte_graph_clone(rte_graph_t id, const char *name, struct rte_graph_param *prm);
297
308
319
331int rte_graph_export(const char *name, FILE *f);
332
344
352
367struct rte_graph *rte_graph_lookup(const char *name);
368
376
385void rte_graph_dump(FILE *f, rte_graph_t id);
386
394
405void rte_graph_obj_dump(FILE *f, struct rte_graph *graph, bool all);
406
408#define rte_graph_foreach_node(count, off, graph, node) \
409 for (count = 0, off = graph->nodes_start, \
410 node = RTE_PTR_ADD(graph, off); \
411 count < graph->nb_nodes; \
412 off = node->next, node = RTE_PTR_ADD(graph, off), count++)
413
425struct rte_node *rte_graph_node_get(rte_graph_t graph_id, rte_node_t node_id);
426
438struct rte_node *rte_graph_node_get_by_name(const char *graph,
439 const char *name);
440
451struct rte_graph_cluster_stats *rte_graph_cluster_stats_create(
452 const struct rte_graph_cluster_stats_param *prm);
453
460void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat);
461
470void rte_graph_cluster_stats_get(struct rte_graph_cluster_stats *stat,
471 bool skip_cb);
472
479void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);
480
486 uint16_t nb_xstats;
488};
489
497 uint64_t flags;
498#define RTE_NODE_SOURCE_F (1ULL << 0)
506 const char *next_nodes[];
507};
508
523
533#define RTE_NODE_REGISTER(node) \
534 RTE_INIT(rte_node_register_##node) \
535 { \
536 node.parent_id = RTE_NODE_ID_INVALID; \
537 node.id = __rte_node_register(&node); \
538 }
539
554
566
577
588
606 const char **next_nodes, uint16_t nb_edges);
607
620
635
643
652void rte_node_dump(FILE *f, rte_node_t id);
653
660void rte_node_list_dump(FILE *f);
661
671static __rte_always_inline int
673{
674 return (id == RTE_NODE_ID_INVALID);
675}
676
688__rte_experimental
690
700static __rte_always_inline int
702{
703 return (id == RTE_EDGE_ID_INVALID);
704}
705
715static __rte_always_inline int
717{
718 return (id == RTE_GRAPH_ID_INVALID);
719}
720
727static __rte_always_inline int
729{
730#ifdef RTE_LIBRTE_GRAPH_STATS
731 return RTE_LIBRTE_GRAPH_STATS;
732#else
733 return 0;
734#endif
735}
736
737#ifdef __cplusplus
738}
739#endif
740
741#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:716
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:672
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
void(* packets_enqueued_cb)(struct rte_graph *graph, uint64_t cb_priv)
Definition: rte_graph.h:161
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:701
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:728
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:208
rte_graph_cluster_stats_cb_t fn
Definition: rte_graph.h:199
uint16_t nb_node_patterns
Definition: rte_graph.h:170
uint32_t mp_capacity
Definition: rte_graph.h:184
const char ** node_patterns
Definition: rte_graph.h:171
uint32_t wq_size_max
Definition: rte_graph.h:183
uint64_t rsvd
Definition: rte_graph.h:180
char * pcap_filename
Definition: rte_graph.h:176
uint64_t num_pkt_to_capture
Definition: rte_graph.h:175
rte_node_fini_t fini
Definition: rte_graph.h:501
const char * next_nodes[]
Definition: rte_graph.h:506
rte_node_t parent_id
Definition: rte_graph.h:504
rte_node_process_t process
Definition: rte_graph.h:499
char name[RTE_NODE_NAMESIZE]
Definition: rte_graph.h:496
uint64_t flags
Definition: rte_graph.h:497
rte_edge_t nb_edges
Definition: rte_graph.h:505
struct rte_node_xstats * xstats
Definition: rte_graph.h:502
rte_node_init_t init
Definition: rte_graph.h:500
rte_node_t id
Definition: rte_graph.h:503
uint16_t nb_xstats
Definition: rte_graph.h:486
char xstat_desc[][RTE_NODE_XSTAT_DESC_SIZE]
Definition: rte_graph.h:487