Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [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 headers_t hdr, |
| 22 | inout local_metadata_t local_metadata, |
| 23 | inout standard_metadata_t standard_metadata) { |
| 24 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 25 | action init_metadata(switch_id_t switch_id) { |
| 26 | local_metadata.int_meta.transit = _TRUE; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 27 | local_metadata.int_meta.switch_id = switch_id; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 28 | } |
| 29 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 30 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 31 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 35 | @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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 40 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 41 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 42 | action int_set_header_2() { //hop_latency |
| 43 | hdr.int_hop_latency.setValid(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 44 | hdr.int_hop_latency.hop_latency = (bit<32>) standard_metadata.egress_global_timestamp - (bit<32>) standard_metadata.ingress_global_timestamp; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 45 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 46 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 47 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 56 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 57 | action int_set_header_4() { //ingress_tstamp |
| 58 | hdr.int_ingress_tstamp.setValid(); |
| 59 | hdr.int_ingress_tstamp.ingress_tstamp = |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 60 | (bit<32>) standard_metadata.ingress_global_timestamp; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 61 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 62 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 63 | action int_set_header_5() { //egress_timestamp |
| 64 | hdr.int_egress_tstamp.setValid(); |
| 65 | hdr.int_egress_tstamp.egress_tstamp = |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 66 | (bit<32>) standard_metadata.egress_global_timestamp; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 67 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 68 | @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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 76 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 84 | // 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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 89 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 90 | |
| 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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 122 | int_set_header_3(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 123 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 124 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 125 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 126 | action int_set_header_0003_i2() { |
| 127 | int_set_header_2(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 128 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 129 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 130 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 131 | action int_set_header_0003_i3() { |
| 132 | int_set_header_3(); |
| 133 | int_set_header_2(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 134 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 135 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 136 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 137 | action int_set_header_0003_i4() { |
| 138 | int_set_header_1(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 139 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 140 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 141 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 142 | action int_set_header_0003_i5() { |
| 143 | int_set_header_3(); |
| 144 | int_set_header_1(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 145 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 146 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 147 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 148 | action int_set_header_0003_i6() { |
| 149 | int_set_header_2(); |
| 150 | int_set_header_1(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 151 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 152 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 153 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 154 | action int_set_header_0003_i7() { |
| 155 | int_set_header_3(); |
| 156 | int_set_header_2(); |
| 157 | int_set_header_1(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 158 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 159 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 160 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 161 | action int_set_header_0003_i8() { |
| 162 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 163 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 164 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 165 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 166 | action int_set_header_0003_i9() { |
| 167 | int_set_header_3(); |
| 168 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 169 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 170 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 171 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 172 | action int_set_header_0003_i10() { |
| 173 | int_set_header_2(); |
| 174 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 175 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 176 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 177 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 178 | action int_set_header_0003_i11() { |
| 179 | int_set_header_3(); |
| 180 | int_set_header_2(); |
| 181 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 182 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 183 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 184 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 185 | action int_set_header_0003_i12() { |
| 186 | int_set_header_1(); |
| 187 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 188 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 189 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 190 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 191 | action int_set_header_0003_i13() { |
| 192 | int_set_header_3(); |
| 193 | int_set_header_1(); |
| 194 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 195 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 196 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 197 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 198 | action int_set_header_0003_i14() { |
| 199 | int_set_header_2(); |
| 200 | int_set_header_1(); |
| 201 | int_set_header_0(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 202 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 203 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 204 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 205 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 210 | add_4(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 213 | /* action function for bits 4-7 combinations, 4 is msb, 7 is lsb */ |
| 214 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 215 | action int_set_header_0407_i0() { |
| 216 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 217 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 218 | action int_set_header_0407_i1() { |
| 219 | int_set_header_7(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 220 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 221 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 222 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 223 | action int_set_header_0407_i2() { |
| 224 | int_set_header_6(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 225 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 226 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 227 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 228 | action int_set_header_0407_i3() { |
| 229 | int_set_header_7(); |
| 230 | int_set_header_6(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 231 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 232 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 233 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 234 | action int_set_header_0407_i4() { |
| 235 | int_set_header_5(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 236 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 237 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 238 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 239 | action int_set_header_0407_i5() { |
| 240 | int_set_header_7(); |
| 241 | int_set_header_5(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 242 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 243 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 244 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 245 | action int_set_header_0407_i6() { |
| 246 | int_set_header_6(); |
| 247 | int_set_header_5(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 248 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 249 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 250 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 251 | action int_set_header_0407_i7() { |
| 252 | int_set_header_7(); |
| 253 | int_set_header_6(); |
| 254 | int_set_header_5(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 255 | add_4(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 256 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 257 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 258 | action int_set_header_0407_i8() { |
| 259 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 260 | add_1(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 261 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 262 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 263 | action int_set_header_0407_i9() { |
| 264 | int_set_header_7(); |
| 265 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 266 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 267 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 268 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 269 | action int_set_header_0407_i10() { |
| 270 | int_set_header_6(); |
| 271 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 272 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 273 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 274 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 275 | action int_set_header_0407_i11() { |
| 276 | int_set_header_7(); |
| 277 | int_set_header_6(); |
| 278 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 279 | add_4(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 280 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 281 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 282 | action int_set_header_0407_i12() { |
| 283 | int_set_header_5(); |
| 284 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 285 | add_2(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 286 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 287 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 288 | action int_set_header_0407_i13() { |
| 289 | int_set_header_7(); |
| 290 | int_set_header_5(); |
| 291 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 292 | add_3(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 293 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 294 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 295 | action int_set_header_0407_i14() { |
| 296 | int_set_header_6(); |
| 297 | int_set_header_5(); |
| 298 | int_set_header_4(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 299 | add_4(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 300 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 301 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 302 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 307 | add_5(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 310 | // Default action used to set switch ID. |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 311 | table tb_int_insert { |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 312 | // 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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 316 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 317 | actions = { |
| 318 | init_metadata; |
| 319 | @defaultonly nop; |
| 320 | } |
| 321 | const default_action = nop(); |
| 322 | size = 1; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /* Table to process instruction bits 0-3 */ |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 326 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 327 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 349 | 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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | /* Table to process instruction bits 4-7 */ |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 370 | @hidden |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 371 | 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 Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 393 | 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 Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | apply { |
| 414 | tb_int_insert.apply(); |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 415 | if (local_metadata.int_meta.transit == _FALSE) { |
| 416 | return; |
| 417 | } |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 418 | tb_int_inst_0003.apply(); |
| 419 | tb_int_inst_0407.apply(); |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 420 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 421 | // Decrement remaining hop cnt |
| 422 | hdr.int_header.remaining_hop_cnt = hdr.int_header.remaining_hop_cnt - 1; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 423 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 424 | // Update headers lengths. |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 425 | if (hdr.ipv4.isValid()) { |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 426 | hdr.ipv4.len = hdr.ipv4.len + local_metadata.int_meta.new_bytes; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 427 | } |
Jonghwan Hyun | 8be0339 | 2017-12-04 15:48:44 -0800 | [diff] [blame] | 428 | if (hdr.udp.isValid()) { |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 429 | hdr.udp.length_ = hdr.udp.length_ + local_metadata.int_meta.new_bytes; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 430 | } |
Jonghwan Hyun | 8be0339 | 2017-12-04 15:48:44 -0800 | [diff] [blame] | 431 | if (hdr.intl4_shim.isValid()) { |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 432 | hdr.intl4_shim.len = hdr.intl4_shim.len + local_metadata.int_meta.new_words; |
Jonghwan Hyun | 8be0339 | 2017-12-04 15:48:44 -0800 | [diff] [blame] | 433 | } |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
| 437 | #endif |