blob: dfde32349e4d35156d4722546a089eb7116fad2c [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 __DEFINE__
18#define __DEFINE__
19
20#define MAX_PORTS 511
21
Carmelo Cascone79a3a312018-08-16 17:14:43 -070022#if defined(WITH_INT_SOURCE) || defined(WITH_INT_TRANSIT) || defined(WITH_INT_SINK)
23#define WITH_INT
24#endif
25
Carmelo Cascone35d9b332018-06-15 16:27:22 +020026#ifndef _BOOL
27#define _BOOL bool
28#endif
29#ifndef _TRUE
30#define _TRUE true
31#endif
32#ifndef _FALSE
Yi Tseng34af3162018-06-17 18:02:21 +080033#define _FALSE false
Carmelo Cascone35d9b332018-06-15 16:27:22 +020034#endif
35
36#ifndef _PKT_OUT_HDR_ANNOT
37#define _PKT_OUT_HDR_ANNOT
38#endif
39
Carmelo Casconefa421582018-09-13 10:05:57 -070040#ifndef _PRE_INGRESS
41#define _PRE_INGRESS
42#endif
43
44#ifndef _PRE_EGRESS
45#define _PRE_EGRESS
46#endif
47
Carmelo Cascone35d9b332018-06-15 16:27:22 +020048#ifndef IP_VER_LENGTH
49#define IP_VER_LENGTH 4
50#endif
51#ifndef IP_VERSION_4
52#define IP_VERSION_4 4
53#endif
54#ifndef IP_VERSION_6
55#define IP_VERSION_6 6
56#endif
57
58#define ETH_HDR_SIZE 14
59#define IPV4_HDR_SIZE 20
60#define UDP_HDR_SIZE 8
61#define GTP_HDR_SIZE 8
62
63#define UDP_PORT_GTPU 2152
64#define GTP_GPDU 0xff
65#define GTPU_VERSION 0x01
66#define GTP_PROTOCOL_TYPE_GTP 0x01
67
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090068#define PKT_INSTANCE_TYPE_NORMAL 0
69#define PKT_INSTANCE_TYPE_INGRESS_CLONE 1
70#define PKT_INSTANCE_TYPE_EGRESS_CLONE 2
71#define PKT_INSTANCE_TYPE_COALESCED 3
72#define PKT_INSTANCE_TYPE_INGRESS_RECIRC 4
73#define PKT_INSTANCE_TYPE_REPLICATION 5
74#define PKT_INSTANCE_TYPE_RESUBMIT 6
75
Yi Tsengbe342052017-11-03 10:21:23 -070076typedef bit<3> fwd_type_t;
Yi Tseng1b154bd2017-11-20 17:48:19 -080077typedef bit<32> next_id_t;
Yi Tsengbe342052017-11-03 10:21:23 -070078typedef bit<20> mpls_label_t;
79typedef bit<9> port_num_t;
80typedef bit<48> mac_addr_t;
81typedef bit<16> group_id_t;
82typedef bit<12> vlan_id_t;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -070083typedef bit<32> ipv4_addr_t;
84typedef bit<16> l4_port_t;
85
86// SPGW types
87typedef bit<2> direction_t;
88typedef bit pcc_gate_status_t;
89typedef bit<32> sdf_rule_id_t;
90typedef bit<32> pcc_rule_id_t;
91
92// spgw.p4 expects uplink packets with IP dst on this subnet
93// 140.0.0.0/8
94const ipv4_addr_t S1U_SGW_PREFIX = 2348810240;
95#define S1U_SGW_PREFIX_LEN 8
Yi Tsengbe342052017-11-03 10:21:23 -070096
97const bit<16> ETHERTYPE_QINQ = 0x88A8;
98const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100;
99const bit<16> ETHERTYPE_VLAN = 0x8100;
100const bit<16> ETHERTYPE_MPLS = 0x8847;
101const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848;
102const bit<16> ETHERTYPE_IPV4 = 0x0800;
103const bit<16> ETHERTYPE_IPV6 = 0x86dd;
104const bit<16> ETHERTYPE_ARP = 0x0806;
105
Yi Tsengbe342052017-11-03 10:21:23 -0700106const bit<8> PROTO_ICMP = 1;
107const bit<8> PROTO_TCP = 6;
108const bit<8> PROTO_UDP = 17;
109const bit<8> PROTO_ICMPV6 = 58;
110
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800111const bit<4> IPV4_MIN_IHL = 5;
112
Yi Tsengbe342052017-11-03 10:21:23 -0700113const fwd_type_t FWD_BRIDGING = 0;
114const fwd_type_t FWD_MPLS = 1;
115const fwd_type_t FWD_IPV4_UNICAST = 2;
116const fwd_type_t FWD_IPV4_MULTICAST = 3;
117const fwd_type_t FWD_IPV6_UNICAST = 4;
118const fwd_type_t FWD_IPV6_MULTICAST = 5;
Carmelo Cascone8a715f82018-08-20 23:16:27 -0700119const fwd_type_t FWD_UNKNOWN = 7;
120
121const vlan_id_t DEFAULT_VLAN_ID = 12w4094;
Yi Tsengbe342052017-11-03 10:21:23 -0700122
Yi Tseng1b154bd2017-11-20 17:48:19 -0800123const bit<8> DEFAULT_MPLS_TTL = 64;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800124const bit<8> DEFAULT_IPV4_TTL = 64;
125
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800126const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0;
127const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700128const direction_t SPGW_DIR_UNKNOWN = 2w0;
129const direction_t SPGW_DIR_UPLINK = 2w1;
130const direction_t SPGW_DIR_DOWNLINK = 2w2;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800131const pcc_gate_status_t PCC_GATE_OPEN = 1w0;
132const pcc_gate_status_t PCC_GATE_CLOSED = 1w1;
Yi Tseng1b154bd2017-11-20 17:48:19 -0800133
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900134/* indicate INT at LSB of DSCP */
135const bit<6> INT_DSCP = 0x1;
136
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700137// Length of the whole INT header,
138// including shim and tail, excluding metadata stack.
139const bit<8> INT_HEADER_LEN_WORDS = 4;
140const bit<16> INT_HEADER_LEN_BYTES = 16;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900141
142const bit<8> CPU_MIRROR_SESSION_ID = 250;
143const bit<32> REPORT_MIRROR_SESSION_ID = 500;
144
145const bit<4> NPROTO_ETHERNET = 0;
146const bit<4> NPROTO_TELEMETRY_DROP_HEADER = 1;
147const bit<4> NPROTO_TELEMETRY_SWITCH_LOCAL_HEADER = 2;
148
149const bit<6> HW_ID = 1;
150const bit<8> REPORT_FIXED_HEADER_LEN = 12;
151const bit<8> DROP_REPORT_HEADER_LEN = 12;
152const bit<8> LOCAL_REPORT_HEADER_LEN = 16;
153const bit<8> ETH_HEADER_LEN = 14;
154const bit<8> IPV4_MIN_HEAD_LEN = 20;
155const bit<8> UDP_HEADER_LEN = 8;
156
Yi Tsengbe342052017-11-03 10:21:23 -0700157#endif