Carmelo Cascone | 3053ed1 | 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 | #ifndef __INT_HEADER__ |
| 18 | #define __INT_HEADER__ |
| 19 | |
| 20 | #include "../define.p4" |
| 21 | |
| 22 | struct int_metadata_t { |
| 23 | _BOOL source; |
| 24 | _BOOL transit; |
| 25 | _BOOL sink; |
| 26 | bit<32> switch_id; |
| 27 | bit<8> new_words; |
| 28 | bit<16> new_bytes; |
| 29 | } |
| 30 | |
| 31 | // INT headers - 8 bytes |
| 32 | header int_header_t { |
| 33 | bit<2> ver; |
| 34 | bit<2> rep; |
| 35 | bit<1> c; |
| 36 | bit<1> e; |
| 37 | bit<5> rsvd1; |
| 38 | bit<5> ins_cnt; |
| 39 | bit<8> max_hop_cnt; |
| 40 | bit<8> total_hop_cnt; |
| 41 | bit<4> instruction_mask_0003; /* split the bits for lookup */ |
| 42 | bit<4> instruction_mask_0407; |
| 43 | bit<4> instruction_mask_0811; |
| 44 | bit<4> instruction_mask_1215; |
| 45 | bit<16> rsvd2; |
| 46 | } |
| 47 | |
| 48 | // INT shim header for TCP/UDP - 4 bytes |
| 49 | header intl4_shim_t { |
| 50 | bit<8> int_type; |
| 51 | bit<8> rsvd1; |
| 52 | bit<8> len_words; // 4-byte words. |
| 53 | bit<8> rsvd2; |
| 54 | } |
| 55 | // INT tail header for TCP/UDP - 4 bytes |
| 56 | header intl4_tail_t { |
| 57 | bit<8> next_proto; |
| 58 | bit<16> dest_port; |
| 59 | bit<2> padding; |
| 60 | bit<6> dscp; |
| 61 | } |
| 62 | |
| 63 | header int_data_t { |
| 64 | // Maximum int metadata stack size in bits: |
| 65 | // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header) |
| 66 | varbit<8032> data; |
| 67 | } |
| 68 | |
| 69 | #ifdef WITH_INT_TRANSIT |
| 70 | // INT meta-value headers - 4 bytes each |
| 71 | // Different header for each value type |
| 72 | header int_switch_id_t { |
| 73 | bit<32> switch_id; |
| 74 | } |
| 75 | header int_port_ids_t { |
| 76 | bit<16> ingress_port_id; |
| 77 | bit<16> egress_port_id; |
| 78 | } |
| 79 | header int_hop_latency_t { |
| 80 | bit<32> hop_latency; |
| 81 | } |
| 82 | header int_q_occupancy_t { |
| 83 | bit<8> q_id; |
| 84 | bit<24> q_occupancy; |
| 85 | } |
| 86 | header int_ingress_tstamp_t { |
| 87 | bit<32> ingress_tstamp; |
| 88 | } |
| 89 | header int_egress_tstamp_t { |
| 90 | bit<32> egress_tstamp; |
| 91 | } |
| 92 | header int_q_congestion_t { |
| 93 | bit<8> q_id; |
| 94 | bit<24> q_congestion; |
| 95 | } |
| 96 | header int_egress_port_tx_util_t { |
| 97 | bit<32> egress_port_tx_util; |
| 98 | } |
| 99 | #endif // WITH_INT_TRANSIT |
| 100 | |
| 101 | #ifdef WITH_INT_SINK |
| 102 | // Report Telemetry Headers |
| 103 | header report_fixed_header_t { |
| 104 | bit<4> ver; |
| 105 | bit<4> nproto; |
| 106 | bit<1> d; |
| 107 | bit<1> q; |
| 108 | bit<1> f; |
| 109 | bit<15> rsvd; |
| 110 | bit<6> hw_id; |
| 111 | bit<32> seq_no; |
| 112 | bit<32> ingress_tstamp; |
| 113 | } |
| 114 | |
| 115 | // Telemetry drop report header |
| 116 | header drop_report_header_t { |
| 117 | bit<32> switch_id; |
| 118 | bit<16> ingress_port_id; |
| 119 | bit<16> egress_port_id; |
| 120 | bit<8> queue_id; |
| 121 | bit<8> drop_reason; |
| 122 | bit<16> pad; |
| 123 | } |
| 124 | |
| 125 | // Switch Local Report Header |
| 126 | header local_report_header_t { |
| 127 | bit<32> switch_id; |
| 128 | bit<16> ingress_port_id; |
| 129 | bit<16> egress_port_id; |
| 130 | bit<8> queue_id; |
| 131 | bit<24> queue_occupancy; |
| 132 | bit<32> egress_tstamp; |
| 133 | } |
| 134 | |
| 135 | header_union local_report_t { |
| 136 | drop_report_header_t drop_report_header; |
| 137 | local_report_header_t local_report_header; |
| 138 | } |
| 139 | #endif // WITH_INT_SINK |
| 140 | |
| 141 | #endif |