examples/l3fwd: add vector stubs for RISC-V
[dpdk.git] / examples / pipeline / examples / recirculation.spec
1 ; SPDX-License-Identifier: BSD-3-Clause
2 ; Copyright(c) 2022 Intel Corporation
3
4 ; This simple example illustrates how to perform packet recirculation. The "recirculate" instruction
5 ; is used to mark the current packet for recirculation, which means that at TX time the packet is
6 ; reinjected into the pipeline for another full pass as opposed to being sent to the output port.
7 ;
8 ; The same packet can be recirculated multiple times, with the recirculation pass ID retrieved by
9 ; the "recircid" instruction. The pass ID can be used by the program to execute different code on
10 ; the same packet in different pipeline passes. The packet meta-data is preserved between the
11 ; pipeline passes.
12
13 //
14 // Headers
15 //
16 struct ethernet_h {
17         bit<48> dst_addr
18         bit<48> src_addr
19         bit<16> ethertype
20 }
21
22 struct ipv4_h {
23         bit<8> ver_ihl
24         bit<8> diffserv
25         bit<16> total_len
26         bit<16> identification
27         bit<16> flags_offset
28         bit<8> ttl
29         bit<8> protocol
30         bit<16> hdr_checksum
31         bit<32> src_addr
32         bit<32> dst_addr
33 }
34
35 struct udp_h {
36         bit<16> src_port
37         bit<16> dst_port
38         bit<16> length
39         bit<16> checksum
40 }
41
42 header ethernet instanceof ethernet_h
43 header ipv4 instanceof ipv4_h
44 header udp instanceof udp_h
45
46 //
47 // Meta-data.
48 //
49 struct metadata_t {
50         bit<32> port
51         bit<32> pass_id
52 }
53
54 metadata instanceof metadata_t
55
56 //
57 // Pipeline.
58 //
59 apply {
60         rx m.port
61         extract h.ethernet
62         extract h.ipv4
63         extract h.udp
64
65         //
66         // State machine based on the recirculation pass ID.
67         //
68         // During each of the first 5 passes through the pipeline (m.pass_id is 0 .. 4), the UDP
69         // source port is incremented and the packet is marked for recirculation, while on the final
70         // iteration (m.pass_id is 5) the packet is sent out.
71         //
72         recircid m.pass_id
73         jmpgt EMIT m.pass_id 4
74         add h.udp.src_port 1
75         recirculate
76
77         EMIT : emit h.ethernet
78         emit h.ipv4
79         emit h.udp
80         tx m.port
81 }