blob: c81ec51068149ae28be2fb3f5d500a80335287b5 [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 Cascone35d9b332018-06-15 16:27:22 +020028_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;
58 bit<8> diffserv;
59 bit<16> total_len;
60 bit<16> identification;
61 bit<3> flags;
62 bit<13> frag_offset;
63 bit<8> ttl;
64 bit<8> protocol;
65 bit<16> hdr_checksum;
66 bit<32> src_addr;
67 bit<32> dst_addr;
68}
69
70header ipv6_t {
71 bit<4> version;
72 bit<8> traffic_class;
73 bit<20> flow_label;
74 bit<16> payload_len;
75 bit<8> next_hdr;
76 bit<8> hop_limit;
77 bit<128> src_addr;
78 bit<128> dst_addr;
79}
80
81header arp_t {
82 bit<16> hw_type;
83 bit<16> proto_type;
84 bit<8> hw_addr_len;
85 bit<8> proto_addr_len;
86 bit<16> opcode;
87}
88
89header tcp_t {
90 bit<16> src_port;
91 bit<16> dst_port;
92 bit<32> seq_no;
93 bit<32> ack_no;
94 bit<4> data_offset;
95 bit<3> res;
96 bit<3> ecn;
97 bit<6> ctrl;
98 bit<16> window;
99 bit<16> checksum;
100 bit<16> urgent_ptr;
101}
102
103header udp_t {
104 bit<16> src_port;
105 bit<16> dst_port;
106 bit<16> len;
107 bit<16> checksum;
108}
109
110header icmp_t {
111 bit<8> icmp_type;
112 bit<8> icmp_code;
113 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800114 bit<16> identifier;
115 bit<16> sequence_number;
116 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700117}
118
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800119#ifdef WITH_SPGW
120// GTPU v1
121header gtpu_t {
122 bit<3> version; /* version */
123 bit<1> pt; /* protocol type */
124 bit<1> spare; /* reserved */
125 bit<1> ex_flag; /* next extension hdr present? */
126 bit<1> seq_flag; /* sequence no. */
127 bit<1> npdu_flag; /* n-pdn number present ? */
128 bit<8> msgtype; /* message type */
129 bit<16> msglen; /* message length */
130 bit<32> teid; /* tunnel endpoint id */
131}
132
133struct spgw_meta_t {
Carmelo Cascone35d9b332018-06-15 16:27:22 +0200134 _BOOL do_spgw;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800135 direction_t direction;
Carmelo Cascone274daef2018-02-14 20:32:49 -0800136 bit<16> ipv4_len;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800137 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
Yi Tsengbe342052017-11-03 10:21:23 -0700150//Custom metadata definition
151struct fabric_metadata_t {
152 fwd_type_t fwd_type;
153 next_id_t next_id;
Carmelo Cascone35d9b332018-06-15 16:27:22 +0200154 _BOOL pop_vlan_when_packet_in;
Carmelo Casconea5400af2018-07-17 22:11:54 +0200155 _BOOL drop_if_egress_is_ingress;
Yi Tsengbe342052017-11-03 10:21:23 -0700156 bit<8> ip_proto;
157 bit<16> l4_src_port;
158 bit<16> l4_dst_port;
Yi Tseng1d842672017-11-28 16:06:52 -0800159 bit<16> original_ether_type;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800160#ifdef WITH_SPGW
161 spgw_meta_t spgw;
162#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700163}
164
165struct parsed_headers_t {
166 ethernet_t ethernet;
167 vlan_tag_t vlan_tag;
Yi Tsengbe342052017-11-03 10:21:23 -0700168 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800169#ifdef WITH_SPGW
170 ipv4_t gtpu_ipv4;
171 udp_t gtpu_udp;
172 gtpu_t gtpu;
173#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700174 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800175#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700176 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800177#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700178 arp_t arp;
179 tcp_t tcp;
180 udp_t udp;
181 icmp_t icmp;
182 packet_out_header_t packet_out;
183 packet_in_header_t packet_in;
184}
185
186#endif