[v11,05/16] graph: introduce graph node core affinity API
Checks
Commit Message
Add lcore_id for node to hold affinity core id and impl
rte_graph_model_mcore_dispatch_lcore_affinity_set to set node affinity
with specific lcore.
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>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
lib/graph/graph_private.h | 2 +
lib/graph/meson.build | 1 +
lib/graph/node.c | 1 +
lib/graph/rte_graph_model_mcore_dispatch.c | 30 +++++++++++++++
lib/graph/rte_graph_model_mcore_dispatch.h | 45 ++++++++++++++++++++++
lib/graph/version.map | 1 +
6 files changed, 80 insertions(+)
create mode 100644 lib/graph/rte_graph_model_mcore_dispatch.c
create mode 100644 lib/graph/rte_graph_model_mcore_dispatch.h
@@ -51,6 +51,8 @@ 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 used for mcore dispatch model. */
rte_node_process_t process; /**< Node process function. */
rte_node_init_t init; /**< Node init function. */
rte_node_fini_t fini; /**< Node fini function. */
@@ -16,6 +16,7 @@ sources = files(
'graph_populate.c',
'graph_pcap.c',
'rte_graph_worker.c',
+ 'rte_graph_model_mcore_dispatch.c',
)
headers = files('rte_graph.h', 'rte_graph_worker.h')
@@ -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 */
new file mode 100644
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Intel Corporation
+ */
+
+#include "graph_private.h"
+#include "rte_graph_model_mcore_dispatch.h"
+
+int
+rte_graph_model_mcore_dispatch_node_lcore_affinity_set(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;
+}
new file mode 100644
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Intel Corporation
+ */
+
+#ifndef _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_
+#define _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_
+
+/**
+ * @file rte_graph_model_mcore_dispatch.h
+ *
+ * @warning
+ * @b EXPERIMENTAL:
+ * All functions in this file may be changed or removed without prior notice.
+ *
+ * These APIs allow to set core affinity with the node and only used for mcore
+ * dispatch model.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "rte_graph_worker_common.h"
+
+/**
+ * Set lcore affinity with the node used for mcore dispatch model.
+ *
+ * @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_graph_model_mcore_dispatch_node_lcore_affinity_set(const char *name,
+ unsigned int lcore_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_GRAPH_MODEL_MCORE_DISPATCH_H_ */
@@ -15,6 +15,7 @@ EXPERIMENTAL {
rte_graph_list_dump;
rte_graph_max_count;
rte_graph_model_is_valid;
+ rte_graph_model_mcore_dispatch_node_lcore_affinity_set;
rte_graph_node_get;
rte_graph_node_get_by_name;
rte_graph_obj_dump;