blob: 0a0814e4a8cb32c3e2fd03bf9ee7a8c03c8bf67e [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
28@controller_header("packet_out")
29header packet_out_header_t {
30 port_num_t egress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080031 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070032}
33
34header ethernet_t {
35 mac_addr_t dst_addr;
36 mac_addr_t src_addr;
37 bit<16> ether_type;
38}
39
40header vlan_tag_t {
41 bit<3> pri;
42 bit<1> cfi;
43 vlan_id_t vlan_id;
44 bit<16> ether_type;
45}
46
47header mpls_t {
48 bit<20> label;
49 bit<3> tc;
50 bit<1> bos;
51 bit<8> ttl;
52}
53
54header ipv4_t {
55 bit<4> version;
56 bit<4> ihl;
57 bit<8> diffserv;
58 bit<16> total_len;
59 bit<16> identification;
60 bit<3> flags;
61 bit<13> frag_offset;
62 bit<8> ttl;
63 bit<8> protocol;
64 bit<16> hdr_checksum;
65 bit<32> src_addr;
66 bit<32> dst_addr;
67}
68
69header ipv6_t {
70 bit<4> version;
71 bit<8> traffic_class;
72 bit<20> flow_label;
73 bit<16> payload_len;
74 bit<8> next_hdr;
75 bit<8> hop_limit;
76 bit<128> src_addr;
77 bit<128> dst_addr;
78}
79
80header arp_t {
81 bit<16> hw_type;
82 bit<16> proto_type;
83 bit<8> hw_addr_len;
84 bit<8> proto_addr_len;
85 bit<16> opcode;
86}
87
88header tcp_t {
89 bit<16> src_port;
90 bit<16> dst_port;
91 bit<32> seq_no;
92 bit<32> ack_no;
93 bit<4> data_offset;
94 bit<3> res;
95 bit<3> ecn;
96 bit<6> ctrl;
97 bit<16> window;
98 bit<16> checksum;
99 bit<16> urgent_ptr;
100}
101
102header udp_t {
103 bit<16> src_port;
104 bit<16> dst_port;
105 bit<16> len;
106 bit<16> checksum;
107}
108
109header icmp_t {
110 bit<8> icmp_type;
111 bit<8> icmp_code;
112 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800113 bit<16> identifier;
114 bit<16> sequence_number;
115 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700116}
117
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800118#ifdef WITH_SPGW
119// GTPU v1
120header gtpu_t {
121 bit<3> version; /* version */
122 bit<1> pt; /* protocol type */
123 bit<1> spare; /* reserved */
124 bit<1> ex_flag; /* next extension hdr present? */
125 bit<1> seq_flag; /* sequence no. */
126 bit<1> npdu_flag; /* n-pdn number present ? */
127 bit<8> msgtype; /* message type */
128 bit<16> msglen; /* message length */
129 bit<32> teid; /* tunnel endpoint id */
130}
131
132struct spgw_meta_t {
133 bool do_spgw;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800134 direction_t direction;
135 bit<32> teid;
136 bit<32> s1u_enb_addr;
137 bit<32> s1u_sgw_addr;
138#ifdef WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800139 bit<16> l4_src_port;
140 bit<16> l4_dst_port;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800141 pcc_gate_status_t pcc_gate_status;
142 sdf_rule_id_t sdf_rule_id;
143 pcc_rule_id_t pcc_rule_id;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800144#endif // WITH_SPGW_PCC_GATING
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800145}
146#endif // WITH_SPGW
147
Yi Tsengbe342052017-11-03 10:21:23 -0700148//Custom metadata definition
149struct fabric_metadata_t {
150 fwd_type_t fwd_type;
151 next_id_t next_id;
Yi Tsengbe342052017-11-03 10:21:23 -0700152 bool pop_vlan_at_egress;
153 bit<8> ip_proto;
154 bit<16> l4_src_port;
155 bit<16> l4_dst_port;
Yi Tseng1d842672017-11-28 16:06:52 -0800156 bit<16> original_ether_type;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800157#ifdef WITH_SPGW
158 spgw_meta_t spgw;
159#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700160}
161
162struct parsed_headers_t {
163 ethernet_t ethernet;
164 vlan_tag_t vlan_tag;
Yi Tsengbe342052017-11-03 10:21:23 -0700165 mpls_t mpls;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800166#ifdef WITH_SPGW
167 ipv4_t gtpu_ipv4;
168 udp_t gtpu_udp;
169 gtpu_t gtpu;
170#endif // WITH_SPGW
Yi Tsengbe342052017-11-03 10:21:23 -0700171 ipv4_t ipv4;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800172#ifdef WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700173 ipv6_t ipv6;
Carmelo Casconeb757dbc2018-01-25 17:53:17 -0800174#endif // WITH_IPV6
Yi Tsengbe342052017-11-03 10:21:23 -0700175 arp_t arp;
176 tcp_t tcp;
177 udp_t udp;
178 icmp_t icmp;
179 packet_out_header_t packet_out;
180 packet_in_header_t packet_in;
181}
182
183#endif