Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame^] | 22 | #if defined(WITH_INT_SOURCE) || defined(WITH_INT_TRANSIT) || defined(WITH_INT_SINK) |
| 23 | #define WITH_INT |
| 24 | #endif |
| 25 | |
Carmelo Cascone | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 26 | #ifndef _BOOL |
| 27 | #define _BOOL bool |
| 28 | #endif |
| 29 | #ifndef _TRUE |
| 30 | #define _TRUE true |
| 31 | #endif |
| 32 | #ifndef _FALSE |
Yi Tseng | 34af316 | 2018-06-17 18:02:21 +0800 | [diff] [blame] | 33 | #define _FALSE false |
Carmelo Cascone | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 34 | #endif |
| 35 | |
| 36 | #ifndef _PKT_OUT_HDR_ANNOT |
| 37 | #define _PKT_OUT_HDR_ANNOT |
| 38 | #endif |
| 39 | |
| 40 | #ifndef IP_VER_LENGTH |
| 41 | #define IP_VER_LENGTH 4 |
| 42 | #endif |
| 43 | #ifndef IP_VERSION_4 |
| 44 | #define IP_VERSION_4 4 |
| 45 | #endif |
| 46 | #ifndef IP_VERSION_6 |
| 47 | #define IP_VERSION_6 6 |
| 48 | #endif |
| 49 | |
| 50 | #define ETH_HDR_SIZE 14 |
| 51 | #define IPV4_HDR_SIZE 20 |
| 52 | #define UDP_HDR_SIZE 8 |
| 53 | #define GTP_HDR_SIZE 8 |
| 54 | |
| 55 | #define UDP_PORT_GTPU 2152 |
| 56 | #define GTP_GPDU 0xff |
| 57 | #define GTPU_VERSION 0x01 |
| 58 | #define GTP_PROTOCOL_TYPE_GTP 0x01 |
| 59 | |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 60 | #define PKT_INSTANCE_TYPE_NORMAL 0 |
| 61 | #define PKT_INSTANCE_TYPE_INGRESS_CLONE 1 |
| 62 | #define PKT_INSTANCE_TYPE_EGRESS_CLONE 2 |
| 63 | #define PKT_INSTANCE_TYPE_COALESCED 3 |
| 64 | #define PKT_INSTANCE_TYPE_INGRESS_RECIRC 4 |
| 65 | #define PKT_INSTANCE_TYPE_REPLICATION 5 |
| 66 | #define PKT_INSTANCE_TYPE_RESUBMIT 6 |
| 67 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 68 | typedef bit<3> fwd_type_t; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 69 | typedef bit<32> next_id_t; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 70 | typedef bit<20> mpls_label_t; |
| 71 | typedef bit<9> port_num_t; |
| 72 | typedef bit<48> mac_addr_t; |
| 73 | typedef bit<16> group_id_t; |
| 74 | typedef bit<12> vlan_id_t; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 75 | typedef bit<32> ipv4_addr_t; |
| 76 | typedef bit<16> l4_port_t; |
| 77 | |
| 78 | // SPGW types |
| 79 | typedef bit<2> direction_t; |
| 80 | typedef bit pcc_gate_status_t; |
| 81 | typedef bit<32> sdf_rule_id_t; |
| 82 | typedef bit<32> pcc_rule_id_t; |
| 83 | |
| 84 | // spgw.p4 expects uplink packets with IP dst on this subnet |
| 85 | // 140.0.0.0/8 |
| 86 | const ipv4_addr_t S1U_SGW_PREFIX = 2348810240; |
| 87 | #define S1U_SGW_PREFIX_LEN 8 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 88 | |
| 89 | const bit<16> ETHERTYPE_QINQ = 0x88A8; |
| 90 | const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100; |
| 91 | const bit<16> ETHERTYPE_VLAN = 0x8100; |
| 92 | const bit<16> ETHERTYPE_MPLS = 0x8847; |
| 93 | const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848; |
| 94 | const bit<16> ETHERTYPE_IPV4 = 0x0800; |
| 95 | const bit<16> ETHERTYPE_IPV6 = 0x86dd; |
| 96 | const bit<16> ETHERTYPE_ARP = 0x0806; |
| 97 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 98 | const bit<8> PROTO_ICMP = 1; |
| 99 | const bit<8> PROTO_TCP = 6; |
| 100 | const bit<8> PROTO_UDP = 17; |
| 101 | const bit<8> PROTO_ICMPV6 = 58; |
| 102 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 103 | const bit<4> IPV4_MIN_IHL = 5; |
| 104 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 105 | const fwd_type_t FWD_BRIDGING = 0; |
| 106 | const fwd_type_t FWD_MPLS = 1; |
| 107 | const fwd_type_t FWD_IPV4_UNICAST = 2; |
| 108 | const fwd_type_t FWD_IPV4_MULTICAST = 3; |
| 109 | const fwd_type_t FWD_IPV6_UNICAST = 4; |
| 110 | const fwd_type_t FWD_IPV6_MULTICAST = 5; |
Carmelo Cascone | 8a715f8 | 2018-08-20 23:16:27 -0700 | [diff] [blame] | 111 | const fwd_type_t FWD_UNKNOWN = 7; |
| 112 | |
| 113 | const vlan_id_t DEFAULT_VLAN_ID = 12w4094; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 114 | |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 115 | const bit<8> DEFAULT_MPLS_TTL = 64; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 116 | const bit<8> DEFAULT_IPV4_TTL = 64; |
| 117 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 118 | const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0; |
| 119 | const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 120 | const direction_t SPGW_DIR_UNKNOWN = 2w0; |
| 121 | const direction_t SPGW_DIR_UPLINK = 2w1; |
| 122 | const direction_t SPGW_DIR_DOWNLINK = 2w2; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 123 | const pcc_gate_status_t PCC_GATE_OPEN = 1w0; |
| 124 | const pcc_gate_status_t PCC_GATE_CLOSED = 1w1; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 125 | |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 126 | /* indicate INT at LSB of DSCP */ |
| 127 | const bit<6> INT_DSCP = 0x1; |
| 128 | |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame^] | 129 | // Length of the whole INT header, |
| 130 | // including shim and tail, excluding metadata stack. |
| 131 | const bit<8> INT_HEADER_LEN_WORDS = 4; |
| 132 | const bit<16> INT_HEADER_LEN_BYTES = 16; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 133 | |
| 134 | const bit<8> CPU_MIRROR_SESSION_ID = 250; |
| 135 | const bit<32> REPORT_MIRROR_SESSION_ID = 500; |
| 136 | |
| 137 | const bit<4> NPROTO_ETHERNET = 0; |
| 138 | const bit<4> NPROTO_TELEMETRY_DROP_HEADER = 1; |
| 139 | const bit<4> NPROTO_TELEMETRY_SWITCH_LOCAL_HEADER = 2; |
| 140 | |
| 141 | const bit<6> HW_ID = 1; |
| 142 | const bit<8> REPORT_FIXED_HEADER_LEN = 12; |
| 143 | const bit<8> DROP_REPORT_HEADER_LEN = 12; |
| 144 | const bit<8> LOCAL_REPORT_HEADER_LEN = 16; |
| 145 | const bit<8> ETH_HEADER_LEN = 14; |
| 146 | const bit<8> IPV4_MIN_HEAD_LEN = 20; |
| 147 | const bit<8> UDP_HEADER_LEN = 8; |
| 148 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 149 | #endif |