Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 1 | #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 Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 9 | #include "include/packet_io.p4" |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 10 | |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 11 | control ingress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) { |
| 12 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 13 | 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 Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 30 | |
| 31 | PacketIoIngressControl() packet_io_ingress_control; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 32 | PortCountersControl() port_counters_control; |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 33 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 34 | apply { |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 35 | packet_io_ingress_control.apply(hdr, standard_metadata); |
| 36 | if (!hdr.packet_out.isValid()) { |
| 37 | table0.apply(); |
| 38 | } |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 39 | port_counters_control.apply(hdr, meta, standard_metadata); |
| 40 | } |
| 41 | |
| 42 | } |
| 43 | |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 44 | control egress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) { |
| 45 | |
| 46 | PacketIoEgressControl() packet_io_egress_control; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 47 | apply { |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 48 | packet_io_egress_control.apply(hdr, standard_metadata); |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 52 | V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; |