event/cnxk: fix clang build on Arm
[dpdk.git] / examples / pipeline / examples / registers.spec
1 ; SPDX-License-Identifier: BSD-3-Clause
2 ; Copyright(c) 2021 Intel Corporation
3
4 ; This program is setting up two register arrays called "pkt_counters" and "byte_counters".
5 ; On every input packet (Ethernet/IPv4), the "pkt_counters" register at location indexed by
6 ; the IPv4 header "Source Address" field is incremented, while the same location in the
7 ; "byte_counters" array accummulates the value of the IPv4 header "Total Length" field.
8 ;
9 ; The "regrd" and "regwr" CLI commands can be used to read and write the current value of
10 ; any register array location.
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 regarray pkt_counters size 65536 initval 0
51 regarray byte_counters size 65536 initval 0
52
53 //
54 // Pipeline.
55 //
56 apply {
57         rx m.port_in
58         extract h.ethernet
59         extract h.ipv4
60         regadd pkt_counters h.ipv4.src_addr 1
61         regadd byte_counters h.ipv4.src_addr h.ipv4.total_len
62         mov m.port_out m.port_in
63         xor m.port_out 1
64         emit h.ethernet
65         emit h.ipv4
66         tx m.port_out
67 }