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" |
| 21 | |
| 22 | @controller_header("packet_in") |
| 23 | header packet_in_header_t { |
| 24 | port_num_t ingress_port; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 25 | bit<7> _pad; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 26 | } |
| 27 | |
Carmelo Cascone | b531b68 | 2018-01-30 17:55:56 -0800 | [diff] [blame] | 28 | _PKT_OUT_HDR_ANNOT_ |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 29 | @controller_header("packet_out") |
| 30 | header packet_out_header_t { |
| 31 | port_num_t egress_port; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 32 | bit<7> _pad; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | header ethernet_t { |
| 36 | mac_addr_t dst_addr; |
| 37 | mac_addr_t src_addr; |
| 38 | bit<16> ether_type; |
| 39 | } |
| 40 | |
| 41 | header vlan_tag_t { |
| 42 | bit<3> pri; |
| 43 | bit<1> cfi; |
| 44 | vlan_id_t vlan_id; |
| 45 | bit<16> ether_type; |
| 46 | } |
| 47 | |
| 48 | header mpls_t { |
| 49 | bit<20> label; |
| 50 | bit<3> tc; |
| 51 | bit<1> bos; |
| 52 | bit<8> ttl; |
| 53 | } |
| 54 | |
| 55 | header ipv4_t { |
| 56 | bit<4> version; |
| 57 | bit<4> ihl; |
| 58 | bit<8> diffserv; |
| 59 | bit<16> total_len; |
| 60 | bit<16> identification; |
| 61 | bit<3> flags; |
| 62 | bit<13> frag_offset; |
| 63 | bit<8> ttl; |
| 64 | bit<8> protocol; |
| 65 | bit<16> hdr_checksum; |
| 66 | bit<32> src_addr; |
| 67 | bit<32> dst_addr; |
| 68 | } |
| 69 | |
| 70 | header ipv6_t { |
| 71 | bit<4> version; |
| 72 | bit<8> traffic_class; |
| 73 | bit<20> flow_label; |
| 74 | bit<16> payload_len; |
| 75 | bit<8> next_hdr; |
| 76 | bit<8> hop_limit; |
| 77 | bit<128> src_addr; |
| 78 | bit<128> dst_addr; |
| 79 | } |
| 80 | |
| 81 | header arp_t { |
| 82 | bit<16> hw_type; |
| 83 | bit<16> proto_type; |
| 84 | bit<8> hw_addr_len; |
| 85 | bit<8> proto_addr_len; |
| 86 | bit<16> opcode; |
| 87 | } |
| 88 | |
| 89 | header tcp_t { |
| 90 | bit<16> src_port; |
| 91 | bit<16> dst_port; |
| 92 | bit<32> seq_no; |
| 93 | bit<32> ack_no; |
| 94 | bit<4> data_offset; |
| 95 | bit<3> res; |
| 96 | bit<3> ecn; |
| 97 | bit<6> ctrl; |
| 98 | bit<16> window; |
| 99 | bit<16> checksum; |
| 100 | bit<16> urgent_ptr; |
| 101 | } |
| 102 | |
| 103 | header udp_t { |
| 104 | bit<16> src_port; |
| 105 | bit<16> dst_port; |
| 106 | bit<16> len; |
| 107 | bit<16> checksum; |
| 108 | } |
| 109 | |
| 110 | header icmp_t { |
| 111 | bit<8> icmp_type; |
| 112 | bit<8> icmp_code; |
| 113 | bit<16> checksum; |
Yi Tseng | f73a553 | 2017-11-17 15:58:57 -0800 | [diff] [blame] | 114 | bit<16> identifier; |
| 115 | bit<16> sequence_number; |
| 116 | bit<64> timestamp; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 119 | #ifdef WITH_SPGW |
| 120 | // GTPU v1 |
| 121 | header gtpu_t { |
| 122 | bit<3> version; /* version */ |
| 123 | bit<1> pt; /* protocol type */ |
| 124 | bit<1> spare; /* reserved */ |
| 125 | bit<1> ex_flag; /* next extension hdr present? */ |
| 126 | bit<1> seq_flag; /* sequence no. */ |
| 127 | bit<1> npdu_flag; /* n-pdn number present ? */ |
| 128 | bit<8> msgtype; /* message type */ |
| 129 | bit<16> msglen; /* message length */ |
| 130 | bit<32> teid; /* tunnel endpoint id */ |
| 131 | } |
| 132 | |
| 133 | struct spgw_meta_t { |
| 134 | bool do_spgw; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 135 | direction_t direction; |
Carmelo Cascone | 274daef | 2018-02-14 20:32:49 -0800 | [diff] [blame] | 136 | bit<16> ipv4_len; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 137 | bit<32> teid; |
| 138 | bit<32> s1u_enb_addr; |
| 139 | bit<32> s1u_sgw_addr; |
| 140 | #ifdef WITH_SPGW_PCC_GATING |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 141 | bit<16> l4_src_port; |
| 142 | bit<16> l4_dst_port; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 143 | pcc_gate_status_t pcc_gate_status; |
| 144 | sdf_rule_id_t sdf_rule_id; |
| 145 | pcc_rule_id_t pcc_rule_id; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 146 | #endif // WITH_SPGW_PCC_GATING |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 147 | } |
| 148 | #endif // WITH_SPGW |
| 149 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 150 | //Custom metadata definition |
| 151 | struct fabric_metadata_t { |
| 152 | fwd_type_t fwd_type; |
| 153 | next_id_t next_id; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 154 | bool pop_vlan_at_egress; |
| 155 | bit<8> ip_proto; |
| 156 | bit<16> l4_src_port; |
| 157 | bit<16> l4_dst_port; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 158 | bit<16> original_ether_type; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 159 | #ifdef WITH_SPGW |
| 160 | spgw_meta_t spgw; |
| 161 | #endif // WITH_SPGW |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | struct parsed_headers_t { |
| 165 | ethernet_t ethernet; |
| 166 | vlan_tag_t vlan_tag; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 167 | mpls_t mpls; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 168 | #ifdef WITH_SPGW |
| 169 | ipv4_t gtpu_ipv4; |
| 170 | udp_t gtpu_udp; |
| 171 | gtpu_t gtpu; |
| 172 | #endif // WITH_SPGW |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 173 | ipv4_t ipv4; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 174 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 175 | ipv6_t ipv6; |
Carmelo Cascone | b757dbc | 2018-01-25 17:53:17 -0800 | [diff] [blame] | 176 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 177 | arp_t arp; |
| 178 | tcp_t tcp; |
| 179 | udp_t udp; |
| 180 | icmp_t icmp; |
| 181 | packet_out_header_t packet_out; |
| 182 | packet_in_header_t packet_in; |
| 183 | } |
| 184 | |
| 185 | #endif |