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: Add target_name field for tables to context json. #3380

Merged
merged 2 commits into from
Jun 3, 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
8 changes: 6 additions & 2 deletions backends/dpdk/DPDK_context_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"properties": {
"name": {
"type": "string",
"description": "Name of the referenced table."
"description": "Name of the referenced table as in the P4 file."
},
"target_name": {
"type": "string",
"description": "Name of the referenced table as in the spec file."
},
"handle": {
"type": "integer",
Expand All @@ -26,7 +30,7 @@
"type": "string",
"description": "Name of the action as in P4 file"
},
"target_action_name": {
"target_name": {
"type": "string",
"description": "Name of the action as in spec file"
},
Expand Down
13 changes: 10 additions & 3 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,8 +1676,6 @@ SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) {
} else {
BUG("Unexpected table implementation type");
}
auto hidden = new IR::Annotations();
hidden->add(new IR::Annotation(IR::Annotation::hiddenAnnotation, {}));
IR::Vector<IR::KeyElement> match_keys;
for (auto key : tbl->getKey()->keyElements) {
if (key->matchType->toString() != "selector") {
Expand All @@ -1697,7 +1695,8 @@ SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) {
if (tbl->getSizeProperty()) {
properties.push_back(new IR::Property("size",
new IR::ExpressionValue(tbl->getSizeProperty()), false)); }
auto match_table = new IR::P4Table(tbl->name, new IR::TableProperties(properties));
auto match_table = new IR::P4Table(tbl->name, tbl->annotations,
new IR::TableProperties(properties));
return std::make_tuple(match_table, actionName);
}

Expand Down Expand Up @@ -1725,6 +1724,10 @@ const IR::P4Table* SplitP4TableCommon::create_member_table(const IR::P4Table* tb

auto hidden = new IR::Annotations();
hidden->add(new IR::Annotation(IR::Annotation::hiddenAnnotation, {}));
auto nameAnnon = tbl->getAnnotation(IR::Annotation::nameAnnotation);
cstring nameA = nameAnnon->getSingleString();
cstring memName = nameA.replace(nameA.findlast('.'), "." + memberTableName);
hidden->addAnnotation(IR::Annotation::nameAnnotation, new IR::StringLiteral(memName), false);

IR::IndexedVector<IR::ActionListElement> memberActionList;
for (auto action : tbl->getActionList()->actionList)
Expand Down Expand Up @@ -1755,6 +1758,10 @@ const IR::P4Table* SplitP4TableCommon::create_group_table(const IR::P4Table* tbl
}
auto hidden = new IR::Annotations();
hidden->add(new IR::Annotation(IR::Annotation::hiddenAnnotation, {}));
auto nameAnnon = tbl->getAnnotation(IR::Annotation::nameAnnotation);
cstring nameA = nameAnnon->getSingleString();
cstring selName = nameA.replace(nameA.findlast('.'), "." + selectorTableName);
hidden->addAnnotation(IR::Annotation::nameAnnotation, new IR::StringLiteral(selName), false);
IR::IndexedVector<IR::Property> selector_properties;
selector_properties.push_back(new IR::Property("selector", new IR::Key(selector_keys), false));
selector_properties.push_back(new IR::Property("group_id",
Expand Down
4 changes: 3 additions & 1 deletion backends/dpdk/dpdkContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void DpdkContextGenerator::CollectTablesAndSetAttributes() {
struct TableAttributes tblAttr;
tblAttr.direction = direction;
tblAttr.controlName = control->name.originalName;
tblAttr.externalName = tbl->controlPlaneName();
tblAttr.tableHandle = getNewTableHandle();
auto size = tbl->getSizeProperty();
tblAttr.size = dpdk_default_table_size;
Expand Down Expand Up @@ -139,7 +140,8 @@ Util::JsonObject* DpdkContextGenerator::initTableCommonJson(
const cstring name, const struct TableAttributes & attr) {
auto* tableJson = new Util::JsonObject();
cstring tableName = attr.controlName + "." + name;
tableJson->emplace("name", tableName);
tableJson->emplace("name", attr.externalName);
tableJson->emplace("target_name", tableName);
tableJson->emplace("direction", attr.direction);
tableJson->emplace("handle", attr.tableHandle);
tableJson->emplace("table_type", attr.tableType);
Expand Down
1 change: 1 addition & 0 deletions backends/dpdk/dpdkContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct TableAttributes {
bool isHidden;
unsigned size;
cstring controlName;
cstring externalName;
unsigned default_action_handle;
/* Non selector table keys from original P4 program */
std::vector<std::pair<cstring, cstring>> tableKeys;
Expand Down