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

DPDK Backend: Minor fix to emit target_action_name in context json #3213

Merged
merged 1 commit into from
Apr 14, 2022
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
6 changes: 5 additions & 1 deletion backends/dpdk/DPDK_context_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"properties": {
"action_name": {
"type": "string",
"description": "Name of the action"
"description": "Name of the action as in P4 file"
},
"target_action_name": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Who consumes the internal action name, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pipe manager will query the action handle in dpdk target to associate with context.json action handle. For this it needs to use the same name as the name in the spec file.

In the spec file, we use the internal names as the originalName is modified by the frontend in some cases to uniquify them and causes a mismatch between action name in action definition and the one in the table action list.

"type": "string",
"description": "Name of the action as in spec file"
},
"action_handle": {
"type": "integer",
Expand Down
12 changes: 9 additions & 3 deletions backends/dpdk/dpdkContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,15 @@ DpdkContextGenerator::addMatchAttributes(const IR::P4Table*table, const cstring
auto* oneAction = new Util::JsonObject();
struct actionAttributes attr = ::get(actionAttrMap, action->getName());
auto actName = toStr(action->expression);
if (actName != "NoAction")
auto name = action->externalName();
if (name != "NoAction") {
actName = ctrlName + "." + actName;
oneAction->emplace("action_name", actName);
name = ctrlName + "." + name;
} else {
actName = name;
}
oneAction->emplace("action_name", name);
oneAction->emplace("target_action_name", actName);
oneAction->emplace("action_handle", attr.actionHandle);
auto* immFldArray = new Util::JsonArray();
if (attr.params) {
Expand Down Expand Up @@ -271,7 +277,7 @@ const IR::P4Table * table, const cstring controlName, bool isMatch) {
// Printing compiler added actions is curently not required
if (!attr.is_compiler_added_action) {
auto *act = new Util::JsonObject();
auto actName = toStr(action->expression);
auto actName = action->externalName();

// NoAction is not prefixed with control block name
if (actName != "NoAction")
Expand Down