blob: 2bee27fe4e232bc7081526dc54adf50963bcf6c5 [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"
Carmelo Cascone837e6452017-07-19 20:35:22 -04009#include "include/packet_io.p4"
Yi Tseng21629932017-06-06 11:17:43 -070010
Carmelo Cascone837e6452017-07-19 20:35:22 -040011control ingress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
12
Yi Tseng21629932017-06-06 11:17:43 -070013 direct_counter(CounterType.packets) table0_counter;
Carmelo Casconeb2e3dba2017-07-27 12:07:09 -040014 action_selector(HashAlgorithm.crc16, 32w64, 32w16) ecmp_selector;
Yi Tseng21629932017-06-06 11:17:43 -070015
16 table table0 {
17 support_timeout = true;
Carmelo Casconeb2e3dba2017-07-27 12:07:09 -040018 key = {
19 standard_metadata.ingress_port : ternary;
20 hdr.ethernet.dstAddr : ternary;
21 hdr.ethernet.srcAddr : ternary;
22 hdr.ethernet.etherType : ternary;
23 // Not for matching.
24 // Inputs to the hash function of the action selector.
25 hdr.ipv4.srcAddr : selector;
26 hdr.ipv4.dstAddr : selector;
27 hdr.ipv4.protocol : selector;
28 hdr.tcp.srcPort : selector;
29 hdr.tcp.dstPort : selector;
30 hdr.udp.srcPort : selector;
31 hdr.udp.dstPort : selector;
32 }
Yi Tseng21629932017-06-06 11:17:43 -070033 actions = {
34 set_egress_port(standard_metadata);
35 send_to_cpu(standard_metadata);
36 drop(standard_metadata);
37 }
Yi Tseng21629932017-06-06 11:17:43 -070038 counters = table0_counter;
Carmelo Casconeb2e3dba2017-07-27 12:07:09 -040039 implementation = ecmp_selector;
Yi Tseng21629932017-06-06 11:17:43 -070040 }
Carmelo Cascone837e6452017-07-19 20:35:22 -040041
42 PacketIoIngressControl() packet_io_ingress_control;
Yi Tseng21629932017-06-06 11:17:43 -070043 PortCountersControl() port_counters_control;
Carmelo Cascone837e6452017-07-19 20:35:22 -040044
Yi Tseng21629932017-06-06 11:17:43 -070045 apply {
Carmelo Cascone837e6452017-07-19 20:35:22 -040046 packet_io_ingress_control.apply(hdr, standard_metadata);
47 if (!hdr.packet_out.isValid()) {
48 table0.apply();
49 }
Yi Tseng21629932017-06-06 11:17:43 -070050 port_counters_control.apply(hdr, meta, standard_metadata);
51 }
52
53}
54
Carmelo Cascone837e6452017-07-19 20:35:22 -040055control egress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
56
57 PacketIoEgressControl() packet_io_egress_control;
Yi Tseng21629932017-06-06 11:17:43 -070058 apply {
Carmelo Cascone837e6452017-07-19 20:35:22 -040059 packet_io_egress_control.apply(hdr, standard_metadata);
Yi Tseng21629932017-06-06 11:17:43 -070060 }
61}
62
Yi Tseng21629932017-06-06 11:17:43 -070063V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;