[RFC,v1,1/6] graph: introduce core affinity API into graph
Checks
Commit Message
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(+)
@@ -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. */
@@ -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)
{
@@ -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.
*
@@ -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: *;
};