-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: fruffy <fruffy@nyu.edu>
- Loading branch information
Showing
107 changed files
with
33,613 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
backends/p4tools/modules/testgen/targets/tofino/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
if(ENABLE_TESTING) | ||
# Include the test subdirectory. | ||
message("-- Adding p4testgen tofino test suite") | ||
include(test/P4Tests.cmake) | ||
endif() | ||
|
||
# Source files for p4testgen. | ||
set( | ||
TESTGEN_SOURCES | ||
${TESTGEN_SOURCES} | ||
|
||
${CMAKE_CURRENT_SOURCE_DIR}/test_backend/ptf.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_backend/stf.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_result.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/concolic.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/constants.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/hash_utils.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/map_direct_externs.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/shared_expr_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/shared_program_info.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/shared_table_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/target.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_backend.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_spec.cpp | ||
|
||
${CMAKE_CURRENT_SOURCE_DIR}/tofino/cmd_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tofino/expr_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tofino/program_info.cpp | ||
|
||
${CMAKE_CURRENT_SOURCE_DIR}/tofino2/cmd_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tofino2/expr_stepper.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tofino2/program_info.cpp | ||
|
||
PARENT_SCOPE | ||
) | ||
|
||
# Override default settings in bf-p4c. We want those binaries to be built. | ||
if (NOT TARGET p4cgraphs) | ||
set(ENABLE_P4C_GRAPHS ON CACHE BOOL "TRUE" FORCE) | ||
add_subdirectory(${P4C_SOURCE_DIR}/backends/graphs ${P4C_BINARY_DIR}/backends/graphs) | ||
endif() | ||
|
||
# Ideally, we'd link against just the Barefoot midend and a minimal set of | ||
# transitive dependencies, but the compiler doesn't cleanly separate like | ||
# that. Those transitive dependencies turn out to be most of the compiler! | ||
set( | ||
TESTGEN_LIBS | ||
# tofinobackend | ||
# bfn_p4runtime | ||
# p4cgraphs | ||
# We do not use the target library variable here because top-level testgen will not find it. | ||
# boost_system | ||
${TESTGEN_LIBS} | ||
PARENT_SCOPE | ||
) | ||
|
||
# Custom IR constructs for P4Tools. | ||
set(IR_DEF_FILES ${IR_DEF_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/testgen_tofino.def PARENT_SCOPE) |
51 changes: 51 additions & 0 deletions
51
backends/p4tools/modules/testgen/targets/tofino/check_parser_error.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
* | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
******************************************************************************/ | ||
|
||
#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CHECK_PARSER_ERROR_H_ | ||
#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CHECK_PARSER_ERROR_H_ | ||
|
||
#include "ir/ir.h" | ||
|
||
namespace P4::P4Tools::P4Testgen::Tofino { | ||
|
||
/** | ||
* Walks a given IR node to detect whether it contains a reference to the Tofino parser error. | ||
* This is primarily used to detect that an ingress control references the parser error variable. | ||
* If that is the case, the semantics of parser errors change in the Tofino parser. It will not | ||
* drop packets and instead forward the packet to the MAU. | ||
*/ | ||
class CheckParserError : public Inspector { | ||
private: | ||
bool parserErrorFound = false; | ||
|
||
public: | ||
CheckParserError() { setName("CheckParserError"); } | ||
|
||
bool hasParserError() const { return parserErrorFound; } | ||
|
||
void postorder(const IR::Member *member) override { | ||
if (member->member == "parser_err") { | ||
parserErrorFound = true; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace P4::P4Tools::P4Testgen::Tofino | ||
|
||
#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_CHECK_PARSER_ERROR_H_ */ |
14 changes: 14 additions & 0 deletions
14
backends/p4tools/modules/testgen/targets/tofino/compiler_result.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "backends/p4tools/modules/testgen/targets/tofino/compiler_result.h" | ||
|
||
#include <utility> | ||
|
||
namespace P4::P4Tools::P4Testgen::Tofino { | ||
|
||
TofinoCompilerResult::TofinoCompilerResult(TestgenCompilerResult compilerResult, | ||
DirectExternMap directExternMap) | ||
: TestgenCompilerResult(std::move(compilerResult)), | ||
directExternMap(std::move(directExternMap)) {} | ||
|
||
const DirectExternMap &TofinoCompilerResult::getDirectExternMap() const { return directExternMap; } | ||
|
||
} // namespace P4::P4Tools::P4Testgen::Tofino |
27 changes: 27 additions & 0 deletions
27
backends/p4tools/modules/testgen/targets/tofino/compiler_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_COMPILER_RESULT_H_ | ||
#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_COMPILER_RESULT_H_ | ||
|
||
#include "backends/p4tools/modules/testgen/core/compiler_result.h" | ||
#include "backends/p4tools/modules/testgen/targets/tofino/map_direct_externs.h" | ||
|
||
namespace P4::P4Tools::P4Testgen::Tofino { | ||
|
||
/// Extends the CompilerResult with information specific to the V1Model running on BMv2. | ||
class TofinoCompilerResult : public TestgenCompilerResult { | ||
private: | ||
/// The map of direct extern declarations which are attached to a table. | ||
DirectExternMap directExternMap; | ||
|
||
public: | ||
explicit TofinoCompilerResult(TestgenCompilerResult compilerResult, | ||
DirectExternMap directExternMap); | ||
|
||
/// @returns the map of direct extern declarations which are attached to a table. | ||
[[nodiscard]] const DirectExternMap &getDirectExternMap() const; | ||
|
||
DECLARE_TYPEINFO(TofinoCompilerResult, TestgenCompilerResult); | ||
}; | ||
|
||
} // namespace P4::P4Tools::P4Testgen::Tofino | ||
|
||
#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_COMPILER_RESULT_H_ */ |
Oops, something went wrong.