examples/l3fwd: add vector stubs for RISC-V
[dpdk.git] / examples / pipeline / examples / mirroring.spec
1 ; SPDX-License-Identifier: BSD-3-Clause
2 ; Copyright(c) 2022 Intel Corporation
3
4 ; This simple example illustrates how to perform packet mirroring. The "mirror" instruction is used
5 ; to flag the current packet for mirroring, which means that at TX time, before the current packet
6 ; is sent out, it will first be cloned (using either the fast or the slow/deep cloning method) and
7 ; the clone packet sent out on the output port specified by the mirror session.
8 ;
9 ; In this example, the UDP packets with destination port 5000 are mirrored to the output port
10 ; specified by the mirror session 0, while the rest of the packets are not mirrored. Therefore, for
11 ; every UDP input packet with this specific destination port there will be two output packets (the
12 ; current packet and its clone packet), while for every other input packet there will be a single
13 ; output packet.
14
15 //
16 // Headers
17 //
18 struct ethernet_h {
19         bit<48> dst_addr
20         bit<48> src_addr
21         bit<16> ethertype
22 }
23
24 struct ipv4_h {
25         bit<8> ver_ihl
26         bit<8> diffserv
27         bit<16> total_len
28         bit<16> identification
29         bit<16> flags_offset
30         bit<8> ttl
31         bit<8> protocol
32         bit<16> hdr_checksum
33         bit<32> src_addr
34         bit<32> dst_addr
35 }
36
37 struct udp_h {
38         bit<16> src_port
39         bit<16> dst_port
40         bit<16> length
41         bit<16> checksum
42 }
43
44 header ethernet instanceof ethernet_h
45 header ipv4 instanceof ipv4_h
46 header udp instanceof udp_h
47
48 //
49 // Meta-data.
50 //
51 struct metadata_t {
52         bit<32> port
53         bit<32> mirror_slot
54         bit<32> mirror_session
55 }
56
57 metadata instanceof metadata_t
58
59 //
60 // Pipeline.
61 //
62 apply {
63         rx m.port
64         extract h.ethernet
65         extract h.ipv4
66         extract h.udp
67
68         //
69         // Mark for mirroring all packets with UDP destination port of 5000.
70         //
71         MIRROR_UDP_DST_PORT_5000 : jmpneq EMIT h.udp.dst_port 5000
72         mov m.mirror_slot 0
73         mov m.mirror_session 0
74         mirror m.mirror_slot m.mirror_session
75
76         EMIT : emit h.ethernet
77         emit h.ipv4
78         emit h.udp
79         tx m.port
80 }