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 7997842672; Fri, 29 Sep 2023 12:58:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4688D402AA; Fri, 29 Sep 2023 12:58:32 +0200 (CEST) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mails.dpdk.org (Postfix) with ESMTP id D07B340287 for ; Fri, 29 Sep 2023 12:58:30 +0200 (CEST) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7740729ae12so946167785a.1 for ; Fri, 29 Sep 2023 03:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695985110; x=1696589910; darn=dpdk.org; 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=l3Dd735tjcXJgWnFSEn9LhF0iWRET/2/dsc5cvjEbK8=; b=K9pOwnzazJ574IQHjlYSgyfg1Ltxg2Z+Pws6036KKf63BDxP1ITbXz3eU0LUag5DX2 KNjUmlGTxB+dogX1TSzxvCOZlYFs794Exy61fwHmKM3SUzAalpYzL7PemcAwS8QuoGkW f9TzBCELcG5DiiNz45ot9wV0QDeD0M/3cm83OH1w+No6BhxUvyRKWqQu9bjiwZjKGtkR HbVR71uL5OVnMChW1ItqietS1/nqS2cWGH07J1gFYJPnez3rPhainpI8a+SHJk4duI81 WeE+UjsbxiqFtl7iPsw7eQv9rcS6dmH0euJiDDJmyBUsMaEWuV54akNfdWZrEMe4GVW1 BX2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695985110; x=1696589910; 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=l3Dd735tjcXJgWnFSEn9LhF0iWRET/2/dsc5cvjEbK8=; b=Y0ZMHdb2YW4ngUqaw+vCp9IIZVs1t8YYsLucR6aRzH9iWap4iXRVQ3yiaQoeAiW+bz QvWzdx1vOTNWHSnG0MyO8XdtEF4gis0kgSzRrpSy1eKQTOn0dAkCIGmjIICK/NqPq94P 4+sM0JSYA+yesYEvOCVaZcQ+pwlzL9B7HkgDP0n0Xo8dSBbtBqYMmLu8w0xdciG/nvvJ MTOBzr0poYwv5tnB4C6aic1UqbuxeqEOGUiu0Bhaw2w+UrFMeAdvh3AGZq4srVpD4Nfy qAbVuJMWxaWGsAzs2knziIvR1CDJlP3du87PEJ+k2fBdNO3/9l4FDd58uLq5zoJ1RnET /GDw== X-Gm-Message-State: AOJu0YyxqCbkBtnFrFzavAc2JvVF7WGQ4kq4+HYuxEwxtcaF2JTZqXtg GMDoZIgJsFjWLZKkEKP2wDSva/r537Wb+QIQt+I= X-Google-Smtp-Source: AGHT+IHvOqf1oMLkqT0c2HKAntm9nfpLICnujn3qmf9wv8yG9sKTuSy6MO1uGPjwJNpTbqr5w5rqK7AGGk4OtVDueZc= X-Received: by 2002:a05:622a:40a:b0:40f:1c71:d4f7 with SMTP id n10-20020a05622a040a00b0040f1c71d4f7mr3836425qtx.40.1695985110052; Fri, 29 Sep 2023 03:58:30 -0700 (PDT) MIME-Version: 1.0 References: <20230927124100.4108588-1-rkudurumalla@marvell.com> <20230928102529.4118346-1-rkudurumalla@marvell.com> In-Reply-To: From: Nithin Dabilpuram Date: Fri, 29 Sep 2023 16:28:17 +0530 Message-ID: Subject: Re: [PATCH v6 1/2] node: add IPv4 local node to handle local pkts To: Rakesh Kudurumalla Cc: Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Pavan Nikhilesh , dev@dpdk.org 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 Fri, Sep 29, 2023 at 4:24=E2=80=AFPM Nithin Dabilpuram wrote: > > Series-acked-by: Nithin Dabilpuram > > > On Fri, Sep 29, 2023 at 1:21=E2=80=AFAM Rakesh Kudurumalla > wrote: > > > > Local or Host destined pkts can be redirected IPv4 local node > > using IP4 Lookup node entries with prefix of 32 and be redirected > > to this IP4 local node for further processing. > > > > Signed-off-by: Rakesh Kudurumalla > > --- > > Depends-on: series-29670 ("remove MAX macro from all nodes") > > > > v6: Resolve dependency > > > > doc/guides/prog_guide/graph_lib.rst | 15 ++ > > .../img/graph_inbuilt_node_flow.svg | 138 ++++++++++-------- > > lib/node/ip4_local.c | 88 +++++++++++ > > lib/node/ip4_lookup.c | 1 + > > lib/node/meson.build | 1 + > > lib/node/rte_node_ip4_api.h | 12 ++ > > 6 files changed, 196 insertions(+), 59 deletions(-) > > create mode 100644 lib/node/ip4_local.c > > > > diff --git a/doc/guides/prog_guide/graph_lib.rst b/doc/guides/prog_guid= e/graph_lib.rst > > index e7b6e12004..f2e04a68b9 100644 > > --- a/doc/guides/prog_guide/graph_lib.rst > > +++ b/doc/guides/prog_guide/graph_lib.rst > > @@ -498,3 +498,18 @@ Uses ``poll`` function to poll on the socket fd > > for ``POLLIN`` events to read the packets from raw socket > > to stream buffer and does ``rte_node_next_stream_move()`` > > when there are received packets. > > + > > +ip4_local > > +~~~~~~~~~ > > +This node is an intermediate node that does ``packet_type`` lookup for > > +the received ipv4 packets and the result determines each packets next = node. > > + > > +On successful ``packet_type`` lookup, for any IPv4 protocol the result > > +contains the ``next_node`` id and ``next-hop`` id with which the packe= t > > +needs to be further processed. > > + > > +On packet_type lookup failure, objects are redirected to ``pkt_drop`` = node. > > +``rte_node_ip4_route_add()`` is control path API to add ipv4 address w= ith 32 bit > > +depth to receive to packets. > > +To achieve home run, node use ``rte_node_stream_move()`` as mentioned = in above > > +sections. > > diff --git a/doc/guides/prog_guide/img/graph_inbuilt_node_flow.svg b/do= c/guides/prog_guide/img/graph_inbuilt_node_flow.svg > > index 7eea94701f..b954f6fba1 100644 > > --- a/doc/guides/prog_guide/img/graph_inbuilt_node_flow.svg > > +++ b/doc/guides/prog_guide/img/graph_inbuilt_node_flow.svg > > @@ -37,174 +37,194 @@ digraph dpdk_inbuilt_nodes_flow { > > ethdev_tx -> pkt_drop [color=3D"cyan" style=3D"dashed"] > > pkt_cls->pkt_drop [color=3D"cyan" style=3D"dashed"] > > kernel_tx -> kernel_rx [color=3D"red" style=3D"dashed"] > > + ip4_lookup -> ip4_local > > + ip4_local -> pkt_drop [color=3D"cyan" style=3D"dashed"] > > } > > > > --> > > > > > > - > - viewBox=3D"0.00 0.00 470.23 424.50" xmlns=3D"http://www.w3.org/2000/s= vg" xmlns:xlink=3D"http://www.w3.org/1999/xlink"> > > - > > + > + viewBox=3D"0.00 0.00 524.91 458.00" xmlns=3D"http://www.w3.org/2000/s= vg" xmlns:xlink=3D"http://www.w3.org/1999/xlink"> > > + > > dpdk_inbuilt_nodes_flow > > - > > + > > > > > > ethdev_rx > > - > > -ethdev_rx > > + > > +ethdev_rx > > > > > > > > pkt_cls > > - > > -pkt_cls > > + > > +pkt_cls > > > > > > > > ethdev_rx->pkt_cls > > - > > - > > + > > + > > > > > > > > kernel_rx > > - > > -kernel_rx > > + > > +kernel_rx > > > > > > > > kernel_rx->pkt_cls > > - > > - > > + > > + > > > > > > > > ethdev_tx > > - > > -ethdev_tx > > + > > +ethdev_tx > > > > > > > > pkt_drop > > - > > -pkt_drop > > + > > +pkt_drop > > > > > > > > ethdev_tx->pkt_drop > > - > > - > > + > > + > > > > > > > > kernel_tx > > - > > -kernel_tx > > + > > +kernel_tx > > > > > > > > kernel_tx->kernel_rx > > - > > - > > + > > + > > > > > > > > pkt_cls->pkt_drop > > - > > - > > + > > + > > > > > > > > pkt_cls->kernel_tx > > - > > - > > -exception pkts > > + > > + > > +exception pkts > > > > > > > > ip4_lookup > > - > > -ip4_lookup > > + > > +ip4_lookup > > > > > > > > pkt_cls->ip4_lookup > > - > > - > > -ipv4 > > + > > + > > +ipv4 > > > > > > > > ip6_lookup > > - > > -ip6_lookup > > + > > +ip6_lookup > > > > > > > > pkt_cls->ip6_lookup > > - > > - > > -ipv6 > > + > > + > > +ipv6 > > > > > > > > ip4_lookup->pkt_drop > > - > > - > > + > > + > > > > > > > > ip4_rewrite > > - > > -ip4_rewrite > > + > > +ip4_rewrite > > > > > > > > ip4_lookup->ip4_rewrite > > - > > - > > + > > + > > + > > + > > + > > +ip4_local > > + > > +ip4_local > > + > > + > > + > > +ip4_lookup->ip4_local > > + > > + > > > > > > > > ip6_lookup->pkt_drop > > - > > - > > + > > + > > > > > > > > ip6_rewrite > > - > > -ip6_rewrite > > + > > +ip6_rewrite > > > > > > > > ip6_lookup->ip6_rewrite > > - > > - > > + > > + > > > > > > > > ip4_rewrite->ethdev_tx > > - > > - > > + > > + > > > > > > > > ip4_rewrite->pkt_drop > > - > > - > > + > > + > > > > > > > > ip6_rewrite->ethdev_tx > > - > > - > > + > > + > > > > > > > > ip6_rewrite->pkt_drop > > - > > - > > + > > + > > + > > + > > + > > +ip4_local->pkt_drop > > + > > + > > > > > > > > diff --git a/lib/node/ip4_local.c b/lib/node/ip4_local.c > > new file mode 100644 > > index 0000000000..fb31d0f970 > > --- /dev/null > > +++ b/lib/node/ip4_local.c > > @@ -0,0 +1,88 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright(C) 2023 Marvell International Ltd. > > + */ > > + > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > + > > +#include "rte_node_ip4_api.h" > > + > > +#include "node_private.h" > > + > > +static uint16_t > > +ip4_local_node_process_scalar(struct rte_graph *graph, struct rte_node= *node, > > + void **objs, uint16_t nb_objs) > > +{ > > + void **to_next, **from; > > + uint16_t last_spec =3D 0; > > + rte_edge_t next_index; > > + struct rte_mbuf *mbuf; > > + uint16_t held =3D 0; > > + uint32_t l4; > > + int i; > > + > > + /* Speculative next */ > > + next_index =3D RTE_NODE_IP4_LOCAL_NEXT_UDP4_INPUT; > > + > > + from =3D objs; > > + to_next =3D rte_node_next_stream_get(graph, node, next_index, n= b_objs); > > + for (i =3D 0; i < nb_objs; i++) { > > + uint16_t next; > > + > > + mbuf =3D (struct rte_mbuf *)objs[i]; > > + l4 =3D mbuf->packet_type & RTE_PTYPE_L4_MASK; > > + > > + next =3D (l4 =3D=3D RTE_PTYPE_L4_UDP) > > + ? next_index > > + : RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP; > > + > > + if (unlikely(next_index !=3D next)) { > > + /* Copy things successfully speculated till now= */ > > + rte_memcpy(to_next, from, last_spec * sizeof(fr= om[0])); > > + from +=3D last_spec; > > + to_next +=3D last_spec; > > + held +=3D last_spec; > > + last_spec =3D 0; > > + > > + rte_node_enqueue_x1(graph, node, next, from[0])= ; > > + from +=3D 1; > > + } else { > > + last_spec +=3D 1; > > + } > > + } > > + /* !!! Home run !!! */ > > + if (likely(last_spec =3D=3D nb_objs)) { > > + rte_node_next_stream_move(graph, node, next_index); > > + return nb_objs; > > + } > > + held +=3D last_spec; > > + rte_memcpy(to_next, from, last_spec * sizeof(from[0])); > > + rte_node_next_stream_put(graph, node, next_index, held); > > + > > + return nb_objs; > > +} > > + > > +static struct rte_node_register ip4_local_node =3D { > > + .process =3D ip4_local_node_process_scalar, > > + .name =3D "ip4_local", > > + > > + .nb_edges =3D RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP + 1, > > + .next_nodes =3D { > > + [RTE_NODE_IP4_LOCAL_NEXT_UDP4_INPUT] =3D "udp4_input", > > + [RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP] =3D "pkt_drop", > > + }, > > +}; > > + > > +RTE_NODE_REGISTER(ip4_local_node); > > diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c > > index 72fd760512..0dbfde64fe 100644 > > --- a/lib/node/ip4_lookup.c > > +++ b/lib/node/ip4_lookup.c > > @@ -227,6 +227,7 @@ static struct rte_node_register ip4_lookup_node =3D= { > > > > .nb_edges =3D RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP + 1, > > .next_nodes =3D { > > + [RTE_NODE_IP4_LOOKUP_NEXT_IP4_LOCAL] =3D "ip4_local", > > [RTE_NODE_IP4_LOOKUP_NEXT_REWRITE] =3D "ip4_rewrite", > > [RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP] =3D "pkt_drop", > > }, > > diff --git a/lib/node/meson.build b/lib/node/meson.build > > index 2fa7c1c8f3..c0d5b09e2f 100644 > > --- a/lib/node/meson.build > > +++ b/lib/node/meson.build > > @@ -12,6 +12,7 @@ sources =3D files( > > 'ethdev_rx.c', > > 'ethdev_tx.c', > > 'ip4_lookup.c', > > + 'ip4_local.c', > > 'ip4_rewrite.c', > > 'ip6_lookup.c', > > 'ip6_rewrite.c', > > diff --git a/lib/node/rte_node_ip4_api.h b/lib/node/rte_node_ip4_api.h > > index 0f997761b6..40af3860b5 100644 > > --- a/lib/node/rte_node_ip4_api.h > > +++ b/lib/node/rte_node_ip4_api.h > > @@ -28,10 +28,22 @@ extern "C" { > > enum rte_node_ip4_lookup_next { > > RTE_NODE_IP4_LOOKUP_NEXT_REWRITE, > > /**< Rewrite node. */ > > + RTE_NODE_IP4_LOOKUP_NEXT_IP4_LOCAL, > > + /** IP Local node. */ > > RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP, > > /**< Number of next nodes of lookup node. */ > > }; > > > > +/** > > + * IP4 Local next nodes. > > + */ > > +enum rte_node_ip4_local_next { > > + RTE_NODE_IP4_LOCAL_NEXT_UDP4_INPUT, > > + /**< ip4 Local node. */ > > + RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP, > > + /**< Packet drop node. */ > > +}; > > + > > /** > > * Add ipv4 route to lookup table. > > * > > -- > > 2.25.1 > >