From: Zhirun Yan <zhirun.yan@intel.com>
To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com
Cc: cunming.liang@intel.com, haiyue.wang@intel.com,
Zhirun Yan <zhirun.yan@intel.com>
Subject: [RFC, v1 1/6] graph: introduce core affinity API into graph
Date: Thu, 8 Sep 2022 10:09:54 +0800 [thread overview]
Message-ID: <20220908020959.1675953-2-zhirun.yan@intel.com> (raw)
In-Reply-To: <20220908020959.1675953-1-zhirun.yan@intel.com>
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 <haiyue.wang@intel.com>
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
---
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
next prev parent reply other threads:[~2022-09-08 2:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 2:09 [RFC, v1 0/6] graph enhancement for multi-core dispatch Zhirun Yan
2022-09-08 2:09 ` Zhirun Yan [this message]
2022-09-08 2:09 ` [RFC, v1 2/6] graph: introduce graph clone API for other worker core Zhirun Yan
2022-09-08 2:09 ` [RFC, v1 3/6] graph: enable stream moving cross cores Zhirun Yan
2022-09-08 2:09 ` [RFC, v1 4/6] graph: enhance graph walk by cross-core dispatch Zhirun Yan
2022-09-08 5:27 ` [EXT] " Pavan Nikhilesh Bhagavatula
2022-09-15 1:52 ` Yan, Zhirun
2022-09-08 2:09 ` [RFC, v1 5/6] graph: add stats for corss-core dispatching Zhirun Yan
2022-09-08 2:09 ` [RFC, v1 6/6] examples: add l2fwd-graph Zhirun Yan
2022-09-20 9:33 ` [RFC, v1 0/6] graph enhancement for multi-core dispatch Jerin Jacob
2022-09-30 6:41 ` Yan, Zhirun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220908020959.1675953-2-zhirun.yan@intel.com \
--to=zhirun.yan@intel.com \
--cc=cunming.liang@intel.com \
--cc=dev@dpdk.org \
--cc=haiyue.wang@intel.com \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).