blob: 46fa022d1ad6b2b7a0f8694de3bc8ae9b4cec856 [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;
39 bit<16> ether_type;
40}
41
42header vlan_tag_t {
43 bit<3> pri;
44 bit<1> cfi;
45 vlan_id_t vlan_id;
46 bit<16> ether_type;
47}
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
83header arp_t {
84 bit<16> hw_type;
85 bit<16> proto_type;
86 bit<8> hw_addr_len;
87 bit<8> proto_addr_len;
88 bit<16> opcode;
89}
90
91header tcp_t {
92 bit<16> src_port;
93 bit<16> dst_port;
94 bit<32> seq_no;
95 bit<32> ack_no;
96 bit<4> data_offset;
97 bit<3> res;
98 bit<3> ecn;
99 bit<6> ctrl;
100 bit<16> window;
101 bit<16> checksum;
102 bit<16> urgent_ptr;
103}
104
105header udp_t {
106 bit<16> src_port;
107 bit<16> dst_port;
108 bit<16> len;
109 bit<16> checksum;
110}
111
112header icmp_t {
113 bit<8> icmp_type;
114 bit<8> icmp_code;
115 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800116 bit<16> identifier;
117 bit<16> sequence_number;
118 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700119}
120
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800121#ifdef WITH_SPGW
122// GTPU v1
123header gtpu_t {
124 bit<3> version; /* version */
125 bit<1> pt; /* protocol type */
126 bit<1> spare; /* reserved */
127 bit<1> ex_flag; /* next extension hdr present? */
128 bit<1> seq_flag; /* sequence no. */
129 bit<1> npdu_flag; /* n-pdn number present ? */
130 bit<8> msgtype; /* message type */
131 bit<16> msglen; /* message length */
132 bit<32> teid; /* tunnel endpoint id */
133}
134
135struct spgw_meta_t {
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
Yi Tsengbe342052017-11-03 10:21:23 -0700151//Custom metadata definition
152struct fabric_metadata_t {
153 fwd_type_t fwd_type;
154 next_id_t next_id;
Carmelo Cascone35d9b332018-06-15 16:27:22 +0200155 _BOOL pop_vlan_when_packet_in;
Carmelo Cascone1e8843f2018-07-19 19:01:12 +0200156 _BOOL is_multicast;
Carmelo Cascone8d2d1b22018-08-27 18:33:53 -0700157 _BOOL is_controller_packet_out;
Carmelo Cascone1e8843f2018-07-19 19:01:12 +0200158 _BOOL clone_to_cpu;
Yi Tsengbe342052017-11-03 10:21:23 -0700159 bit<8> ip_proto;
160 bit<16> l4_src_port;
161 bit<16> l4_dst_port;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800162#ifdef WITH_SPGW
163 spgw_meta_t spgw;
164#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;
Yi Tsengbe342052017-11-03 10:21:23 -0700173 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800174#ifdef WITH_SPGW
175 ipv4_t gtpu_ipv4;
176 udp_t gtpu_udp;
177 gtpu_t gtpu;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700178 ipv4_t inner_ipv4;
179 udp_t inner_udp;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800180#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700181 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800182#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700183 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800184#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700185 arp_t arp;
186 tcp_t tcp;
187 udp_t udp;
188 icmp_t icmp;
189 packet_out_header_t packet_out;
190 packet_in_header_t packet_in;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700191#ifdef WITH_INT_SINK
192 // INT Report encap
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900193 ethernet_t report_ethernet;
194 ipv4_t report_ipv4;
195 udp_t report_udp;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700196 // INT Report header (support only fixed)
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900197 report_fixed_header_t report_fixed_header;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700198 // local_report_t report_local;
199#endif // WITH_INT_SINK
200#ifdef WITH_INT
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900201 // INT specific headers
202 intl4_shim_t intl4_shim;
203 int_header_t int_header;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900204 int_switch_id_t int_switch_id;
205 int_port_ids_t int_port_ids;
206 int_hop_latency_t int_hop_latency;
207 int_q_occupancy_t int_q_occupancy;
208 int_ingress_tstamp_t int_ingress_tstamp;
209 int_egress_tstamp_t int_egress_tstamp;
210 int_q_congestion_t int_q_congestion;
211 int_egress_port_tx_util_t int_egress_tx_util;
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700212 int_data_t int_data;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900213 intl4_tail_t intl4_tail;
214#endif //WITH_INT
Yi Tsengbe342052017-11-03 10:21:23 -0700215}
216
217#endif