New API used by feature arc library to override node's original
process() func.

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

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;
+}
-- 
2.43.0

Reply via email to