P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/modules/testgen/targets/tofino/constants.h
1/*******************************************************************************
2 * Copyright (C) 2024 Intel Corporation
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,
11 * software 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
14 * and limitations under the License.
15 *
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 ******************************************************************************/
19
20#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CONSTANTS_H_
21#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CONSTANTS_H_
22
23#include <cstdint>
24
25#include "ir/ir.h"
26
27namespace P4::P4Tools::P4Testgen::Tofino {
28
30 public:
31 // The minimum packet sizes required to run a successful PTF test.
32 static constexpr int64_t PTF_INPUT_PKT_MIN_SIZE = 512;
33 static constexpr int64_t PTF_OUTPUT_PKT_MIN_SIZE = 240;
35 static constexpr const char *MATCH_KIND_RANGE = "range";
37 static constexpr const char *MATCH_KIND_SELECTOR = "selector";
39 static constexpr const char *MATCH_KIND_ATCAM = "atcam_partition_index";
41 static constexpr int DROP_CONSTANT = 511;
45 // Seven least significant bits of port number determine the physical port (the rest
46 // determines pipe number). 0x7f allows all ports of the first pipe.
47 // For now, target only the first pipe.
48 // TODO: allow the mask to be specified by a parameter
49 static constexpr size_t VALID_INPUT_PORT_MASK = 0x7f;
50};
51
53 public:
54 // Parser error codes, copied from tofino.p4.
55 static constexpr int PARSER_ERROR_OK = 0x0000;
56 static constexpr int PARSER_ERROR_NO_MATCH = 0x0001;
57 static constexpr int PARSER_ERROR_PARTIAL_HDR = 0x0002;
58 static constexpr int PARSER_ERROR_CTR_RANGE = 0x0004;
59 static constexpr int PARSER_ERROR_TIMEOUT_USER = 0x0008;
60 static constexpr int PARSER_ERROR_TIMEOUT_HW = 0x0010;
61 static constexpr int PARSER_ERROR_SRC_EXT = 0x0020;
62 static constexpr int PARSER_ERROR_DST_CONT = 0x0040;
63 static constexpr int PARSER_ERROR_PHV_OWNER = 0x0080;
64 static constexpr int PARSER_ERROR_MULTIWRITE = 0x0100;
65 static constexpr int PARSER_ERROR_ARAM_MBE = 0x0400;
66 static constexpr int PARSER_ERROR_FCS = 0x0800;
67 // The format of the port metadata appears to be unspecified, but is 64 bits on Tofino.
68 static constexpr int PORT_METADATA_SIZE = 64;
69 // Size of the frame check sequence appended to the packet.
70 static constexpr int64_t ETH_FCS_SIZE = 32;
71 // The variable corresponding to the parameter that controls packet drops.
72 static const IR::Member INGRESS_DROP_VAR;
73 static const IR::Member EGRESS_DROP_VAR;
75 static constexpr int PORT_BIT_WIDTH = 9;
76};
77
79 public:
80 // Parser error codes, copied from tofino2.p4.
81 static constexpr int PARSER_ERROR_OK = 0x0000;
82 static constexpr int PARSER_ERROR_NO_MATCH = 0x0001;
83 static constexpr int PARSER_ERROR_PARTIAL_HDR = 0x0002;
84 static constexpr int PARSER_ERROR_CTR_RANGE = 0x0004;
85 static constexpr int PARSER_ERROR_TIMEOUT_USER = 0x0008;
86 static constexpr int PARSER_ERROR_TIMEOUT_HW = 0x0010;
87 static constexpr int PARSER_ERROR_SRC_EXT = 0x0020;
88 static constexpr int PARSER_ERROR_DST_CONT = 0x0040;
89 static constexpr int PARSER_ERROR_PHV_OWNER = 0x0080;
90 static constexpr int PARSER_ERROR_MULTIWRITE = 0x0100;
91 static constexpr int PARSER_ERROR_ARAM_MBE = 0x0400;
92 static constexpr int PARSER_ERROR_FCS = 0x0800;
93 static constexpr int PARSER_ERROR_CSUM_MBE = 0x1000;
94 // The format of the port metadata appears to be unspecified, but is 192 bits on JBay.
95 static constexpr int PORT_METADATA_SIZE = 192;
96 // Size of the frame check sequence appended to the packet.
97 static constexpr int64_t ETH_FCS_SIZE = 32;
98 // The variable corresponding to the parameter that controls packet drops.
99 static const IR::Member INGRESS_DROP_VAR;
100 static const IR::Member EGRESS_DROP_VAR;
102 static constexpr int PORT_BIT_WIDTH = 9;
103};
104
105} // namespace P4::P4Tools::P4Testgen::Tofino
106
107#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CONSTANTS_H_ */
Definition p4tools/modules/testgen/targets/tofino/constants.h:78
static constexpr int PORT_BIT_WIDTH
Port width in bits.
Definition p4tools/modules/testgen/targets/tofino/constants.h:102
Definition p4tools/modules/testgen/targets/tofino/constants.h:29
static constexpr size_t VALID_INPUT_PORT_MASK
Definition p4tools/modules/testgen/targets/tofino/constants.h:49
static constexpr const char * MATCH_KIND_SELECTOR
A match that is used as an argument for the selector.
Definition p4tools/modules/testgen/targets/tofino/constants.h:37
static constexpr int DROP_CONSTANT
The port value that corresponds to a dropped packet.
Definition p4tools/modules/testgen/targets/tofino/constants.h:41
static constexpr const char * MATCH_KIND_ATCAM
A match that is as an argument for the atcam index.
Definition p4tools/modules/testgen/targets/tofino/constants.h:39
static constexpr const char * MATCH_KIND_RANGE
Entries that can match a range.
Definition p4tools/modules/testgen/targets/tofino/constants.h:35
Definition p4tools/modules/testgen/targets/tofino/constants.h:52
static constexpr int PORT_BIT_WIDTH
Port width in bits.
Definition p4tools/modules/testgen/targets/tofino/constants.h:75