[v6,1/4] graph: add API to override node process function

Message ID 20250103060612.2671836-2-nsaxena@marvell.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series add feature arc in rte_graph |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing fail build patch failure

Commit Message

Nitin Saxena Jan. 3, 2025, 6:06 a.m. UTC
New API used by feature arc library to override node's original
process() func.

Signed-off-by: Nitin Saxena <nsaxena@marvell.com>
---
 lib/graph/graph_private.h | 11 +++++++++++
 lib/graph/node.c          | 23 +++++++++++++++++++++++
 2 files changed, 34 insertions(+)
  

Patch

diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index da48d73587..ceff0c8f50 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -198,6 +198,17 @@  struct node_head *node_list_head_get(void);
  */
 struct node *node_from_name(const char *name);
 
+/**
+ * @internal
+ *
+ * Override process func of a node.
+ *
+ * @return
+ *   - 0: Success.
+ *   - <0: Error
+ */
+int node_override_process_func(rte_node_t id, rte_node_process_t process);
+
 /* Graph list functions */
 STAILQ_HEAD(graph_head, graph);
 
diff --git a/lib/graph/node.c b/lib/graph/node.c
index 63db629da8..82834a6634 100644
--- a/lib/graph/node.c
+++ b/lib/graph/node.c
@@ -419,3 +419,26 @@  rte_node_max_count(void)
 {
 	return node_id;
 }
+
+int
+node_override_process_func(rte_node_t id, rte_node_process_t process)
+{
+	struct node *node;
+
+	NODE_ID_CHECK(id);
+	graph_spinlock_lock();
+
+	STAILQ_FOREACH(node, &node_list, next) {
+		if (node->id == id) {
+			node->process = process;
+			graph_spinlock_unlock();
+			return 0;
+		}
+	}
+
+	graph_spinlock_unlock();
+
+	return 0;
+fail:
+	return -1;
+}