[V3] examples/pipeline: simplify the L2 forwarding examples

Message ID 20240215192601.1575859-1-cristian.dumitrescu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [V3] examples/pipeline: simplify the L2 forwarding examples |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Cristian Dumitrescu Feb. 15, 2024, 7:26 p.m. UTC
  Simplified the L2 forwarding examples by removing all tables and
actions, as they are not really needed for these simple use-cases.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/pipeline/examples/l2fwd.spec        | 34 +++++-------------
 examples/pipeline/examples/l2fwd_macswp.spec | 36 ++++++--------------
 2 files changed, 19 insertions(+), 51 deletions(-)
  

Comments

Thomas Monjalon Feb. 19, 2024, 12:55 a.m. UTC | #1
15/02/2024 20:26, Cristian Dumitrescu:
> Simplified the L2 forwarding examples by removing all tables and
> actions, as they are not really needed for these simple use-cases.
> 
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.
  

Patch

diff --git a/examples/pipeline/examples/l2fwd.spec b/examples/pipeline/examples/l2fwd.spec
index 0aebafd07b..1e3e1ad040 100644
--- a/examples/pipeline/examples/l2fwd.spec
+++ b/examples/pipeline/examples/l2fwd.spec
@@ -1,42 +1,24 @@ 
 ; SPDX-License-Identifier: BSD-3-Clause
 ; Copyright(c) 2020 Intel Corporation
 
+; The simplest pipeline processing with just packet reception and transmission. No header parsing,
+; table lookup or action execution involved. Packets received on port 0 are sent out on port 1,
+; those received on port 1 are sent out on port 0, etc.
+
 //
 // Meta-data.
 //
 struct metadata_t {
-	bit<32> port_in
-	bit<32> port_out
+	bit<32> port
 }
 
 metadata instanceof metadata_t
 
-//
-// Actions.
-//
-action NoAction args none {
-	return
-}
-
-//
-// Tables.
-//
-table stub {
-	key {
-	}
-
-	actions {
-		NoAction
-	}
-
-	default_action NoAction args none const
-}
-
 //
 // Pipeline.
 //
 apply {
-	rx m.port_in
-	table stub
-	tx m.port_in
+	rx m.port
+	xor m.port 1
+	tx m.port
 }
diff --git a/examples/pipeline/examples/l2fwd_macswp.spec b/examples/pipeline/examples/l2fwd_macswp.spec
index e81f20622e..4bd5c23c7a 100644
--- a/examples/pipeline/examples/l2fwd_macswp.spec
+++ b/examples/pipeline/examples/l2fwd_macswp.spec
@@ -1,6 +1,9 @@ 
 ; SPDX-License-Identifier: BSD-3-Clause
 ; Copyright(c) 2020 Intel Corporation
 
+; Layer 2 Forwarding with MACADDR swapping (i.e. within the Ethernet header of the output packet,
+; the destination MAC address is swapped with the source MAC address).
+
 //
 // Packet headers.
 //
@@ -22,37 +25,20 @@  struct metadata_t {
 
 metadata instanceof metadata_t
 
-//
-// Actions.
-//
-action macswp args none {
-	mov m.addr h.ethernet.dst_addr
-	mov h.ethernet.dst_addr h.ethernet.src_addr
-	mov h.ethernet.src_addr m.addr
-	return
-}
-
-//
-// Tables.
-//
-table stub {
-	key {
-	}
-
-	actions {
-		macswp
-	}
-
-	default_action macswp args none const
-}
-
 //
 // Pipeline.
 //
 apply {
 	rx m.port
 	extract h.ethernet
-	table stub
+
+	//
+	// Ethernet header: dst_addr swapped with src_addr.
+	//
+	mov m.addr h.ethernet.dst_addr
+	mov h.ethernet.dst_addr h.ethernet.src_addr
+	mov h.ethernet.src_addr m.addr
+
 	xor m.port 1
 	emit h.ethernet
 	tx m.port