blob: c1df60ed68bc727111596f50cebf3bceb596f9b8 [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 Cascone35d9b332018-06-15 16:27:22 +0200135 _BOOL do_spgw;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800136 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800137 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800138 bit<32> teid;
139 bit<32> s1u_enb_addr;
140 bit<32> s1u_sgw_addr;
141#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800142 bit<16> l4_src_port;
143 bit<16> l4_dst_port;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800144 pcc_gate_status_t pcc_gate_status;
145 sdf_rule_id_t sdf_rule_id;
146 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800147#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800148}
149#endif // WITH_SPGW
150
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900151#ifdef WITH_INT
152// Report Telemetry Headers
153header report_fixed_header_t {
154 bit<4> ver;
155 bit<4> nproto;
156 bit<1> d;
157 bit<1> q;
158 bit<1> f;
159 bit<15> rsvd;
160 bit<6> hw_id;
161 bit<32> seq_no;
162 bit<32> ingress_tstamp;
163}
164
165// Telemetry drop report header
166header drop_report_header_t {
167 bit<32> switch_id;
168 bit<16> ingress_port_id;
169 bit<16> egress_port_id;
170 bit<8> queue_id;
171 bit<8> drop_reason;
172 bit<16> pad;
173}
174
175// Switch Local Report Header
176header local_report_header_t {
177 bit<32> switch_id;
178 bit<16> ingress_port_id;
179 bit<16> egress_port_id;
180 bit<8> queue_id;
181 bit<24> queue_occupancy;
182 bit<32> egress_tstamp;
183}
184
185header_union local_report_t {
186 drop_report_header_t drop_report_header;
187 local_report_header_t local_report_header;
188}
189
190// INT headers
191header int_header_t {
192 bit<2> ver;
193 bit<2> rep;
194 bit<1> c;
195 bit<1> e;
196 bit<5> rsvd1;
197 bit<5> ins_cnt;
198 bit<8> max_hop_cnt;
199 bit<8> total_hop_cnt;
200 bit<4> instruction_mask_0003; /* split the bits for lookup */
201 bit<4> instruction_mask_0407;
202 bit<4> instruction_mask_0811;
203 bit<4> instruction_mask_1215;
204 bit<16> rsvd2;
205}
206
207// INT meta-value headers - different header for each value type
208header int_switch_id_t {
209 bit<32> switch_id;
210}
211header int_port_ids_t {
212 bit<16> ingress_port_id;
213 bit<16> egress_port_id;
214}
215header int_hop_latency_t {
216 bit<32> hop_latency;
217}
218header int_q_occupancy_t {
219 bit<8> q_id;
220 bit<24> q_occupancy;
221}
222header int_ingress_tstamp_t {
223 bit<32> ingress_tstamp;
224}
225header int_egress_tstamp_t {
226 bit<32> egress_tstamp;
227}
228header int_q_congestion_t {
229 bit<8> q_id;
230 bit<24> q_congestion;
231}
232header int_egress_port_tx_util_t {
233 bit<32> egress_port_tx_util;
234}
235
236header int_data_t {
237 // Maximum int metadata stack size in bits:
238 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
239 varbit<8032> data;
240}
241
242/* INT shim header for TCP/UDP */
243header intl4_shim_t {
244 bit<8> int_type;
245 bit<8> rsvd1;
246 bit<8> len;
247 bit<8> rsvd2;
248}
249/* INT tail header for TCP/UDP */
250header intl4_tail_t {
251 bit<8> next_proto;
252 bit<16> dest_port;
253 bit<8> dscp;
254}
255
256struct int_metadata_t {
257 switch_id_t switch_id;
258 bit<16> insert_byte_cnt;
259 bit<1> source;
260 bit<1> sink;
261 bit<8> mirror_id;
262 bit<16> flow_id;
263 bit<8> metadata_len;
264}
265#endif // WITH_INT
266
Yi Tsengbe342052017-11-03 10:21:23 -0700267//Custom metadata definition
268struct fabric_metadata_t {
269 fwd_type_t fwd_type;
270 next_id_t next_id;
Carmelo Cascone35d9b332018-06-15 16:27:22 +0200271 _BOOL pop_vlan_when_packet_in;
Carmelo Cascone1e8843f2018-07-19 19:01:12 +0200272 _BOOL is_multicast;
273 _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;
294#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700295 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800296#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700297 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800298#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700299 arp_t arp;
300 tcp_t tcp;
301 udp_t udp;
302 icmp_t icmp;
303 packet_out_header_t packet_out;
304 packet_in_header_t packet_in;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900305#ifdef WITH_INT
306 // INT Report Encapsulation
307 ethernet_t report_ethernet;
308 ipv4_t report_ipv4;
309 udp_t report_udp;
310 // INT Report Headers
311 report_fixed_header_t report_fixed_header;
312 local_report_t report_local;
313 // INT specific headers
314 intl4_shim_t intl4_shim;
315 int_header_t int_header;
316 int_data_t int_data;
317 int_switch_id_t int_switch_id;
318 int_port_ids_t int_port_ids;
319 int_hop_latency_t int_hop_latency;
320 int_q_occupancy_t int_q_occupancy;
321 int_ingress_tstamp_t int_ingress_tstamp;
322 int_egress_tstamp_t int_egress_tstamp;
323 int_q_congestion_t int_q_congestion;
324 int_egress_port_tx_util_t int_egress_tx_util;
325 intl4_tail_t intl4_tail;
326#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700327}
328
329#endif