Carmelo Cascone | 9ab4061 | 2017-09-19 16:31:55 +0900 | [diff] [blame] | 1 | // Copyright (c) 2017, Google Inc. |
| 2 | // |
| 3 | // P4_16 specification for a ToR (top-of-rack) switch. |
| 4 | // Status: WORK IN PROGRESS |
| 5 | // Note: This code has not been tested and is expected to contain bugs. |
| 6 | |
| 7 | #include "parser.p4" |
| 8 | #include "class_id.p4" |
| 9 | #include "spoof_protection.p4" |
| 10 | #include "l3_fwd.p4" |
| 11 | #include "packetio.p4" |
| 12 | #include "punt.p4" |
| 13 | #include "vrf.p4" |
| 14 | #include "ipv4_checksum.p4" |
| 15 | |
| 16 | |
| 17 | control ingress_tor(inout parsed_packet_t hdr, |
| 18 | inout local_metadata_t local_metadata, |
| 19 | inout standard_metadata_t standard_metadata) { |
| 20 | apply { |
| 21 | if (hdr.packet_out.isValid()) { |
| 22 | packetio_ingress.apply(hdr, local_metadata, standard_metadata); |
| 23 | } |
| 24 | vrf.apply(hdr, local_metadata, standard_metadata); |
| 25 | class_id.apply(hdr, local_metadata, standard_metadata); |
| 26 | l3_fwd.apply(hdr, local_metadata, standard_metadata); |
| 27 | punt.apply(hdr, local_metadata, standard_metadata); |
| 28 | } |
| 29 | } // end ingress_tor |
| 30 | |
| 31 | control egress_tor(inout parsed_packet_t hdr, |
| 32 | inout local_metadata_t local_metadata, |
| 33 | inout standard_metadata_t standard_metadata) { |
| 34 | apply { |
| 35 | packetio_egress.apply(hdr, local_metadata, standard_metadata); |
| 36 | spoof_protection.apply(hdr, local_metadata, standard_metadata); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | V1Switch(pkt_parser(), verify_checksum(), ingress_tor(), egress_tor(), |
| 41 | compute_checksum(), pkt_deparser()) main; |