From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A3AC343676;
	Tue,  5 Dec 2023 10:27:19 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7361842D45;
	Tue,  5 Dec 2023 10:27:19 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id B4752402D2
 for <dev@dpdk.org>; Tue,  5 Dec 2023 10:27:17 +0100 (CET)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 3B4NxYXg022361 for <dev@dpdk.org>; Tue, 5 Dec 2023 01:27:16 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0220;
 bh=tXm7yBoEYkSZJzujY2QAmzkGaZrOdh5ujzQl5z5YZpY=;
 b=WD2OiK4WE3+ZbMwfrX0HH01esDuZ/GtFrqJO7xbkcLsaXyI36OUH5k1UVLymRuL1t/9J
 7918JngUKQrIz1aIg1geIsovYzWHFpftx1U8DH0EC65RMjTCkKYYeYYM3DIOMgL4Yfyz
 xLH8kUwR9NKROGTOrADCnl+bZh9cejc+5CRTyv5Vs2+imH9WspjSEYSz3KCknJdjnyJy
 4k/izUycdQbrXOQImYCKI2iVriomdSO0XHs9+1Hnz2Fr/EobEboH0wfew0zSuFA/AEp6
 yLAAML2JhrMV/zWQNOwWou5V1MplMaTUiJ5vJH3NhWxEfTD5jj+0qhm9lmXSGTVUbi3j cA== 
Received: from dc5-exch01.marvell.com ([199.233.59.181])
 by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3usrx3hfwp-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)
 for <dev@dpdk.org>; Tue, 05 Dec 2023 01:27:16 -0800
Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;
 Tue, 5 Dec 2023 01:27:15 -0800
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend
 Transport; Tue, 5 Dec 2023 01:27:14 -0800
Received: from localhost.localdomain (unknown [10.28.36.154])
 by maili.marvell.com (Postfix) with ESMTP id AEF6D3F7099;
 Tue,  5 Dec 2023 01:27:11 -0800 (PST)
From: Rakesh Kudurumalla <rkudurumalla@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>, Pavan Nikhilesh
 <pbhagavatula@marvell.com>
CC: <dev@dpdk.org>, <jerinj@marvell.com>, Rakesh Kudurumalla
 <rkudurumalla@marvell.com>
Subject: [PATCH v4 1/3] node: support to add next node to ethdev Rx node
Date: Tue, 5 Dec 2023 14:57:08 +0530
Message-ID: <20231205092710.1375795-1-rkudurumalla@marvell.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20231205074645.1370608-1-rkudurumalla@marvell.com>
References: <20231205074645.1370608-1-rkudurumalla@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: iX1HFKraunUijrcsLuEfkuqyf6fCVJ46
X-Proofpoint-ORIG-GUID: iX1HFKraunUijrcsLuEfkuqyf6fCVJ46
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26
 definitions=2023-12-05_04,2023-12-04_01,2023-05-22_02
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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>
---
v4: Resolve compilation issues

 lib/node/ethdev_ctrl.c      | 45 +++++++++++++++++++++++++++++++++++++
 lib/node/rte_node_eth_api.h | 19 ++++++++++++++++
 lib/node/version.map        |  1 +
 3 files changed, 65 insertions(+)

diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c
index d564b80e37..0faf4c19f2 100644
--- a/lib/node/ethdev_ctrl.c
+++ b/lib/node/ethdev_ctrl.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdlib.h>
+#include <errno.h>
 
 #include <rte_ethdev.h>
 #include <rte_graph.h>
@@ -129,3 +130,47 @@ 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;
+	uint32_t count;
+	uint16_t i = 0;
+
+	if (edge_name == NULL)
+		return rc;
+
+	count = rte_node_edge_get(id, NULL);
+
+	if (count == RTE_NODE_ID_INVALID)
+		return rc;
+
+	next_nodes = malloc(count);
+	if (next_nodes == NULL)
+		return -ENOMEM;
+
+	count = 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 exit;
+				}
+				elem = elem->next;
+			}
+		}
+		i++;
+	}
+exit:
+	free(next_nodes);
+	return rc;
+}
diff --git a/lib/node/rte_node_eth_api.h b/lib/node/rte_node_eth_api.h
index eaae50772d..b082a5bec1 100644
--- a/lib/node/rte_node_eth_api.h
+++ b/lib/node/rte_node_eth_api.h
@@ -23,6 +23,7 @@ extern "C" {
 #include <rte_compat.h>
 #include <rte_common.h>
 #include <rte_mempool.h>
+#include <rte_graph.h>
 
 /**
  * Port config for ethdev_rx and ethdev_tx node.
@@ -57,6 +58,24 @@ 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
+ *   RTE_EDGE_ID_INVALID if id is invalid
+ *   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..07abc3a79f 100644
--- a/lib/node/version.map
+++ b/lib/node/version.map
@@ -16,6 +16,7 @@ EXPERIMENTAL {
 	rte_node_ip6_route_add;
 
 	# added in 23.11
+	rte_node_ethdev_rx_next_update;
 	rte_node_ip4_reassembly_configure;
 	rte_node_udp4_dst_port_add;
 	rte_node_udp4_usr_node_add;
-- 
2.25.1