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 91240A00C2; Thu, 17 Nov 2022 06:09:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8434742D1D; Thu, 17 Nov 2022 06:09:48 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 4941F42D2C for ; Thu, 17 Nov 2022 06:09:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668661787; x=1700197787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M/ALlbn5KPII3RoYz/BP3J2Efi5RNggj1hxPXaxiR4o=; b=A8lAPA0hzmaaeAf7AcdaNiTq4PMIgxNweBV8poI4Z28dict6qc6taAJy ZLxsR+cBjIyg5NGO1ZOx7oYqlCmGrv72empaFklapZMVsqX7TJ605KUTF FLhG4V1F247cFvET+HdLE68PBDoah/mtOlxsQvEJoNwB275ryIwTZcvUt 6iENoBaNI5kQ9nAuNuoEojiX5BfdG1PappwJvFgS93G/RudbLZ4e4Cckh 2ywI7nPk+8exuz+/9B4M3TdSAWUCfkNbKZjL78u3HAqeorcarofqW3jxx 7o1DI4rbeFZwGKGsSl9k56Y4Owe2C4wWqg86QRErX0Xyrus9Z45F2REH/ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="377026665" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="377026665" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 21:09:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="617466051" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="617466051" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.118.230]) by orsmga006.jf.intel.com with ESMTP; 16 Nov 2022 21:09:44 -0800 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v1 03/13] graph: add macro to walk on graph circular buffer Date: Thu, 17 Nov 2022 13:09:16 +0800 Message-Id: <20221117050926.136974-4-zhirun.yan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117050926.136974-1-zhirun.yan@intel.com> References: <20221117050926.136974-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 It is common to walk on graph circular buffer and use macro to make it reusable for other worker models. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/rte_graph_model_rtc.h | 23 ++--------------------- lib/graph/rte_graph_worker_common.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/graph/rte_graph_model_rtc.h b/lib/graph/rte_graph_model_rtc.h index c80b0ce962..5474b06063 100644 --- a/lib/graph/rte_graph_model_rtc.h +++ b/lib/graph/rte_graph_model_rtc.h @@ -12,30 +12,11 @@ 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; - /* - * 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_graph_walk_node(graph, head, node) __rte_node_process(graph, node); - head = likely((int32_t)head > 0) ? head & mask : head; - } + graph->tail = 0; } diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index b7b2bb958c..df33204336 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -121,6 +121,29 @@ void __rte_node_stream_alloc_size(struct rte_graph *graph, /* Fast path helper functions */ +/** + * Macro to 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 + */ +#define rte_graph_walk_node(graph, head, node) \ + for ((node) = RTE_PTR_ADD((graph), (graph)->cir_start[(int32_t)(head)]); \ + likely((head) != (graph)->tail); \ + (head)++, \ + (node) = RTE_PTR_ADD((graph), (graph)->cir_start[(int32_t)(head)]), \ + (head) = likely((int32_t)(head) > 0) ? (head) & (graph)->cir_mask : (head)) + /** * @internal * -- 2.25.1