blob: bb6ff7c21fdabc51c354f021425eea2f016d748f [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
Carmelo Cascone70e816b2019-03-19 16:15:47 -070020#include "include/size.p4"
Yi Tsengbe342052017-11-03 10:21:23 -070021#include "include/control/filtering.p4"
22#include "include/control/forwarding.p4"
Wailok Shumfb7e7872021-06-18 17:30:08 +080023#include "include/control/pre_next.p4"
Carmelo Casconeb5324e72018-11-25 02:26:32 -080024#include "include/control/acl.p4"
Yi Tsengbe342052017-11-03 10:21:23 -070025#include "include/control/next.p4"
26#include "include/control/packetio.p4"
Daniele Moro08c9e7f2021-07-28 18:53:34 +020027#include "include/control/lookup_md_init.p4"
28#include "include/control/slicing.p4"
Yi Tsengbe342052017-11-03 10:21:23 -070029#include "include/header.p4"
30#include "include/checksum.p4"
31#include "include/parser.p4"
32
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070033#ifdef WITH_PORT_COUNTER
34#include "include/control/port_counter.p4"
35#endif // WITH_PORT_COUNTER
36
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080037#ifdef WITH_SPGW
Robert MacDavidde12b982020-07-15 18:38:59 -070038#include "include/control/spgw.p4"
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080039#endif // WITH_SPGW
40
Carmelo Cascone4d8785b2019-05-31 17:11:26 -070041#ifdef WITH_BNG
42#include "include/bng.p4"
43#endif // WITH_BNG
44
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090045#ifdef WITH_INT
Carmelo Cascone79a3a312018-08-16 17:14:43 -070046#include "include/int/int_main.p4"
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090047#endif // WITH_INT
48
Carmelo Casconeb5324e72018-11-25 02:26:32 -080049control FabricIngress (inout parsed_headers_t hdr,
50 inout fabric_metadata_t fabric_metadata,
51 inout standard_metadata_t standard_metadata) {
52
Daniele Moro08c9e7f2021-07-28 18:53:34 +020053 LookupMdInit() lkp_md_init;
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -070054 PacketIoIngress() pkt_io_ingress;
Yi Tsengbe342052017-11-03 10:21:23 -070055 Filtering() filtering;
56 Forwarding() forwarding;
Wailok Shumfb7e7872021-06-18 17:30:08 +080057 PreNext() pre_next;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080058 Acl() acl;
Yi Tsengbe342052017-11-03 10:21:23 -070059 Next() next;
Daniele Moro08c9e7f2021-07-28 18:53:34 +020060 IngressSliceTcClassifier() slice_tc_classifier;
61 IngressQos() qos;
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070062#ifdef WITH_PORT_COUNTER
Yi Tsengbe342052017-11-03 10:21:23 -070063 PortCountersControl() port_counters_control;
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070064#endif // WITH_PORT_COUNTER
Robert MacDavidde12b982020-07-15 18:38:59 -070065#ifdef WITH_SPGW
Carmelo Cascone2102bfb2020-12-04 16:54:24 -080066 SpgwIngress() spgw;
Robert MacDavidde12b982020-07-15 18:38:59 -070067#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -070068
69 apply {
Carmelo Casconefa421582018-09-13 10:05:57 -070070 _PRE_INGRESS
Daniele Moro08c9e7f2021-07-28 18:53:34 +020071 lkp_md_init.apply(hdr, fabric_metadata.lkp);
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -070072 pkt_io_ingress.apply(hdr, fabric_metadata, standard_metadata);
Daniele Moro08c9e7f2021-07-28 18:53:34 +020073 slice_tc_classifier.apply(hdr, fabric_metadata, standard_metadata);
Robert MacDavidde12b982020-07-15 18:38:59 -070074 filtering.apply(hdr, fabric_metadata, standard_metadata);
Daniele Moro08c9e7f2021-07-28 18:53:34 +020075#ifdef WITH_SPGW
76 if (fabric_metadata.skip_forwarding == _FALSE) {
77 spgw.apply(hdr, fabric_metadata, standard_metadata);
78 }
79#endif // WITH_SPGW
Carmelo Casconeb5324e72018-11-25 02:26:32 -080080 if (fabric_metadata.skip_forwarding == _FALSE) {
81 forwarding.apply(hdr, fabric_metadata, standard_metadata);
82 }
Wailok Shumfb7e7872021-06-18 17:30:08 +080083 if (fabric_metadata.skip_next == _FALSE) {
84 pre_next.apply(hdr, fabric_metadata);
85 }
Carmelo Casconeb5324e72018-11-25 02:26:32 -080086 acl.apply(hdr, fabric_metadata, standard_metadata);
87 if (fabric_metadata.skip_next == _FALSE) {
88 next.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070089#ifdef WITH_PORT_COUNTER
Carmelo Casconeb5324e72018-11-25 02:26:32 -080090 // FIXME: we're not counting pkts punted to cpu or forwarded via
91 // multicast groups. Remove when gNMI support will be there.
92 port_counters_control.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -070093#endif // WITH_PORT_COUNTER
Carmelo Cascone79a3a312018-08-16 17:14:43 -070094#if defined(WITH_INT_SOURCE) || defined(WITH_INT_SINK)
Carmelo Casconeb5324e72018-11-25 02:26:32 -080095 process_set_source_sink.apply(hdr, fabric_metadata, standard_metadata);
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090096#endif
Carmelo Casconeb5324e72018-11-25 02:26:32 -080097 }
Daniele Moro7c3a0022019-07-12 13:38:34 -070098#ifdef WITH_BNG
99 bng_ingress.apply(hdr, fabric_metadata, standard_metadata);
100#endif // WITH_BNG
Daniele Moro08c9e7f2021-07-28 18:53:34 +0200101 qos.apply(fabric_metadata, standard_metadata);
Yi Tsengbe342052017-11-03 10:21:23 -0700102 }
103}
104
105control FabricEgress (inout parsed_headers_t hdr,
106 inout fabric_metadata_t fabric_metadata,
107 inout standard_metadata_t standard_metadata) {
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800108
Yi Tseng1d842672017-11-28 16:06:52 -0800109 PacketIoEgress() pkt_io_egress;
Yi Tseng20f9e7b2018-05-24 23:27:39 +0800110 EgressNextControl() egress_next;
Daniele Moro08c9e7f2021-07-28 18:53:34 +0200111 EgressDscpRewriter() dscp_rewriter;
Robert MacDavidde12b982020-07-15 18:38:59 -0700112#ifdef WITH_SPGW
Carmelo Cascone2102bfb2020-12-04 16:54:24 -0800113 SpgwEgress() spgw;
Robert MacDavidde12b982020-07-15 18:38:59 -0700114#endif // WITH_SPGW
Yi Tseng20f9e7b2018-05-24 23:27:39 +0800115
Yi Tsengbe342052017-11-03 10:21:23 -0700116 apply {
Carmelo Casconefa421582018-09-13 10:05:57 -0700117 _PRE_EGRESS
Yi Tseng1d842672017-11-28 16:06:52 -0800118 pkt_io_egress.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -0700119 egress_next.apply(hdr, fabric_metadata, standard_metadata);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800120#ifdef WITH_SPGW
Carmelo Cascone2102bfb2020-12-04 16:54:24 -0800121 spgw.apply(hdr, fabric_metadata);
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800122#endif // WITH_SPGW
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700123#ifdef WITH_BNG
124 bng_egress.apply(hdr, fabric_metadata, standard_metadata);
125#endif // WITH_BNG
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900126#ifdef WITH_INT
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700127 process_int_main.apply(hdr, fabric_metadata, standard_metadata);
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900128#endif
Daniele Moro08c9e7f2021-07-28 18:53:34 +0200129 dscp_rewriter.apply(hdr, fabric_metadata, standard_metadata);
Yi Tsengbe342052017-11-03 10:21:23 -0700130 }
131}
132
133V1Switch(
134 FabricParser(),
135 FabricVerifyChecksum(),
136 FabricIngress(),
137 FabricEgress(),
138 FabricComputeChecksum(),
139 FabricDeparser()
140) main;