blob: 5591c11d6e3480ef765f5f27539750b7e9d8d50a [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"
21
22@controller_header("packet_in")
23header packet_in_header_t {
24 port_num_t ingress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080025 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070026}
27
Carmelo Cascone35d9b332018-06-15 16:27:22 +020028_PKT_OUT_HDR_ANNOT
Yi Tsengbe342052017-11-03 10:21:23 -070029@controller_header("packet_out")
30header packet_out_header_t {
31 port_num_t egress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080032 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070033}
34
35header ethernet_t {
36 mac_addr_t dst_addr;
37 mac_addr_t src_addr;
38 bit<16> ether_type;
39}
40
41header vlan_tag_t {
42 bit<3> pri;
43 bit<1> cfi;
44 vlan_id_t vlan_id;
45 bit<16> ether_type;
46}
47
48header mpls_t {
49 bit<20> label;
50 bit<3> tc;
51 bit<1> bos;
52 bit<8> ttl;
53}
54
55header ipv4_t {
56 bit<4> version;
57 bit<4> ihl;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090058 bit<6> dscp;
59 bit<2> ecn;
Yi Tsengbe342052017-11-03 10:21:23 -070060 bit<16> total_len;
61 bit<16> identification;
62 bit<3> flags;
63 bit<13> frag_offset;
64 bit<8> ttl;
65 bit<8> protocol;
66 bit<16> hdr_checksum;
67 bit<32> src_addr;
68 bit<32> dst_addr;
69}
70
71header ipv6_t {
72 bit<4> version;
73 bit<8> traffic_class;
74 bit<20> flow_label;
75 bit<16> payload_len;
76 bit<8> next_hdr;
77 bit<8> hop_limit;
78 bit<128> src_addr;
79 bit<128> dst_addr;
80}
81
82header arp_t {
83 bit<16> hw_type;
84 bit<16> proto_type;
85 bit<8> hw_addr_len;
86 bit<8> proto_addr_len;
87 bit<16> opcode;
88}
89
90header tcp_t {
91 bit<16> src_port;
92 bit<16> dst_port;
93 bit<32> seq_no;
94 bit<32> ack_no;
95 bit<4> data_offset;
96 bit<3> res;
97 bit<3> ecn;
98 bit<6> ctrl;
99 bit<16> window;
100 bit<16> checksum;
101 bit<16> urgent_ptr;
102}
103
104header udp_t {
105 bit<16> src_port;
106 bit<16> dst_port;
107 bit<16> len;
108 bit<16> checksum;
109}
110
111header icmp_t {
112 bit<8> icmp_type;
113 bit<8> icmp_code;
114 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800115 bit<16> identifier;
116 bit<16> sequence_number;
117 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700118}
119
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800120#ifdef WITH_SPGW
121// GTPU v1
122header gtpu_t {
123 bit<3> version; /* version */
124 bit<1> pt; /* protocol type */
125 bit<1> spare; /* reserved */
126 bit<1> ex_flag; /* next extension hdr present? */
127 bit<1> seq_flag; /* sequence no. */
128 bit<1> npdu_flag; /* n-pdn number present ? */
129 bit<8> msgtype; /* message type */
130 bit<16> msglen; /* message length */
131 bit<32> teid; /* tunnel endpoint id */
132}
133
134struct spgw_meta_t {
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800135 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800136 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800137 bit<32> teid;
138 bit<32> s1u_enb_addr;
139 bit<32> s1u_sgw_addr;
140#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800141 bit<16> l4_src_port;
142 bit<16> l4_dst_port;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800143 pcc_gate_status_t pcc_gate_status;
144 sdf_rule_id_t sdf_rule_id;
145 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800146#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800147}
148#endif // WITH_SPGW
149
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900150#ifdef WITH_INT
151// Report Telemetry Headers
152header report_fixed_header_t {
153 bit<4> ver;
154 bit<4> nproto;
155 bit<1> d;
156 bit<1> q;
157 bit<1> f;
158 bit<15> rsvd;
159 bit<6> hw_id;
160 bit<32> seq_no;
161 bit<32> ingress_tstamp;
162}
163
164// Telemetry drop report header
165header drop_report_header_t {
166 bit<32> switch_id;
167 bit<16> ingress_port_id;
168 bit<16> egress_port_id;
169 bit<8> queue_id;
170 bit<8> drop_reason;
171 bit<16> pad;
172}
173
174// Switch Local Report Header
175header local_report_header_t {
176 bit<32> switch_id;
177 bit<16> ingress_port_id;
178 bit<16> egress_port_id;
179 bit<8> queue_id;
180 bit<24> queue_occupancy;
181 bit<32> egress_tstamp;
182}
183
184header_union local_report_t {
185 drop_report_header_t drop_report_header;
186 local_report_header_t local_report_header;
187}
188
189// INT headers
190header int_header_t {
191 bit<2> ver;
192 bit<2> rep;
193 bit<1> c;
194 bit<1> e;
195 bit<5> rsvd1;
196 bit<5> ins_cnt;
197 bit<8> max_hop_cnt;
198 bit<8> total_hop_cnt;
199 bit<4> instruction_mask_0003; /* split the bits for lookup */
200 bit<4> instruction_mask_0407;
201 bit<4> instruction_mask_0811;
202 bit<4> instruction_mask_1215;
203 bit<16> rsvd2;
204}
205
206// INT meta-value headers - different header for each value type
207header int_switch_id_t {
208 bit<32> switch_id;
209}
210header int_port_ids_t {
211 bit<16> ingress_port_id;
212 bit<16> egress_port_id;
213}
214header int_hop_latency_t {
215 bit<32> hop_latency;
216}
217header int_q_occupancy_t {
218 bit<8> q_id;
219 bit<24> q_occupancy;
220}
221header int_ingress_tstamp_t {
222 bit<32> ingress_tstamp;
223}
224header int_egress_tstamp_t {
225 bit<32> egress_tstamp;
226}
227header int_q_congestion_t {
228 bit<8> q_id;
229 bit<24> q_congestion;
230}
231header int_egress_port_tx_util_t {
232 bit<32> egress_port_tx_util;
233}
234
235header int_data_t {
236 // Maximum int metadata stack size in bits:
237 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
238 varbit<8032> data;
239}
240
241/* INT shim header for TCP/UDP */
242header intl4_shim_t {
243 bit<8> int_type;
244 bit<8> rsvd1;
245 bit<8> len;
246 bit<8> rsvd2;
247}
248/* INT tail header for TCP/UDP */
249header intl4_tail_t {
250 bit<8> next_proto;
251 bit<16> dest_port;
252 bit<8> dscp;
253}
254
255struct int_metadata_t {
256 switch_id_t switch_id;
257 bit<16> insert_byte_cnt;
258 bit<1> source;
259 bit<1> sink;
260 bit<8> mirror_id;
261 bit<16> flow_id;
262 bit<8> metadata_len;
263}
264#endif // WITH_INT
265
Yi Tsengbe342052017-11-03 10:21:23 -0700266//Custom metadata definition
267struct fabric_metadata_t {
268 fwd_type_t fwd_type;
269 next_id_t next_id;
Carmelo Cascone35d9b332018-06-15 16:27:22 +0200270 _BOOL pop_vlan_when_packet_in;
Carmelo Cascone1e8843f2018-07-19 19:01:12 +0200271 _BOOL is_multicast;
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -0700272 _BOOL is_controller_packet_out;
Carmelo Cascone1e8843f2018-07-19 19:01:12 +0200273 _BOOL clone_to_cpu;
Yi Tsengbe342052017-11-03 10:21:23 -0700274 bit<8> ip_proto;
275 bit<16> l4_src_port;
276 bit<16> l4_dst_port;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800277#ifdef WITH_SPGW
278 spgw_meta_t spgw;
279#endif // WITH_SPGW
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900280#ifdef WITH_INT
281 int_metadata_t int_meta;
282 bool compute_checksum;
283#endif // WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700284}
285
286struct parsed_headers_t {
287 ethernet_t ethernet;
288 vlan_tag_t vlan_tag;
Yi Tsengbe342052017-11-03 10:21:23 -0700289 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800290#ifdef WITH_SPGW
291 ipv4_t gtpu_ipv4;
292 udp_t gtpu_udp;
293 gtpu_t gtpu;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700294 ipv4_t inner_ipv4;
295 udp_t inner_udp;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800296#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700297 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800298#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700299 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800300#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700301 arp_t arp;
302 tcp_t tcp;
303 udp_t udp;
304 icmp_t icmp;
305 packet_out_header_t packet_out;
306 packet_in_header_t packet_in;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900307#ifdef WITH_INT
308 // INT Report Encapsulation
309 ethernet_t report_ethernet;
310 ipv4_t report_ipv4;
311 udp_t report_udp;
312 // INT Report Headers
313 report_fixed_header_t report_fixed_header;
314 local_report_t report_local;
315 // INT specific headers
316 intl4_shim_t intl4_shim;
317 int_header_t int_header;
318 int_data_t int_data;
319 int_switch_id_t int_switch_id;
320 int_port_ids_t int_port_ids;
321 int_hop_latency_t int_hop_latency;
322 int_q_occupancy_t int_q_occupancy;
323 int_ingress_tstamp_t int_ingress_tstamp;
324 int_egress_tstamp_t int_egress_tstamp;
325 int_q_congestion_t int_q_congestion;
326 int_egress_port_tx_util_t int_egress_tx_util;
327 intl4_tail_t intl4_tail;
328#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700329}
330
331#endif