blob: 0aee32b0fbd7bfb8fd5f29e709d6a68f0ed9be29 [file] [log] [blame]
Yi Tsengbe342052017-11-03 10:21:23 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <core.p4>
18#include <v1model.p4>
19
20#include "include/control/filtering.p4"
21#include "include/control/forwarding.p4"
22#include "include/control/next.p4"
23#include "include/control/packetio.p4"
Yi Tsengbe342052017-11-03 10:21:23 -070024#include "include/header.p4"
25#include "include/checksum.p4"
26#include "include/parser.p4"
27
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070028#ifdef WITH_PORT_COUNTER
29#include "include/control/port_counter.p4"
30#endif // WITH_PORT_COUNTER
31
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080032#ifdef WITH_SPGW
33#include "include/spgw.p4"
34#endif // WITH_SPGW
35
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090036#ifdef WITH_INT
Carmelo Cascone79a3a312018-08-16 17:14:43 -070037#include "include/int/int_main.p4"
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090038#endif // WITH_INT
39
Yi Tsengbe342052017-11-03 10:21:23 -070040control FabricIngress (
41inout parsed_headers_t hdr,
42inout fabric_metadata_t fabric_metadata,
43inout standard_metadata_t standard_metadata) {
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -070044 PacketIoIngress() pkt_io_ingress;
Yi Tsengbe342052017-11-03 10:21:23 -070045 Filtering() filtering;
46 Forwarding() forwarding;
47 Next() next;
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070048#ifdef WITH_PORT_COUNTER
Yi Tsengbe342052017-11-03 10:21:23 -070049 PortCountersControl() port_counters_control;
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070050#endif // WITH_PORT_COUNTER
Yi Tsengbe342052017-11-03 10:21:23 -070051
52 apply {
Carmelo Cascone9b0171b2018-08-14 01:43:57 -070053#ifdef WITH_SPGW
54 spgw_normalizer.apply(hdr.gtpu.isValid(), hdr.gtpu_ipv4, hdr.gtpu_udp,
55 hdr.ipv4, hdr.udp, hdr.inner_ipv4, hdr.inner_udp);
56#endif // WITH_SPGW
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -070057 pkt_io_ingress.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080058#ifdef WITH_SPGW
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080059#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080060 fabric_metadata.spgw.l4_src_port = fabric_metadata.l4_src_port;
61 fabric_metadata.spgw.l4_dst_port = fabric_metadata.l4_dst_port;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080062#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080063 spgw_ingress.apply(hdr.gtpu_ipv4, hdr.gtpu_udp, hdr.gtpu,
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080064 hdr.ipv4, hdr.udp, fabric_metadata.spgw);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080065#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -070066 filtering.apply(hdr, fabric_metadata, standard_metadata);
67 forwarding.apply(hdr, fabric_metadata, standard_metadata);
68 next.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070069#ifdef WITH_PORT_COUNTER
Carmelo Cascone79a3a312018-08-16 17:14:43 -070070 // FIXME: we're not counting pkts punted to cpu or forwarded via multicast groups.
Yi Tsengbe342052017-11-03 10:21:23 -070071 port_counters_control.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070072#endif // WITH_PORT_COUNTER
Carmelo Cascone79a3a312018-08-16 17:14:43 -070073#if defined(WITH_INT_SOURCE) || defined(WITH_INT_SINK)
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090074 process_set_source_sink.apply(hdr, fabric_metadata, standard_metadata);
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090075#endif
Yi Tsengbe342052017-11-03 10:21:23 -070076 }
77}
78
79control FabricEgress (inout parsed_headers_t hdr,
80 inout fabric_metadata_t fabric_metadata,
81 inout standard_metadata_t standard_metadata) {
Yi Tseng1d842672017-11-28 16:06:52 -080082 PacketIoEgress() pkt_io_egress;
Yi Tseng20f9e7b2018-05-24 23:27:39 +080083 EgressNextControl() egress_next;
84
Yi Tsengbe342052017-11-03 10:21:23 -070085 apply {
Yi Tseng1d842672017-11-28 16:06:52 -080086 pkt_io_egress.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -070087 egress_next.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080088#ifdef WITH_SPGW
Carmelo Cascone33e85c02018-02-01 13:30:18 -080089 spgw_egress.apply(hdr.ipv4, hdr.gtpu_ipv4, hdr.gtpu_udp, hdr.gtpu,
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080090 fabric_metadata.spgw, standard_metadata);
91#endif // WITH_SPGW
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090092#ifdef WITH_INT
Carmelo Cascone79a3a312018-08-16 17:14:43 -070093 process_int_main.apply(hdr, fabric_metadata, standard_metadata);
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090094#endif
Yi Tsengbe342052017-11-03 10:21:23 -070095 }
96}
97
98V1Switch(
99 FabricParser(),
100 FabricVerifyChecksum(),
101 FabricIngress(),
102 FabricEgress(),
103 FabricComputeChecksum(),
104 FabricDeparser()
105) main;