[RFC, v1 1/6] graph: introduce core affinity API into graph
Zhirun Yan
zhirun.yan at intel.com
Thu Sep 8 04:09:54 CEST 2022
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 at intel.com>
Signed-off-by: Cunming Liang <cunming.liang at intel.com>
Signed-off-by: Zhirun Yan <zhirun.yan at 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
More information about the dev
mailing list