From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30BD042BF1; Mon, 5 Jun 2023 18:33:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F09264021F; Mon, 5 Jun 2023 18:33:08 +0200 (CEST) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by mails.dpdk.org (Postfix) with ESMTP id B1E034003C for ; Mon, 5 Jun 2023 18:33:07 +0200 (CEST) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-3f83114e0c6so56025331cf.0 for ; Mon, 05 Jun 2023 09:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685982787; x=1688574787; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SemjxnLFVDoru2Fhk3H23Xrt6VhRkLbnIFcIlJryluA=; b=kTROmukm7jTfut1Xnm3LZrrRZwkhgZ/kvjVhjaaKaH0cbn6BTGi5c+2pj9/CeqwLC0 qmGL8sG14s+lyKg4P56GEyjdL3m7V7dEnFJgwsSLGAttUB4Po7/D81KyXXKjorV05RNm z4UoKDO0CsMzAH3WashSi6VFaXkAirWD9QQsbon1gmANVStCxrgkhRq/8YS86QheYkOJ aPq287jzs1fCOPBGNsdyWci7tTUGldouZaCORDBdLE1eS9oljazj8xetaMuCmco3ChMu VSzMTvSUWbbDQtbqkl4hD3emr0WA8pML510aeWMQcgf4MLRHTrvHCh6whlMnwBXyz18e TzWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685982787; x=1688574787; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SemjxnLFVDoru2Fhk3H23Xrt6VhRkLbnIFcIlJryluA=; b=jRFP9yHPP9rRr4axgz5N+a0Wq0zJLUjgLAtV0pRk/gtyVo1sKly1Nk9jMHoks2g2YD IYrPJgMdojutxpojZeyW/wmVGT3by+0imppCQ6d3VGc44mAJPF+pTF8ac2GVt3KhQGyA dai8yHqBtEkkzR6M9SiC+LOMaf8rwN42agqeF/6+Eyi5I75+jeJhlbThkVhZMrNrdpYx wbYrF52a20DDmt5lRTaqY/isjim0xtUoDjwBkY3CNWrAO1iyryIuqIuYNIZ28qJ6vzT7 I+e7MgzVLJUnHr+3NENGlXUij92EoJcHA0X1CloAGaGDBp+g+qbzPcy7XNOKtn7THqzh /RkA== X-Gm-Message-State: AC+VfDyRsct0psbpiA2CRkwJV3R2jDxvImSKQDzD7hZQ18QVaiVP0Q1x y4/1b7lidvo1Nf7M3ezomv3/EZ8r/LS6PD55tKM= X-Google-Smtp-Source: ACHHUZ4Se3n54bj8lh97bNPlN7W3B9RrdHnnmIvEhpN3sXU2hamOnKg/HQDqngLO0xROhENF9nSGHvMcl2UwhI8hKx8= X-Received: by 2002:a05:622a:18a1:b0:3ef:6c09:edcc with SMTP id v33-20020a05622a18a100b003ef6c09edccmr9822138qtc.22.1685982786880; Mon, 05 Jun 2023 09:33:06 -0700 (PDT) MIME-Version: 1.0 References: <20230518155654.1756576-1-amitprakashs@marvell.com> <20230531113743.1929627-1-amitprakashs@marvell.com> <20230531113743.1929627-3-amitprakashs@marvell.com> In-Reply-To: <20230531113743.1929627-3-amitprakashs@marvell.com> From: Nithin Dabilpuram Date: Mon, 5 Jun 2023 22:02:54 +0530 Message-ID: Subject: Re: [PATCH v3 3/3] examples/l3fwd-graph: add IPv6 lookup and rewrite support To: Amit Prakash Shukla Cc: Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , dev@dpdk.org, skori@marvell.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Acked-by: Nithin Dabilpuram On Wed, May 31, 2023 at 5:08=E2=80=AFPM Amit Prakash Shukla wrote: > > 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 > --- > 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/s= ample_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 no= des > -``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 o= ver > graph using ``rte_graph_walk()`` with graph objects created one per work= er lcore. > > -The lookup method is as per implementation of ``ip4_lookup`` graph node. > +The lookup method is as per implementation of ``ip4_lookup``/``ip6_looku= p`` graph node. > The ID of the output interface for the input packet is the next hop retu= rned by > the LPM lookup. The set of LPM rules used by the application is statical= ly > -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_r= ewrite_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 t= he 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 lc= ore > +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 as= sociate 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 rewri= te > -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 suppo= rt > - 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 f= orwarding > + data like route and rewrite data, forwarding data is added before pa= cket > + 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_r= x-X-Y`` > associated with a given graph and Rx the available packets and enque= ue 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 E= thernet header > + to the following node ``pkt_cls`` which based on the packet type wil= l enqueue > + them to ``ip4_lookup``/``ip6_lookup`` which then will enqueue them t= o > + ``ip4_rewrite``/``ip6_rewrite`` node if LPM lookup succeeds. > + ``ip4_rewrite``/``ip6_rewrite`` node then will update Ethernet heade= r > as per next-hop data and transmit the packet via port 'Z' by enqueui= ng > 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_ro= ute_array[] =3D { > {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[] =3D { > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x00}, 48, 0}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x01}, 48, 1}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x02}, 48, 2}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x03}, 48, 3}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x04}, 48, 4}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x05}, 48, 5}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 0x00, 0x00, 0x00, 0x00, > + 0x06}, 48, 6}, > + {{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0= 0, 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 =3D sizeof(rewrite_data); > > - /* Add route to ip4 graph infra. 8< */ > + /* Add routes and rewrite data to graph infra. 8< */ > for (i =3D 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 =3D 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) =3D=3D 0) > + continue; > + > + dst_port =3D 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 =3D 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 =3D 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); > -- > 2.25.1 >