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 F0737A00C2; Thu, 17 Nov 2022 06:10:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9AA5042D3A; Thu, 17 Nov 2022 06:09:54 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 4849242D30 for ; Thu, 17 Nov 2022 06:09:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668661793; x=1700197793; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sDdf0Cl1viIbZaEbvQSQTjkz0pIhebwYI4cZagY8no4=; b=aQfm2td6gcY2+5/5sdwmUi0rRyUc//BUDbyXgCybY51ulCg7Bi3OJH7n ZYFaewl2bMiPk3xrV5G3eHKGPEi2gfoJHPCSN5PFVQTHDcY4wtz1BagOE 1aJOQGV7g+UzP4PyyAO2I4pP2jXpPG627KMUMa8vCrNIoGskbKpf00Zwe cpiG98t4ixVJYu1AwF4AUbPcUK+s6TOP6Zqw1TT4aAUGFhqgVViGy3vPN 7PeKSReYCyKhrt9UGfllMxzaVB76ymaonQmtRiwl5OMj8/68EEwpxvg4d R6qDX4qEMEj3xrPm5CYxx3I+1chhbeMgGyovo38isciO4WfQgt1q4oyW0 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="377026676" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="377026676" 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:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="617466061" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="617466061" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.118.230]) by orsmga006.jf.intel.com with ESMTP; 16 Nov 2022 21:09:50 -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 05/13] graph: introduce core affinity API Date: Thu, 17 Nov 2022 13:09:18 +0800 Message-Id: <20221117050926.136974-6-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 1. add lcore_id for node to hold affinity core id. 2. impl rte_node_model_generic_set_lcore_affinity to affinity node with one lcore. 3. update version map for graph public API. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph_private.h | 1 + lib/graph/meson.build | 1 + lib/graph/node.c | 1 + lib/graph/rte_graph_model_generic.c | 31 +++++++++++++++++++++ lib/graph/rte_graph_model_generic.h | 43 +++++++++++++++++++++++++++++ lib/graph/version.map | 2 ++ 6 files changed, 79 insertions(+) create mode 100644 lib/graph/rte_graph_model_generic.c create mode 100644 lib/graph/rte_graph_model_generic.h diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index f9a85c8926..627090f802 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -49,6 +49,7 @@ struct node { STAILQ_ENTRY(node) next; /**< Next node in the list. */ char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */ uint64_t flags; /**< Node configuration flag. */ + unsigned int lcore_id; /**< Node runs on the Lcore ID */ rte_node_process_t process; /**< Node process function. */ rte_node_init_t init; /**< Node init function. */ rte_node_fini_t fini; /**< Node fini function. */ diff --git a/lib/graph/meson.build b/lib/graph/meson.build index c7327549e8..8c8b11ed27 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -14,6 +14,7 @@ sources = files( 'graph_debug.c', 'graph_stats.c', 'graph_populate.c', + 'rte_graph_model_generic.c', ) headers = files('rte_graph.h', 'rte_graph_worker.h') diff --git a/lib/graph/node.c b/lib/graph/node.c index fc6345de07..8ad4b3cbeb 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -100,6 +100,7 @@ __rte_node_register(const struct rte_node_register *reg) goto free; } + node->lcore_id = RTE_MAX_LCORE; node->id = node_id++; /* Add the node at tail */ diff --git a/lib/graph/rte_graph_model_generic.c b/lib/graph/rte_graph_model_generic.c new file mode 100644 index 0000000000..54ff659c7b --- /dev/null +++ b/lib/graph/rte_graph_model_generic.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2022 Intel Corporation + */ + +#include "graph_private.h" +#include "rte_graph_model_generic.h" + +int +rte_node_model_generic_set_lcore_affinity(const char *name, unsigned int lcore_id) +{ + struct node *node; + int ret = -EINVAL; + + if (lcore_id >= RTE_MAX_LCORE) + return ret; + + graph_spinlock_lock(); + + STAILQ_FOREACH(node, node_list_head_get(), next) { + if (strncmp(node->name, name, RTE_NODE_NAMESIZE) == 0) { + node->lcore_id = lcore_id; + ret = 0; + break; + } + } + + graph_spinlock_unlock(); + + return ret; +} + diff --git a/lib/graph/rte_graph_model_generic.h b/lib/graph/rte_graph_model_generic.h new file mode 100644 index 0000000000..20ca48a9e3 --- /dev/null +++ b/lib/graph/rte_graph_model_generic.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2022 Intel Corporation + */ + +#ifndef _RTE_GRAPH_MODEL_GENERIC_H_ +#define _RTE_GRAPH_MODEL_GENERIC_H_ + +/** + * @file rte_graph_model_generic.h + * + * @warning + * @b EXPERIMENTAL: + * All functions in this file may be changed or removed without prior notice. + * + * This API allows a worker thread to walk over a graph and nodes to create, + * process, enqueue and move streams of objects to the next nodes. + */ +#include "rte_graph_worker_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Set lcore affinity to the node. + * + * @param name + * Valid node name. In the case of the cloned node, the name will be + * "parent node name" + "-" + name. + * @param lcore_id + * The lcore ID value. + * + * @return + * 0 on success, error otherwise. + */ +__rte_experimental +int rte_node_model_generic_set_lcore_affinity(const char *name, unsigned int lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_GRAPH_MODEL_GENERIC_H_ */ diff --git a/lib/graph/version.map b/lib/graph/version.map index eea73ec9ca..33ff055be6 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -46,5 +46,7 @@ EXPERIMENTAL { rte_graph_worker_model_set; rte_graph_worker_model_get; + rte_node_model_generic_set_lcore_affinity; + local: *; }; -- 2.25.1