blob: ad7d8d3d2f5f6650b371d9b61e923ba38413f580 [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#ifndef __INT_TRANSIT__
19#define __INT_TRANSIT__
20control process_int_transit (
21 inout headers_t hdr,
22 inout local_metadata_t local_metadata,
23 inout standard_metadata_t standard_metadata) {
24
Jonghwan Hyunc235d462019-01-30 23:31:48 +090025 action init_metadata(switch_id_t switch_id) {
26 local_metadata.int_meta.transit = _TRUE;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080027 local_metadata.int_meta.switch_id = switch_id;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080028 }
29
Jonghwan Hyunc235d462019-01-30 23:31:48 +090030 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080031 action int_set_header_0() { //switch_id
32 hdr.int_switch_id.setValid();
33 hdr.int_switch_id.switch_id = local_metadata.int_meta.switch_id;
34 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090035 @hidden
36 action int_set_header_1() { //level1_port_id
37 hdr.int_level1_port_ids.setValid();
38 hdr.int_level1_port_ids.ingress_port_id = (bit<16>) standard_metadata.ingress_port;
39 hdr.int_level1_port_ids.egress_port_id = (bit<16>) standard_metadata.egress_port;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080040 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090041 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080042 action int_set_header_2() { //hop_latency
43 hdr.int_hop_latency.setValid();
Jonghwan Hyunc235d462019-01-30 23:31:48 +090044 hdr.int_hop_latency.hop_latency = (bit<32>) standard_metadata.egress_global_timestamp - (bit<32>) standard_metadata.ingress_global_timestamp;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080045 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090046 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080047 action int_set_header_3() { //q_occupancy
48 // TODO: Support egress queue ID
49 hdr.int_q_occupancy.setValid();
50 hdr.int_q_occupancy.q_id =
51 0;
52 // (bit<8>) standard_metadata.egress_qid;
53 hdr.int_q_occupancy.q_occupancy =
54 (bit<24>) standard_metadata.deq_qdepth;
55 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090056 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080057 action int_set_header_4() { //ingress_tstamp
58 hdr.int_ingress_tstamp.setValid();
59 hdr.int_ingress_tstamp.ingress_tstamp =
Jonghwan Hyunc235d462019-01-30 23:31:48 +090060 (bit<32>) standard_metadata.ingress_global_timestamp;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080061 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090062 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080063 action int_set_header_5() { //egress_timestamp
64 hdr.int_egress_tstamp.setValid();
65 hdr.int_egress_tstamp.egress_tstamp =
Jonghwan Hyunc235d462019-01-30 23:31:48 +090066 (bit<32>) standard_metadata.egress_global_timestamp;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080067 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090068 @hidden
69 action int_set_header_6() { //level2_port_id
70 hdr.int_level2_port_ids.setValid();
71 // level2_port_id indicates Logical port ID
72 hdr.int_level2_port_ids.ingress_port_id = (bit<32>) standard_metadata.ingress_port;
73 hdr.int_level2_port_ids.egress_port_id = (bit<32>) standard_metadata.egress_port;
74 }
75 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080076 action int_set_header_7() { //egress_port_tx_utilization
77 // TODO: implement tx utilization support in BMv2
78 hdr.int_egress_tx_util.setValid();
79 hdr.int_egress_tx_util.egress_port_tx_util =
80 // (bit<32>) queueing_metadata.tx_utilization;
81 0;
82 }
83
Jonghwan Hyunc235d462019-01-30 23:31:48 +090084 // Actions to keep track of the new metadata added.
85 @hidden
86 action add_1() {
87 local_metadata.int_meta.new_words = local_metadata.int_meta.new_words + 1;
88 local_metadata.int_meta.new_bytes = local_metadata.int_meta.new_bytes + 4;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080089 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +090090
91 @hidden
92 action add_2() {
93 local_metadata.int_meta.new_words = local_metadata.int_meta.new_words + 2;
94 local_metadata.int_meta.new_bytes = local_metadata.int_meta.new_bytes + 8;
95 }
96
97 @hidden
98 action add_3() {
99 local_metadata.int_meta.new_words = local_metadata.int_meta.new_words + 3;
100 local_metadata.int_meta.new_bytes = local_metadata.int_meta.new_bytes + 12;
101 }
102
103 @hidden
104 action add_4() {
105 local_metadata.int_meta.new_words = local_metadata.int_meta.new_words + 4;
106 local_metadata.int_meta.new_bytes = local_metadata.int_meta.new_bytes + 16;
107 }
108
109 @hidden
110 action add_5() {
111 local_metadata.int_meta.new_words = local_metadata.int_meta.new_words + 5;
112 local_metadata.int_meta.new_bytes = local_metadata.int_meta.new_bytes + 20;
113 }
114
115 /* action function for bits 0-3 combinations, 0 is msb, 3 is lsb */
116 /* Each bit set indicates that corresponding INT header should be added */
117 @hidden
118 action int_set_header_0003_i0() {
119 }
120 @hidden
121 action int_set_header_0003_i1() {
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800122 int_set_header_3();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900123 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800124 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900125 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800126 action int_set_header_0003_i2() {
127 int_set_header_2();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900128 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800129 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900130 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800131 action int_set_header_0003_i3() {
132 int_set_header_3();
133 int_set_header_2();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900134 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800135 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900136 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800137 action int_set_header_0003_i4() {
138 int_set_header_1();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900139 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800140 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900141 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800142 action int_set_header_0003_i5() {
143 int_set_header_3();
144 int_set_header_1();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900145 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800146 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900147 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800148 action int_set_header_0003_i6() {
149 int_set_header_2();
150 int_set_header_1();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900151 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800152 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900153 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800154 action int_set_header_0003_i7() {
155 int_set_header_3();
156 int_set_header_2();
157 int_set_header_1();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900158 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800159 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900160 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800161 action int_set_header_0003_i8() {
162 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900163 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800164 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900165 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800166 action int_set_header_0003_i9() {
167 int_set_header_3();
168 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900169 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800170 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900171 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800172 action int_set_header_0003_i10() {
173 int_set_header_2();
174 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900175 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800176 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900177 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800178 action int_set_header_0003_i11() {
179 int_set_header_3();
180 int_set_header_2();
181 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900182 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800183 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900184 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800185 action int_set_header_0003_i12() {
186 int_set_header_1();
187 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900188 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800189 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900190 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800191 action int_set_header_0003_i13() {
192 int_set_header_3();
193 int_set_header_1();
194 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900195 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800196 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900197 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800198 action int_set_header_0003_i14() {
199 int_set_header_2();
200 int_set_header_1();
201 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900202 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800203 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900204 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800205 action int_set_header_0003_i15() {
206 int_set_header_3();
207 int_set_header_2();
208 int_set_header_1();
209 int_set_header_0();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900210 add_4();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800211 }
212
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900213 /* action function for bits 4-7 combinations, 4 is msb, 7 is lsb */
214 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800215 action int_set_header_0407_i0() {
216 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900217 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800218 action int_set_header_0407_i1() {
219 int_set_header_7();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900220 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800221 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900222 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800223 action int_set_header_0407_i2() {
224 int_set_header_6();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900225 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800226 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900227 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800228 action int_set_header_0407_i3() {
229 int_set_header_7();
230 int_set_header_6();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900231 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800232 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900233 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800234 action int_set_header_0407_i4() {
235 int_set_header_5();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900236 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800237 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900238 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800239 action int_set_header_0407_i5() {
240 int_set_header_7();
241 int_set_header_5();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900242 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800243 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900244 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800245 action int_set_header_0407_i6() {
246 int_set_header_6();
247 int_set_header_5();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900248 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800249 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900250 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800251 action int_set_header_0407_i7() {
252 int_set_header_7();
253 int_set_header_6();
254 int_set_header_5();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900255 add_4();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800256 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900257 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800258 action int_set_header_0407_i8() {
259 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900260 add_1();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800261 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900262 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800263 action int_set_header_0407_i9() {
264 int_set_header_7();
265 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900266 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800267 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900268 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800269 action int_set_header_0407_i10() {
270 int_set_header_6();
271 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900272 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800273 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900274 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800275 action int_set_header_0407_i11() {
276 int_set_header_7();
277 int_set_header_6();
278 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900279 add_4();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800280 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900281 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800282 action int_set_header_0407_i12() {
283 int_set_header_5();
284 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900285 add_2();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800286 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900287 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800288 action int_set_header_0407_i13() {
289 int_set_header_7();
290 int_set_header_5();
291 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900292 add_3();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800293 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900294 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800295 action int_set_header_0407_i14() {
296 int_set_header_6();
297 int_set_header_5();
298 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900299 add_4();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800300 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900301 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800302 action int_set_header_0407_i15() {
303 int_set_header_7();
304 int_set_header_6();
305 int_set_header_5();
306 int_set_header_4();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900307 add_5();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800308 }
309
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900310 // Default action used to set switch ID.
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800311 table tb_int_insert {
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900312 // We don't really need a key here, however we add a dummy one as a
313 // workaround to ONOS inability to properly support default actions.
314 key = {
315 hdr.int_header.isValid(): exact @name("int_is_valid");
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800316 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900317 actions = {
318 init_metadata;
319 @defaultonly nop;
320 }
321 const default_action = nop();
322 size = 1;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800323 }
324
325 /* Table to process instruction bits 0-3 */
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900326 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800327 table tb_int_inst_0003 {
328 key = {
329 hdr.int_header.instruction_mask_0003 : exact;
330 }
331 actions = {
332 int_set_header_0003_i0;
333 int_set_header_0003_i1;
334 int_set_header_0003_i2;
335 int_set_header_0003_i3;
336 int_set_header_0003_i4;
337 int_set_header_0003_i5;
338 int_set_header_0003_i6;
339 int_set_header_0003_i7;
340 int_set_header_0003_i8;
341 int_set_header_0003_i9;
342 int_set_header_0003_i10;
343 int_set_header_0003_i11;
344 int_set_header_0003_i12;
345 int_set_header_0003_i13;
346 int_set_header_0003_i14;
347 int_set_header_0003_i15;
348 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900349 const entries = {
350 (0x0) : int_set_header_0003_i0();
351 (0x1) : int_set_header_0003_i1();
352 (0x2) : int_set_header_0003_i2();
353 (0x3) : int_set_header_0003_i3();
354 (0x4) : int_set_header_0003_i4();
355 (0x5) : int_set_header_0003_i5();
356 (0x6) : int_set_header_0003_i6();
357 (0x7) : int_set_header_0003_i7();
358 (0x8) : int_set_header_0003_i8();
359 (0x9) : int_set_header_0003_i9();
360 (0xA) : int_set_header_0003_i10();
361 (0xB) : int_set_header_0003_i11();
362 (0xC) : int_set_header_0003_i12();
363 (0xD) : int_set_header_0003_i13();
364 (0xE) : int_set_header_0003_i14();
365 (0xF) : int_set_header_0003_i15();
366 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800367 }
368
369 /* Table to process instruction bits 4-7 */
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900370 @hidden
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800371 table tb_int_inst_0407 {
372 key = {
373 hdr.int_header.instruction_mask_0407 : exact;
374 }
375 actions = {
376 int_set_header_0407_i0;
377 int_set_header_0407_i1;
378 int_set_header_0407_i2;
379 int_set_header_0407_i3;
380 int_set_header_0407_i4;
381 int_set_header_0407_i5;
382 int_set_header_0407_i6;
383 int_set_header_0407_i7;
384 int_set_header_0407_i8;
385 int_set_header_0407_i9;
386 int_set_header_0407_i10;
387 int_set_header_0407_i11;
388 int_set_header_0407_i12;
389 int_set_header_0407_i13;
390 int_set_header_0407_i14;
391 int_set_header_0407_i15;
392 }
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900393 const entries = {
394 (0x0) : int_set_header_0407_i0();
395 (0x1) : int_set_header_0407_i1();
396 (0x2) : int_set_header_0407_i2();
397 (0x3) : int_set_header_0407_i3();
398 (0x4) : int_set_header_0407_i4();
399 (0x5) : int_set_header_0407_i5();
400 (0x6) : int_set_header_0407_i6();
401 (0x7) : int_set_header_0407_i7();
402 (0x8) : int_set_header_0407_i8();
403 (0x9) : int_set_header_0407_i9();
404 (0xA) : int_set_header_0407_i10();
405 (0xB) : int_set_header_0407_i11();
406 (0xC) : int_set_header_0407_i12();
407 (0xD) : int_set_header_0407_i13();
408 (0xE) : int_set_header_0407_i14();
409 (0xF) : int_set_header_0407_i15();
410 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800411 }
412
413 apply {
414 tb_int_insert.apply();
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900415 if (local_metadata.int_meta.transit == _FALSE) {
416 return;
417 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800418 tb_int_inst_0003.apply();
419 tb_int_inst_0407.apply();
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800420
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900421 // Decrement remaining hop cnt
422 hdr.int_header.remaining_hop_cnt = hdr.int_header.remaining_hop_cnt - 1;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800423
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900424 // Update headers lengths.
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800425 if (hdr.ipv4.isValid()) {
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900426 hdr.ipv4.len = hdr.ipv4.len + local_metadata.int_meta.new_bytes;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800427 }
Jonghwan Hyun8be03392017-12-04 15:48:44 -0800428 if (hdr.udp.isValid()) {
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900429 hdr.udp.length_ = hdr.udp.length_ + local_metadata.int_meta.new_bytes;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800430 }
Jonghwan Hyun8be03392017-12-04 15:48:44 -0800431 if (hdr.intl4_shim.isValid()) {
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900432 hdr.intl4_shim.len = hdr.intl4_shim.len + local_metadata.int_meta.new_words;
Jonghwan Hyun8be03392017-12-04 15:48:44 -0800433 }
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800434 }
435}
436
437#endif