blob: 09df685c0bc9e5814c26436eaecf727557cef354 [file] [log] [blame]
Yi Tsengbe342052017-11-03 10:21:23 -07001/*
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 Cascone79a3a312018-08-16 17:14:43 -070021#include "int/int_header.p4"
Yi Tsengbe342052017-11-03 10:21:23 -070022
23@controller_header("packet_in")
24header packet_in_header_t {
25 port_num_t ingress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080026 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070027}
28
Carmelo Cascone35d9b332018-06-15 16:27:22 +020029_PKT_OUT_HDR_ANNOT
Yi Tsengbe342052017-11-03 10:21:23 -070030@controller_header("packet_out")
31header packet_out_header_t {
32 port_num_t egress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080033 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070034}
35
36header ethernet_t {
37 mac_addr_t dst_addr;
38 mac_addr_t src_addr;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080039 bit<16> eth_type;
Yi Tsengbe342052017-11-03 10:21:23 -070040}
41
42header vlan_tag_t {
43 bit<3> pri;
44 bit<1> cfi;
45 vlan_id_t vlan_id;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080046 bit<16> eth_type;
Yi Tsengbe342052017-11-03 10:21:23 -070047}
48
49header mpls_t {
50 bit<20> label;
51 bit<3> tc;
52 bit<1> bos;
53 bit<8> ttl;
54}
55
Carmelo Cascone4d8785b2019-05-31 17:11:26 -070056header pppoe_t {
57 bit<4> version;
58 bit<4> type_id;
59 bit<8> code;
60 bit<16> session_id;
61 bit<16> length;
62 bit<16> protocol;
63}
64
Yi Tsengbe342052017-11-03 10:21:23 -070065header ipv4_t {
66 bit<4> version;
67 bit<4> ihl;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090068 bit<6> dscp;
69 bit<2> ecn;
Yi Tsengbe342052017-11-03 10:21:23 -070070 bit<16> total_len;
71 bit<16> identification;
72 bit<3> flags;
73 bit<13> frag_offset;
74 bit<8> ttl;
75 bit<8> protocol;
76 bit<16> hdr_checksum;
77 bit<32> src_addr;
78 bit<32> dst_addr;
79}
80
81header ipv6_t {
82 bit<4> version;
83 bit<8> traffic_class;
84 bit<20> flow_label;
85 bit<16> payload_len;
86 bit<8> next_hdr;
87 bit<8> hop_limit;
88 bit<128> src_addr;
89 bit<128> dst_addr;
90}
91
Yi Tsengbe342052017-11-03 10:21:23 -070092header tcp_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -080093 bit<16> sport;
94 bit<16> dport;
Yi Tsengbe342052017-11-03 10:21:23 -070095 bit<32> seq_no;
96 bit<32> ack_no;
97 bit<4> data_offset;
98 bit<3> res;
99 bit<3> ecn;
100 bit<6> ctrl;
101 bit<16> window;
102 bit<16> checksum;
103 bit<16> urgent_ptr;
104}
105
106header udp_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800107 bit<16> sport;
108 bit<16> dport;
Yi Tsengbe342052017-11-03 10:21:23 -0700109 bit<16> len;
110 bit<16> checksum;
111}
112
113header icmp_t {
114 bit<8> icmp_type;
115 bit<8> icmp_code;
116 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800117 bit<16> identifier;
118 bit<16> sequence_number;
119 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700120}
121
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800122#ifdef WITH_SPGW
123// GTPU v1
124header gtpu_t {
125 bit<3> version; /* version */
126 bit<1> pt; /* protocol type */
127 bit<1> spare; /* reserved */
128 bit<1> ex_flag; /* next extension hdr present? */
129 bit<1> seq_flag; /* sequence no. */
130 bit<1> npdu_flag; /* n-pdn number present ? */
131 bit<8> msgtype; /* message type */
132 bit<16> msglen; /* message length */
133 bit<32> teid; /* tunnel endpoint id */
134}
135
136struct spgw_meta_t {
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800137 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800138 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800139 bit<32> teid;
140 bit<32> s1u_enb_addr;
141 bit<32> s1u_sgw_addr;
142#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800143 bit<16> l4_sport;
144 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800145 pcc_gate_status_t pcc_gate_status;
146 sdf_rule_id_t sdf_rule_id;
147 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800148#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800149}
150#endif // WITH_SPGW
151
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700152#ifdef WITH_BNG
153
154typedef bit<2> bng_type_t;
155const bng_type_t BNG_TYPE_INVALID = 2w0x0;
156const bng_type_t BNG_TYPE_UPSTREAM = 2w0x1;
157const bng_type_t BNG_TYPE_DOWNSTREAM = 2w0x2;;
158
159struct bng_meta_t {
160 bit<2> type; // upstream or downstream
161 bit<32> line_id; // subscriber line
Daniele Moro7c3a0022019-07-12 13:38:34 -0700162 bit<16> pppoe_session_id;
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700163 bit<32> ds_meter_result; // for downstream metering
164}
165#endif // WITH_BNG
166
Yi Tsengbe342052017-11-03 10:21:23 -0700167//Custom metadata definition
168struct fabric_metadata_t {
Daniele Moro7c3a0022019-07-12 13:38:34 -0700169 bit<16> last_eth_type;
170 _BOOL is_ipv4;
171 _BOOL is_ipv6;
172 _BOOL is_mpls;
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800173 bit<16> ip_eth_type;
174 vlan_id_t vlan_id;
175 bit<3> vlan_pri;
176 bit<1> vlan_cfi;
Daniele Moro7c3a0022019-07-12 13:38:34 -0700177#ifdef WITH_DOUBLE_VLAN_TERMINATION
178 _BOOL push_double_vlan;
179 vlan_id_t inner_vlan_id;
180 bit<3> inner_vlan_pri;
181 bit<1> inner_vlan_cfi;
182#endif // WITH_DOUBLE_VLAN_TERMINATION
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800183 mpls_label_t mpls_label;
184 bit<8> mpls_ttl;
185 _BOOL skip_forwarding;
186 _BOOL skip_next;
187 fwd_type_t fwd_type;
188 next_id_t next_id;
189 _BOOL is_multicast;
190 _BOOL is_controller_packet_out;
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800191 bit<8> ip_proto;
192 bit<16> l4_sport;
193 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800194#ifdef WITH_SPGW
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800195 spgw_meta_t spgw;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800196#endif // WITH_SPGW
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700197#ifdef WITH_BNG
198 bng_meta_t bng;
199#endif // WITH_BNG
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900200#ifdef WITH_INT
201 int_metadata_t int_meta;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900202#endif // WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700203}
204
205struct parsed_headers_t {
206 ethernet_t ethernet;
207 vlan_tag_t vlan_tag;
Daniele Moro7c3a0022019-07-12 13:38:34 -0700208#if defined(WITH_XCONNECT) || defined(WITH_BNG) || defined(WITH_DOUBLE_VLAN_TERMINATION)
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800209 vlan_tag_t inner_vlan_tag;
Daniele Moro7c3a0022019-07-12 13:38:34 -0700210#endif // WITH_XCONNECT || WITH_BNG || WITH_DOUBLE_VLAN_TERMINATION
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700211#ifdef WITH_BNG
212 pppoe_t pppoe;
213#endif // WITH_BNG
Yi Tsengbe342052017-11-03 10:21:23 -0700214 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800215#ifdef WITH_SPGW
216 ipv4_t gtpu_ipv4;
217 udp_t gtpu_udp;
218 gtpu_t gtpu;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700219 ipv4_t inner_ipv4;
220 udp_t inner_udp;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800221#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700222 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800223#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700224 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800225#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700226 tcp_t tcp;
227 udp_t udp;
228 icmp_t icmp;
229 packet_out_header_t packet_out;
230 packet_in_header_t packet_in;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700231#ifdef WITH_INT_SINK
232 // INT Report encap
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900233 ethernet_t report_ethernet;
234 ipv4_t report_ipv4;
235 udp_t report_udp;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700236 // INT Report header (support only fixed)
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900237 report_fixed_header_t report_fixed_header;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700238 // local_report_t report_local;
239#endif // WITH_INT_SINK
240#ifdef WITH_INT
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900241 // INT specific headers
242 intl4_shim_t intl4_shim;
243 int_header_t int_header;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900244 int_switch_id_t int_switch_id;
245 int_port_ids_t int_port_ids;
246 int_hop_latency_t int_hop_latency;
247 int_q_occupancy_t int_q_occupancy;
248 int_ingress_tstamp_t int_ingress_tstamp;
249 int_egress_tstamp_t int_egress_tstamp;
250 int_q_congestion_t int_q_congestion;
251 int_egress_port_tx_util_t int_egress_tx_util;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700252#ifdef WITH_INT_SINK
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700253 int_data_t int_data;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700254#endif // WITH_INT_SINK
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900255 intl4_tail_t intl4_tail;
256#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700257}
258
259#endif