blob: 508928c6f384fb33b74d0d155dbfcc2290e56401 [file] [log] [blame]
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -08001/*
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/* -*- P4_16 -*- */
18#include <core.p4>
19#include <v1model.p4>
20
21#include "include/defines.p4"
22#include "include/headers.p4"
23#include "include/actions.p4"
Jonghwan Hyun8be03392017-12-04 15:48:44 -080024#include "include/int_definitions.p4"
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080025#include "include/int_headers.p4"
26#include "include/packet_io.p4"
27#include "include/port_counters.p4"
28#include "include/table0.p4"
29#include "include/checksums.p4"
30#include "include/int_parser.p4"
31#include "include/int_source.p4"
32#include "include/int_transit.p4"
33#include "include/int_sink.p4"
Jonghwan Hyun6777d532018-11-18 20:50:16 +090034#include "include/int_report.p4"
35
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080036
Jonghwan Hyunf5d57822018-05-09 10:19:50 -070037control ingress (
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080038 inout headers_t hdr,
39 inout local_metadata_t local_metadata,
40 inout standard_metadata_t standard_metadata) {
41
42 apply {
43 port_counters_ingress.apply(hdr, standard_metadata);
44 packetio_ingress.apply(hdr, standard_metadata);
45 table0_control.apply(hdr, local_metadata, standard_metadata);
Jonghwan Hyunc235d462019-01-30 23:31:48 +090046 process_int_source_sink.apply(hdr, local_metadata, standard_metadata);
47
48 if (local_metadata.int_meta.source == _TRUE) {
49 process_int_source.apply(hdr, local_metadata, standard_metadata);
50 }
51
52 if (local_metadata.int_meta.sink == _TRUE && hdr.int_header.isValid()) {
Jonghwan Hyun6777d532018-11-18 20:50:16 +090053 // clone packet for Telemetry Report
54 // FIXME: this works only on BMv2
Jonghwan Hyunc235d462019-01-30 23:31:48 +090055 #ifdef TARGET_BMV2
56 clone3(CloneType.I2E, REPORT_MIRROR_SESSION_ID, standard_metadata);
57 #endif // TARGET_BMV2
Jonghwan Hyun6777d532018-11-18 20:50:16 +090058 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080059 }
60}
61
Jonghwan Hyunf5d57822018-05-09 10:19:50 -070062control egress (
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080063 inout headers_t hdr,
64 inout local_metadata_t local_metadata,
65 inout standard_metadata_t standard_metadata) {
66
67 apply {
Jonghwan Hyunc235d462019-01-30 23:31:48 +090068 if(hdr.int_header.isValid()) {
69 process_int_transit.apply(hdr, local_metadata, standard_metadata);
70
71 #ifdef TARGET_BMV2
72 if (IS_I2E_CLONE(standard_metadata)) {
73 /* send int report */
74 process_int_report.apply(hdr, local_metadata, standard_metadata);
Jonghwan Hyun8be03392017-12-04 15:48:44 -080075 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090076
77 if (local_metadata.int_meta.sink == _TRUE && !IS_I2E_CLONE(standard_metadata)) {
78 #else
79 if (local_metadata.int_meta.sink == _TRUE) {
80 #endif // TARGET_BMV2
81 process_int_sink.apply(hdr, local_metadata, standard_metadata);
82 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080083 }
84 port_counters_egress.apply(hdr, standard_metadata);
85 packetio_egress.apply(hdr, standard_metadata);
86 }
87}
88
89V1Switch(
90 int_parser(),
91 verify_checksum_control(),
Jonghwan Hyunf5d57822018-05-09 10:19:50 -070092 ingress(),
93 egress(),
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080094 compute_checksum_control(),
95 int_deparser()
Jonghwan Hyun6777d532018-11-18 20:50:16 +090096) main;