Yi Tseng | be34205 | 2017-11-03 10:21:23 -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 __HEADER__ |
| 18 | #define __HEADER__ |
| 19 | |
| 20 | #include "define.p4" |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 21 | #include "int/int_header.p4" |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 22 | |
| 23 | @controller_header("packet_in") |
| 24 | header packet_in_header_t { |
| 25 | port_num_t ingress_port; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 26 | bit<7> _pad; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 27 | } |
| 28 | |
Carmelo Cascone | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 29 | _PKT_OUT_HDR_ANNOT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 30 | @controller_header("packet_out") |
| 31 | header packet_out_header_t { |
| 32 | port_num_t egress_port; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 33 | bit<7> _pad; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | header ethernet_t { |
| 37 | mac_addr_t dst_addr; |
| 38 | mac_addr_t src_addr; |
| 39 | bit<16> ether_type; |
| 40 | } |
| 41 | |
| 42 | header vlan_tag_t { |
| 43 | bit<3> pri; |
| 44 | bit<1> cfi; |
| 45 | vlan_id_t vlan_id; |
| 46 | bit<16> ether_type; |
| 47 | } |
| 48 | |
| 49 | header mpls_t { |
| 50 | bit<20> label; |
| 51 | bit<3> tc; |
| 52 | bit<1> bos; |
| 53 | bit<8> ttl; |
| 54 | } |
| 55 | |
| 56 | header ipv4_t { |
| 57 | bit<4> version; |
| 58 | bit<4> ihl; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 59 | bit<6> dscp; |
| 60 | bit<2> ecn; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 61 | bit<16> total_len; |
| 62 | bit<16> identification; |
| 63 | bit<3> flags; |
| 64 | bit<13> frag_offset; |
| 65 | bit<8> ttl; |
| 66 | bit<8> protocol; |
| 67 | bit<16> hdr_checksum; |
| 68 | bit<32> src_addr; |
| 69 | bit<32> dst_addr; |
| 70 | } |
| 71 | |
| 72 | header ipv6_t { |
| 73 | bit<4> version; |
| 74 | bit<8> traffic_class; |
| 75 | bit<20> flow_label; |
| 76 | bit<16> payload_len; |
| 77 | bit<8> next_hdr; |
| 78 | bit<8> hop_limit; |
| 79 | bit<128> src_addr; |
| 80 | bit<128> dst_addr; |
| 81 | } |
| 82 | |
| 83 | header arp_t { |
| 84 | bit<16> hw_type; |
| 85 | bit<16> proto_type; |
| 86 | bit<8> hw_addr_len; |
| 87 | bit<8> proto_addr_len; |
| 88 | bit<16> opcode; |
| 89 | } |
| 90 | |
| 91 | header tcp_t { |
| 92 | bit<16> src_port; |
| 93 | bit<16> dst_port; |
| 94 | bit<32> seq_no; |
| 95 | bit<32> ack_no; |
| 96 | bit<4> data_offset; |
| 97 | bit<3> res; |
| 98 | bit<3> ecn; |
| 99 | bit<6> ctrl; |
| 100 | bit<16> window; |
| 101 | bit<16> checksum; |
| 102 | bit<16> urgent_ptr; |
| 103 | } |
| 104 | |
| 105 | header udp_t { |
| 106 | bit<16> src_port; |
| 107 | bit<16> dst_port; |
| 108 | bit<16> len; |
| 109 | bit<16> checksum; |
| 110 | } |
| 111 | |
| 112 | header icmp_t { |
| 113 | bit<8> icmp_type; |
| 114 | bit<8> icmp_code; |
| 115 | bit<16> checksum; |
Yi Tseng | f73a553 | 2017-11-17 15:58:57 -0800 | [diff] [blame] | 116 | bit<16> identifier; |
| 117 | bit<16> sequence_number; |
| 118 | bit<64> timestamp; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 121 | #ifdef WITH_SPGW |
| 122 | // GTPU v1 |
| 123 | header gtpu_t { |
| 124 | bit<3> version; /* version */ |
| 125 | bit<1> pt; /* protocol type */ |
| 126 | bit<1> spare; /* reserved */ |
| 127 | bit<1> ex_flag; /* next extension hdr present? */ |
| 128 | bit<1> seq_flag; /* sequence no. */ |
| 129 | bit<1> npdu_flag; /* n-pdn number present ? */ |
| 130 | bit<8> msgtype; /* message type */ |
| 131 | bit<16> msglen; /* message length */ |
| 132 | bit<32> teid; /* tunnel endpoint id */ |
| 133 | } |
| 134 | |
| 135 | struct spgw_meta_t { |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 136 | direction_t direction; |
Carmelo Cascone | 274daef | 2018-02-14 20:32:49 -0800 | [diff] [blame] | 137 | bit<16> ipv4_len; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 138 | bit<32> teid; |
| 139 | bit<32> s1u_enb_addr; |
| 140 | bit<32> s1u_sgw_addr; |
| 141 | #ifdef WITH_SPGW_PCC_GATING |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 142 | bit<16> l4_src_port; |
| 143 | bit<16> l4_dst_port; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 144 | pcc_gate_status_t pcc_gate_status; |
| 145 | sdf_rule_id_t sdf_rule_id; |
| 146 | pcc_rule_id_t pcc_rule_id; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 147 | #endif // WITH_SPGW_PCC_GATING |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 148 | } |
| 149 | #endif // WITH_SPGW |
| 150 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 151 | //Custom metadata definition |
| 152 | struct fabric_metadata_t { |
| 153 | fwd_type_t fwd_type; |
| 154 | next_id_t next_id; |
Carmelo Cascone | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 155 | _BOOL pop_vlan_when_packet_in; |
Carmelo Cascone | 1e8843f | 2018-07-19 19:01:12 +0200 | [diff] [blame] | 156 | _BOOL is_multicast; |
Carmelo Cascone | 8d2d1b2 | 2018-08-27 18:33:53 -0700 | [diff] [blame] | 157 | _BOOL is_controller_packet_out; |
Carmelo Cascone | 1e8843f | 2018-07-19 19:01:12 +0200 | [diff] [blame] | 158 | _BOOL clone_to_cpu; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 159 | bit<8> ip_proto; |
| 160 | bit<16> l4_src_port; |
| 161 | bit<16> l4_dst_port; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 162 | #ifdef WITH_SPGW |
| 163 | spgw_meta_t spgw; |
| 164 | #endif // WITH_SPGW |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 165 | #ifdef WITH_INT |
| 166 | int_metadata_t int_meta; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 167 | #endif // WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | struct parsed_headers_t { |
| 171 | ethernet_t ethernet; |
| 172 | vlan_tag_t vlan_tag; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 173 | mpls_t mpls; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 174 | #ifdef WITH_SPGW |
| 175 | ipv4_t gtpu_ipv4; |
| 176 | udp_t gtpu_udp; |
| 177 | gtpu_t gtpu; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 178 | ipv4_t inner_ipv4; |
| 179 | udp_t inner_udp; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 180 | #endif // WITH_SPGW |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 181 | ipv4_t ipv4; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 182 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 183 | ipv6_t ipv6; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 184 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 185 | arp_t arp; |
| 186 | tcp_t tcp; |
| 187 | udp_t udp; |
| 188 | icmp_t icmp; |
| 189 | packet_out_header_t packet_out; |
| 190 | packet_in_header_t packet_in; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 191 | #ifdef WITH_INT_SINK |
| 192 | // INT Report encap |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 193 | ethernet_t report_ethernet; |
| 194 | ipv4_t report_ipv4; |
| 195 | udp_t report_udp; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 196 | // INT Report header (support only fixed) |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 197 | report_fixed_header_t report_fixed_header; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 198 | // local_report_t report_local; |
| 199 | #endif // WITH_INT_SINK |
| 200 | #ifdef WITH_INT |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 201 | // INT specific headers |
| 202 | intl4_shim_t intl4_shim; |
| 203 | int_header_t int_header; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 204 | int_switch_id_t int_switch_id; |
| 205 | int_port_ids_t int_port_ids; |
| 206 | int_hop_latency_t int_hop_latency; |
| 207 | int_q_occupancy_t int_q_occupancy; |
| 208 | int_ingress_tstamp_t int_ingress_tstamp; |
| 209 | int_egress_tstamp_t int_egress_tstamp; |
| 210 | int_q_congestion_t int_q_congestion; |
| 211 | int_egress_port_tx_util_t int_egress_tx_util; |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 212 | #ifdef WITH_INT_SINK |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 213 | int_data_t int_data; |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 214 | #endif // WITH_INT_SINK |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 215 | intl4_tail_t intl4_tail; |
| 216 | #endif //WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | #endif |