Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the DASH BMv2 model to the tested programs. #3885

Merged
merged 6 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
e26a49dbf5749ee92585cec9e95ca781d377ebfd
# clang-format ir and lib folder.
7a722a3fb8205c57d7e9554fc7c62c2629720d5a
# Switched from left to right pointer alignment.
f1181a071844f759b618ed3c894cf56e2df1dd05
3 changes: 2 additions & 1 deletion backends/bmv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ p4c_find_tests("${P4TESTS_FOR_V1MODEL}" v1tests INCLUDE "${V1_INCLUDE_PATTERNS}"

set (BMV2_V1MODEL_TEST_SUITES
"${P4C_SOURCE_DIR}/testdata/p4_16_bmv_errors/*-bmv2.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/dash/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/fabric_*/fabric.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/omec/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_14_samples/switch_*/switch.p4"
"${P4C_SOURCE_DIR}/testdata/p4_14_samples/*.p4"
${v1tests}
Expand Down
3 changes: 2 additions & 1 deletion backends/p4test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ set(P4TEST_DRIVER ${P4C_SOURCE_DIR}/backends/p4test/run-p4-sample.py)

set (P4TEST_SUITES
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/dash/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/fabric_*/fabric.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/omec/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
)

# Builds a list of tests for which P4Info generation is not supported. It makes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ p4tools_add_xfail_reason(
# At index 0: INVALID_ARGUMENT, 'Bytestring provided does not fit within 0 bits'
pins_middleblock.p4
issue2283_1-bmv2.p4
# INVALID_ARGUMENT, 'Zero priority for ternary match'
dash-pipeline.p4
)

p4tools_add_xfail_reason(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ p4tools_add_xfail_reason(
p4tools_add_xfail_reason(
"testgen-p4c-bmv2"
"Exception"
# Running simple_switch_CLI: Exception Unexpected key field &
# Running simple_switch_CLI: Exception Unexpected key field &
match-on-exprs2-bmv2.p4
# Running simple_switch_CLI: Exception Unexpected key field :
dash-pipeline.p4
# Could not find table
nonstandard_table_names-bmv2.p4
)

p4tools_add_xfail_reason(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ p4tools_find_tests("${P4_16_V1_TESTS}" v1tests EXCLUDE "")
set(
TESTGEN_BMV2_P416_TESTS
"${CMAKE_CURRENT_LIST_DIR}/p4-programs/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/omec/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/dash/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/fabric_*/fabric.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/omec/*.p4"
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/pins/*.p4"
)

p4c_find_tests("${TESTGEN_BMV2_P416_TESTS}" BMV2_P4_16_V1_TESTS INCLUDE "${V1_SEARCH_PATTERNS}" EXCLUDE "")
Expand Down
14 changes: 9 additions & 5 deletions frontends/p4/inlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,18 @@ class ComputeNewNames : public Inspector {
BUG_CHECK(decl->is<IR::IAnnotated>(), "%1%: no annotations", decl);
cstring name = decl->externalName();
cstring extName;
if (name.startsWith("."))
if (name.startsWith(".")) {
// Do not change the external name of objects starting with a leading dot
extName = name;
else
} else {
extName = prefix + "." + name;
cstring baseName = extName.replace('.', '_');
cstring newName = refMap->newName(baseName);
renameMap->setNewName(decl, newName, extName);
}
// Replace non-alphanumeric characters with an underscore.
std::string baseName = extName.c_str();
std::replace_if(
baseName.begin(), baseName.end(),
[](char ch) { return (::isalnum(ch) == 0) && ch != '_'; }, '_');
renameMap->setNewName(decl, refMap->newName(baseName), extName);
}
void postorder(const IR::P4Table *table) override { rename(table); }
void postorder(const IR::P4ValueSet *set) override { rename(set); }
Expand Down
4 changes: 4 additions & 0 deletions testdata/p4_16_samples/dash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# DASH P4 Programs
The Disaggregated API for SONiC Hosts (DASH) defines a behavioral model for conformance testing of network devices. The P4 programs contained here model various network architecture scenarios related to the DASH project.

They are sourced from https://github.com/sonic-net/DASH. For more information, please see https://github.com/sonic-net/DASH/blob/main/documentation/general/dash-high-level-design.md.
Loading