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 6EC78A0509; Wed, 6 Apr 2022 20:56:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0EB942881; Wed, 6 Apr 2022 20:55:45 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id BD00442867 for ; Wed, 6 Apr 2022 20:55:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649271343; x=1680807343; h=from:to:subject:date:message-id:in-reply-to:references; bh=TaIWtsMryOqRat4+0tfDCYBIWovcUcsaNHwE7q1tg3k=; b=njnA/3z6GOR00A8PZFVQuD06FT1ujf+4MqDOq86inlGjJ7qQv7uMPJdE yN+KG/Hzx5636jGTE7dkqcU3/WVAeuKT8O/v1NiBRnLVjyLemO4K2BOX3 V18cK9/KhLncDXVZP9phtOczTB65Tsnkfqa+LzRfFgB2NPP/QJZZavpeh zh6jx+CIV7QjhaythcsTUAkwaNE2ID2uuR6Y8+4v1eE/GXgh0gEq+GlwA XZyRT6oQyrW/uM4BuImlJp2/MptpnpKO8ZsdMtLjqTRHMkTq7klPlr44d utJJAVNlZBRUlQ1tUDlRhrd2jFJWJ5/Zsh7zzJ/EDxAfxn7et0qcFQSEK A==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="243266971" X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="243266971" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 11:55:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="524055158" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga002.jf.intel.com with ESMTP; 06 Apr 2022 11:55:42 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH V5 6/6] examples/pipeline: add packet recirculation example Date: Wed, 6 Apr 2022 19:55:35 +0100 Message-Id: <20220406185535.73084-6-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220406185535.73084-1-cristian.dumitrescu@intel.com> References: <20220406184836.72784-1-cristian.dumitrescu@intel.com> <20220406185535.73084-1-cristian.dumitrescu@intel.com> 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 Add example program to illustrate packet recirculation. Signed-off-by: Cristian Dumitrescu --- examples/pipeline/examples/recirculation.cli | 34 ++++++++ examples/pipeline/examples/recirculation.spec | 81 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 examples/pipeline/examples/recirculation.cli create mode 100644 examples/pipeline/examples/recirculation.spec diff --git a/examples/pipeline/examples/recirculation.cli b/examples/pipeline/examples/recirculation.cli new file mode 100644 index 0000000000..f855c5c327 --- /dev/null +++ b/examples/pipeline/examples/recirculation.cli @@ -0,0 +1,34 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2022 Intel Corporation + +; +; Customize the LINK parameters to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 + +link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on + +; +; PIPELINE0 setup. +; +pipeline PIPELINE0 create 0 + +pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 +pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 +pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 +pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 + +pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 +pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 +pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 +pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 + +pipeline PIPELINE0 build ./examples/pipeline/examples/recirculation.spec + +; +; Pipelines-to-threads mapping. +; +thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/recirculation.spec b/examples/pipeline/examples/recirculation.spec new file mode 100644 index 0000000000..3cc115610e --- /dev/null +++ b/examples/pipeline/examples/recirculation.spec @@ -0,0 +1,81 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2022 Intel Corporation + +; This simple example illustrates how to perform packet recirculation. The "recirculate" instruction +; is used to mark the current packet for recirculation, which means that at TX time the packet is +; reinjected into the pipeline for another full pass as opposed to being sent to the output port. +; +; The same packet can be recirculated multiple times, with the recirculation pass ID retrieved by +; the "recircid" instruction. The pass ID can be used by the program to execute different code on +; the same packet in different pipeline passes. The packet meta-data is preserved between the +; pipeline passes. + +// +// Headers +// +struct ethernet_h { + bit<48> dst_addr + bit<48> src_addr + bit<16> ethertype +} + +struct ipv4_h { + bit<8> ver_ihl + bit<8> diffserv + bit<16> total_len + bit<16> identification + bit<16> flags_offset + bit<8> ttl + bit<8> protocol + bit<16> hdr_checksum + bit<32> src_addr + bit<32> dst_addr +} + +struct udp_h { + bit<16> src_port + bit<16> dst_port + bit<16> length + bit<16> checksum +} + +header ethernet instanceof ethernet_h +header ipv4 instanceof ipv4_h +header udp instanceof udp_h + +// +// Meta-data. +// +struct metadata_t { + bit<32> port + bit<32> pass_id +} + +metadata instanceof metadata_t + +// +// Pipeline. +// +apply { + rx m.port + extract h.ethernet + extract h.ipv4 + extract h.udp + + // + // State machine based on the recirculation pass ID. + // + // During each of the first 5 passes through the pipeline (m.pass_id is 0 .. 4), the UDP + // source port is incremented and the packet is marked for recirculation, while on the final + // iteration (m.pass_id is 5) the packet is sent out. + // + recircid m.pass_id + jmpgt EMIT m.pass_id 4 + add h.udp.src_port 1 + recirculate + + EMIT : emit h.ethernet + emit h.ipv4 + emit h.udp + tx m.port +} -- 2.17.1