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 078D3A0548; Fri, 9 Jul 2021 19:07:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87881410FA; Fri, 9 Jul 2021 19:07:07 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id F2C8D4003F for ; Fri, 9 Jul 2021 19:07:05 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10039"; a="196915115" X-IronPort-AV: E=Sophos;i="5.84,226,1620716400"; d="scan'208";a="196915115" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2021 10:07:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,226,1620716400"; d="scan'208";a="488214610" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by FMSMGA003.fm.intel.com with ESMTP; 09 Jul 2021 10:07:01 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Churchill Khangar Date: Fri, 9 Jul 2021 18:07:00 +0100 Message-Id: <20210709170700.24979-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/pipeline: add FIB example 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 Sender: "dev" Add example for FIB with VRF and ECMP support. Signed-off-by: Cristian Dumitrescu Signed-off-by: Churchill Khangar --- Depends-on: patch-17716 ("[V2] pipeline: add support for LPM lookup") examples/pipeline/examples/fib.cli | 58 ++++++ examples/pipeline/examples/fib.spec | 171 ++++++++++++++++++ .../examples/fib_nexthop_group_table.txt | 54 ++++++ .../pipeline/examples/fib_nexthop_table.txt | 22 +++ .../pipeline/examples/fib_routing_table.txt | 30 +++ 5 files changed, 335 insertions(+) create mode 100644 examples/pipeline/examples/fib.cli create mode 100644 examples/pipeline/examples/fib.spec create mode 100644 examples/pipeline/examples/fib_nexthop_group_table.txt create mode 100644 examples/pipeline/examples/fib_nexthop_table.txt create mode 100644 examples/pipeline/examples/fib_routing_table.txt diff --git a/examples/pipeline/examples/fib.cli b/examples/pipeline/examples/fib.cli new file mode 100644 index 000000000..b20aed3cf --- /dev/null +++ b/examples/pipeline/examples/fib.cli @@ -0,0 +1,58 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2020 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 port out 4 sink none + +pipeline PIPELINE0 build ./examples/pipeline/examples/fib.spec + +; +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. Once the application +; has been successfully started, the command to get the CLI prompt is: telnet 0.0.0.0 8086. +; +pipeline PIPELINE0 table routing_table add ./examples/pipeline/examples/fib_routing_table.txt +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group add +pipeline PIPELINE0 selector nexthop_group_table group member add ./examples/pipeline/examples/fib_nexthop_group_table.txt +pipeline PIPELINE0 table nexthop_table add ./examples/pipeline/examples/fib_nexthop_table.txt +pipeline PIPELINE0 commit + +; +; Pipelines-to-threads mapping. +; +thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/fib.spec b/examples/pipeline/examples/fib.spec new file mode 100644 index 000000000..3f8c76610 --- /dev/null +++ b/examples/pipeline/examples/fib.spec @@ -0,0 +1,171 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2021 Intel Corporation + +; This example illustrates a FIB [1] with VRF [2] and ECMP [3] support. A FIB essentially is the +; data plane copy of the routing table. The VRF support allows for multiple logical routing tables +; to co-exist as part of the same "physical" routing table; the VRF ID typically identifies the +; logical table to provide the matching route for the IP destination address of the input packet. +; The ECMP provides a load balancing mechanism for the packet forwarding by allowing for multiple +; next hops (of equal or different weights, in case of WCMP [4]) to be provided for each route. +; +; In this example, the VRF ID is read from the IP source address of the input packet as opposed to a +; more complex classification scheme being used. The routing table produces the ID of the group of +; next hops associated with the current route, out of which a single next hop is selected based on a +; hashing scheme that preserves the packet order within each flow (with the flow defined here by a +; typical 3-tuple) by always selecting the same next hop for packets that are part of the same flow. +; The next hop provides the Ethernet header and the output port for the outgoing packet. +; +; [1] Forwarding Information Base (FIB): +; https://en.wikipedia.org/wiki/Forwarding_information_base +; [2] Virtual Routing and Forwarding (VRF): +; https://en.wikipedia.org/wiki/Virtual_routing_and_forwarding +; [3] Equal-Cost Multi-Path (ECMP) routing: +; https://en.wikipedia.org/wiki/Equal-cost_multi-path_routing +; [4] Weighted-Cost Multi-Path (WCMP) routing. + +// +// 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 +} + +header ethernet instanceof ethernet_h +header ipv4 instanceof ipv4_h + +// +// Meta-data +// +struct metadata_t { + bit<32> port_in + bit<32> port_out + bit<32> vrf_id + bit<32> dst_addr + bit<32> nexthop_group_id + bit<32> nexthop_id +} + +metadata instanceof metadata_t + +// +// Actions +// +struct nexthop_group_action_args_t { + bit<32> nexthop_group_id +} + +action nexthop_group_action args instanceof nexthop_group_action_args_t { + mov m.nexthop_group_id t.nexthop_group_id + return +} + +struct nexthop_action_args_t { + bit<48> ethernet_dst_addr + bit<48> ethernet_src_addr + bit<16> ethernet_ethertype + bit<32> port_out +} + +action nexthop_action args instanceof nexthop_action_args_t { + //Set Ethernet header. + mov h.ethernet.dst_addr t.ethernet_dst_addr + mov h.ethernet.src_addr t.ethernet_src_addr + mov h.ethernet.ethertype t.ethernet_ethertype + validate h.ethernet + + //Decrement the TTL and update the checksum within the IPv4 header. + cksub h.ipv4.hdr_checksum h.ipv4.ttl + sub h.ipv4.ttl 0x1 + ckadd h.ipv4.hdr_checksum h.ipv4.ttl + + //Set the output port. + mov m.port_out t.port_out + + return +} + +action drop args none { + drop +} + +// +// Tables +// +table routing_table { + key { + m.vrf_id exact + m.dst_addr lpm + } + + actions { + nexthop_group_action + drop + } + + default_action drop args none + + size 1048576 +} + +selector nexthop_group_table { + group_id m.nexthop_group_id + + selector { + h.ipv4.protocol + h.ipv4.src_addr + h.ipv4.dst_addr + } + + member_id m.nexthop_id + + n_groups_max 65536 + + n_members_per_group_max 64 +} + +table nexthop_table { + key { + m.nexthop_id exact + } + + actions { + nexthop_action + drop + } + + default_action drop args none + + size 1048576 +} + +// +// Pipeline +// +apply { + rx m.port_in + extract h.ethernet + extract h.ipv4 + mov m.vrf_id h.ipv4.src_addr + mov m.dst_addr h.ipv4.dst_addr + table routing_table + table nexthop_group_table + table nexthop_table + emit h.ethernet + emit h.ipv4 + tx m.port_out +} diff --git a/examples/pipeline/examples/fib_nexthop_group_table.txt b/examples/pipeline/examples/fib_nexthop_group_table.txt new file mode 100644 index 000000000..4b4019df5 --- /dev/null +++ b/examples/pipeline/examples/fib_nexthop_group_table.txt @@ -0,0 +1,54 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2021 Intel Corporation + +// Nexthop group #0 (Single member) +group 0 member 0 weight 1 + +// Nexthop group #1 (Single member) +group 1 member 1 weight 1 + +// Nexthop group #2 (Single member) +group 2 member 2 weight 1 + +// Nexthop group #3 (Single member) +group 3 member 3 weight 1 + +// Nexthop group #4 (ECMP) +group 4 member 4 weight 1 +group 4 member 5 weight 1 + +// Nexthop group #5 (ECMP) +group 5 member 5 weight 1 +group 5 member 6 weight 1 + +// Nexthop group #6 (ECMP) +group 6 member 6 weight 1 +group 6 member 7 weight 1 + +// Nexthop group #7 (ECMP) +group 7 member 7 weight 1 +group 7 member 4 weight 1 + +// Nexthop group #8 (WCMP) +group 8 member 8 weight 4 +group 8 member 9 weight 2 +group 8 member 10 weight 1 +group 8 member 11 weight 1 + +// Nexthop group #9 (WCMP) +group 9 member 9 weight 4 +group 9 member 10 weight 2 +group 9 member 11 weight 1 +group 9 member 8 weight 1 + +// Nexthop group #10 (WCMP) +group 10 member 10 weight 4 +group 10 member 11 weight 2 +group 10 member 8 weight 1 +group 10 member 9 weight 1 + +// Nexthop group #11 (WCMP) +group 11 member 11 weight 4 +group 11 member 8 weight 2 +group 11 member 9 weight 1 +group 11 member 10 weight 1 diff --git a/examples/pipeline/examples/fib_nexthop_table.txt b/examples/pipeline/examples/fib_nexthop_table.txt new file mode 100644 index 000000000..b8df5670b --- /dev/null +++ b/examples/pipeline/examples/fib_nexthop_table.txt @@ -0,0 +1,22 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2021 Intel Corporation + +match 0 action nexthop_action ethernet_dst_addr 0xaabbcc000000 ethernet_src_addr 0xddeeff000000 ethernet_ethertype 0x0800 port_out 0 +match 1 action nexthop_action ethernet_dst_addr 0xaabbcc000001 ethernet_src_addr 0xddeeff000001 ethernet_ethertype 0x0800 port_out 1 +match 2 action nexthop_action ethernet_dst_addr 0xaabbcc000002 ethernet_src_addr 0xddeeff000002 ethernet_ethertype 0x0800 port_out 2 +match 3 action nexthop_action ethernet_dst_addr 0xaabbcc000003 ethernet_src_addr 0xddeeff000003 ethernet_ethertype 0x0800 port_out 3 + +match 4 action nexthop_action ethernet_dst_addr 0xaabbcc000004 ethernet_src_addr 0xddeeff000004 ethernet_ethertype 0x0800 port_out 0 +match 5 action nexthop_action ethernet_dst_addr 0xaabbcc000005 ethernet_src_addr 0xddeeff000005 ethernet_ethertype 0x0800 port_out 1 +match 6 action nexthop_action ethernet_dst_addr 0xaabbcc000006 ethernet_src_addr 0xddeeff000006 ethernet_ethertype 0x0800 port_out 2 +match 7 action nexthop_action ethernet_dst_addr 0xaabbcc000007 ethernet_src_addr 0xddeeff000007 ethernet_ethertype 0x0800 port_out 3 + +match 8 action nexthop_action ethernet_dst_addr 0xaabbcc000008 ethernet_src_addr 0xddeeff000008 ethernet_ethertype 0x0800 port_out 0 +match 9 action nexthop_action ethernet_dst_addr 0xaabbcc000009 ethernet_src_addr 0xddeeff000009 ethernet_ethertype 0x0800 port_out 1 +match 10 action nexthop_action ethernet_dst_addr 0xaabbcc00000a ethernet_src_addr 0xddeeff00000a ethernet_ethertype 0x0800 port_out 2 +match 11 action nexthop_action ethernet_dst_addr 0xaabbcc00000b ethernet_src_addr 0xddeeff00000b ethernet_ethertype 0x0800 port_out 3 + +match 12 action nexthop_action ethernet_dst_addr 0xaabbcc00000c ethernet_src_addr 0xddeeff00000c ethernet_ethertype 0x0800 port_out 0 +match 13 action nexthop_action ethernet_dst_addr 0xaabbcc00000d ethernet_src_addr 0xddeeff00000d ethernet_ethertype 0x0800 port_out 1 +match 14 action nexthop_action ethernet_dst_addr 0xaabbcc00000e ethernet_src_addr 0xddeeff00000e ethernet_ethertype 0x0800 port_out 2 +match 15 action nexthop_action ethernet_dst_addr 0xaabbcc00000f ethernet_src_addr 0xddeeff00000f ethernet_ethertype 0x0800 port_out 3 diff --git a/examples/pipeline/examples/fib_routing_table.txt b/examples/pipeline/examples/fib_routing_table.txt new file mode 100644 index 000000000..b13a2e214 --- /dev/null +++ b/examples/pipeline/examples/fib_routing_table.txt @@ -0,0 +1,30 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2021 Intel Corporation + +// VRF #0 +match 0 0x00000000/0xC0000000 action nexthop_group_action nexthop_group_id 0 +match 0 0x40000000/0xC0000000 action nexthop_group_action nexthop_group_id 1 +match 0 0x80000000/0xC0000000 action nexthop_group_action nexthop_group_id 2 +match 0 0xC0000000/0xC0000000 action nexthop_group_action nexthop_group_id 3 + +// VRF #1 +match 1 0x00000000/0xC0000000 action nexthop_group_action nexthop_group_id 4 +match 1 0x40000000/0xC0000000 action nexthop_group_action nexthop_group_id 5 +match 1 0x80000000/0xC0000000 action nexthop_group_action nexthop_group_id 6 +match 1 0xC0000000/0xC0000000 action nexthop_group_action nexthop_group_id 7 + +// VRF #2 +match 2 0x00000000/0xC0000000 action nexthop_group_action nexthop_group_id 8 +match 2 0x40000000/0xC0000000 action nexthop_group_action nexthop_group_id 9 +match 2 0x80000000/0xC0000000 action nexthop_group_action nexthop_group_id 10 +match 2 0xC0000000/0xC0000000 action nexthop_group_action nexthop_group_id 11 + +// VRF #3 +match 3 0x00000000/0x00000000 action nexthop_group_action nexthop_group_id 4 +match 3 0x80000000/0x80000000 action nexthop_group_action nexthop_group_id 5 +match 3 0xC0000000/0xC0000000 action nexthop_group_action nexthop_group_id 6 + +// VRF #4 +match 4 0x00000000/0x00000000 action nexthop_group_action nexthop_group_id 8 +match 4 0x80000000/0x80000000 action nexthop_group_action nexthop_group_id 9 +match 4 0xC0000000/0xC0000000 action nexthop_group_action nexthop_group_id 10 -- 2.17.1