blob: 77808bd260c7f8fb0b0d4993d1880163ee054baa [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 Cascone35d9b332018-06-15 16:27:22 +020022#ifndef _BOOL
23#define _BOOL bool
24#endif
25#ifndef _TRUE
26#define _TRUE true
27#endif
28#ifndef _FALSE
Yi Tseng34af3162018-06-17 18:02:21 +080029#define _FALSE false
Carmelo Cascone35d9b332018-06-15 16:27:22 +020030#endif
31
32#ifndef _PKT_OUT_HDR_ANNOT
33#define _PKT_OUT_HDR_ANNOT
34#endif
35
36#ifndef IP_VER_LENGTH
37#define IP_VER_LENGTH 4
38#endif
39#ifndef IP_VERSION_4
40#define IP_VERSION_4 4
41#endif
42#ifndef IP_VERSION_6
43#define IP_VERSION_6 6
44#endif
45
46#define ETH_HDR_SIZE 14
47#define IPV4_HDR_SIZE 20
48#define UDP_HDR_SIZE 8
49#define GTP_HDR_SIZE 8
50
51#define UDP_PORT_GTPU 2152
52#define GTP_GPDU 0xff
53#define GTPU_VERSION 0x01
54#define GTP_PROTOCOL_TYPE_GTP 0x01
55
Jonghwan Hyuned478dc2018-08-06 15:35:18 +090056#define PKT_INSTANCE_TYPE_NORMAL 0
57#define PKT_INSTANCE_TYPE_INGRESS_CLONE 1
58#define PKT_INSTANCE_TYPE_EGRESS_CLONE 2
59#define PKT_INSTANCE_TYPE_COALESCED 3
60#define PKT_INSTANCE_TYPE_INGRESS_RECIRC 4
61#define PKT_INSTANCE_TYPE_REPLICATION 5
62#define PKT_INSTANCE_TYPE_RESUBMIT 6
63
Yi Tsengbe342052017-11-03 10:21:23 -070064typedef bit<3> fwd_type_t;
Yi Tseng1b154bd2017-11-20 17:48:19 -080065typedef bit<32> next_id_t;
Yi Tsengbe342052017-11-03 10:21:23 -070066typedef bit<20> mpls_label_t;
67typedef bit<9> port_num_t;
68typedef bit<48> mac_addr_t;
69typedef bit<16> group_id_t;
70typedef bit<12> vlan_id_t;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -070071typedef bit<48> timestamp_t;
72typedef bit<32> switch_id_t;
73typedef bit<32> ipv4_addr_t;
74typedef bit<16> l4_port_t;
75
76// SPGW types
77typedef bit<2> direction_t;
78typedef bit pcc_gate_status_t;
79typedef bit<32> sdf_rule_id_t;
80typedef bit<32> pcc_rule_id_t;
81
82// spgw.p4 expects uplink packets with IP dst on this subnet
83// 140.0.0.0/8
84const ipv4_addr_t S1U_SGW_PREFIX = 2348810240;
85#define S1U_SGW_PREFIX_LEN 8
Yi Tsengbe342052017-11-03 10:21:23 -070086
87const bit<16> ETHERTYPE_QINQ = 0x88A8;
88const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100;
89const bit<16> ETHERTYPE_VLAN = 0x8100;
90const bit<16> ETHERTYPE_MPLS = 0x8847;
91const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848;
92const bit<16> ETHERTYPE_IPV4 = 0x0800;
93const bit<16> ETHERTYPE_IPV6 = 0x86dd;
94const bit<16> ETHERTYPE_ARP = 0x0806;
95
Yi Tsengbe342052017-11-03 10:21:23 -070096const bit<8> PROTO_ICMP = 1;
97const bit<8> PROTO_TCP = 6;
98const bit<8> PROTO_UDP = 17;
99const bit<8> PROTO_ICMPV6 = 58;
100
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800101const bit<4> IPV4_MIN_IHL = 5;
102
Yi Tsengbe342052017-11-03 10:21:23 -0700103const fwd_type_t FWD_BRIDGING = 0;
104const fwd_type_t FWD_MPLS = 1;
105const fwd_type_t FWD_IPV4_UNICAST = 2;
106const fwd_type_t FWD_IPV4_MULTICAST = 3;
107const fwd_type_t FWD_IPV6_UNICAST = 4;
108const fwd_type_t FWD_IPV6_MULTICAST = 5;
Carmelo Cascone8a715f82018-08-20 23:16:27 -0700109const fwd_type_t FWD_UNKNOWN = 7;
110
111const vlan_id_t DEFAULT_VLAN_ID = 12w4094;
Yi Tsengbe342052017-11-03 10:21:23 -0700112
Yi Tseng1b154bd2017-11-20 17:48:19 -0800113const bit<8> DEFAULT_MPLS_TTL = 64;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800114const bit<8> DEFAULT_IPV4_TTL = 64;
115
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800116const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0;
117const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0;
Carmelo Cascone9b0171b2018-08-14 01:43:57 -0700118const direction_t SPGW_DIR_UNKNOWN = 2w0;
119const direction_t SPGW_DIR_UPLINK = 2w1;
120const direction_t SPGW_DIR_DOWNLINK = 2w2;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -0800121const pcc_gate_status_t PCC_GATE_OPEN = 1w0;
122const pcc_gate_status_t PCC_GATE_CLOSED = 1w1;
Yi Tseng1b154bd2017-11-20 17:48:19 -0800123
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900124/* indicate INT at LSB of DSCP */
125const bit<6> INT_DSCP = 0x1;
126
Jonghwan Hyuned478dc2018-08-06 15:35:18 +0900127const bit<8> INT_HEADER_LEN_WORD = 4;
128
129const bit<8> CPU_MIRROR_SESSION_ID = 250;
130const bit<32> REPORT_MIRROR_SESSION_ID = 500;
131
132const bit<4> NPROTO_ETHERNET = 0;
133const bit<4> NPROTO_TELEMETRY_DROP_HEADER = 1;
134const bit<4> NPROTO_TELEMETRY_SWITCH_LOCAL_HEADER = 2;
135
136const bit<6> HW_ID = 1;
137const bit<8> REPORT_FIXED_HEADER_LEN = 12;
138const bit<8> DROP_REPORT_HEADER_LEN = 12;
139const bit<8> LOCAL_REPORT_HEADER_LEN = 16;
140const bit<8> ETH_HEADER_LEN = 14;
141const bit<8> IPV4_MIN_HEAD_LEN = 20;
142const bit<8> UDP_HEADER_LEN = 8;
143
Yi Tsengbe342052017-11-03 10:21:23 -0700144#endif