blob: 36a5ec76a2c5c555d88edfde0d05b933b8a24219 [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
Daniele Moro5a2de712019-09-24 14:34:07 -070026#if defined(WITH_BNG)
27#define WITH_DOUBLE_VLAN_TERMINATION
28#endif
29
Carmelo Casconeb5324e72018-11-25 02:26:32 -080030#ifndef WITHOUT_XCONNECT
31#define WITH_XCONNECT
32#endif
33
34#if ! defined(WITH_SIMPLE_NEXT)
35#define WITH_HASHED_NEXT
36#endif
37
Carmelo Cascone35d9b332018-06-15 16:27:22 +020038#ifndef _BOOL
39#define _BOOL bool
40#endif
41#ifndef _TRUE
42#define _TRUE true
43#endif
44#ifndef _FALSE
Yi Tseng34af3162018-06-17 18:02:21 +080045#define _FALSE false
Carmelo Cascone35d9b332018-06-15 16:27:22 +020046#endif
47
48#ifndef _PKT_OUT_HDR_ANNOT
49#define _PKT_OUT_HDR_ANNOT
50#endif
51
Carmelo Casconefa421582018-09-13 10:05:57 -070052#ifndef _PRE_INGRESS
53#define _PRE_INGRESS
54#endif
55
56#ifndef _PRE_EGRESS
57#define _PRE_EGRESS
58#endif
59
Carmelo Cascone35d9b332018-06-15 16:27:22 +020060#ifndef IP_VER_LENGTH
61#define IP_VER_LENGTH 4
62#endif
63#ifndef IP_VERSION_4
64#define IP_VERSION_4 4
65#endif
66#ifndef IP_VERSION_6
67#define IP_VERSION_6 6
68#endif
69
Carmelo Cascone2388cc12021-05-26 19:30:30 +020070#define PACKET_OUT_HDR_SIZE 2
Carmelo Cascone35d9b332018-06-15 16:27:22 +020071#define ETH_HDR_SIZE 14
72#define IPV4_HDR_SIZE 20
73#define UDP_HDR_SIZE 8
74#define GTP_HDR_SIZE 8
75
76#define UDP_PORT_GTPU 2152
77#define GTP_GPDU 0xff
Carmelo Cascone2a308ff2021-06-01 18:31:57 -070078#define GTP_V1 0x01
Carmelo Cascone35d9b332018-06-15 16:27:22 +020079#define GTP_PROTOCOL_TYPE_GTP 0x01
80
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090081#define PKT_INSTANCE_TYPE_NORMAL 0
82#define PKT_INSTANCE_TYPE_INGRESS_CLONE 1
83#define PKT_INSTANCE_TYPE_EGRESS_CLONE 2
84#define PKT_INSTANCE_TYPE_COALESCED 3
85#define PKT_INSTANCE_TYPE_INGRESS_RECIRC 4
86#define PKT_INSTANCE_TYPE_REPLICATION 5
87#define PKT_INSTANCE_TYPE_RESUBMIT 6
88
Yi Tsengbe342052017-11-03 10:21:23 -070089typedef bit<3> fwd_type_t;
Yi Tseng1b154bd2017-11-20 17:48:19 -080090typedef bit<32> next_id_t;
Yi Tsengbe342052017-11-03 10:21:23 -070091typedef bit<20> mpls_label_t;
92typedef bit<9> port_num_t;
93typedef bit<48> mac_addr_t;
Carmelo Casconeb5324e72018-11-25 02:26:32 -080094typedef bit<16> mcast_group_id_t;
Yi Tsengbe342052017-11-03 10:21:23 -070095typedef bit<12> vlan_id_t;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -070096typedef bit<32> ipv4_addr_t;
97typedef bit<16> l4_port_t;
98
99// SPGW types
100typedef bit<2> direction_t;
Robert MacDavidde12b982020-07-15 18:38:59 -0700101typedef bit<8> spgw_interface_t;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700102typedef bit pcc_gate_status_t;
103typedef bit<32> sdf_rule_id_t;
104typedef bit<32> pcc_rule_id_t;
Robert MacDavidbec6b6a2020-05-21 21:32:38 -0400105typedef bit<32> far_id_t;
Robert MacDavidde12b982020-07-15 18:38:59 -0700106typedef bit<32> pdr_ctr_id_t;
Robert MacDavidbec6b6a2020-05-21 21:32:38 -0400107typedef bit<32> teid_t;
ersuneetsinghe326c722021-03-25 21:17:29 -0300108typedef bit<5> qid_t;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700109
Robert MacDavidde12b982020-07-15 18:38:59 -0700110const spgw_interface_t SPGW_IFACE_UNKNOWN = 8w0;
111const spgw_interface_t SPGW_IFACE_ACCESS = 8w1;
112const spgw_interface_t SPGW_IFACE_CORE = 8w2;
Carmelo Cascone2102bfb2020-12-04 16:54:24 -0800113const spgw_interface_t SPGW_IFACE_FROM_DBUF = 8w3;
Yi Tsengbe342052017-11-03 10:21:23 -0700114
Wailok Shumfb7e7872021-06-18 17:30:08 +0800115// PORT types. Set by the control plane using the actions
116// of the filtering.ingress_port_vlan table.
117typedef bit<2> port_type_t;
118// Default value. Set by deny action.
119const port_type_t PORT_TYPE_UNKNOWN = 0x0;
120// Host-facing port on a leaf switch.
121const port_type_t PORT_TYPE_EDGE = 0x1;
122// Switch-facing port on a leaf or spine switch.
123const port_type_t PORT_TYPE_INFRA = 0x2;
124// ASIC-internal port such as the recirculation one (used for INT or UE-to-UE).
125const port_type_t PORT_TYPE_INTERNAL = 0x3;
126
Yi Tsengbe342052017-11-03 10:21:23 -0700127const bit<16> ETHERTYPE_QINQ = 0x88A8;
128const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100;
129const bit<16> ETHERTYPE_VLAN = 0x8100;
130const bit<16> ETHERTYPE_MPLS = 0x8847;
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700131const bit<16> ETHERTYPE_MPLS_MULTICAST = 0x8848;
Yi Tsengbe342052017-11-03 10:21:23 -0700132const bit<16> ETHERTYPE_IPV4 = 0x0800;
133const bit<16> ETHERTYPE_IPV6 = 0x86dd;
134const bit<16> ETHERTYPE_ARP = 0x0806;
Carmelo Cascone4d8785b2019-05-31 17:11:26 -0700135const bit<16> ETHERTYPE_PPPOED = 0x8863;
136const bit<16> ETHERTYPE_PPPOES = 0x8864;
137
138const bit<16> PPPOE_PROTOCOL_IP4 = 0x0021;
139const bit<16> PPPOE_PROTOCOL_IP6 = 0x0057;
Daniele Moroe22b5742019-06-28 15:32:37 -0700140const bit<16> PPPOE_PROTOCOL_MPLS = 0x0281;
Yi Tsengbe342052017-11-03 10:21:23 -0700141
Yi Tsengbe342052017-11-03 10:21:23 -0700142const bit<8> PROTO_ICMP = 1;
143const bit<8> PROTO_TCP = 6;
144const bit<8> PROTO_UDP = 17;
145const bit<8> PROTO_ICMPV6 = 58;
146
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800147const bit<4> IPV4_MIN_IHL = 5;
148
Yi Tsengbe342052017-11-03 10:21:23 -0700149const fwd_type_t FWD_BRIDGING = 0;
150const fwd_type_t FWD_MPLS = 1;
151const fwd_type_t FWD_IPV4_UNICAST = 2;
152const fwd_type_t FWD_IPV4_MULTICAST = 3;
153const fwd_type_t FWD_IPV6_UNICAST = 4;
154const fwd_type_t FWD_IPV6_MULTICAST = 5;
Carmelo Cascone8a715f82018-08-20 23:16:27 -0700155const fwd_type_t FWD_UNKNOWN = 7;
156
157const vlan_id_t DEFAULT_VLAN_ID = 12w4094;
Yi Tsengbe342052017-11-03 10:21:23 -0700158
Yi Tseng1b154bd2017-11-20 17:48:19 -0800159const bit<8> DEFAULT_MPLS_TTL = 64;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800160const bit<8> DEFAULT_IPV4_TTL = 64;
161
Robert MacDavidde12b982020-07-15 18:38:59 -0700162
Yi Tseng1b154bd2017-11-20 17:48:19 -0800163
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900164/* indicate INT at LSB of DSCP */
165const bit<6> INT_DSCP = 0x1;
166
Carmelo Cascone79a3a312018-08-16 17:14:43 -0700167// Length of the whole INT header,
168// including shim and tail, excluding metadata stack.
169const bit<8> INT_HEADER_LEN_WORDS = 4;
170const bit<16> INT_HEADER_LEN_BYTES = 16;
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900171
172const bit<8> CPU_MIRROR_SESSION_ID = 250;
173const bit<32> REPORT_MIRROR_SESSION_ID = 500;
174
175const bit<4> NPROTO_ETHERNET = 0;
176const bit<4> NPROTO_TELEMETRY_DROP_HEADER = 1;
177const bit<4> NPROTO_TELEMETRY_SWITCH_LOCAL_HEADER = 2;
178
179const bit<6> HW_ID = 1;
180const bit<8> REPORT_FIXED_HEADER_LEN = 12;
181const bit<8> DROP_REPORT_HEADER_LEN = 12;
182const bit<8> LOCAL_REPORT_HEADER_LEN = 16;
183const bit<8> ETH_HEADER_LEN = 14;
184const bit<8> IPV4_MIN_HEAD_LEN = 20;
185const bit<8> UDP_HEADER_LEN = 8;
186
Carmelo Casconeb5324e72018-11-25 02:26:32 -0800187action nop() {
188 NoAction();
189}
190
Yi Tsengbe342052017-11-03 10:21:23 -0700191#endif