blob: f57e974f33fbd4552ba7e3dd6eb47e312e290371 [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;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080039 bit<16> eth_type;
Yi Tsengbe342052017-11-03 10:21:23 -070040}
41
42header vlan_tag_t {
43 bit<3> pri;
44 bit<1> cfi;
45 vlan_id_t vlan_id;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080046 bit<16> eth_type;
Yi Tsengbe342052017-11-03 10:21:23 -070047}
48
49header mpls_t {
50 bit<20> label;
51 bit<3> tc;
52 bit<1> bos;
53 bit<8> ttl;
54}
55
56header ipv4_t {
57 bit<4> version;
58 bit<4> ihl;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090059 bit<6> dscp;
60 bit<2> ecn;
Yi Tsengbe342052017-11-03 10:21:23 -070061 bit<16> total_len;
62 bit<16> identification;
63 bit<3> flags;
64 bit<13> frag_offset;
65 bit<8> ttl;
66 bit<8> protocol;
67 bit<16> hdr_checksum;
68 bit<32> src_addr;
69 bit<32> dst_addr;
70}
71
72header ipv6_t {
73 bit<4> version;
74 bit<8> traffic_class;
75 bit<20> flow_label;
76 bit<16> payload_len;
77 bit<8> next_hdr;
78 bit<8> hop_limit;
79 bit<128> src_addr;
80 bit<128> dst_addr;
81}
82
Yi Tsengbe342052017-11-03 10:21:23 -070083header tcp_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -080084 bit<16> sport;
85 bit<16> dport;
Yi Tsengbe342052017-11-03 10:21:23 -070086 bit<32> seq_no;
87 bit<32> ack_no;
88 bit<4> data_offset;
89 bit<3> res;
90 bit<3> ecn;
91 bit<6> ctrl;
92 bit<16> window;
93 bit<16> checksum;
94 bit<16> urgent_ptr;
95}
96
97header udp_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<16> len;
101 bit<16> checksum;
102}
103
104header icmp_t {
105 bit<8> icmp_type;
106 bit<8> icmp_code;
107 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800108 bit<16> identifier;
109 bit<16> sequence_number;
110 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700111}
112
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800113#ifdef WITH_SPGW
114// GTPU v1
115header gtpu_t {
116 bit<3> version; /* version */
117 bit<1> pt; /* protocol type */
118 bit<1> spare; /* reserved */
119 bit<1> ex_flag; /* next extension hdr present? */
120 bit<1> seq_flag; /* sequence no. */
121 bit<1> npdu_flag; /* n-pdn number present ? */
122 bit<8> msgtype; /* message type */
123 bit<16> msglen; /* message length */
124 bit<32> teid; /* tunnel endpoint id */
125}
126
127struct spgw_meta_t {
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800128 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800129 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800130 bit<32> teid;
131 bit<32> s1u_enb_addr;
132 bit<32> s1u_sgw_addr;
133#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800134 bit<16> l4_sport;
135 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800136 pcc_gate_status_t pcc_gate_status;
137 sdf_rule_id_t sdf_rule_id;
138 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800139#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800140}
141#endif // WITH_SPGW
142
Yi Tsengbe342052017-11-03 10:21:23 -0700143//Custom metadata definition
144struct fabric_metadata_t {
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800145 bit<16> eth_type;
146 bit<16> ip_eth_type;
147 vlan_id_t vlan_id;
148 bit<3> vlan_pri;
149 bit<1> vlan_cfi;
150 mpls_label_t mpls_label;
151 bit<8> mpls_ttl;
152 _BOOL skip_forwarding;
153 _BOOL skip_next;
154 fwd_type_t fwd_type;
155 next_id_t next_id;
156 _BOOL is_multicast;
157 _BOOL is_controller_packet_out;
158 _BOOL clone_to_cpu;
159 bit<8> ip_proto;
160 bit<16> l4_sport;
161 bit<16> l4_dport;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800162#ifdef WITH_SPGW
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800163 spgw_meta_t spgw;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800164#endif // WITH_SPGW
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900165#ifdef WITH_INT
166 int_metadata_t int_meta;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900167#endif // WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700168}
169
170struct parsed_headers_t {
171 ethernet_t ethernet;
172 vlan_tag_t vlan_tag;
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800173#ifdef WITH_XCONNECT
174 vlan_tag_t inner_vlan_tag;
175#endif // WITH_XCONNECT
Yi Tsengbe342052017-11-03 10:21:23 -0700176 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800177#ifdef WITH_SPGW
178 ipv4_t gtpu_ipv4;
179 udp_t gtpu_udp;
180 gtpu_t gtpu;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700181 ipv4_t inner_ipv4;
182 udp_t inner_udp;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800183#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700184 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800185#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700186 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800187#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700188 tcp_t tcp;
189 udp_t udp;
190 icmp_t icmp;
191 packet_out_header_t packet_out;
192 packet_in_header_t packet_in;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700193#ifdef WITH_INT_SINK
194 // INT Report encap
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900195 ethernet_t report_ethernet;
196 ipv4_t report_ipv4;
197 udp_t report_udp;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700198 // INT Report header (support only fixed)
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900199 report_fixed_header_t report_fixed_header;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700200 // local_report_t report_local;
201#endif // WITH_INT_SINK
202#ifdef WITH_INT
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900203 // INT specific headers
204 intl4_shim_t intl4_shim;
205 int_header_t int_header;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900206 int_switch_id_t int_switch_id;
207 int_port_ids_t int_port_ids;
208 int_hop_latency_t int_hop_latency;
209 int_q_occupancy_t int_q_occupancy;
210 int_ingress_tstamp_t int_ingress_tstamp;
211 int_egress_tstamp_t int_egress_tstamp;
212 int_q_congestion_t int_q_congestion;
213 int_egress_port_tx_util_t int_egress_tx_util;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700214#ifdef WITH_INT_SINK
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700215 int_data_t int_data;
Carmelo Cascone8e5818d2018-10-26 11:45:23 -0700216#endif // WITH_INT_SINK
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900217 intl4_tail_t intl4_tail;
218#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700219}
220
221#endif