[v10,1/3] node: support to add next node to ethdev Rx node

Message ID 20240102073038.886704-1-rkudurumalla@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v10,1/3] node: support to add next node to ethdev Rx node |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Rakesh Kudurumalla Jan. 2, 2024, 7:30 a.m. UTC
  By default all packets received on ethdev_rx node
is forwarded to pkt_cls node.This patch provides
library support to add a new node as next node to
ethdev_rx node and forward packet to new node from
rx node.

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
v10: Code style

 lib/node/ethdev_ctrl.c      | 48 +++++++++++++++++++++++++++++++++++++
 lib/node/rte_node_eth_api.h | 18 ++++++++++++++
 lib/node/version.map        |  3 +++
 3 files changed, 69 insertions(+)
  

Comments

Sunil Kumar Kori Jan. 2, 2024, 9:20 a.m. UTC | #1
> -----Original Message-----
> From: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Sent: Tuesday, January 2, 2024 1:01 PM
> To: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Pavan
> Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Subject: [EXT] [PATCH v10 1/3] node: support to add next node to ethdev Rx
> node
> 
> External Email
> 
> ----------------------------------------------------------------------
> By default all packets received on ethdev_rx node is forwarded to pkt_cls
> node.This patch provides library support to add a new node as next node to
> ethdev_rx node and forward packet to new node from rx node.
> 
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> ---
> v10: Code style
> 
>  lib/node/ethdev_ctrl.c      | 48
> +++++++++++++++++++++++++++++++++++++
>  lib/node/rte_node_eth_api.h | 18 ++++++++++++++
>  lib/node/version.map        |  3 +++
>  3 files changed, 69 insertions(+)
> 

Acked-by: Sunil Kumar Kori <skori@marvell.com>

> 2.25.1
  
Thomas Monjalon Feb. 18, 2024, 11:15 p.m. UTC | #2
02/01/2024 08:30, Rakesh Kudurumalla:
> +/**
> + * Update ethdev rx next node.
> + *
> + * @param id
> + *   Node id whose edge is to be updated.
> + * @param edge_name
> + *   Name of the next node.
> + *
> + * @return
> + *   ENINVAL: Either of input parameters are invalid

typo: EINVAL

> + *   ENOMEM: If memory allocation failed
> + *   0 on successful initialization.

The errors are rendered on the same line by Doxygen.
Fixed by making it a list.
  
Thomas Monjalon Feb. 18, 2024, 11:17 p.m. UTC | #3
02/01/2024 08:30, Rakesh Kudurumalla:
> By default all packets received on ethdev_rx node
> is forwarded to pkt_cls node.This patch provides
> library support to add a new node as next node to
> ethdev_rx node and forward packet to new node from
> rx node.
> 
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>

Series applied with few doxygen fixes.
  

Patch

diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c
index d564b80e37..cd52e8be08 100644
--- a/lib/node/ethdev_ctrl.c
+++ b/lib/node/ethdev_ctrl.c
@@ -2,6 +2,7 @@ 
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
+#include <errno.h>
 #include <stdlib.h>
 
 #include <rte_ethdev.h>
@@ -129,3 +130,50 @@  rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs,
 	ctrl.nb_graphs = nb_graphs;
 	return 0;
 }
+
+int
+rte_node_ethdev_rx_next_update(rte_node_t id, const char *edge_name)
+{
+	struct ethdev_rx_node_main *data;
+	ethdev_rx_node_elem_t *elem;
+	char **next_nodes;
+	int rc = -EINVAL;
+	uint16_t i = 0;
+	uint32_t size;
+
+	if (edge_name == NULL)
+		goto exit;
+
+	size = rte_node_edge_get(id, NULL);
+
+	if (size == RTE_NODE_ID_INVALID)
+		goto exit;
+
+	next_nodes = calloc((size / sizeof(char *)) + 1, sizeof(*next_nodes));
+	if (next_nodes == NULL) {
+		rc = -ENOMEM;
+		goto exit;
+	}
+
+	size = rte_node_edge_get(id, next_nodes);
+
+	while (next_nodes[i] != NULL) {
+		if (strcmp(edge_name, next_nodes[i]) == 0) {
+			data = ethdev_rx_get_node_data_get();
+			elem = data->head;
+			while (elem->next != data->head) {
+				if (elem->nid == id) {
+					elem->ctx.cls_next = i;
+					rc = 0;
+					goto found;
+				}
+				elem = elem->next;
+			}
+		}
+		i++;
+	}
+found:
+	free(next_nodes);
+exit:
+	return rc;
+}
diff --git a/lib/node/rte_node_eth_api.h b/lib/node/rte_node_eth_api.h
index eaae50772d..d2f705e908 100644
--- a/lib/node/rte_node_eth_api.h
+++ b/lib/node/rte_node_eth_api.h
@@ -22,6 +22,7 @@  extern "C" {
 
 #include <rte_compat.h>
 #include <rte_common.h>
+#include <rte_graph.h>
 #include <rte_mempool.h>
 
 /**
@@ -57,6 +58,23 @@  struct rte_node_ethdev_config {
  */
 int rte_node_eth_config(struct rte_node_ethdev_config *cfg,
 			uint16_t cnt, uint16_t nb_graphs);
+
+/**
+ * Update ethdev rx next node.
+ *
+ * @param id
+ *   Node id whose edge is to be updated.
+ * @param edge_name
+ *   Name of the next node.
+ *
+ * @return
+ *   ENINVAL: Either of input parameters are invalid
+ *   ENOMEM: If memory allocation failed
+ *   0 on successful initialization.
+ */
+__rte_experimental
+int rte_node_ethdev_rx_next_update(rte_node_t id, const char *edge_name);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/node/version.map b/lib/node/version.map
index 99ffcdd414..6bdb944c4c 100644
--- a/lib/node/version.map
+++ b/lib/node/version.map
@@ -19,4 +19,7 @@  EXPERIMENTAL {
 	rte_node_ip4_reassembly_configure;
 	rte_node_udp4_dst_port_add;
 	rte_node_udp4_usr_node_add;
+
+	# added in 24.03
+	rte_node_ethdev_rx_next_update;
 };