Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [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 | /* -*- P4_16 -*- */ |
| 18 | #ifndef __INT_DEFINE__ |
| 19 | #define __INT_DEFINE__ |
| 20 | |
| 21 | #include "defines.p4" |
| 22 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 23 | /* indicate INT by DSCP value */ |
| 24 | const bit<6> DSCP_INT = 0x17; |
| 25 | const bit<6> DSCP_MASK = 0x3F; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 26 | |
| 27 | typedef bit<48> timestamp_t; |
| 28 | typedef bit<32> switch_id_t; |
| 29 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 30 | const bit<8> INT_HEADER_LEN_WORD = 3; |
| 31 | const bit<16> INT_HEADER_SIZE = 8; |
| 32 | const bit<16> INT_SHIM_HEADER_SIZE = 4; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 33 | |
| 34 | const bit<8> CPU_MIRROR_SESSION_ID = 250; |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 35 | const bit<32> REPORT_MIRROR_SESSION_ID = 500; |
| 36 | const bit<6> HW_ID = 1; |
| 37 | const bit<8> REPORT_HDR_TTL = 64; |
Jonghwan Hyun | 4a9a671 | 2017-11-13 14:43:55 -0800 | [diff] [blame] | 38 | |
Jonghwan Hyun | c235d46 | 2019-01-30 23:31:48 +0900 | [diff] [blame] | 39 | #ifdef TARGET_BMV2 |
| 40 | // These definitions are from: |
| 41 | // https://github.com/jafingerhut/p4-guide/blob/master/v1model-special-ops/v1model-special-ops.p4 |
| 42 | |
| 43 | // These definitions are derived from the numerical values of the enum |
| 44 | // named "PktInstanceType" in the p4lang/behavioral-model source file |
| 45 | // targets/simple_switch/simple_switch.h |
| 46 | // https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch/simple_switch.h#L126-L134 |
| 47 | |
| 48 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_NORMAL = 0; |
| 49 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE = 1; |
| 50 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_EGRESS_CLONE = 2; |
| 51 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_COALESCED = 3; |
| 52 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RECIRC = 4; |
| 53 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION = 5; |
| 54 | const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RESUBMIT = 6; |
| 55 | |
| 56 | #define IS_RESUBMITTED(smeta) (smeta.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_RESUBMIT) |
| 57 | #define IS_RECIRCULATED(smeta) (smeta.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_RECIRC) |
| 58 | #define IS_I2E_CLONE(smeta) (smeta.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE) |
| 59 | #define IS_E2E_CLONE(smeta) (smeta.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_EGRESS_CLONE) |
| 60 | #define IS_REPLICATED(smeta) (smeta.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION) |
| 61 | #endif // TARGET__BMV2 |
| 62 | |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 63 | #endif |