blob: 6a484524585cc1dabd62de8ca7231d8023530251 [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 Casconeb531b682018-01-30 17:55:56 -080028_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;
Carmelo Cascone04888222018-03-19 22:18:12 -070058 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 Cascone04888222018-03-19 22:18:12 -0700135 bit<1> 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
Carmelo Cascone04888222018-03-19 22:18:12 -0700151#ifdef WITH_INT_TRANSIT
152
153header intl4_shim_t {
154 bit<8> int_type;
155 bit<8> rsvd1;
156 bit<8> len;
157 bit<8> rsvd2;
158}
159
160// INT headers
161header int_header_t {
162 bit<4> ver;
163 bit<2> rep;
164 bit<1> c;
165 bit<1> e;
166 bit<3> rsvd1;
167 bit<5> ins_cnt;
168 bit<8> max_hop_cnt;
169 bit<8> total_hop_cnt;
170 bit<4> instruction_mask_0003; // split the bits for lookup
171 bit<4> instruction_mask_0407;
172 bit<4> instruction_mask_0811;
173 bit<4> instruction_mask_1215;
174 bit<16> rsvd2;
175}
176
177// INT meta-value headers - different header for each value type
178header int_switch_id_t {
179 bit<32> switch_id;
180}
181
182header int_port_ids_t {
183 bit<16> ingress_port_id;
184 bit<16> egress_port_id;
185}
186
187header int_hop_latency_t {
188 bit<32> hop_latency;
189}
190
191header int_q_occupancy_t {
192 bit<8> q_id;
193 bit<24> q_occupancy;
194}
195
196header int_ingress_tstamp_t {
197 bit<32> ingress_tstamp;
198}
199
200header int_egress_tstamp_t {
201 bit<32> egress_tstamp;
202}
203
204header int_q_congestion_t {
205 bit<8> q_id;
206 bit<24> q_congestion;
207}
208
209header int_egress_port_tx_util_t {
210 bit<32> egress_port_tx_util;
211}
212
213// switch internal variables for INT logic implementation
214struct int_metadata_t {
215 bit<16> insert_byte_cnt;
216 bit<8> int_hdr_word_len;
217 bit<32> switch_id;
218 bit<5> ins_cnt_tmp;
219}
220
221#endif // WITH_INT_TRANSIT
222
Yi Tsengbe342052017-11-03 10:21:23 -0700223//Custom metadata definition
224struct fabric_metadata_t {
225 fwd_type_t fwd_type;
226 next_id_t next_id;
Yi Tsengbe342052017-11-03 10:21:23 -0700227 bool pop_vlan_at_egress;
228 bit<8> ip_proto;
229 bit<16> l4_src_port;
230 bit<16> l4_dst_port;
Yi Tseng1d842672017-11-28 16:06:52 -0800231 bit<16> original_ether_type;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800232#ifdef WITH_SPGW
233 spgw_meta_t spgw;
234#endif // WITH_SPGW
Carmelo Cascone04888222018-03-19 22:18:12 -0700235#ifdef WITH_INT_TRANSIT
236 int_metadata_t int_metadata;
237#endif // WITH_INT_TRANSIT
Yi Tsengbe342052017-11-03 10:21:23 -0700238}
239
240struct parsed_headers_t {
241 ethernet_t ethernet;
242 vlan_tag_t vlan_tag;
Yi Tsengbe342052017-11-03 10:21:23 -0700243 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800244#ifdef WITH_SPGW
245 ipv4_t gtpu_ipv4;
246 udp_t gtpu_udp;
247 gtpu_t gtpu;
248#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700249 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800250#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700251 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800252#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700253 arp_t arp;
254 tcp_t tcp;
255 udp_t udp;
256 icmp_t icmp;
257 packet_out_header_t packet_out;
258 packet_in_header_t packet_in;
Carmelo Cascone04888222018-03-19 22:18:12 -0700259#ifdef WITH_INT_TRANSIT
260 intl4_shim_t intl4_shim;
261 int_header_t int_header;
262 int_switch_id_t int_switch_id;
263 int_port_ids_t int_port_ids;
264 int_hop_latency_t int_hop_latency;
265 int_q_occupancy_t int_q_occupancy;
266 int_ingress_tstamp_t int_ingress_tstamp;
267 int_egress_tstamp_t int_egress_tstamp;
268 int_q_congestion_t int_q_congestion;
269 int_egress_port_tx_util_t int_egress_port_tx_util;
270#endif // WITH_INT_TRANSIT
Yi Tsengbe342052017-11-03 10:21:23 -0700271}
272
273#endif