From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE6E142CAB; Tue, 13 Jun 2023 16:12:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4B1142C24; Tue, 13 Jun 2023 16:12:05 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 9533D42C24 for ; Tue, 13 Jun 2023 16:12:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686665523; x=1718201523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2+vlldtPBi5yHSO6obkyLqyrGMKyecOmSwmYD9nf1Zo=; b=daX3jl/ccVmH7FqJdi4YqQldoQxm1CXQ5nZXeqHibdKHGN4OFThiSF3h XPLTQwV0SercCTRG1gJNVo279r3n4T2I01daCqEdjmKG0zQ99b/lW44CA wdDpF946qvrpyBr35Ds/EDoza1VHK5uR5M7LiLBdNiWK77UP+AfBWmqjW 3ZEfJiDZCQ80njO+emyH5+RW7eZNzAisDz9fOHFsakmYvCKm1JjGBUZzP 3tuhROFvnbdZjPyVdkGeXCPpX78yqXcdzUCuR3OLLHmpWodhDGHK0F+ZK MCDtCDDoTdh7TeWgPQvpol2368YQ2TFzrIxgKVh06QzeZTcO4DMiA3jdo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="355839639" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="355839639" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 07:12:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="741439281" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="741439281" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.94]) by orsmga008.jf.intel.com with ESMTP; 13 Jun 2023 07:11:59 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com, stephen@networkplumber.org, pbhagavatula@marvell.com, jerinjacobk@gmail.com, david.marchand@redhat.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, mattias.ronnblom@ericsson.com, Zhirun Yan Subject: [PATCH v14 02/16] graph: split graph worker into common and default model Date: Tue, 13 Jun 2023 22:04:31 +0800 Message-Id: <20230613140445.2155542-3-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230613140445.2155542-1-zhirun.yan@intel.com> References: <20230613101404.1787790-1-zhirun.yan@intel.com> <20230613140445.2155542-1-zhirun.yan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan Acked-by: Jerin Jacob --- 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 | 6 ++- 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/ip6_lookup.c | 2 +- lib/node/ip6_rewrite.c | 2 +- lib/node/kernel_rx.c | 2 +- lib/node/kernel_tx.c | 2 +- lib/node/pkt_cls.c | 2 +- 20 files changed, 118 insertions(+), 74 deletions(-) create mode 100644 lib/graph/rte_graph_model_rtc.h create mode 100644 lib/graph/rte_graph_worker.h diff --git a/app/test/test_graph.c b/app/test/test_graph.c index c2c855f776..1a2d1e6fab 100644 --- a/app/test/test_graph.c +++ b/app/test/test_graph.c @@ -24,7 +24,7 @@ test_node_list_dump(void) #else #include -#include +#include #include #include #include diff --git a/app/test/test_graph_perf.c b/app/test/test_graph_perf.c index 5c4e9c917b..c5b463f700 100644 --- a/app/test/test_graph_perf.c +++ b/app/test/test_graph_perf.c @@ -23,7 +23,7 @@ test_graph_perf_func(void) #else #include -#include +#include #include #include #include diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index cc1ad395f3..32bf7b72b2 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -205,7 +205,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) diff --git a/doc/guides/prog_guide/graph_lib.rst b/doc/guides/prog_guide/graph_lib.rst index 18d29e1422..07248f06c4 100644 --- a/doc/guides/prog_guide/graph_lib.rst +++ b/doc/guides/prog_guide/graph_lib.rst @@ -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 -------------------------------- diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c index cddbdf327b..0c82e24513 100644 --- a/examples/l3fwd-graph/main.c +++ b/examples/l3fwd-graph/main.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c index f7767fb8be..db722c375f 100644 --- a/lib/graph/graph_pcap.c +++ b/lib/graph/graph_pcap.c @@ -11,7 +11,7 @@ #include #include -#include "rte_graph_worker_common.h" +#include "rte_graph_worker.h" #include "graph_pcap_private.h" diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 307e5f70bc..eacdef45f0 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -13,7 +13,7 @@ #include #include "rte_graph.h" -#include "rte_graph_worker_common.h" +#include "rte_graph_worker.h" extern int rte_graph_logtype; diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 4e2b612ad3..31d78a1dc2 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -16,6 +16,10 @@ 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') +indirect_headers += files( + 'rte_graph_model_rtc.h', + 'rte_graph_worker_common.h', + ) deps += ['eal', 'pcapng'] diff --git a/lib/graph/rte_graph_model_rtc.h b/lib/graph/rte_graph_model_rtc.h new file mode 100644 index 0000000000..10b359772f --- /dev/null +++ b/lib/graph/rte_graph_model_rtc.h @@ -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; +} diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h new file mode 100644 index 0000000000..5b58f7bda9 --- /dev/null +++ b/lib/graph/rte_graph_worker.h @@ -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_ */ diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 5a4b54e490..475ccdc0ee 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.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 */ /** diff --git a/lib/node/ethdev_rx.c b/lib/node/ethdev_rx.c index 87cccbcc7b..d131034991 100644 --- a/lib/node/ethdev_rx.c +++ b/lib/node/ethdev_rx.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "ethdev_rx_priv.h" #include "node_private.h" diff --git a/lib/node/ethdev_tx.c b/lib/node/ethdev_tx.c index 17231d8b34..7d2d72f823 100644 --- a/lib/node/ethdev_tx.c +++ b/lib/node/ethdev_tx.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "ethdev_tx_priv.h" diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index b84c066fe3..8bce03d7db 100644 --- a/lib/node/ip4_lookup.c +++ b/lib/node/ip4_lookup.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/node/ip4_rewrite.c b/lib/node/ip4_rewrite.c index 72ca4b1370..34a920df5e 100644 --- a/lib/node/ip4_rewrite.c +++ b/lib/node/ip4_rewrite.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c index 912e33688c..2898b3f8f6 100644 --- a/lib/node/ip6_lookup.c +++ b/lib/node/ip6_lookup.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/node/ip6_rewrite.c b/lib/node/ip6_rewrite.c index 83f698a0c8..198d8d8820 100644 --- a/lib/node/ip6_rewrite.c +++ b/lib/node/ip6_rewrite.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/node/kernel_rx.c b/lib/node/kernel_rx.c index cdd2740170..2dba7c8cc7 100644 --- a/lib/node/kernel_rx.c +++ b/lib/node/kernel_rx.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/node/kernel_tx.c b/lib/node/kernel_tx.c index 0db83a91a9..27d1808c71 100644 --- a/lib/node/kernel_tx.c +++ b/lib/node/kernel_tx.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include "kernel_tx_priv.h" diff --git a/lib/node/pkt_cls.c b/lib/node/pkt_cls.c index 2e5b339a60..a8302b8d28 100644 --- a/lib/node/pkt_cls.c +++ b/lib/node/pkt_cls.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include "pkt_cls_priv.h" #include "node_private.h" -- 2.37.2