blob: 610975c51e2ce43b476708f95145bf1fae7225a9 [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"
24#include "include/control/port_counter.p4"
25#include "include/header.p4"
26#include "include/checksum.p4"
27#include "include/parser.p4"
28
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080029#ifdef WITH_SPGW
30#include "include/spgw.p4"
31#endif // WITH_SPGW
32
Carmelo Cascone04888222018-03-19 22:18:12 -070033#ifdef WITH_INT_TRANSIT
34#include "include/int_transit.p4"
35#endif // WITH_INT_TRANSIT
36
Yi Tsengbe342052017-11-03 10:21:23 -070037control FabricIngress (
38inout parsed_headers_t hdr,
39inout fabric_metadata_t fabric_metadata,
40inout standard_metadata_t standard_metadata) {
41 PacketIoIngress() packet_io_ingress;
42 Filtering() filtering;
43 Forwarding() forwarding;
44 Next() next;
45 PortCountersControl() port_counters_control;
Yi Tseng3a5731e2018-01-22 11:38:58 -080046 EgressNextControl() egress_next;
Yi Tsengbe342052017-11-03 10:21:23 -070047
48 apply {
49 packet_io_ingress.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080050#ifdef WITH_SPGW
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080051#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080052 fabric_metadata.spgw.l4_src_port = fabric_metadata.l4_src_port;
53 fabric_metadata.spgw.l4_dst_port = fabric_metadata.l4_dst_port;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080054#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080055 spgw_ingress.apply(hdr.gtpu_ipv4, hdr.gtpu_udp, hdr.gtpu,
Carmelo Casconeb757dbc2018-01-25 17:53:17 -080056 hdr.ipv4, hdr.udp, fabric_metadata.spgw);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080057#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -070058 filtering.apply(hdr, fabric_metadata, standard_metadata);
59 forwarding.apply(hdr, fabric_metadata, standard_metadata);
60 next.apply(hdr, fabric_metadata, standard_metadata);
61 port_counters_control.apply(hdr, fabric_metadata, standard_metadata);
Yi Tseng3a5731e2018-01-22 11:38:58 -080062 egress_next.apply(hdr, fabric_metadata, standard_metadata);
Yi Tsengbe342052017-11-03 10:21:23 -070063 }
64}
65
66control FabricEgress (inout parsed_headers_t hdr,
67 inout fabric_metadata_t fabric_metadata,
68 inout standard_metadata_t standard_metadata) {
Yi Tseng1d842672017-11-28 16:06:52 -080069 PacketIoEgress() pkt_io_egress;
Yi Tsengbe342052017-11-03 10:21:23 -070070 apply {
Yi Tseng1d842672017-11-28 16:06:52 -080071 pkt_io_egress.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone04888222018-03-19 22:18:12 -070072#ifdef WITH_INT_TRANSIT
73 int_egress.apply(hdr, fabric_metadata.int_metadata, standard_metadata);
74#endif // WITH_INT_TRANSIT
75 // gtpu encap needs to happen after INT to ensure length fields are set
76 // correctly
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080077#ifdef WITH_SPGW
Carmelo Cascone33e85c02018-02-01 13:30:18 -080078 spgw_egress.apply(hdr.ipv4, hdr.gtpu_ipv4, hdr.gtpu_udp, hdr.gtpu,
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080079 fabric_metadata.spgw, standard_metadata);
80#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -070081 }
82}
83
84V1Switch(
85 FabricParser(),
86 FabricVerifyChecksum(),
87 FabricIngress(),
88 FabricEgress(),
89 FabricComputeChecksum(),
90 FabricDeparser()
91) main;