To support multiple graph worker model, split graph into common
and default. Naming the current walk function as rte_graph_model_rtc
cause the default model is RTC(Run-to-completion).
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
app/test/test_graph.c | 2 +-
app/test/test_graph_perf.c | 2 +-
doc/api/doxy-api-index.md | 2 +-
doc/guides/prog_guide/graph_lib.rst | 2 +-
examples/l3fwd-graph/main.c | 2 +-
lib/graph/graph_pcap.c | 2 +-
lib/graph/graph_private.h | 2 +-
lib/graph/meson.build | 2 +-
lib/graph/rte_graph_model_rtc.h | 62 +++++++++++++++++++++++++++++
lib/graph/rte_graph_worker.h | 35 ++++++++++++++++
lib/graph/rte_graph_worker_common.h | 57 --------------------------
lib/node/ethdev_rx.c | 2 +-
lib/node/ethdev_tx.c | 2 +-
lib/node/ip4_lookup.c | 2 +-
lib/node/ip4_rewrite.c | 2 +-
lib/node/pkt_cls.c | 2 +-
16 files changed, 110 insertions(+), 70 deletions(-)
create mode 100644 lib/graph/rte_graph_model_rtc.h
create mode 100644 lib/graph/rte_graph_worker.h
@@ -24,7 +24,7 @@ test_node_list_dump(void)
#else
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include <rte_mbuf.h>
#include <rte_mbuf_dyn.h>
#include <rte_random.h>
@@ -23,7 +23,7 @@ test_graph_perf_func(void)
#else
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_mbuf.h>
@@ -201,7 +201,7 @@ The public API headers are grouped by topics:
[table_em](@ref rte_swx_table_em.h)
[table_wm](@ref rte_swx_table_wm.h)
* [graph](@ref rte_graph.h):
- [graph_worker](@ref rte_graph_worker_common.h)
+ [graph_worker](@ref rte_graph_worker.h)
* graph_nodes:
[eth_node](@ref rte_node_eth_api.h),
[ip4_node](@ref rte_node_ip4_api.h)
@@ -26,7 +26,7 @@ Features of the Graph library are:
- Low overhead statistics collection infrastructure.
- Support to export the graph as a Graphviz dot file. See ``rte_graph_export()``.
- Allow having another graph walk implementation in the future by segregating
- the fast path(``rte_graph_worker_common.h``) and slow path code.
+ the fast path(``rte_graph_worker.h``) and slow path code.
Advantages of Graph architecture
--------------------------------
@@ -23,7 +23,7 @@
#include <rte_cycles.h>
#include <rte_eal.h>
#include <rte_ethdev.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include <rte_launch.h>
#include <rte_lcore.h>
#include <rte_log.h>
@@ -10,7 +10,7 @@
#include <rte_mbuf.h>
#include <rte_pcapng.h>
-#include "rte_graph_worker_common.h"
+#include "rte_graph_worker.h"
#include "graph_pcap_private.h"
@@ -13,7 +13,7 @@
#include <rte_spinlock.h>
#include "rte_graph.h"
-#include "rte_graph_worker_common.h"
+#include "rte_graph_worker.h"
extern int rte_graph_logtype;
@@ -16,6 +16,6 @@ sources = files(
'graph_populate.c',
'graph_pcap.c',
)
-headers = files('rte_graph.h', 'rte_graph_worker_common.h')
+headers = files('rte_graph.h', 'rte_graph_worker.h')
deps += ['eal', 'pcapng']
new file mode 100644
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ * Copyright(C) 2023 Intel Corporation
+ */
+
+#include "rte_graph_worker_common.h"
+
+/**
+ * Perform graph walk on the circular buffer and invoke the process function
+ * of the nodes and collect the stats.
+ *
+ * @param graph
+ * Graph pointer returned from rte_graph_lookup function.
+ *
+ * @see rte_graph_lookup()
+ */
+static inline void
+rte_graph_walk_rtc(struct rte_graph *graph)
+{
+ const rte_graph_off_t *cir_start = graph->cir_start;
+ const rte_node_t mask = graph->cir_mask;
+ uint32_t head = graph->head;
+ struct rte_node *node;
+ uint64_t start;
+ uint16_t rc;
+ void **objs;
+
+ /*
+ * Walk on the source node(s) ((cir_start - head) -> cir_start) and then
+ * on the pending streams (cir_start -> (cir_start + mask) -> cir_start)
+ * in a circular buffer fashion.
+ *
+ * +-----+ <= cir_start - head [number of source nodes]
+ * | |
+ * | ... | <= source nodes
+ * | |
+ * +-----+ <= cir_start [head = 0] [tail = 0]
+ * | |
+ * | ... | <= pending streams
+ * | |
+ * +-----+ <= cir_start + mask
+ */
+ while (likely(head != graph->tail)) {
+ node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
+ RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
+ objs = node->objs;
+ rte_prefetch0(objs);
+
+ if (rte_graph_has_stats_feature()) {
+ start = rte_rdtsc();
+ rc = node->process(graph, node, objs, node->idx);
+ node->total_cycles += rte_rdtsc() - start;
+ node->total_calls++;
+ node->total_objs += rc;
+ } else {
+ node->process(graph, node, objs, node->idx);
+ }
+ node->idx = 0;
+ head = likely((int32_t)head > 0) ? head & mask : head;
+ }
+ graph->tail = 0;
+}
new file mode 100644
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ * Copyright(C) 2023 Intel Corporation
+ */
+
+#ifndef _RTE_GRAPH_WORKER_H_
+#define _RTE_GRAPH_WORKER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "rte_graph_model_rtc.h"
+
+/**
+ * Perform graph walk on the circular buffer and invoke the process function
+ * of the nodes and collect the stats.
+ *
+ * @param graph
+ * Graph pointer returned from rte_graph_lookup function.
+ *
+ * @see rte_graph_lookup()
+ */
+__rte_experimental
+static inline void
+rte_graph_walk(struct rte_graph *graph)
+{
+ rte_graph_walk_rtc(graph);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_GRAPH_WORKER_H_ */
@@ -128,63 +128,6 @@ __rte_experimental
void __rte_node_stream_alloc_size(struct rte_graph *graph,
struct rte_node *node, uint16_t req_size);
-/**
- * Perform graph walk on the circular buffer and invoke the process function
- * of the nodes and collect the stats.
- *
- * @param graph
- * Graph pointer returned from rte_graph_lookup function.
- *
- * @see rte_graph_lookup()
- */
-__rte_experimental
-static inline void
-rte_graph_walk(struct rte_graph *graph)
-{
- const rte_graph_off_t *cir_start = graph->cir_start;
- const rte_node_t mask = graph->cir_mask;
- uint32_t head = graph->head;
- struct rte_node *node;
- uint64_t start;
- uint16_t rc;
- void **objs;
-
- /*
- * Walk on the source node(s) ((cir_start - head) -> cir_start) and then
- * on the pending streams (cir_start -> (cir_start + mask) -> cir_start)
- * in a circular buffer fashion.
- *
- * +-----+ <= cir_start - head [number of source nodes]
- * | |
- * | ... | <= source nodes
- * | |
- * +-----+ <= cir_start [head = 0] [tail = 0]
- * | |
- * | ... | <= pending streams
- * | |
- * +-----+ <= cir_start + mask
- */
- while (likely(head != graph->tail)) {
- node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
- RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
- objs = node->objs;
- rte_prefetch0(objs);
-
- if (rte_graph_has_stats_feature()) {
- start = rte_rdtsc();
- rc = node->process(graph, node, objs, node->idx);
- node->total_cycles += rte_rdtsc() - start;
- node->total_calls++;
- node->total_objs += rc;
- } else {
- node->process(graph, node, objs, node->idx);
- }
- node->idx = 0;
- head = likely((int32_t)head > 0) ? head & mask : head;
- }
- graph->tail = 0;
-}
-
/* Fast path helper functions */
/**
@@ -6,7 +6,7 @@
#include <rte_ethdev.h>
#include <rte_ether.h>
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include "ethdev_rx_priv.h"
#include "node_private.h"
@@ -5,7 +5,7 @@
#include <rte_debug.h>
#include <rte_ethdev.h>
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include "ethdev_tx_priv.h"
@@ -8,7 +8,7 @@
#include <rte_ethdev.h>
#include <rte_ether.h>
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include <rte_ip.h>
#include <rte_lpm.h>
@@ -5,7 +5,7 @@
#include <rte_ethdev.h>
#include <rte_ether.h>
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include <rte_ip.h>
#include <rte_malloc.h>
#include <rte_vect.h>
@@ -3,7 +3,7 @@
*/
#include <rte_graph.h>
-#include <rte_graph_worker_common.h>
+#include <rte_graph_worker.h>
#include "pkt_cls_priv.h"
#include "node_private.h"