From patchwork Mon Jan 1 08:37:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 135632 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61153437EA; Mon, 1 Jan 2024 09:37:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D28D6402AD; Mon, 1 Jan 2024 09:37:34 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6C17C40270 for ; Mon, 1 Jan 2024 09:37:33 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4017Zx8h015872 for ; Mon, 1 Jan 2024 00:37:32 -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=ET3iPCMDD8s8JIikvrGjra4K/QR1CCvjUCmWZ/7atFM=; b=NH4 QA5xFBNvxof/IT+qdd8QKQ8xSgF6HkKcU5ed2xAK3c6n/whw03GAJKFYq73GXWHK OnJgASJ6OAanCcvadqWko0YMUlyJc0VSaG7BArMLEolWC0uf4x9A/+CvkKh6xdSe Q1YeeONXn1q9IXfbyfOt/ZpHAc/qeSJDBCzxrjp98XXq41SgjZ7OCjY1y1l0E6Nd atg9PGLYftpERtzfDSy/2/8zsTbkmdxbhvhwGzyzf9WlBlgHFAe3yqt8p625/3E6 lhcAjT+mmolB21mfPaiMZyXV6OZaZxu6CnWcBfhbSgjdQiD/RgMYLAc1FqoTX9f9 OL3vOx+9Mydezmfcv9A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vakkkuv3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 01 Jan 2024 00:37:32 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 1 Jan 2024 00:37:30 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 1 Jan 2024 00:37:30 -0800 Received: from localhost.localdomain (unknown [10.28.36.154]) by maili.marvell.com (Postfix) with ESMTP id 8B27E3F7093; Mon, 1 Jan 2024 00:37:28 -0800 (PST) From: Rakesh Kudurumalla To: Nithin Dabilpuram , Pavan Nikhilesh CC: , , Rakesh Kudurumalla Subject: [PATCH v8 1/3] node: support to add next node to ethdev Rx node Date: Mon, 1 Jan 2024 14:07:24 +0530 Message-ID: <20240101083726.875161-1-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231220094443.760544-1-rkudurumalla@marvell.com> References: <20231220094443.760544-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: e7-96ts5V57pEGTusYjuh2-_WYWTy6Et X-Proofpoint-GUID: e7-96ts5V57pEGTusYjuh2-_WYWTy6Et 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-09_02,2023-12-07_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 --- v8: Doc correction lib/node/ethdev_ctrl.c | 48 +++++++++++++++++++++++++++++++++++++ lib/node/rte_node_eth_api.h | 18 ++++++++++++++ lib/node/version.map | 3 +++ 3 files changed, 69 insertions(+) diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c index d564b80e37..a5fa8ee54b 100644 --- a/lib/node/ethdev_ctrl.c +++ b/lib/node/ethdev_ctrl.c @@ -2,6 +2,7 @@ * Copyright(C) 2020 Marvell International Ltd. */ +#include #include #include @@ -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; + uint32_t size; + uint16_t i = 0; + + 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 + 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 #include +#include #include /** @@ -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; }; From patchwork Mon Jan 1 08:37:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 135633 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9BD0B437EA; Mon, 1 Jan 2024 09:37:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1412402E3; Mon, 1 Jan 2024 09:37:37 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 362D1402E2 for ; Mon, 1 Jan 2024 09:37:36 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4017bSHR018291 for ; Mon, 1 Jan 2024 00:37:35 -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=yWO9Vr/wFsR5nOa/bmwEH/e2V/HKQ2q3B1mbPlZgXRA=; b=IJ1 tviognSSSaSMqW3sQcT/rvnRuygyMY6WzeyWIvf24UNK1S4TZkDz+IH5zWEgrE5t HKYeD/uw22QNRtQh3gJe3AXS+TvHv5yofzVYY3tCF/H1Fr7aKolQ6HtYDAnrDIm1 bk/33LQAeOV+PX/esU9JnOSaGePrvULUMqa4DbWi9OeaHMrL3LJJ1NSQQNmLalFY t+3EaMEzo1t1gcFMVtcHz2cevkWk7Q8VmyZYT8WTOIB0A3YV79uRlcCr8EIanUXv mw5vB6StWZIU/tRw6RcbxbkxtjmgROiUCr5T8aN1eYHsfm5Uj3uoNoExBNMn7c3K XawVS/LMYNwNx1kI96g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vakkkuv3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 01 Jan 2024 00:37:35 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 1 Jan 2024 00:37:33 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 1 Jan 2024 00:37:33 -0800 Received: from localhost.localdomain (unknown [10.28.36.154]) by maili.marvell.com (Postfix) with ESMTP id 957833F7067; Mon, 1 Jan 2024 00:37:31 -0800 (PST) From: Rakesh Kudurumalla To: Sunil Kumar Kori , Rakesh Kudurumalla CC: , , Subject: [PATCH v8 2/3] app/graph: add ethdev forward command Date: Mon, 1 Jan 2024 14:07:25 +0530 Message-ID: <20240101083726.875161-2-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240101083726.875161-1-rkudurumalla@marvell.com> References: <20231220094443.760544-1-rkudurumalla@marvell.com> <20240101083726.875161-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: cGZCldKT0lRi1pODiHvxeQ6jfQhtD9PL X-Proofpoint-GUID: cGZCldKT0lRi1pODiHvxeQ6jfQhtD9PL 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-09_02,2023-12-07_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Adds a txport to forward packet for every rxport Mapping will be used to forward packets to txport received on rxport Following commands are exposed: - ethdev forward " Signed-off-by: Rakesh Kudurumalla Acked-by: Sunil Kumar Kori --- app/graph/cli.c | 1 + app/graph/ethdev.c | 63 ++++++++++++++++++++++++++++++++++++++ app/graph/ethdev.h | 1 + app/graph/ethdev_priv.h | 8 +++++ doc/guides/tools/graph.rst | 4 +++ 5 files changed, 77 insertions(+) diff --git a/app/graph/cli.c b/app/graph/cli.c index 30b12312d6..76f5b8e670 100644 --- a/app/graph/cli.c +++ b/app/graph/cli.c @@ -32,6 +32,7 @@ cmdline_parse_ctx_t modules_ctx[] = { (cmdline_parse_inst_t *)ðdev_prom_mode_cmd_ctx, (cmdline_parse_inst_t *)ðdev_ip4_cmd_ctx, (cmdline_parse_inst_t *)ðdev_ip6_cmd_ctx, + (cmdline_parse_inst_t *)ðdev_forward_cmd_ctx, (cmdline_parse_inst_t *)ðdev_cmd_ctx, (cmdline_parse_inst_t *)ðdev_help_cmd_ctx, (cmdline_parse_inst_t *)ðdev_rx_cmd_ctx, diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c index c9b09168c1..bb502a6134 100644 --- a/app/graph/ethdev.c +++ b/app/graph/ethdev.c @@ -38,6 +38,9 @@ cmd_ethdev_ip4_addr_help[] = "ethdev ip4 addr add netmask tx_port_id = portid_tx; + rc = 0; + } else { + rc = -EINVAL; + } + + return rc; +} + +static void +cli_ethdev_forward(void *parsed_result, __rte_unused struct cmdline *cl, void *data __rte_unused) +{ + struct ethdev_fwd_cmd_tokens *res = parsed_result; + int rc = -EINVAL; + + rc = ethdev_forward_config(res->tx_dev, res->rx_dev); + if (rc < 0) + printf(MSG_CMD_FAIL, res->cmd); +} + +cmdline_parse_token_string_t ethdev_fwd_cfg = + TOKEN_STRING_INITIALIZER(struct ethdev_fwd_cmd_tokens, cmd, "ethdev"); +cmdline_parse_token_string_t ethdev_fwd_cmd = + TOKEN_STRING_INITIALIZER(struct ethdev_fwd_cmd_tokens, fwd, "forward"); +cmdline_parse_token_string_t ethdev_tx_device = + TOKEN_STRING_INITIALIZER(struct ethdev_fwd_cmd_tokens, tx_dev, NULL); +cmdline_parse_token_string_t ethdev_rx_device = + TOKEN_STRING_INITIALIZER(struct ethdev_fwd_cmd_tokens, rx_dev, NULL); + +cmdline_parse_inst_t ethdev_forward_cmd_ctx = { + .f = cli_ethdev_forward, + .data = NULL, + .help_str = cmd_ethdev_forward_help, + .tokens = { + (void *)ðdev_fwd_cfg, + (void *)ðdev_fwd_cmd, + (void *)ðdev_tx_device, + (void *)ðdev_rx_device, + NULL, + }, +}; diff --git a/app/graph/ethdev.h b/app/graph/ethdev.h index 94d3247a2c..836052046b 100644 --- a/app/graph/ethdev.h +++ b/app/graph/ethdev.h @@ -15,6 +15,7 @@ extern cmdline_parse_inst_t ethdev_mtu_cmd_ctx; extern cmdline_parse_inst_t ethdev_prom_mode_cmd_ctx; extern cmdline_parse_inst_t ethdev_ip4_cmd_ctx; extern cmdline_parse_inst_t ethdev_ip6_cmd_ctx; +extern cmdline_parse_inst_t ethdev_forward_cmd_ctx; extern cmdline_parse_inst_t ethdev_cmd_ctx; extern cmdline_parse_inst_t ethdev_help_cmd_ctx; diff --git a/app/graph/ethdev_priv.h b/app/graph/ethdev_priv.h index f231f3f3e1..af79553438 100644 --- a/app/graph/ethdev_priv.h +++ b/app/graph/ethdev_priv.h @@ -61,6 +61,13 @@ struct ethdev_ip6_cmd_tokens { cmdline_fixed_string_t mask; }; +struct ethdev_fwd_cmd_tokens { + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t fwd; + cmdline_fixed_string_t tx_dev; + cmdline_fixed_string_t rx_dev; +}; + struct ethdev_cmd_tokens { cmdline_fixed_string_t cmd; cmdline_fixed_string_t dev; @@ -104,6 +111,7 @@ struct ethdev_config { struct ethdev { TAILQ_ENTRY(ethdev) next; + uint16_t tx_port_id; struct ethdev_config config; struct ipv4_addr_config ip4_addr; struct ipv6_addr_config ip6_addr; diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst index 1855d12891..0aab41cbca 100644 --- a/doc/guides/tools/graph.rst +++ b/doc/guides/tools/graph.rst @@ -195,6 +195,9 @@ file to express the requested use case configuration. | ethdev mtu | | Command to configure MTU of DPDK| Yes | Yes | | | | port. | | | +--------------------------------------+-----------------------------------+---------+----------+ + | | ethdev forward | | Command to configure port | No | Yes | + | | | | forwarding of DPDK | | | + +--------------------------------------+-----------------------------------+---------+----------+ | | ethdev promiscuous | | Command to enable/disable | Yes | Yes | | | | | promiscuous mode on DPDK port. | | | +--------------------------------------+-----------------------------------+---------+----------+ @@ -297,6 +300,7 @@ Example: ``dpdk-graph`` is started with ``-h 10.28.35.207`` and ``-p 50000`` the ethdev rxq txq ethdev ip4 addr add netmask ethdev ip6 addr add netmask + ethdev forward ethdev promiscuous ethdev mtu ethdev stats From patchwork Mon Jan 1 08:37:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 135634 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A92CF437EA; Mon, 1 Jan 2024 09:37:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51809402E7; Mon, 1 Jan 2024 09:37:41 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 9E4DF402E7 for ; Mon, 1 Jan 2024 09:37:39 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4017PjQs031461 for ; Mon, 1 Jan 2024 00:37:39 -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=+pcf5a40aWcqsKGLVKd2OQfK8xGq3ECBp/GBWgiNmKI=; b=hHA PYR9PxuGSgzsfWpoI9hLDdiFBT4zhyCETRL75hRuh9SlAiWpjHrulqEq2zfMcV1k io7A/UF5sxPnOQ0MstuSV//Ae9O7kh3EKLj20PhapMLgYpweCRJ+ppm5UReljVr+ T9YR5WVK/2UwOMZKVahsTAgW4Gx1zgmxIs14PndxYXPTbAhVnH7sQ+x6X84QVbmF taJ7WOw4dQZx5I6djC++Bnq2bynU5YwCa3afBJPE+RgJ+hXkrMoOOWnctuA6ZZyH qHlYmGWezsZB67B3adn5CbNvqrr3TINHDr4K9A2ZNpwumuc5MP+YbDH1Of7DcIlc +sSH6widd2FmWSF0npw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vakkkuv3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 01 Jan 2024 00:37:38 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 1 Jan 2024 00:37:36 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 1 Jan 2024 00:37:36 -0800 Received: from localhost.localdomain (unknown [10.28.36.154]) by maili.marvell.com (Postfix) with ESMTP id 9E5363F7093; Mon, 1 Jan 2024 00:37:34 -0800 (PST) From: Rakesh Kudurumalla To: Sunil Kumar Kori , Rakesh Kudurumalla CC: , , Subject: [PATCH v8 3/3] app/graph: implement port forward usecase Date: Mon, 1 Jan 2024 14:07:26 +0530 Message-ID: <20240101083726.875161-3-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240101083726.875161-1-rkudurumalla@marvell.com> References: <20231220094443.760544-1-rkudurumalla@marvell.com> <20240101083726.875161-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: VTbVvbx7X027vXZTHusMzgiZRVGmjjTA X-Proofpoint-GUID: VTbVvbx7X027vXZTHusMzgiZRVGmjjTA 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-09_02,2023-12-07_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added portforward usecase.In this usecase packets received Rx port is forwarded to respective Tx port. Signed-off-by: Rakesh Kudurumalla Acked-by: Sunil Kumar Kori --- app/graph/ethdev.c | 13 ++ app/graph/ethdev.h | 1 + app/graph/examples/l2fwd.cli | 41 +++++ app/graph/examples/l2fwd_pcap.cli | 37 +++++ app/graph/graph.c | 8 +- app/graph/l2fwd.c | 152 +++++++++++++++++++ app/graph/l2fwd.h | 11 ++ app/graph/meson.build | 1 + app/graph/module_api.h | 1 + doc/guides/tools/graph.rst | 21 +++ doc/guides/tools/img/graph-usecase-l2fwd.svg | 92 +++++++++++ 11 files changed, 377 insertions(+), 1 deletion(-) create mode 100644 app/graph/examples/l2fwd.cli create mode 100644 app/graph/examples/l2fwd_pcap.cli create mode 100644 app/graph/l2fwd.c create mode 100644 app/graph/l2fwd.h create mode 100644 doc/guides/tools/img/graph-usecase-l2fwd.svg diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c index bb502a6134..a622275338 100644 --- a/app/graph/ethdev.c +++ b/app/graph/ethdev.c @@ -76,6 +76,19 @@ ethdev_port_by_id(uint16_t port_id) return NULL; } +int16_t +ethdev_txport_by_rxport_get(uint16_t portid_rx) +{ + int portid = -EINVAL; + struct ethdev *port; + + port = ethdev_port_by_id(portid_rx); + if (port) + portid = port->tx_port_id; + + return portid; +} + void * ethdev_mempool_list_by_portid(uint16_t portid) { diff --git a/app/graph/ethdev.h b/app/graph/ethdev.h index 836052046b..ec457b89bf 100644 --- a/app/graph/ethdev.h +++ b/app/graph/ethdev.h @@ -36,6 +36,7 @@ void ethdev_stop(void); void *ethdev_mempool_list_by_portid(uint16_t portid); int16_t ethdev_portid_by_ip4(uint32_t ip, uint32_t mask); int16_t ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask); +int16_t ethdev_txport_by_rxport_get(uint16_t portid_rx); void ethdev_list_clean(void); #endif diff --git a/app/graph/examples/l2fwd.cli b/app/graph/examples/l2fwd.cli new file mode 100644 index 0000000000..861e83bd70 --- /dev/null +++ b/app/graph/examples/l2fwd.cli @@ -0,0 +1,41 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2023 Marvell. + +; +; Graph configuration for given usecase +; +graph l2fwd coremask 0xff bsz 32 tmo 10 model default pcap_enable 1 num_pcap_pkts 100000 pcap_file /tmp/output.pcap + +; +; Mempools to be attached with ethdev +; +mempool mempool0 size 8192 buffers 4000 cache 256 numa 0 + +; +; DPDK devices and configuration. +; +; Note: Customize the parameters below to match your setup. +; +ethdev 0002:01:00.1 rxq 1 txq 8 mempool0 +ethdev 0002:01:00.4 rxq 1 txq 8 mempool0 +ethdev 0002:01:00.6 rxq 1 txq 8 mempool0 +ethdev 0002:02:00.0 rxq 1 txq 8 mempool0 + +; +; Rx/Tx port mapping +; +ethdev forward 0002:01:00.4 0002:02:00.0 +ethdev forward 0002:01:00.1 0002:01:00.6 + +; +; Port-Queue-Core mapping for ethdev_rx node +; +ethdev_rx map port 0002:02:00.0 queue 0 core 1 +ethdev_rx map port 0002:01:00.6 queue 0 core 2 + +; +; Graph start command to create graph. +; +; Note: No more command should come after this. +; +graph start diff --git a/app/graph/examples/l2fwd_pcap.cli b/app/graph/examples/l2fwd_pcap.cli new file mode 100644 index 0000000000..67308b3b72 --- /dev/null +++ b/app/graph/examples/l2fwd_pcap.cli @@ -0,0 +1,37 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2023 Marvell. + +; +; Graph configuration for given usecase +; +graph l2fwd coremask 0xff bsz 32 tmo 10 model default pcap_enable 1 num_pcap_pkts 100000 pcap_file /tmp/output.pcap + +; +; Mempools to be attached with ethdev +; +mempool mempool0 size 8192 buffers 4000 cache 256 numa 0 + +; +; DPDK devices and configuration. +; +; Note: Customize the parameters below to match your setup. +; +ethdev net_pcap0 rxq 1 txq 8 mempool0 +ethdev net_pcap1 rxq 1 txq 8 mempool0 + +; +; Rx/Tx port mapping +; +ethdev forward net_pcap1 net_pcap0 + +; +; Port-Queue-Core mapping for ethdev_rx node +; +ethdev_rx map port net_pcap0 queue 0 core 1 + +; +; Graph start command to create graph. +; +; Note: No more command should come after this. +; +graph start diff --git a/app/graph/graph.c b/app/graph/graph.c index a65723a196..4e0441f1a7 100644 --- a/app/graph/graph.c +++ b/app/graph/graph.c @@ -24,7 +24,7 @@ cmd_graph_help[] = "graph bsz tmo coremask " "model pcap_enable <0 | 1> num_pcap_pkts " "pcap_file "; -static const char * const supported_usecases[] = {"l3fwd"}; +static const char * const supported_usecases[] = {"l3fwd", "l2fwd"}; struct graph_config graph_config; bool graph_started; @@ -273,6 +273,12 @@ cli_graph_start(__rte_unused void *parsed_result, __rte_unused struct cmdline *c break; } } + if (!strcmp(graph_config.usecases[i].name, "l2fwd")) { + if (graph_config.usecases[i].enabled) { + rc = usecase_l2fwd_configure(conf, nb_conf, nb_graphs); + break; + } + } } if (!rc) diff --git a/app/graph/l2fwd.c b/app/graph/l2fwd.c new file mode 100644 index 0000000000..20894b64fe --- /dev/null +++ b/app/graph/l2fwd.c @@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Marvell. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "module_api.h" + +static int +l2fwd_pattern_configure(void) +{ + struct rte_graph_param graph_conf; + const char **node_patterns; + uint64_t pcap_pkts_count; + struct lcore_conf *qconf; + uint16_t nb_patterns; + uint8_t pcap_ena; + char *pcap_file; + int lcore_id; + + nb_patterns = 0; + node_patterns = malloc((ETHDEV_RX_QUEUE_PER_LCORE_MAX + nb_patterns) * + sizeof(*node_patterns)); + if (!node_patterns) + return -ENOMEM; + + memset(&graph_conf, 0, sizeof(graph_conf)); + graph_conf.node_patterns = node_patterns; + + /* Pcap config */ + graph_pcap_config_get(&pcap_ena, &pcap_pkts_count, &pcap_file); + graph_conf.pcap_enable = pcap_ena; + graph_conf.num_pkt_to_capture = pcap_pkts_count; + graph_conf.pcap_filename = strdup(pcap_file); + + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { + rte_graph_t graph_id; + rte_edge_t i; + + if (rte_lcore_is_enabled(lcore_id) == 0) + continue; + + qconf = &lcore_conf[lcore_id]; + + /* Skip graph creation if no source exists */ + if (!qconf->n_rx_queue) + continue; + + /* Add rx node patterns of this lcore */ + for (i = 0; i < qconf->n_rx_queue; i++) { + graph_conf.node_patterns[nb_patterns + i] = + qconf->rx_queue_list[i].node_name; + } + + graph_conf.nb_node_patterns = nb_patterns + i; + graph_conf.socket_id = rte_lcore_to_socket_id(lcore_id); + + snprintf(qconf->name, sizeof(qconf->name), "worker_%u", + lcore_id); + + graph_id = rte_graph_create(qconf->name, &graph_conf); + if (graph_id == RTE_GRAPH_ID_INVALID) + rte_exit(EXIT_FAILURE, + "rte_graph_create(): graph_id invalid" + " for lcore %u\n", lcore_id); + + qconf->graph_id = graph_id; + qconf->graph = rte_graph_lookup(qconf->name); + /* >8 End of graph initialization. */ + if (!qconf->graph) + rte_exit(EXIT_FAILURE, + "rte_graph_lookup(): graph %s not found\n", + qconf->name); + } + + /* Launch per-lcore init on every worker lcore */ + rte_eal_mp_remote_launch(graph_walk_start, NULL, SKIP_MAIN); + + /* Accumulate and print stats on main until exit */ + if (rte_graph_has_stats_feature() && app_graph_stats_enabled()) + graph_stats_print(); + + return 0; +} + +static int +ethdev_rx_to_tx_node_link(uint32_t lcore_id) +{ + char name[RTE_NODE_NAMESIZE]; + const char *next_node = name; + struct lcore_conf *qconf; + uint16_t queue, port_id; + rte_node_t rx_id; + int16_t txport; + int rc = 0; + + qconf = &lcore_conf[lcore_id]; + + for (queue = 0; queue < qconf->n_rx_queue; ++queue) { + port_id = qconf->rx_queue_list[queue].port_id; + txport = ethdev_txport_by_rxport_get(port_id); + if (txport >= 0) { + rx_id = rte_node_from_name(qconf->rx_queue_list[queue].node_name); + snprintf(name, sizeof(name), "ethdev_tx-%u", txport); + rte_node_edge_update(rx_id, RTE_EDGE_ID_INVALID, &next_node, 1); + rc = rte_node_ethdev_rx_next_update(rx_id, name); + if (rc) + goto exit; + } else { + rc = -EINVAL; + goto exit; + } + } +exit: + return rc; +} + + +int +usecase_l2fwd_configure(struct rte_node_ethdev_config *conf, uint16_t nb_confs, uint16_t nb_graphs) +{ + uint32_t lcore_id; + int rc; + + rc = rte_node_eth_config(conf, nb_confs, nb_graphs); + if (rc) + rte_exit(EXIT_FAILURE, "rte_node_eth_config: err=%d\n", rc); + + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { + rc = ethdev_rx_to_tx_node_link(lcore_id); + if (rc) + rte_exit(EXIT_FAILURE, "rte_node_eth_config: err=%d\n", rc); + } + + rc = l2fwd_pattern_configure(); + if (rc) + rte_exit(EXIT_FAILURE, "l2fwd_pattern_failure: err=%d\n", rc); + + return rc; +} diff --git a/app/graph/l2fwd.h b/app/graph/l2fwd.h new file mode 100644 index 0000000000..3486ce52b2 --- /dev/null +++ b/app/graph/l2fwd.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Marvell. + */ + +#ifndef APP_GRAPH_L2FWD_H +#define APP_GRAPH_L2FWD_H + +int usecase_l2fwd_configure(struct rte_node_ethdev_config *conf, uint16_t nb_conf, + uint16_t nb_graphs); + +#endif diff --git a/app/graph/meson.build b/app/graph/meson.build index 5b0f966d99..edd6b17ebc 100644 --- a/app/graph/meson.build +++ b/app/graph/meson.build @@ -17,6 +17,7 @@ sources = files( 'graph.c', 'ip4_route.c', 'ip6_route.c', + 'l2fwd.c', 'l3fwd.c', 'main.c', 'mempool.c', diff --git a/app/graph/module_api.h b/app/graph/module_api.h index 7193e0b616..c80eeb704c 100644 --- a/app/graph/module_api.h +++ b/app/graph/module_api.h @@ -13,6 +13,7 @@ #include "ethdev.h" #include "ethdev_rx.h" #include "graph.h" +#include "l2fwd.h" #include "l3fwd.h" #include "mempool.h" #include "neigh.h" diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst index 0aab41cbca..5308967b6b 100644 --- a/doc/guides/tools/graph.rst +++ b/doc/guides/tools/graph.rst @@ -77,6 +77,13 @@ This use case is supported for both H/W and PCAP vdev network devices. To demonstrate, corresponding ``.cli`` files are available at ``app/graph/examples/`` named as ``l3fwd.cli`` and ``l3fwd_pcap.cli`` respectively. +l2fwd +~~~~~ + +This use case is supported for both H/W and PCAP vdev network devices. +To demonstrate, corresponding ``.cli`` files are available at ``app/graph/examples/`` +named as ``l2fwd.cli`` and ``l2fwd_pcap.cli`` respectively. + Example Commands ^^^^^^^^^^^^^^^^ For H/W devices @@ -86,6 +93,9 @@ For H/W devices ./dpdk-graph -c 0xff -a 0002:02:00.0 -a 0002:03:00.0 -- -s /app/graph/examples/l3fwd.cli + ./dpdk-graph -c 0xff -a 0002:02:00.0 -a 0002:03:00.0 -- + -s /app/graph/examples/l2fwd.cli + For net_pcapX devices .. code-block:: console @@ -94,6 +104,10 @@ For net_pcapX devices --vdev=net_pcap1,rx_pcap=in_net_pcap1.pcap,tx_pcap=out_net_pcap0.pcap -- -s /app/graph/examples/l3fwd_pcap.cli + ./dpdk-graph -c 0xff --vdev=net_pcap0,rx_pcap=in_net_pcap0.pcap,tx_pcap=out_net_pcap1.pcap + --vdev=net_pcap1,rx_pcap=in_net_pcap1.pcap,tx_pcap=out_net_pcap0.pcap + -- -s /app/graph/examples/l2fwd_pcap.cli + Verifying traffic ^^^^^^^^^^^^^^^^^ @@ -325,3 +339,10 @@ l3fwd .. _figure_l3fwd_graph: .. figure:: img/graph-usecase-l3fwd.* + +l2fwd +~~~~~ + +.. _figure_l2fwd_graph: + +.. figure:: img/graph-usecase-l2fwd.* diff --git a/doc/guides/tools/img/graph-usecase-l2fwd.svg b/doc/guides/tools/img/graph-usecase-l2fwd.svg new file mode 100644 index 0000000000..15763d8fa5 --- /dev/null +++ b/doc/guides/tools/img/graph-usecase-l2fwd.svg @@ -0,0 +1,92 @@ + + + + + + + + + + +dpdk_app_graph_l2fwd_nodes_flow + + + +ingress_port + +ingress_port + + + +ethdev_rx + +ethdev_rx + + + +ingress_port->ethdev_rx + + +ingress packet + + + +ethdev_tx + +ethdev_tx + + + +ethdev_rx->ethdev_tx + + + + + +pkt_drop + +pkt_drop + + + +ethdev_tx->pkt_drop + + + + + +egress_port + +egress_port + + + +ethdev_tx->egress_port + + +egress packet + + +