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 __CUSTOM_HEADERS__ |
| 19 | #define __CUSTOM_HEADERS__ |
| 20 | |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 21 | #ifndef __INT_HEADERS__ |
| 22 | #define __INT_HEADERS__ |
| 23 | #include "telemetry_report_headers.p4" |
| 24 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 25 | // INT version 1.0 |
| 26 | |
| 27 | // INT header |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 28 | header int_header_t { |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 29 | bit<4> ver; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 30 | bit<2> rep; |
| 31 | bit<1> c; |
| 32 | bit<1> e; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 33 | bit<1> m; |
| 34 | bit<7> rsvd1; |
| 35 | bit<3> rsvd2; |
| 36 | bit<5> hop_metadata_len; |
| 37 | bit<8> remaining_hop_cnt; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 38 | bit<4> instruction_mask_0003; /* split the bits for lookup */ |
| 39 | bit<4> instruction_mask_0407; |
| 40 | bit<4> instruction_mask_0811; |
| 41 | bit<4> instruction_mask_1215; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 42 | bit<16> rsvd3; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | // INT meta-value headers - different header for each value type |
| 46 | header int_switch_id_t { |
| 47 | bit<32> switch_id; |
| 48 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 49 | header int_level1_port_ids_t { |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 50 | bit<16> ingress_port_id; |
| 51 | bit<16> egress_port_id; |
| 52 | } |
| 53 | header int_hop_latency_t { |
| 54 | bit<32> hop_latency; |
| 55 | } |
| 56 | header int_q_occupancy_t { |
| 57 | bit<8> q_id; |
| 58 | bit<24> q_occupancy; |
| 59 | } |
| 60 | header int_ingress_tstamp_t { |
| 61 | bit<32> ingress_tstamp; |
| 62 | } |
| 63 | header int_egress_tstamp_t { |
| 64 | bit<32> egress_tstamp; |
| 65 | } |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 66 | header int_level2_port_ids_t { |
| 67 | bit<32> ingress_port_id; |
| 68 | bit<32> egress_port_id; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 69 | } |
| 70 | header int_egress_port_tx_util_t { |
| 71 | bit<32> egress_port_tx_util; |
| 72 | } |
| 73 | |
| 74 | header int_data_t { |
| 75 | // Maximum int metadata stack size in bits: |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 76 | // (0x3F - 3) * 4 * 8 (excluding INT shim header and INT header) |
| 77 | varbit<1920> data; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 80 | // INT shim header for TCP/UDP |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 81 | header intl4_shim_t { |
| 82 | bit<8> int_type; |
| 83 | bit<8> rsvd1; |
| 84 | bit<8> len; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 85 | bit<6> dscp; |
| 86 | bit<2> rsvd2; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Jonghwan Hyun | 8be0339 | 2017-12-04 15:48:44 -0800 | [diff] [blame] | 89 | struct int_metadata_t { |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 90 | switch_id_t switch_id; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 91 | bit<16> new_bytes; |
| 92 | bit<8> new_words; |
| 93 | _BOOL source; |
| 94 | _BOOL sink; |
| 95 | _BOOL transit; |
| 96 | bit<8> intl4_shim_len; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | struct headers_t { |
| 100 | packet_out_header_t packet_out; |
| 101 | packet_in_header_t packet_in; |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 102 | // INT Report Encapsulation |
| 103 | ethernet_t report_ethernet; |
| 104 | ipv4_t report_ipv4; |
| 105 | udp_t report_udp; |
| 106 | // INT Report Headers |
| 107 | report_fixed_header_t report_fixed_header; |
| 108 | local_report_t report_local; |
| 109 | // Original packet's headers |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 110 | ethernet_t ethernet; |
| 111 | ipv4_t ipv4; |
| 112 | tcp_t tcp; |
| 113 | udp_t udp; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 114 | // INT specific headers |
| 115 | intl4_shim_t intl4_shim; |
| 116 | int_header_t int_header; |
| 117 | int_data_t int_data; |
| 118 | int_switch_id_t int_switch_id; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 119 | int_level1_port_ids_t int_level1_port_ids; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 120 | int_hop_latency_t int_hop_latency; |
| 121 | int_q_occupancy_t int_q_occupancy; |
| 122 | int_ingress_tstamp_t int_ingress_tstamp; |
| 123 | int_egress_tstamp_t int_egress_tstamp; |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 124 | int_level2_port_ids_t int_level2_port_ids; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 125 | int_egress_port_tx_util_t int_egress_tx_util; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | struct local_metadata_t { |
| 129 | bit<16> l4_src_port; |
| 130 | bit<16> l4_dst_port; |
| 131 | next_hop_id_t next_hop_id; |
| 132 | bit<16> selector; |
| 133 | int_metadata_t int_meta; |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 134 | bool compute_checksum; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 135 | } |
| 136 | |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 137 | #endif // __INT_HEADERS__ |
| 138 | #endif // __CUSTOM_HEADERS__ |