blob: 95af85f012bba452d3e27b126ab434eb24f74faf [file] [log] [blame]
Carmelo Cascone4f011022017-06-05 01:41:02 -04001#include "include/defines.p4"
2#include "include/headers.p4"
3#include "include/parser.p4"
4#include "include/actions.p4"
5#include "include/port_counters.p4"
6
7header_type ecmp_metadata_t {
8 fields {
9 groupId : 16;
10 selector : 16;
11 }
12}
13
14metadata ecmp_metadata_t ecmp_metadata;
15
16field_list ecmp_hash_fields {
17 ipv4.srcAddr;
18 ipv4.dstAddr;
19 ipv4.protocol;
20 tcp.srcPort;
21 tcp.dstPort;
22 udp.srcPort;
23 udp.dstPort;
24}
25
26field_list_calculation ecmp_hash {
27 input {
28 ecmp_hash_fields;
29 }
30 algorithm : bmv2_hash;
31 output_width : 64;
32}
33
34action ecmp_group(groupId, groupSize) {
35 modify_field(ecmp_metadata.groupId, groupId);
36 modify_field_with_hash_based_offset(ecmp_metadata.selector, 0, ecmp_hash, groupSize);
37}
38
39table table0 {
40 reads {
41 standard_metadata.ingress_port : ternary;
42 ethernet.dstAddr : ternary;
43 ethernet.srcAddr : ternary;
44 ethernet.etherType : ternary;
45 }
46 actions {
47 set_egress_port;
48 ecmp_group;
49 send_to_cpu;
50 _drop;
51 }
52 support_timeout: true;
53}
54
55table ecmp_group_table {
56 reads {
57 ecmp_metadata.groupId : exact;
58 ecmp_metadata.selector : exact;
59 }
60 actions {
61 set_egress_port;
62 }
63}
64
65counter table0_counter {
66 type: packets;
67 direct: table0;
68 min_width : 32;
69}
70
71counter ecmp_group_table_counter {
72 type: packets;
73 direct: ecmp_group_table;
74 min_width : 32;
75}
76
77control ingress {
78 apply(table0) {
79 ecmp_group {
80 apply(ecmp_group_table);
81 }
82 }
83 process_port_counters();
84}