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

P4Tools: Implement default action override for BMv2 STF. #3685

Merged
merged 4 commits into from
Nov 22, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Mitigate issues with multicast.
  • Loading branch information
fruffy committed Nov 22, 2022
commit 1b86265fc586079abe5c35d999847efffe014e71
12 changes: 10 additions & 2 deletions backends/p4tools/testgen/targets/bmv2/program_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ std::vector<Continuation::Command> BMv2_V1ModelProgramInfo::processDeclaration(
// Add the copy out assignments after the pipe has completed executing.
cmds.insert(cmds.end(), copyOuts.begin(), copyOuts.end());

auto* dropStmt =
new IR::MethodCallStatement(Utils::generateInternalMethodCall("drop_and_exit", {}));

// Update some metadata variables for egress processing after we are done with Ingress
// processing. For example, the egress port.
if ((archMember->blockName == "Ingress")) {
Expand All @@ -128,6 +131,13 @@ std::vector<Continuation::Command> BMv2_V1ModelProgramInfo::processDeclaration(
new IR::PathExpression("*standard_metadata"), "egress_port");
auto* portStmt = new IR::AssignmentStatement(egressPortVar, getTargetOutputPortVar());
cmds.emplace_back(portStmt);
// TODO: We have not implemented multi cast yet.
// Drop the packet if the multicast group is set.
const IR::Expression* mcastGroupVar = new IR::Member(
IR::getBitType(16), new IR::PathExpression("*standard_metadata"), "mcast_grp");
mcastGroupVar = new IR::Neq(mcastGroupVar, IR::getConstant(IR::getBitType(16), 0));
auto* mcastStmt = new IR::IfStatement(mcastGroupVar, dropStmt, nullptr);
cmds.emplace_back(mcastStmt);
}
// After some specific pipelines (deparsers), we have to append the remaining packet
// payload. We use an extern call for this.
Expand All @@ -136,8 +146,6 @@ std::vector<Continuation::Command> BMv2_V1ModelProgramInfo::processDeclaration(
Utils::generateInternalMethodCall("prepend_emit_buffer", {}));
cmds.emplace_back(stmt);
// Also check whether we need to drop the packet.
auto* dropStmt =
new IR::MethodCallStatement(Utils::generateInternalMethodCall("drop_and_exit", {}));
const auto* dropCheck = new IR::IfStatement(dropIsActive(), dropStmt, nullptr);
cmds.emplace_back(dropCheck);
const auto* recirculateCheck =
Expand Down