From patchwork Mon Jul 3 10:05:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 129205 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 BC34D42DAF; Mon, 3 Jul 2023 12:05:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A710D41151; Mon, 3 Jul 2023 12:05:59 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id AE99F40156 for ; Mon, 3 Jul 2023 12:05:57 +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 362MwbSB021232; Mon, 3 Jul 2023 03:05:56 -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=OLAYT9zGv8YN0PPmiM29WV3R8S4d5VuFtrRxGxi7Ozs=; b=aADsBWcZvVoqb+iPOJX2pN36QCQuu7lCBLq7Lum9KImSPevSmpaeNnUml5iyeW1JE874 5Og0r4a+zDd2fqqhdqNBc2uknxAXkL325qhmhA3i07wC7HwJ39MKyB6tNjOgDOie4L// Z0hM6Q7PRXCPcCAe90kJID3tp/NsUulRArEZ3T6hdMGEcNwNQcst7DYJW+yzbLhhj8YQ G6q8XA47g7AQsBytA/HB4UJJikSMwQhlk14G8Y6stT4zoRfrsfYLNcxK8Pd39dS1Rtcu CpGh62lS+Yd5ZjpdbXmtUKlcoNpOWDRRh6jSY5Q3z4wP++GtpopqIc3qPvqxPeeX+HdU kQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3rjhgnd4yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jul 2023 03:05:56 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 3 Jul 2023 03:05:54 -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; Mon, 3 Jul 2023 03:05:54 -0700 Received: from localhost.localdomain (unknown [10.28.36.154]) by maili.marvell.com (Postfix) with ESMTP id 200373F705C; Mon, 3 Jul 2023 03:05:51 -0700 (PDT) From: Rakesh Kudurumalla To: Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Pavan Nikhilesh CC: , Rakesh Kudurumalla Subject: [PATCH v2 1/2] node: add IPv4 local node to handle local pkts Date: Mon, 3 Jul 2023 15:35:48 +0530 Message-ID: <20230703100549.4104148-1-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230703091347.4038271-1-rkudurumalla@marvell.com> References: <20230703091347.4038271-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: C1ZhDgO-WYlzFX_zdo7OvewCkY3fi08d X-Proofpoint-GUID: C1ZhDgO-WYlzFX_zdo7OvewCkY3fi08d X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-03_08,2023-06-30_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 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-28622 ("add inbuilt graph nodes data flow") v2 : - Resolve compilation on intel 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_guide/graph_lib.rst index 96af29e8da..eaa8ee337e 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 packet +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 with 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/doc/guides/prog_guide/img/graph_inbuilt_node_flow.svg index 02fe768dfe..7a3ace48dc 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="cyan" style="dashed"] pkt_cls->pkt_drop [color="cyan" style="dashed"] kernel_tx -> kernel_rx [color="red" style="dashed"] + ip4_lookup -> ip4_local + ip4_local -> pkt_drop [color="cyan" style="dashed"] } --> - - + + 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 = 0; + rte_edge_t next_index; + struct rte_mbuf *mbuf; + uint16_t held = 0; + uint32_t l4; + int i; + + /* Speculative next */ + next_index = RTE_NODE_IP4_LOCAL_NEXT_UDP4_INPUT; + + from = objs; + to_next = rte_node_next_stream_get(graph, node, next_index, nb_objs); + for (i = 0; i < nb_objs; i++) { + uint16_t next; + + mbuf = (struct rte_mbuf *)objs[i]; + l4 = mbuf->packet_type & RTE_PTYPE_L4_MASK; + + next = (l4 == RTE_PTYPE_L4_UDP) + ? next_index + : RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP; + + if (unlikely(next_index != next)) { + /* Copy things successfully speculated till now */ + rte_memcpy(to_next, from, last_spec * sizeof(from[0])); + from += last_spec; + to_next += last_spec; + held += last_spec; + last_spec = 0; + + rte_node_enqueue_x1(graph, node, next, from[0]); + from += 1; + } else { + last_spec += 1; + } + } + /* !!! Home run !!! */ + if (likely(last_spec == nb_objs)) { + rte_node_next_stream_move(graph, node, next_index); + return nb_objs; + } + held += 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 = { + .process = ip4_local_node_process_scalar, + .name = "ip4_local", + + .nb_edges = RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP + 1, + .next_nodes = { + [RTE_NODE_IP4_LOCAL_NEXT_UDP4_INPUT] = "udp4_input", + [RTE_NODE_IP4_LOCAL_NEXT_PKT_DROP] = "pkt_drop", + }, +}; + +RTE_NODE_REGISTER(ip4_local_node); diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index 8bce03d7db..d3fc48baf7 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 = { .nb_edges = RTE_NODE_IP4_LOOKUP_NEXT_MAX, .next_nodes = { + [RTE_NODE_IP4_LOOKUP_NEXT_IP4_LOCAL] = "ip4_local", [RTE_NODE_IP4_LOOKUP_NEXT_REWRITE] = "ip4_rewrite", [RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP] = "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 = 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 3397da0ae8..405bdd3283 100644 --- a/lib/node/rte_node_ip4_api.h +++ b/lib/node/rte_node_ip4_api.h @@ -30,10 +30,22 @@ enum rte_node_ip4_lookup_next { /**< Rewrite node. */ RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP, /**< Packet drop node. */ + RTE_NODE_IP4_LOOKUP_NEXT_IP4_LOCAL, + /** IP Local node. */ RTE_NODE_IP4_LOOKUP_NEXT_MAX, /**< 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. *