blob: 1bbfefda70ffef5a1b29f90d0545a8e1eda34c0d [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"
24#include "include/int_defines.p4"
25#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"
34
35control int_ingress (
36 inout headers_t hdr,
37 inout local_metadata_t local_metadata,
38 inout standard_metadata_t standard_metadata) {
39
40 apply {
41 port_counters_ingress.apply(hdr, standard_metadata);
42 packetio_ingress.apply(hdr, standard_metadata);
43 table0_control.apply(hdr, local_metadata, standard_metadata);
44 process_set_source_sink.apply(hdr, local_metadata, standard_metadata);
45 }
46}
47
48control int_egress (
49 inout headers_t hdr,
50 inout local_metadata_t local_metadata,
51 inout standard_metadata_t standard_metadata) {
52
53 apply {
54 if (standard_metadata.ingress_port != CPU_PORT &&
55 standard_metadata.egress_port != CPU_PORT &&
56 hdr.udp.isValid()) {
57 process_int_source.apply(hdr, local_metadata, standard_metadata);
58 if(hdr.udp.dst_port == INT_PORT) {
59 process_int_transit.apply(hdr, local_metadata, standard_metadata);
60 // update underlay header based on INT information inserted
61 process_int_outer_encap.apply(hdr, local_metadata, standard_metadata);
62 // int sink
63 process_int_sink.apply(hdr, local_metadata, standard_metadata);
64 }
65 }
66 port_counters_egress.apply(hdr, standard_metadata);
67 packetio_egress.apply(hdr, standard_metadata);
68 }
69}
70
71V1Switch(
72 int_parser(),
73 verify_checksum_control(),
74 int_ingress(),
75 int_egress(),
76 compute_checksum_control(),
77 int_deparser()
78) main;