blob: bea96195ce3bf0776152308f3053825c966ac3bf [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;
Daniele Moro5a2de712019-09-24 14:34:07 -070039}
40
41// NOTE: splitting the eth_type from the ethernet header helps to match on
42// the actual eth_type without checking validity bit of the VLAN tags.
43header eth_type_t {
44 bit<16> value;
Yi Tsengbe342052017-11-03 10:21:23 -070045}
46
47header vlan_tag_t {
Daniele Moro5a2de712019-09-24 14:34:07 -070048 bit<16> eth_type;
Yi Tsengbe342052017-11-03 10:21:23 -070049 bit<3> pri;
50 bit<1> cfi;
51 vlan_id_t vlan_id;
Yi Tsengbe342052017-11-03 10:21:23 -070052}
53
54header mpls_t {
55 bit<20> label;
56 bit<3> tc;
57 bit<1> bos;
58 bit<8> ttl;
59}
60
Carmelo Cascone4d8785b2019-05-31 17:11:26 -070061header pppoe_t {
62 bit<4> version;
63 bit<4> type_id;
64 bit<8> code;
65 bit<16> session_id;
66 bit<16> length;
67 bit<16> protocol;
68}
69
Yi Tsengbe342052017-11-03 10:21:23 -070070header ipv4_t {
71 bit<4> version;
72 bit<4> ihl;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090073 bit<6> dscp;
74 bit<2> ecn;
Yi Tsengbe342052017-11-03 10:21:23 -070075 bit<16> total_len;
76 bit<16> identification;
77 bit<3> flags;
78 bit<13> frag_offset;
79 bit<8> ttl;
80 bit<8> protocol;
81 bit<16> hdr_checksum;
82 bit<32> src_addr;
83 bit<32> dst_addr;
84}
85
86header ipv6_t {
87 bit<4> version;
88 bit<8> traffic_class;
89 bit<20> flow_label;
90 bit<16> payload_len;
91 bit<8> next_hdr;
92 bit<8> hop_limit;
93 bit<128> src_addr;
94 bit<128> dst_addr;
95}
96
Yi Tsengbe342052017-11-03 10:21:23 -070097header tcp_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -080098 bit<16> sport;
99 bit<16> dport;
Yi Tsengbe342052017-11-03 10:21:23 -0700100 bit<32> seq_no;
101 bit<32> ack_no;
102 bit<4> data_offset;
103 bit<3> res;
104 bit<3> ecn;
105 bit<6> ctrl;
106 bit<16> window;
107 bit<16> checksum;
108 bit<16> urgent_ptr;
109}
110
111header udp_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800112 bit<16> sport;
113 bit<16> dport;
Yi Tsengbe342052017-11-03 10:21:23 -0700114 bit<16> len;
115 bit<16> checksum;
116}
117
118header icmp_t {
119 bit<8> icmp_type;
120 bit<8> icmp_code;
121 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800122 bit<16> identifier;
123 bit<16> sequence_number;
124 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700125}
126
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800127#ifdef WITH_SPGW
128// GTPU v1
129header gtpu_t {
130 bit<3> version; /* version */
131 bit<1> pt; /* protocol type */
132 bit<1> spare; /* reserved */
133 bit<1> ex_flag; /* next extension hdr present? */
134 bit<1> seq_flag; /* sequence no. */
135 bit<1> npdu_flag; /* n-pdn number present ? */
136 bit<8> msgtype; /* message type */
137 bit<16> msglen; /* message length */
138 bit<32> teid; /* tunnel endpoint id */
139}
140
141struct spgw_meta_t {
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800142 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800143 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800144 bit<32> teid;
145 bit<32> s1u_enb_addr;
146 bit<32> s1u_sgw_addr;
147#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800148 bit<16> l4_sport;
149 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800150 pcc_gate_status_t pcc_gate_status;
151 sdf_rule_id_t sdf_rule_id;
152 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800153#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800154}
155#endif // WITH_SPGW
156
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700157#ifdef WITH_BNG
158
159typedef bit<2> bng_type_t;
160const bng_type_t BNG_TYPE_INVALID = 2w0x0;
161const bng_type_t BNG_TYPE_UPSTREAM = 2w0x1;
162const bng_type_t BNG_TYPE_DOWNSTREAM = 2w0x2;;
163
164struct bng_meta_t {
Daniele Morob3d199b2019-11-01 14:01:46 -0700165 bit<2> type; // upstream or downstream
166 bit<32> line_id; // subscriber line
167 bit<16> pppoe_session_id;
168 bit<32> ds_meter_result; // for downstream metering
169 vlan_id_t s_tag;
170 vlan_id_t c_tag;
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700171}
172#endif // WITH_BNG
173
Yi Tsengbe342052017-11-03 10:21:23 -0700174//Custom metadata definition
175struct fabric_metadata_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800176 bit<16> ip_eth_type;
177 vlan_id_t vlan_id;
178 bit<3> vlan_pri;
179 bit<1> vlan_cfi;
Daniele Moro7c3a0022019-07-12 13:38:34 -0700180#ifdef WITH_DOUBLE_VLAN_TERMINATION
181 _BOOL push_double_vlan;
182 vlan_id_t inner_vlan_id;
183 bit<3> inner_vlan_pri;
184 bit<1> inner_vlan_cfi;
185#endif // WITH_DOUBLE_VLAN_TERMINATION
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800186 mpls_label_t mpls_label;
187 bit<8> mpls_ttl;
188 _BOOL skip_forwarding;
189 _BOOL skip_next;
190 fwd_type_t fwd_type;
191 next_id_t next_id;
192 _BOOL is_multicast;
193 _BOOL is_controller_packet_out;
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800194 bit<8> ip_proto;
195 bit<16> l4_sport;
196 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800197#ifdef WITH_SPGW
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800198 spgw_meta_t spgw;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800199#endif // WITH_SPGW
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700200#ifdef WITH_BNG
201 bng_meta_t bng;
202#endif // WITH_BNG
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900203#ifdef WITH_INT
204 int_metadata_t int_meta;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900205#endif // WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700206}
207
208struct parsed_headers_t {
209 ethernet_t ethernet;
210 vlan_tag_t vlan_tag;
Daniele Moro5a2de712019-09-24 14:34:07 -0700211#if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION)
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800212 vlan_tag_t inner_vlan_tag;
Daniele Moro5a2de712019-09-24 14:34:07 -0700213#endif // WITH_XCONNECT || WITH_DOUBLE_VLAN_TERMINATION
214 eth_type_t eth_type;
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700215#ifdef WITH_BNG
216 pppoe_t pppoe;
217#endif // WITH_BNG
Yi Tsengbe342052017-11-03 10:21:23 -0700218 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800219#ifdef WITH_SPGW
220 ipv4_t gtpu_ipv4;
221 udp_t gtpu_udp;
222 gtpu_t gtpu;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700223 ipv4_t inner_ipv4;
224 udp_t inner_udp;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800225#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700226 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800227#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700228 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800229#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700230 tcp_t tcp;
231 udp_t udp;
232 icmp_t icmp;
233 packet_out_header_t packet_out;
234 packet_in_header_t packet_in;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700235#ifdef WITH_INT_SINK
236 // INT Report encap
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900237 ethernet_t report_ethernet;
Daniele Moro5a2de712019-09-24 14:34:07 -0700238 eth_type_t report_eth_type;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900239 ipv4_t report_ipv4;
240 udp_t report_udp;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700241 // INT Report header (support only fixed)
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900242 report_fixed_header_t report_fixed_header;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700243 // local_report_t report_local;
244#endif // WITH_INT_SINK
245#ifdef WITH_INT
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900246 // INT specific headers
247 intl4_shim_t intl4_shim;
248 int_header_t int_header;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900249 int_switch_id_t int_switch_id;
250 int_port_ids_t int_port_ids;
251 int_hop_latency_t int_hop_latency;
252 int_q_occupancy_t int_q_occupancy;
253 int_ingress_tstamp_t int_ingress_tstamp;
254 int_egress_tstamp_t int_egress_tstamp;
255 int_q_congestion_t int_q_congestion;
256 int_egress_port_tx_util_t int_egress_tx_util;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700257#ifdef WITH_INT_SINK
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700258 int_data_t int_data;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700259#endif // WITH_INT_SINK
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900260 intl4_tail_t intl4_tail;
261#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700262}
263
264#endif