blob: 2ffaf1b6b561800cfe9c9aef7e444d477f54fa51 [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;
137 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
Carmelo Cascone04888222018-03-19 22:18:12 -0700150#ifdef WITH_INT_TRANSIT
151
Carmelo Cascone103c0a02018-03-24 00:36:06 -0700152header intl4_shim_t { // 4 byte
Carmelo Cascone04888222018-03-19 22:18:12 -0700153 bit<8> int_type;
154 bit<8> rsvd1;
155 bit<8> len;
156 bit<8> rsvd2;
157}
158
Carmelo Cascone103c0a02018-03-24 00:36:06 -0700159// INT headers / 8byte
Carmelo Cascone04888222018-03-19 22:18:12 -0700160header int_header_t {
161 bit<4> ver;
162 bit<2> rep;
163 bit<1> c;
164 bit<1> e;
165 bit<3> rsvd1;
166 bit<5> ins_cnt;
167 bit<8> max_hop_cnt;
168 bit<8> total_hop_cnt;
169 bit<4> instruction_mask_0003; // split the bits for lookup
170 bit<4> instruction_mask_0407;
171 bit<4> instruction_mask_0811;
172 bit<4> instruction_mask_1215;
173 bit<16> rsvd2;
174}
175
176// INT meta-value headers - different header for each value type
177header int_switch_id_t {
178 bit<32> switch_id;
179}
180
181header int_port_ids_t {
182 bit<16> ingress_port_id;
183 bit<16> egress_port_id;
184}
185
186header int_hop_latency_t {
187 bit<32> hop_latency;
188}
189
190header int_q_occupancy_t {
191 bit<8> q_id;
192 bit<24> q_occupancy;
193}
194
195header int_ingress_tstamp_t {
196 bit<32> ingress_tstamp;
197}
198
199header int_egress_tstamp_t {
200 bit<32> egress_tstamp;
201}
202
203header int_q_congestion_t {
204 bit<8> q_id;
205 bit<24> q_congestion;
206}
207
208header int_egress_port_tx_util_t {
209 bit<32> egress_port_tx_util;
210}
211
212// switch internal variables for INT logic implementation
213struct int_metadata_t {
214 bit<16> insert_byte_cnt;
215 bit<8> int_hdr_word_len;
216 bit<32> switch_id;
217 bit<5> ins_cnt_tmp;
218}
219
220#endif // WITH_INT_TRANSIT
221
Yi Tsengbe342052017-11-03 10:21:23 -0700222//Custom metadata definition
223struct fabric_metadata_t {
224 fwd_type_t fwd_type;
225 next_id_t next_id;
Yi Tsengbe342052017-11-03 10:21:23 -0700226 bool pop_vlan_at_egress;
227 bit<8> ip_proto;
228 bit<16> l4_src_port;
229 bit<16> l4_dst_port;
Yi Tseng1d842672017-11-28 16:06:52 -0800230 bit<16> original_ether_type;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800231#ifdef WITH_SPGW
232 spgw_meta_t spgw;
233#endif // WITH_SPGW
Carmelo Cascone04888222018-03-19 22:18:12 -0700234#ifdef WITH_INT_TRANSIT
235 int_metadata_t int_metadata;
236#endif // WITH_INT_TRANSIT
Yi Tsengbe342052017-11-03 10:21:23 -0700237}
238
239struct parsed_headers_t {
240 ethernet_t ethernet;
241 vlan_tag_t vlan_tag;
Yi Tsengbe342052017-11-03 10:21:23 -0700242 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800243#ifdef WITH_SPGW
244 ipv4_t gtpu_ipv4;
245 udp_t gtpu_udp;
246 gtpu_t gtpu;
247#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700248 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800249#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700250 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800251#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700252 arp_t arp;
253 tcp_t tcp;
254 udp_t udp;
255 icmp_t icmp;
256 packet_out_header_t packet_out;
257 packet_in_header_t packet_in;
Carmelo Cascone04888222018-03-19 22:18:12 -0700258#ifdef WITH_INT_TRANSIT
259 intl4_shim_t intl4_shim;
260 int_header_t int_header;
261 int_switch_id_t int_switch_id;
262 int_port_ids_t int_port_ids;
263 int_hop_latency_t int_hop_latency;
264 int_q_occupancy_t int_q_occupancy;
265 int_ingress_tstamp_t int_ingress_tstamp;
266 int_egress_tstamp_t int_egress_tstamp;
267 int_q_congestion_t int_q_congestion;
268 int_egress_port_tx_util_t int_egress_port_tx_util;
269#endif // WITH_INT_TRANSIT
Yi Tsengbe342052017-11-03 10:21:23 -0700270}
271
272#endif