> -----Original Message-----
> From: Nitin Saxena <nsax...@marvell.com>
> Sent: Wednesday, June 4, 2025 3:42 PM
> To: Jerin Jacob <jer...@marvell.com>; Kiran Kumar Kokkilagadda
> <kirankum...@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpu...@marvell.com>; Zhirun Yan <yanzhirun_...@163.com>; Robin
> Jarry <rja...@redhat.com>; Christophe Fontaine <cfont...@redhat.com>
> Cc: dev@dpdk.org; Nitin Saxena <nsaxen...@gmail.com>
> Subject: [PATCH v10 1/7] graph: add API to override node process function
> 
> New internal 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
> 813dd78b9d..579546e658 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
> 101981ec24..c8a1cd5586 100644
> --- a/lib/graph/node.c
> +++ b/lib/graph/node.c
> @@ -431,3 +431,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;
> +             }
> +     }
> +

Reaching here means, node is not found. Should you return error here, instead 
of 0.


> +     graph_spinlock_unlock();
> +
> +     return 0;
> +fail:
> +     return -1;
> +}
> --
> 2.43.0

Reply via email to