From patchwork Wed May 31 11:37:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Prakash Shukla X-Patchwork-Id: 127785 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 F07CC42BF4; Wed, 31 May 2023 13:38:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F00742B8C; Wed, 31 May 2023 13:38:08 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 7AE6C42D17 for ; Wed, 31 May 2023 13:38:04 +0200 (CEST) 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 34V7r8T7020051 for ; Wed, 31 May 2023 04:38:03 -0700 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=6xECVM/3cI7elPTvcQuc98NmsAtboe0YDSxbW0+Wsb0=; b=Mo/aZ6vEORT8NutxtSux04dha+w5sD4Bns+VwjhVzi3hDXcZ/WgkBmm3Blg3XJ5dCzw3 hKB2/6seipbxbXbb4QNJrsBNInlm8Va8Y6oIdbmVj69T6cclpjvHXFE8Xshyzd56G3dM gxVN7YgDK8MEpX5YYqu99IRdLcvbYaERVBU4Pm1cNE06jEsXWPiy6+bY5tX1nVtujcdZ KVRpQwy1YtG8/xJAzOmY2/SzU1KZiMKlJs0Yy5mll/DU8Llw5np9e+lnA47YrDgvvaY0 ZFhf2/zv1MOUwyWQtxzWY5QSdZtgzOX2nRD7gCSKfw7ogRS4qB8UvMnLUX6JGJFGlxm6 /Q== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qwsb8tude-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 31 May 2023 04:38:03 -0700 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; Wed, 31 May 2023 04:38:01 -0700 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; Wed, 31 May 2023 04:38:00 -0700 Received: from localhost.localdomain (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id E9FBE3F707E; Wed, 31 May 2023 04:37:58 -0700 (PDT) From: Amit Prakash Shukla To: Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram CC: , , Amit Prakash Shukla Subject: [PATCH v3 3/3] examples/l3fwd-graph: add IPv6 lookup and rewrite support Date: Wed, 31 May 2023 17:07:43 +0530 Message-ID: <20230531113743.1929627-3-amitprakashs@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531113743.1929627-1-amitprakashs@marvell.com> References: <20230518155654.1756576-1-amitprakashs@marvell.com> <20230531113743.1929627-1-amitprakashs@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dmjWgzDXzwTjLXvhhDIxBVBBAM8Tw52l X-Proofpoint-GUID: dmjWgzDXzwTjLXvhhDIxBVBBAM8Tw52l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-31_07,2023-05-31_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 From: Sunil Kumar Kori Similar to ipv4, to support IPv6 lookup and rewrite node routes and rewrite data needs to be added. Patch adds routes for ipv6 to validate ip6_lookup node and rewrite data to validate ip6_rewrite node. Signed-off-by: Sunil Kumar Kori Signed-off-by: Amit Prakash Shukla Acked-by: Nithin Dabilpuram --- v2: - Performance related changes v3: - Removing redundant dynamic variable doc/guides/sample_app_ug/l3_forward_graph.rst | 40 ++++++---- examples/l3fwd-graph/main.c | 77 ++++++++++++++++++- 2 files changed, 98 insertions(+), 19 deletions(-) diff --git a/doc/guides/sample_app_ug/l3_forward_graph.rst b/doc/guides/sample_app_ug/l3_forward_graph.rst index 585ac8c898..23f86e4785 100644 --- a/doc/guides/sample_app_ug/l3_forward_graph.rst +++ b/doc/guides/sample_app_ug/l3_forward_graph.rst @@ -12,7 +12,8 @@ Overview -------- The application demonstrates the use of the graph framework and graph nodes -``ethdev_rx``, ``ip4_lookup``, ``ip4_rewrite``, ``ethdev_tx`` and ``pkt_drop`` in DPDK to +``ethdev_rx``, ``pkt_cls``, ``ip4_lookup``/``ip6_lookup``, +``ip4_rewrite``/``ip6_rewrite``, ``ethdev_tx`` and ``pkt_drop`` in DPDK to implement packet forwarding. The initialization is very similar to those of the :doc:`l3_forward`. @@ -24,13 +25,15 @@ TTL update and finally Tx is implemented inside graph nodes. These nodes are interconnected in graph framework. Application main loop needs to walk over graph using ``rte_graph_walk()`` with graph objects created one per worker lcore. -The lookup method is as per implementation of ``ip4_lookup`` graph node. +The lookup method is as per implementation of ``ip4_lookup``/``ip6_lookup`` graph node. The ID of the output interface for the input packet is the next hop returned by the LPM lookup. The set of LPM rules used by the application is statically -configured and provided to ``ip4_lookup`` graph node and ``ip4_rewrite`` graph node -using node control API ``rte_node_ip4_route_add()`` and ``rte_node_ip4_rewrite_add()``. +configured and provided to ``ip4_lookup``/``ip6_lookup`` graph node and +``ip4_rewrite``/``ip6_rewrite`` graph node using node control API +``rte_node_ip4_route_add()``/``rte_node_ip6_route_add`` and +``rte_node_ip4_rewrite_add()``/``rte_node_ip6_rewrite_add``. -In the sample application, only IPv4 forwarding is supported as of now. +In the sample application, IPv4 and IPv6 forwarding is supported. Compiling the Application ------------------------- @@ -149,8 +152,8 @@ lead to the clone of ``ethdev_rx`` and ``ethdev_tx`` nodes as ``ethdev_rx-X-Y`` In case of ``ethdev_tx-X`` nodes, tx queue id assigned per instance of the node is same as graph id. -These cloned nodes along with existing static nodes such as ``ip4_lookup`` and -``ip4_rewrite`` will be used in graph creation to associate node's to lcore +These cloned nodes along with existing static nodes such as ``ip4_lookup``/``ip6_lookup`` +and ``ip4_rewrite``/``ip6_rewrite`` will be used in graph creation to associate node's to lcore specific graph object. .. literalinclude:: ../../../examples/l3fwd-graph/main.c @@ -186,20 +189,21 @@ Forwarding data(Route, Next-Hop) addition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Once graph objects are created, node specific info like routes and rewrite -headers will be provided run-time using ``rte_node_ip4_route_add()`` and -``rte_node_ip4_rewrite_add()`` API. +headers will be provided run-time using ``rte_node_ip4_route_add()``/ +``rte_node_ip6_route_add`` and ``rte_node_ip4_rewrite_add()``/``rte_node_ip6_rewrite_add`` +API. .. note:: - Since currently ``ip4_lookup`` and ``ip4_rewrite`` nodes don't support - lock-less mechanisms(RCU, etc) to add run-time forwarding data like route and - rewrite data, forwarding data is added before packet processing loop is - launched on worker lcore. + Since currently ``ip4_lookup``/``ip6_lookup`` and ``ip4_rewrite``/``ip6_rewrite`` + nodes don't support lock-less mechanisms(RCU, etc) to add run-time forwarding + data like route and rewrite data, forwarding data is added before packet + processing loop is launched on worker lcore. .. literalinclude:: ../../../examples/l3fwd-graph/main.c :language: c - :start-after: Add route to ip4 graph infra. 8< - :end-before: >8 End of adding route to ip4 graph infa. + :start-after: Add routes and rewrite data to graph infra. 8< + :end-before: >8 End of adding routes and rewrite data to graph infa. :dedent: 1 Packet Forwarding using Graph Walk @@ -215,8 +219,10 @@ specific graph object that was already created. rte_graph_walk() will walk over all the sources nodes i.e ``ethdev_rx-X-Y`` associated with a given graph and Rx the available packets and enqueue them - to the following node ``ip4_lookup`` which then will enqueue them to ``ip4_rewrite`` - node if LPM lookup succeeds. ``ip4_rewrite`` node then will update Ethernet header + to the following node ``pkt_cls`` which based on the packet type will enqueue + them to ``ip4_lookup``/``ip6_lookup`` which then will enqueue them to + ``ip4_rewrite``/``ip6_rewrite`` node if LPM lookup succeeds. + ``ip4_rewrite``/``ip6_rewrite`` node then will update Ethernet header as per next-hop data and transmit the packet via port 'Z' by enqueuing to ``ethdev_tx-Z`` node instance in its graph object. diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c index 5feeab4f0f..0c82e24513 100644 --- a/examples/l3fwd-graph/main.c +++ b/examples/l3fwd-graph/main.c @@ -27,9 +27,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -142,6 +144,12 @@ struct ipv4_l3fwd_lpm_route { uint8_t if_out; }; +struct ipv6_l3fwd_lpm_route { + uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE]; + uint8_t depth; + uint8_t if_out; +}; + #define IPV4_L3FWD_LPM_NUM_ROUTES \ (sizeof(ipv4_l3fwd_lpm_route_array) / \ sizeof(ipv4_l3fwd_lpm_route_array[0])) @@ -153,6 +161,28 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { {RTE_IPV4(198, 18, 6, 0), 24, 6}, {RTE_IPV4(198, 18, 7, 0), 24, 7}, }; +#define IPV6_L3FWD_LPM_NUM_ROUTES \ + (sizeof(ipv6_l3fwd_lpm_route_array) / \ + sizeof(ipv6_l3fwd_lpm_route_array[0])) +static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00}, 48, 0}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01}, 48, 1}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02}, 48, 2}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03}, 48, 3}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04}, 48, 4}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05}, 48, 5}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06}, 48, 6}, + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02}, 48, 7}, +}; + static int check_lcore_params(void) { @@ -1128,7 +1158,7 @@ main(int argc, char **argv) memset(&rewrite_data, 0, sizeof(rewrite_data)); rewrite_len = sizeof(rewrite_data); - /* Add route to ip4 graph infra. 8< */ + /* Add routes and rewrite data to graph infra. 8< */ for (i = 0; i < IPV4_L3FWD_LPM_NUM_ROUTES; i++) { char route_str[INET6_ADDRSTRLEN * 4]; char abuf[INET6_ADDRSTRLEN]; @@ -1172,7 +1202,50 @@ main(int argc, char **argv) RTE_LOG(INFO, L3FWD_GRAPH, "Added route %s, next_hop %u\n", route_str, i); } - /* >8 End of adding route to ip4 graph infa. */ + + for (i = 0; i < IPV6_L3FWD_LPM_NUM_ROUTES; i++) { + char route_str[INET6_ADDRSTRLEN * 4]; + char abuf[INET6_ADDRSTRLEN]; + struct in6_addr in6; + uint32_t dst_port; + + /* Skip unused ports */ + if ((1 << ipv6_l3fwd_lpm_route_array[i].if_out & + enabled_port_mask) == 0) + continue; + + dst_port = ipv6_l3fwd_lpm_route_array[i].if_out; + + memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_LPM6_IPV6_ADDR_SIZE); + snprintf(route_str, sizeof(route_str), "%s / %d (%d)", + inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)), + ipv6_l3fwd_lpm_route_array[i].depth, + ipv6_l3fwd_lpm_route_array[i].if_out); + + /* Use route index 'i' as next hop id */ + ret = rte_node_ip6_route_add(ipv6_l3fwd_lpm_route_array[i].ip, + ipv6_l3fwd_lpm_route_array[i].depth, i, + RTE_NODE_IP6_LOOKUP_NEXT_REWRITE); + + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Unable to add ip6 route %s to graph\n", + route_str); + + memcpy(rewrite_data, val_eth + dst_port, rewrite_len); + + /* Add next hop rewrite data for id 'i' */ + ret = rte_node_ip6_rewrite_add(i, rewrite_data, + rewrite_len, dst_port); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Unable to add next hop %u for " + "route %s\n", i, route_str); + + RTE_LOG(INFO, L3FWD_GRAPH, "Added route %s, next_hop %u\n", + route_str, i); + } + /* >8 End of adding routes and rewrite data to graph infa. */ /* Launch per-lcore init on every worker lcore */ rte_eal_mp_remote_launch(graph_main_loop, NULL, SKIP_MAIN);