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 | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 22 | #ifndef _BOOL |
| 23 | #define _BOOL bool |
| 24 | #endif |
| 25 | #ifndef _TRUE |
| 26 | #define _TRUE true |
| 27 | #endif |
| 28 | #ifndef _FALSE |
Yi Tseng | 34af316 | 2018-06-17 18:02:21 +0800 | [diff] [blame] | 29 | #define _FALSE false |
Carmelo Cascone | 35d9b33 | 2018-06-15 16:27:22 +0200 | [diff] [blame] | 30 | #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 Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame^] | 56 | #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 Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 64 | typedef bit<3> fwd_type_t; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 65 | typedef bit<32> next_id_t; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 66 | typedef bit<20> mpls_label_t; |
| 67 | typedef bit<9> port_num_t; |
| 68 | typedef bit<48> mac_addr_t; |
| 69 | typedef bit<16> group_id_t; |
| 70 | typedef bit<12> vlan_id_t; |
| 71 | |
| 72 | const bit<16> ETHERTYPE_QINQ = 0x88A8; |
| 73 | const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100; |
| 74 | const bit<16> ETHERTYPE_VLAN = 0x8100; |
| 75 | const bit<16> ETHERTYPE_MPLS = 0x8847; |
| 76 | const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848; |
| 77 | const bit<16> ETHERTYPE_IPV4 = 0x0800; |
| 78 | const bit<16> ETHERTYPE_IPV6 = 0x86dd; |
| 79 | const bit<16> ETHERTYPE_ARP = 0x0806; |
| 80 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 81 | const bit<8> PROTO_ICMP = 1; |
| 82 | const bit<8> PROTO_TCP = 6; |
| 83 | const bit<8> PROTO_UDP = 17; |
| 84 | const bit<8> PROTO_ICMPV6 = 58; |
| 85 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 86 | const bit<4> IPV4_MIN_IHL = 5; |
| 87 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 88 | const fwd_type_t FWD_BRIDGING = 0; |
| 89 | const fwd_type_t FWD_MPLS = 1; |
| 90 | const fwd_type_t FWD_IPV4_UNICAST = 2; |
| 91 | const fwd_type_t FWD_IPV4_MULTICAST = 3; |
| 92 | const fwd_type_t FWD_IPV6_UNICAST = 4; |
| 93 | const fwd_type_t FWD_IPV6_MULTICAST = 5; |
| 94 | |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 95 | const bit<8> DEFAULT_MPLS_TTL = 64; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 96 | const bit<8> DEFAULT_IPV4_TTL = 64; |
| 97 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 98 | typedef bit direction_t; |
| 99 | typedef bit pcc_gate_status_t; |
| 100 | typedef bit<32> sdf_rule_id_t; |
| 101 | typedef bit<32> pcc_rule_id_t; |
| 102 | |
| 103 | const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0; |
| 104 | const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0; |
| 105 | |
| 106 | const direction_t DIR_UPLINK = 1w0; |
| 107 | const direction_t DIR_DOWNLINK = 1w1; |
| 108 | |
| 109 | const pcc_gate_status_t PCC_GATE_OPEN = 1w0; |
| 110 | const pcc_gate_status_t PCC_GATE_CLOSED = 1w1; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 111 | |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame^] | 112 | /* indicate INT at LSB of DSCP */ |
| 113 | const bit<6> INT_DSCP = 0x1; |
| 114 | |
| 115 | typedef bit<48> timestamp_t; |
| 116 | typedef bit<32> switch_id_t; |
| 117 | typedef bit<32> ip_address_t; |
| 118 | typedef bit<16> l4_port_t; |
| 119 | |
| 120 | const bit<8> INT_HEADER_LEN_WORD = 4; |
| 121 | |
| 122 | const bit<8> CPU_MIRROR_SESSION_ID = 250; |
| 123 | const bit<32> REPORT_MIRROR_SESSION_ID = 500; |
| 124 | |
| 125 | const bit<4> NPROTO_ETHERNET = 0; |
| 126 | const bit<4> NPROTO_TELEMETRY_DROP_HEADER = 1; |
| 127 | const bit<4> NPROTO_TELEMETRY_SWITCH_LOCAL_HEADER = 2; |
| 128 | |
| 129 | const bit<6> HW_ID = 1; |
| 130 | const bit<8> REPORT_FIXED_HEADER_LEN = 12; |
| 131 | const bit<8> DROP_REPORT_HEADER_LEN = 12; |
| 132 | const bit<8> LOCAL_REPORT_HEADER_LEN = 16; |
| 133 | const bit<8> ETH_HEADER_LEN = 14; |
| 134 | const bit<8> IPV4_MIN_HEAD_LEN = 20; |
| 135 | const bit<8> UDP_HEADER_LEN = 8; |
| 136 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 137 | #endif |