-
Notifications
You must be signed in to change notification settings - Fork 447
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
Conversation
856c781
to
18993ee
Compare
@@ -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) |
There was a problem hiding this comment.
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.
fc27d6f
to
8740303
Compare
properties.tableIsImmutable = isConstant || table->getAnnotation("hidden") != nullptr; | ||
const auto* defaultAction = table->properties->getProperty("default_action"); | ||
CHECK_NULL(defaultAction); | ||
properties.defaultIsImmutable = defaultAction->isConstant; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 %}) |
There was a problem hiding this comment.
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!
8740303
to
342412e
Compare
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.