blob: 867249954bef64de6fafb497e74fc61178cb9a38 [file] [log] [blame]
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -08001/*
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 Hyunc235d462019-01-30 23:31:48 +090023/* indicate INT by DSCP value */
24const bit<6> DSCP_INT = 0x17;
25const bit<6> DSCP_MASK = 0x3F;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080026
27typedef bit<48> timestamp_t;
28typedef bit<32> switch_id_t;
29
Jonghwan Hyunc235d462019-01-30 23:31:48 +090030const bit<8> INT_HEADER_LEN_WORD = 3;
31const bit<16> INT_HEADER_SIZE = 8;
32const bit<16> INT_SHIM_HEADER_SIZE = 4;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080033
34const bit<8> CPU_MIRROR_SESSION_ID = 250;
Jonghwan Hyun6777d532018-11-18 20:50:16 +090035const bit<32> REPORT_MIRROR_SESSION_ID = 500;
36const bit<6> HW_ID = 1;
37const bit<8> REPORT_HDR_TTL = 64;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080038
Jonghwan Hyunc235d462019-01-30 23:31:48 +090039#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
48const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_NORMAL = 0;
49const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE = 1;
50const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_EGRESS_CLONE = 2;
51const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_COALESCED = 3;
52const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RECIRC = 4;
53const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION = 5;
54const 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 Hyun6777d532018-11-18 20:50:16 +090063#endif