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