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 319E0A0548; Thu, 8 Sep 2022 04:10:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6279841141; Thu, 8 Sep 2022 04:10:20 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 62AE7400D6 for ; Thu, 8 Sep 2022 04:10:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662603018; x=1694139018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xbhoz/Z17uszlvsVlAo1BOC6kKmr33IMGF7hTtl+1GE=; b=RhmvS7TNFmIC3Lnq442UXXikNcLSLEkjbx5N8akMmG1/RdHfpHRLqHqB P043i/3lTy3KlcB/r9MWbSVxEYxDv3qKzZdiKgZXTXL2IfpRc9iQiKsdB GrKkojBywjmD1cqQg/MDEAaQ2W6rXDY5Lmx4zwcjxbzVPsDeShlUhqXHg AGxjqJdViUp1mrg5fs7FG5/HQ3vWU2ai5kb/+k1PGVyKPKeGYUaASjqiK +jrHvX22g3Ck/KxHtbBZgddeJBJobU21udbalMiN+x4cWYCMo1JoONr9s geB8jhGbzzXnwaJfWbx7DwYrttcTSw3yYfcm+e8YD/ASqkQpr2ge4Vjj4 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="383336882" X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="383336882" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 19:10:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="565755824" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.118.241]) by orsmga003.jf.intel.com with ESMTP; 07 Sep 2022 19:10:16 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [RFC, v1 1/6] graph: introduce core affinity API into graph Date: Thu, 8 Sep 2022 10:09:54 +0800 Message-Id: <20220908020959.1675953-2-zhirun.yan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220908020959.1675953-1-zhirun.yan@intel.com> References: <20220908020959.1675953-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_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/node.c | 25 +++++++++++++++++++++++++ lib/graph/rte_graph.h | 15 +++++++++++++++ lib/graph/version.map | 1 + 4 files changed, 42 insertions(+) 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/node.c b/lib/graph/node.c index ae6eadb260..2ce031886b 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -99,6 +99,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 */ @@ -192,6 +193,30 @@ rte_node_clone(rte_node_t id, const char *name) return RTE_NODE_ID_INVALID; } +int +rte_node_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, next) { + if (strncmp(node->name, name, RTE_NODE_NAMESIZE) == 0) { + node->lcore_id = lcore_id; + ret = 0; + break; + } + } + + graph_spinlock_unlock(); + + return ret; +} + rte_node_t rte_node_from_name(const char *name) { diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index b32c4bc217..9f84461dd8 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -510,6 +510,21 @@ rte_node_t rte_node_from_name(const char *name); __rte_experimental char *rte_node_id_to_name(rte_node_t id); +/** + * 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_set_lcore_affinity(const char *name, unsigned int lcore_id); + /** * Get the number of edges(next-nodes) for a node from node id. * diff --git a/lib/graph/version.map b/lib/graph/version.map index 13b838752d..6d40a74731 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -42,6 +42,7 @@ EXPERIMENTAL { rte_node_next_stream_get; rte_node_next_stream_put; rte_node_next_stream_move; + rte_node_set_lcore_affinity; local: *; }; -- 2.25.1