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; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 39 | bit<16> eth_type; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | header vlan_tag_t { |
| 43 | bit<3> pri; |
| 44 | bit<1> cfi; |
| 45 | vlan_id_t vlan_id; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 46 | bit<16> eth_type; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 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 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 83 | header tcp_t { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 84 | bit<16> sport; |
| 85 | bit<16> dport; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 86 | bit<32> seq_no; |
| 87 | bit<32> ack_no; |
| 88 | bit<4> data_offset; |
| 89 | bit<3> res; |
| 90 | bit<3> ecn; |
| 91 | bit<6> ctrl; |
| 92 | bit<16> window; |
| 93 | bit<16> checksum; |
| 94 | bit<16> urgent_ptr; |
| 95 | } |
| 96 | |
| 97 | header udp_t { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 98 | bit<16> sport; |
| 99 | bit<16> dport; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 100 | bit<16> len; |
| 101 | bit<16> checksum; |
| 102 | } |
| 103 | |
| 104 | header icmp_t { |
| 105 | bit<8> icmp_type; |
| 106 | bit<8> icmp_code; |
| 107 | bit<16> checksum; |
Yi Tseng | f73a553 | 2017-11-17 15:58:57 -0800 | [diff] [blame] | 108 | bit<16> identifier; |
| 109 | bit<16> sequence_number; |
| 110 | bit<64> timestamp; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 113 | #ifdef WITH_SPGW |
| 114 | // GTPU v1 |
| 115 | header gtpu_t { |
| 116 | bit<3> version; /* version */ |
| 117 | bit<1> pt; /* protocol type */ |
| 118 | bit<1> spare; /* reserved */ |
| 119 | bit<1> ex_flag; /* next extension hdr present? */ |
| 120 | bit<1> seq_flag; /* sequence no. */ |
| 121 | bit<1> npdu_flag; /* n-pdn number present ? */ |
| 122 | bit<8> msgtype; /* message type */ |
| 123 | bit<16> msglen; /* message length */ |
| 124 | bit<32> teid; /* tunnel endpoint id */ |
| 125 | } |
| 126 | |
| 127 | struct spgw_meta_t { |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 128 | direction_t direction; |
Carmelo Cascone | 274daef | 2018-02-14 20:32:49 -0800 | [diff] [blame] | 129 | bit<16> ipv4_len; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 130 | bit<32> teid; |
| 131 | bit<32> s1u_enb_addr; |
| 132 | bit<32> s1u_sgw_addr; |
| 133 | #ifdef WITH_SPGW_PCC_GATING |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 134 | bit<16> l4_sport; |
| 135 | bit<16> l4_dport; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 136 | pcc_gate_status_t pcc_gate_status; |
| 137 | sdf_rule_id_t sdf_rule_id; |
| 138 | pcc_rule_id_t pcc_rule_id; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 139 | #endif // WITH_SPGW_PCC_GATING |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 140 | } |
| 141 | #endif // WITH_SPGW |
| 142 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 143 | //Custom metadata definition |
| 144 | struct fabric_metadata_t { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 145 | bit<16> eth_type; |
| 146 | bit<16> ip_eth_type; |
| 147 | vlan_id_t vlan_id; |
| 148 | bit<3> vlan_pri; |
| 149 | bit<1> vlan_cfi; |
| 150 | mpls_label_t mpls_label; |
| 151 | bit<8> mpls_ttl; |
| 152 | _BOOL skip_forwarding; |
| 153 | _BOOL skip_next; |
| 154 | fwd_type_t fwd_type; |
| 155 | next_id_t next_id; |
| 156 | _BOOL is_multicast; |
| 157 | _BOOL is_controller_packet_out; |
| 158 | _BOOL clone_to_cpu; |
| 159 | bit<8> ip_proto; |
| 160 | bit<16> l4_sport; |
| 161 | bit<16> l4_dport; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 162 | #ifdef WITH_SPGW |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 163 | spgw_meta_t spgw; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 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; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 173 | #ifdef WITH_XCONNECT |
| 174 | vlan_tag_t inner_vlan_tag; |
| 175 | #endif // WITH_XCONNECT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 176 | mpls_t mpls; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 177 | #ifdef WITH_SPGW |
| 178 | ipv4_t gtpu_ipv4; |
| 179 | udp_t gtpu_udp; |
| 180 | gtpu_t gtpu; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 181 | ipv4_t inner_ipv4; |
| 182 | udp_t inner_udp; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 183 | #endif // WITH_SPGW |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 184 | ipv4_t ipv4; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 185 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 186 | ipv6_t ipv6; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 187 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 188 | tcp_t tcp; |
| 189 | udp_t udp; |
| 190 | icmp_t icmp; |
| 191 | packet_out_header_t packet_out; |
| 192 | packet_in_header_t packet_in; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 193 | #ifdef WITH_INT_SINK |
| 194 | // INT Report encap |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 195 | ethernet_t report_ethernet; |
| 196 | ipv4_t report_ipv4; |
| 197 | udp_t report_udp; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 198 | // INT Report header (support only fixed) |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 199 | report_fixed_header_t report_fixed_header; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 200 | // local_report_t report_local; |
| 201 | #endif // WITH_INT_SINK |
| 202 | #ifdef WITH_INT |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 203 | // INT specific headers |
| 204 | intl4_shim_t intl4_shim; |
| 205 | int_header_t int_header; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 206 | int_switch_id_t int_switch_id; |
| 207 | int_port_ids_t int_port_ids; |
| 208 | int_hop_latency_t int_hop_latency; |
| 209 | int_q_occupancy_t int_q_occupancy; |
| 210 | int_ingress_tstamp_t int_ingress_tstamp; |
| 211 | int_egress_tstamp_t int_egress_tstamp; |
| 212 | int_q_congestion_t int_q_congestion; |
| 213 | int_egress_port_tx_util_t int_egress_tx_util; |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 214 | #ifdef WITH_INT_SINK |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 215 | int_data_t int_data; |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 216 | #endif // WITH_INT_SINK |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 217 | intl4_tail_t intl4_tail; |
| 218 | #endif //WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | #endif |