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

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Nov 10, 2022

This PR implements default action overrides for P4Testgen's BMv2 extension. Only for the STF back end so far.

If a table does not have a key, it can not match and pick an action. However, it might still be possible to override the default action and choose a different path. This PR implements the logic to override a table's default action.

Also fixes #3557.

@fruffy fruffy force-pushed the fruffy/default_action branch 2 times, most recently from 856c781 to 18993ee Compare November 11, 2022 14:24
@fruffy fruffy marked this pull request as ready for review November 11, 2022 19:28
@@ -452,7 +452,7 @@ def parse_table_set_default(self, cmd):
actionArgs.set(k, v)
command = "table_set_default " + tableName + " " + actionName
if actionArgs.size():
command += " => " + str(actionArgs)
command += " " + str(actionArgs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug in the STF test framework. Default action overrides were not using the correct syntax.

@fruffy fruffy force-pushed the fruffy/default_action branch 3 times, most recently from fc27d6f to 8740303 Compare November 11, 2022 22:16
@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Nov 12, 2022
properties.tableIsImmutable = isConstant || table->getAnnotation("hidden") != nullptr;
const auto* defaultAction = table->properties->getProperty("default_action");
CHECK_NULL(defaultAction);
properties.defaultIsImmutable = defaultAction->isConstant;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -14,7 +16,7 @@ namespace P4Tools {
namespace P4Testgen {

/// THe default base class for the various test frameworks (TF). Every test framework has a test
/// name and a seed associated with it.
/// name and a seed associated with it. Also contains a variety of common utility functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all test frameworks support ActionProfiles and ActionSelectors - do we want to move it to common tf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is shared between enough back ends that we can add it to common.

@@ -302,9 +245,14 @@ static std::string getTestCase() {
## if control_plane
## for table in control_plane.tables
# Table {{table.table_name}}
## if existsIn(table, "default_override")
setdefault {{table.table_name}} {{table.default_override.action_name}}({% for a in table.default_override.act_args %}{{a.param}}:{{a.value}}{% if not loop.is_last %},{% endif %}{% endfor %})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, now it's very convenient, thank you!

@fruffy fruffy force-pushed the fruffy/default_action branch from 8740303 to 342412e Compare November 22, 2022 16:48
@fruffy fruffy merged commit 95e7894 into p4lang:main Nov 22, 2022
@fruffy fruffy deleted the fruffy/default_action branch November 23, 2022 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a utils library for the P4Tools test back ends.
2 participants