pipeline: auto-detect endianness of action arguments
[dpdk.git] / examples / pipeline / examples / meter.spec
1 ; SPDX-License-Identifier: BSD-3-Clause
2 ; Copyright(c) 2021 Intel Corporation
3
4 ; This program is setting up an array of Two Rate Three Color Marker (trTCM) meters called "meters".
5 ; Every input packet (Ethernet/IPv4) is metered by the meter at the location indexed by the IPv4
6 ; header "Source Address" field. All green packets are sent out on port 0, the yellow ones on port 1
7 ; and the red ones on port 2.
8 ;
9 ; The "meter stats" CLI command can be used to read the packet and byte statistics counters of any
10 ; meter in the array.
11
12 //
13 // Headers.
14 //
15 struct ethernet_h {
16         bit<48> dst_addr
17         bit<48> src_addr
18         bit<16> ethertype
19 }
20
21 struct ipv4_h {
22         bit<8> ver_ihl
23         bit<8> diffserv
24         bit<16> total_len
25         bit<16> identification
26         bit<16> flags_offset
27         bit<8> ttl
28         bit<8> protocol
29         bit<16> hdr_checksum
30         bit<32> src_addr
31         bit<32> dst_addr
32 }
33
34 header ethernet instanceof ethernet_h
35 header ipv4 instanceof ipv4_h
36
37 //
38 // Meta-data.
39 //
40 struct metadata_t {
41         bit<32> port_in
42         bit<32> port_out
43 }
44
45 metadata instanceof metadata_t
46
47 //
48 // Registers.
49 //
50 metarray meters size 65536
51
52 //
53 // Pipeline.
54 //
55 apply {
56         rx m.port_in
57         extract h.ethernet
58         extract h.ipv4
59         meter meters h.ipv4.src_addr h.ipv4.total_len 0 m.port_out
60         emit h.ethernet
61         emit h.ipv4
62         tx m.port_out
63 }