blob: 13243b2bbb0834c99f8e793a2f45f6d6b047bc8a [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;
14
15 table table0 {
16 support_timeout = true;
17 actions = {
18 set_egress_port(standard_metadata);
19 send_to_cpu(standard_metadata);
20 drop(standard_metadata);
21 }
22 key = {
23 standard_metadata.ingress_port: ternary;
24 hdr.ethernet.dstAddr : ternary;
25 hdr.ethernet.srcAddr : ternary;
26 hdr.ethernet.etherType : ternary;
27 }
28 counters = table0_counter;
29 }
Carmelo Cascone837e6452017-07-19 20:35:22 -040030
31 PacketIoIngressControl() packet_io_ingress_control;
Yi Tseng21629932017-06-06 11:17:43 -070032 PortCountersControl() port_counters_control;
Carmelo Cascone837e6452017-07-19 20:35:22 -040033
Yi Tseng21629932017-06-06 11:17:43 -070034 apply {
Carmelo Cascone837e6452017-07-19 20:35:22 -040035 packet_io_ingress_control.apply(hdr, standard_metadata);
36 if (!hdr.packet_out.isValid()) {
37 table0.apply();
38 }
Yi Tseng21629932017-06-06 11:17:43 -070039 port_counters_control.apply(hdr, meta, standard_metadata);
40 }
41
42}
43
Carmelo Cascone837e6452017-07-19 20:35:22 -040044control egress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
45
46 PacketIoEgressControl() packet_io_egress_control;
Yi Tseng21629932017-06-06 11:17:43 -070047 apply {
Carmelo Cascone837e6452017-07-19 20:35:22 -040048 packet_io_egress_control.apply(hdr, standard_metadata);
Yi Tseng21629932017-06-06 11:17:43 -070049 }
50}
51
Yi Tseng21629932017-06-06 11:17:43 -070052V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;