blob: 6b3e73edb184b49dba481529f2f660025c82486b [file] [log] [blame]
Yi Tseng21629932017-06-06 11:17:43 -07001#include <core.p4>
2#include <v1model.p4>
3#include "include/defines.p4"
4#include "include/headers.p4"
5#include "include/parsers.p4"
6#include "include/port_counters.p4"
7#include "include/checksums.p4"
8#include "include/actions.p4"
9
10
11control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
12 direct_counter(CounterType.packets) ecmp_group_table_counter;
13 direct_counter(CounterType.packets) table0_counter;
14
15 action ecmp_group(GroupId groupId, GroupSize groupSize) {
16 meta.ecmp_metadata.groupId = groupId;
17 hash(meta.ecmp_metadata.selector, HashAlgorithm.crc16, (bit<64>)0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, hdr.udp.srcPort, hdr.udp.dstPort }, (bit<128>)groupSize);
18 }
19
20 table ecmp_group_table {
21 actions = {
22 set_egress_port(standard_metadata);
23 }
24 key = {
25 meta.ecmp_metadata.groupId : exact;
26 meta.ecmp_metadata.selector: exact;
27 }
28 counters = ecmp_group_table_counter;
29 }
30
31 table table0 {
32 support_timeout = true;
33 actions = {
34 ecmp_group;
35 set_egress_port(standard_metadata);
36 send_to_cpu(standard_metadata);
37 drop(standard_metadata);
38 }
39 key = {
40 standard_metadata.ingress_port: ternary;
41 hdr.ethernet.dstAddr : ternary;
42 hdr.ethernet.srcAddr : ternary;
43 hdr.ethernet.etherType : ternary;
44 }
45 counters = table0_counter;
46 }
47 PortCountersControl() port_counters_control;
48 apply {
49 switch (table0.apply().action_run) {
50 ecmp_group: {
51 ecmp_group_table.apply();
52 }
53 }
54
55 port_counters_control.apply(hdr, meta, standard_metadata);
56 }
57}
58
59control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
60 apply {
61 // Nothing to do
62 }
63}
64
65V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;