Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 1 | /* |
| 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__ |
| 20 | control process_int_transit ( |
| 21 | inout parsed_headers_t hdr, |
| 22 | inout fabric_metadata_t fmeta, |
| 23 | inout standard_metadata_t smeta) { |
| 24 | |
| 25 | action init_metadata(bit<32> switch_id) { |
| 26 | fmeta.int_meta.transit = _TRUE; |
| 27 | #ifdef _INT_INIT_METADATA |
| 28 | // Allow other targets to initialize INT metadata in their own way. |
| 29 | _INT_INIT_METADATA |
| 30 | #else |
| 31 | fmeta.int_meta.switch_id = switch_id; |
| 32 | #endif // _INT_INIT_METADATA |
| 33 | } |
| 34 | |
| 35 | #ifdef _INT_METADATA_ACTIONS |
| 36 | _INT_METADATA_ACTIONS |
| 37 | #else |
| 38 | // Switch ID. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 39 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 40 | action int_set_header_0() { |
| 41 | hdr.int_switch_id.setValid(); |
| 42 | hdr.int_switch_id.switch_id = fmeta.int_meta.switch_id; |
| 43 | } |
| 44 | // Port IDs. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 45 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 46 | action int_set_header_1() { |
| 47 | hdr.int_port_ids.setValid(); |
| 48 | hdr.int_port_ids.ingress_port_id = (bit<16>) smeta.ingress_port; |
| 49 | hdr.int_port_ids.egress_port_id = (bit<16>) smeta.egress_port; |
| 50 | } |
| 51 | // Hop latency. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 52 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 53 | action int_set_header_2() { |
| 54 | hdr.int_hop_latency.setValid(); |
| 55 | hdr.int_hop_latency.hop_latency = (bit<32>) smeta.deq_timedelta; |
| 56 | } |
| 57 | // Queue occupancy. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 58 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 59 | action int_set_header_3() { |
| 60 | hdr.int_q_occupancy.setValid(); |
| 61 | // TODO: support queues in BMv2. ATM we assume only one. |
| 62 | hdr.int_q_occupancy.q_id = 8w0; |
| 63 | hdr.int_q_occupancy.q_occupancy = (bit<24>) smeta.deq_qdepth; |
| 64 | } |
| 65 | // Ingress timestamp. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 66 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 67 | action int_set_header_4() { |
| 68 | hdr.int_ingress_tstamp.setValid(); |
| 69 | hdr.int_ingress_tstamp.ingress_tstamp = (bit<32>) smeta.enq_timestamp; |
| 70 | } |
| 71 | // Egress timestamp. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 72 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 73 | action int_set_header_5() { |
| 74 | hdr.int_egress_tstamp.setValid(); |
| 75 | hdr.int_egress_tstamp.egress_tstamp = (bit<32>) smeta.enq_timestamp + (bit<32>) smeta.deq_timedelta; |
| 76 | } |
| 77 | // Queue congestion. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 78 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 79 | action int_set_header_6() { |
| 80 | hdr.int_q_congestion.setValid(); |
| 81 | // TODO: support queue congestion. |
| 82 | hdr.int_q_congestion.q_id = 8w0; |
| 83 | hdr.int_q_congestion.q_congestion = 24w0; |
| 84 | } |
| 85 | // Egress port utilization. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 86 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 87 | action int_set_header_7() { |
| 88 | hdr.int_egress_tx_util.setValid(); |
| 89 | // TODO: implement tx utilization support in BMv2. |
| 90 | hdr.int_egress_tx_util.egress_port_tx_util = 32w0; |
| 91 | } |
| 92 | #endif // _INT_METADATA_ACTIONS |
| 93 | |
| 94 | // Actions to keep track of the new metadata added. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 95 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 96 | action add_1() { |
| 97 | fmeta.int_meta.new_words = fmeta.int_meta.new_words + 1; |
| 98 | fmeta.int_meta.new_bytes = fmeta.int_meta.new_bytes + 4; |
| 99 | } |
| 100 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 101 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 102 | action add_2() { |
| 103 | fmeta.int_meta.new_words = fmeta.int_meta.new_words + 2; |
| 104 | fmeta.int_meta.new_bytes = fmeta.int_meta.new_bytes + 8; |
| 105 | } |
| 106 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 107 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 108 | action add_3() { |
| 109 | fmeta.int_meta.new_words = fmeta.int_meta.new_words + 3; |
| 110 | fmeta.int_meta.new_bytes = fmeta.int_meta.new_bytes + 12; |
| 111 | } |
| 112 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 113 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 114 | action add_4() { |
| 115 | fmeta.int_meta.new_words = fmeta.int_meta.new_words + 4; |
| 116 | fmeta.int_meta.new_bytes = fmeta.int_meta.new_bytes + 16; |
| 117 | } |
| 118 | |
| 119 | // Action function for bits 0-3 combinations, 0 is msb, 3 is lsb. |
| 120 | // Each bit set indicates that corresponding INT header should be added. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 121 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 122 | action int_set_header_0003_i0() { |
| 123 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 124 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 125 | action int_set_header_0003_i1() { |
| 126 | int_set_header_3(); |
| 127 | add_1(); |
| 128 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 129 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 130 | action int_set_header_0003_i2() { |
| 131 | int_set_header_2(); |
| 132 | add_1(); |
| 133 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 134 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 135 | action int_set_header_0003_i3() { |
| 136 | int_set_header_3(); |
| 137 | int_set_header_2(); |
| 138 | add_2(); |
| 139 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 140 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 141 | action int_set_header_0003_i4() { |
| 142 | int_set_header_1(); |
| 143 | add_1(); |
| 144 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 145 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 146 | action int_set_header_0003_i5() { |
| 147 | int_set_header_3(); |
| 148 | int_set_header_1(); |
| 149 | add_2(); |
| 150 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 151 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 152 | action int_set_header_0003_i6() { |
| 153 | int_set_header_2(); |
| 154 | int_set_header_1(); |
| 155 | add_2(); |
| 156 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 157 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 158 | action int_set_header_0003_i7() { |
| 159 | int_set_header_3(); |
| 160 | int_set_header_2(); |
| 161 | int_set_header_1(); |
| 162 | add_3(); |
| 163 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 164 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 165 | action int_set_header_0003_i8() { |
| 166 | int_set_header_0(); |
| 167 | add_1(); |
| 168 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 169 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 170 | action int_set_header_0003_i9() { |
| 171 | int_set_header_3(); |
| 172 | int_set_header_0(); |
| 173 | add_2(); |
| 174 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 175 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 176 | action int_set_header_0003_i10() { |
| 177 | int_set_header_2(); |
| 178 | int_set_header_0(); |
| 179 | add_2(); |
| 180 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 181 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 182 | action int_set_header_0003_i11() { |
| 183 | int_set_header_3(); |
| 184 | int_set_header_2(); |
| 185 | int_set_header_0(); |
| 186 | add_3(); |
| 187 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 188 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 189 | action int_set_header_0003_i12() { |
| 190 | int_set_header_1(); |
| 191 | int_set_header_0(); |
| 192 | add_2(); |
| 193 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 194 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 195 | action int_set_header_0003_i13() { |
| 196 | int_set_header_3(); |
| 197 | int_set_header_1(); |
| 198 | int_set_header_0(); |
| 199 | add_3(); |
| 200 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 201 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 202 | action int_set_header_0003_i14() { |
| 203 | int_set_header_2(); |
| 204 | int_set_header_1(); |
| 205 | int_set_header_0(); |
| 206 | add_3(); |
| 207 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 208 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 209 | action int_set_header_0003_i15() { |
| 210 | int_set_header_3(); |
| 211 | int_set_header_2(); |
| 212 | int_set_header_1(); |
| 213 | int_set_header_0(); |
| 214 | add_4(); |
| 215 | } |
| 216 | |
| 217 | // Action function for bits 4-7 combinations, 4 is msb, 7 is lsb. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 218 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 219 | action int_set_header_0407_i0() { |
| 220 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 221 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 222 | action int_set_header_0407_i1() { |
| 223 | int_set_header_7(); |
| 224 | add_1(); |
| 225 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 226 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 227 | action int_set_header_0407_i2() { |
| 228 | int_set_header_6(); |
| 229 | add_1(); |
| 230 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 231 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 232 | action int_set_header_0407_i3() { |
| 233 | int_set_header_7(); |
| 234 | int_set_header_6(); |
| 235 | add_2(); |
| 236 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 237 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 238 | action int_set_header_0407_i4() { |
| 239 | int_set_header_5(); |
| 240 | add_1(); |
| 241 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 242 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 243 | action int_set_header_0407_i5() { |
| 244 | int_set_header_7(); |
| 245 | int_set_header_5(); |
| 246 | add_2(); |
| 247 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 248 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 249 | action int_set_header_0407_i6() { |
| 250 | int_set_header_6(); |
| 251 | int_set_header_5(); |
| 252 | add_2(); |
| 253 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 254 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 255 | action int_set_header_0407_i7() { |
| 256 | int_set_header_7(); |
| 257 | int_set_header_6(); |
| 258 | int_set_header_5(); |
| 259 | add_3(); |
| 260 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 261 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 262 | action int_set_header_0407_i8() { |
| 263 | int_set_header_4(); |
| 264 | add_1(); |
| 265 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 266 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 267 | action int_set_header_0407_i9() { |
| 268 | int_set_header_7(); |
| 269 | int_set_header_4(); |
| 270 | add_2(); |
| 271 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 272 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 273 | action int_set_header_0407_i10() { |
| 274 | int_set_header_6(); |
| 275 | int_set_header_4(); |
| 276 | add_2(); |
| 277 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 278 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 279 | action int_set_header_0407_i11() { |
| 280 | int_set_header_7(); |
| 281 | int_set_header_6(); |
| 282 | int_set_header_4(); |
| 283 | add_3(); |
| 284 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 285 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 286 | action int_set_header_0407_i12() { |
| 287 | int_set_header_5(); |
| 288 | int_set_header_4(); |
| 289 | add_2(); |
| 290 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 291 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 292 | action int_set_header_0407_i13() { |
| 293 | int_set_header_7(); |
| 294 | int_set_header_5(); |
| 295 | int_set_header_4(); |
| 296 | add_3(); |
| 297 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 298 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 299 | action int_set_header_0407_i14() { |
| 300 | int_set_header_6(); |
| 301 | int_set_header_5(); |
| 302 | int_set_header_4(); |
| 303 | add_3(); |
| 304 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 305 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 306 | action int_set_header_0407_i15() { |
| 307 | int_set_header_7(); |
| 308 | int_set_header_6(); |
| 309 | int_set_header_5(); |
| 310 | int_set_header_4(); |
| 311 | add_4(); |
| 312 | } |
| 313 | |
| 314 | // Default action used to set switch ID. |
| 315 | table tb_int_insert { |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 316 | // We don't really need a key here, however we add a dummy one as a |
| 317 | // workaround to ONOS inability to properly support default actions. |
| 318 | key = { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 319 | hdr.int_header.isValid(): exact @name("int_is_valid"); |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 320 | } |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 321 | actions = { |
| 322 | init_metadata; |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 323 | @defaultonly nop; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 324 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 325 | const default_action = nop(); |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 326 | size = 1; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | // Table to process instruction bits 0-3. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 330 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 331 | table tb_int_inst_0003 { |
| 332 | key = { |
| 333 | hdr.int_header.instruction_mask_0003 : exact; |
| 334 | } |
| 335 | actions = { |
| 336 | int_set_header_0003_i0; |
| 337 | int_set_header_0003_i1; |
| 338 | int_set_header_0003_i2; |
| 339 | int_set_header_0003_i3; |
| 340 | int_set_header_0003_i4; |
| 341 | int_set_header_0003_i5; |
| 342 | int_set_header_0003_i6; |
| 343 | int_set_header_0003_i7; |
| 344 | int_set_header_0003_i8; |
| 345 | int_set_header_0003_i9; |
| 346 | int_set_header_0003_i10; |
| 347 | int_set_header_0003_i11; |
| 348 | int_set_header_0003_i12; |
| 349 | int_set_header_0003_i13; |
| 350 | int_set_header_0003_i14; |
| 351 | int_set_header_0003_i15; |
| 352 | } |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 353 | const entries = { |
| 354 | (0x0) : int_set_header_0003_i0(); |
| 355 | (0x1) : int_set_header_0003_i1(); |
| 356 | (0x2) : int_set_header_0003_i2(); |
| 357 | (0x3) : int_set_header_0003_i3(); |
| 358 | (0x4) : int_set_header_0003_i4(); |
| 359 | (0x5) : int_set_header_0003_i5(); |
| 360 | (0x6) : int_set_header_0003_i6(); |
| 361 | (0x7) : int_set_header_0003_i7(); |
| 362 | (0x8) : int_set_header_0003_i8(); |
| 363 | (0x9) : int_set_header_0003_i9(); |
| 364 | (0xA) : int_set_header_0003_i10(); |
| 365 | (0xB) : int_set_header_0003_i11(); |
| 366 | (0xC) : int_set_header_0003_i12(); |
| 367 | (0xD) : int_set_header_0003_i13(); |
| 368 | (0xE) : int_set_header_0003_i14(); |
| 369 | (0xF) : int_set_header_0003_i15(); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // Table to process instruction bits 4-7. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 374 | @hidden |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 375 | table tb_int_inst_0407 { |
| 376 | key = { |
| 377 | hdr.int_header.instruction_mask_0407 : exact; |
| 378 | } |
| 379 | actions = { |
| 380 | int_set_header_0407_i0; |
| 381 | int_set_header_0407_i1; |
| 382 | int_set_header_0407_i2; |
| 383 | int_set_header_0407_i3; |
| 384 | int_set_header_0407_i4; |
| 385 | int_set_header_0407_i5; |
| 386 | int_set_header_0407_i6; |
| 387 | int_set_header_0407_i7; |
| 388 | int_set_header_0407_i8; |
| 389 | int_set_header_0407_i9; |
| 390 | int_set_header_0407_i10; |
| 391 | int_set_header_0407_i11; |
| 392 | int_set_header_0407_i12; |
| 393 | int_set_header_0407_i13; |
| 394 | int_set_header_0407_i14; |
| 395 | int_set_header_0407_i15; |
| 396 | } |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 397 | const entries = { |
| 398 | (0x0) : int_set_header_0407_i0(); |
| 399 | (0x1) : int_set_header_0407_i1(); |
| 400 | (0x2) : int_set_header_0407_i2(); |
| 401 | (0x3) : int_set_header_0407_i3(); |
| 402 | (0x4) : int_set_header_0407_i4(); |
| 403 | (0x5) : int_set_header_0407_i5(); |
| 404 | (0x6) : int_set_header_0407_i6(); |
| 405 | (0x7) : int_set_header_0407_i7(); |
| 406 | (0x8) : int_set_header_0407_i8(); |
| 407 | (0x9) : int_set_header_0407_i9(); |
| 408 | (0xA) : int_set_header_0407_i10(); |
| 409 | (0xB) : int_set_header_0407_i11(); |
| 410 | (0xC) : int_set_header_0407_i12(); |
| 411 | (0xD) : int_set_header_0407_i13(); |
| 412 | (0xE) : int_set_header_0407_i14(); |
| 413 | (0xF) : int_set_header_0407_i15(); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | apply { |
| 418 | tb_int_insert.apply(); |
| 419 | if (fmeta.int_meta.transit == _FALSE) { |
| 420 | return; |
| 421 | } |
| 422 | tb_int_inst_0003.apply(); |
| 423 | tb_int_inst_0407.apply(); |
| 424 | // Increment hop cnt |
| 425 | hdr.int_header.total_hop_cnt = hdr.int_header.total_hop_cnt + 1; |
| 426 | // Update headers lengths. |
| 427 | if (hdr.ipv4.isValid()) { |
| 428 | hdr.ipv4.total_len = hdr.ipv4.total_len + fmeta.int_meta.new_bytes; |
| 429 | } |
| 430 | if (hdr.udp.isValid()) { |
| 431 | hdr.udp.len = hdr.udp.len + fmeta.int_meta.new_bytes; |
| 432 | } |
| 433 | if (hdr.intl4_shim.isValid()) { |
| 434 | hdr.intl4_shim.len_words = hdr.intl4_shim.len_words + fmeta.int_meta.new_words; |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | #endif |