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 implicit action set_member_id in action list for action selector #3540

Merged
merged 1 commit into from
Sep 29, 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
33 changes: 20 additions & 13 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,13 +1681,14 @@ getExternInstanceFromProperty(const IR::P4Table* table,
// create P4Table object that represents the matching part of the original P4
// table. This table sets the internal group_id or member_id which are used
// for subsequent table lookup.
std::tuple<const IR::P4Table*, cstring>
std::tuple<const IR::P4Table*, cstring, cstring>
SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) {
cstring actionName;
cstring grpActionName = "", memActionName;
if (implementation == TableImplementation::ACTION_SELECTOR) {
actionName = refMap->newName(tbl->name.originalName + "_set_group_id");
grpActionName = refMap->newName(tbl->name.originalName + "_set_group_id");
memActionName = refMap->newName(tbl->name.originalName + "_set_member_id");
} else if (implementation == TableImplementation::ACTION_PROFILE) {
actionName = refMap->newName(tbl->name.originalName + "_set_member_id");
memActionName = refMap->newName(tbl->name.originalName + "_set_member_id");
} else {
BUG("Unexpected table implementation type");
}
Expand All @@ -1699,8 +1700,12 @@ SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) {
}
IR::IndexedVector<IR::ActionListElement> actionsList;

auto actionCall = new IR::MethodCallExpression(new IR::PathExpression(actionName));
actionsList.push_back(new IR::ActionListElement(actionCall));
if (implementation == TableImplementation::ACTION_SELECTOR) {
auto grpActionCall = new IR::MethodCallExpression(new IR::PathExpression(grpActionName));
actionsList.push_back(new IR::ActionListElement(grpActionCall));
}
auto memActionCall = new IR::MethodCallExpression(new IR::PathExpression(memActionName));
actionsList.push_back(new IR::ActionListElement(memActionCall));
auto default_action = tbl->getDefaultAction();
if (default_action) {
if (auto mc = default_action->to<IR::MethodCallExpression>()) {
Expand All @@ -1723,7 +1728,7 @@ SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) {
new IR::ExpressionValue(tbl->getSizeProperty()), false)); }
auto match_table = new IR::P4Table(tbl->name, tbl->annotations,
new IR::TableProperties(properties));
return std::make_tuple(match_table, actionName);
return std::make_tuple(match_table, grpActionName, memActionName);
}

const IR::P4Action*
Expand Down Expand Up @@ -1877,11 +1882,13 @@ const IR::Node* SplitActionSelectorTable::postorder(IR::P4Table* tbl) {
}

// base table matches on non-selector key and set group_id
cstring actionName;
cstring grpActionName, memActionName;
const IR::P4Table* match_table;
std::tie(match_table, actionName) = create_match_table(tbl);
auto action = create_action(actionName, group_id, "group_id");
decls->push_back(action);
std::tie(match_table, grpActionName, memActionName) = create_match_table(tbl);
auto grpAction = create_action(grpActionName, group_id, "group_id");
auto memAction = create_action(memActionName, member_id, "member_id");
decls->push_back(grpAction);
decls->push_back(memAction);
decls->push_back(match_table);
cstring member_table_name = instance_name;
cstring group_table_name = member_table_name + "_sel";
Expand Down Expand Up @@ -1972,9 +1979,9 @@ const IR::Node* SplitActionProfileTable::postorder(IR::P4Table* tbl) {
decls->push_back(member_id_decl);
}

cstring actionName;
cstring actionName, ignoreGroup;
const IR::P4Table* match_table;
std::tie(match_table, actionName) = create_match_table(tbl);
std::tie(match_table, ignoreGroup, actionName) = create_match_table(tbl);
auto action = create_action(actionName, member_id, "member_id");
decls->push_back(action);
decls->push_back(match_table);
Expand Down
3 changes: 2 additions & 1 deletion backends/dpdk/dpdkArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,8 @@ class SplitP4TableCommon : public Transform {
const IR::Node* postorder(IR::IfStatement*) override;
const IR::Node* postorder(IR::SwitchStatement*) override;

std::tuple<const IR::P4Table*, cstring> create_match_table(const IR::P4Table* /* tbl */);
std::tuple<const IR::P4Table*, cstring, cstring>
create_match_table(const IR::P4Table* /* tbl */);
const IR::P4Action* create_action(cstring /* actionName */, cstring /* id */, cstring);
const IR::P4Table* create_member_table(const IR::P4Table*, cstring, cstring);
const IR::P4Table* create_group_table(const IR::P4Table*, cstring, cstring, cstring, int, int);
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/pna-action-selector-1.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct main_metadata_t {
bit<32> pna_main_input_metadata_input_port
bit<16> local_metadata_data
Expand Down Expand Up @@ -69,12 +73,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.MainControlT_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
set_exception
}
default_action set_exception args vport 0x0 const
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/pna-action-selector.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct main_metadata_t {
bit<32> pna_main_input_metadata_input_port
bit<16> local_metadata_data
Expand Down Expand Up @@ -64,12 +68,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.MainControlT_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
NoAction
}
default_action NoAction args none
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/psa-action-selector1.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct user_meta_t {
bit<32> psa_ingress_input_metadata_ingress_port
bit<8> psa_ingress_output_metadata_drop
Expand Down Expand Up @@ -69,12 +73,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.Ingress_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
NoAction
}
default_action NoAction args none
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/psa-action-selector2.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct user_meta_t {
bit<32> psa_ingress_input_metadata_ingress_port
bit<8> psa_ingress_output_metadata_drop
Expand Down Expand Up @@ -70,12 +74,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.Ingress_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
NoAction
}
default_action NoAction args none
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/psa-action-selector4.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct user_meta_t {
bit<32> psa_ingress_input_metadata_ingress_port
bit<8> psa_ingress_output_metadata_drop
Expand Down Expand Up @@ -69,12 +73,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.Ingress_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
NoAction
}
default_action NoAction args none
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_16_samples_outputs/psa-action-selector5.p4.spec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct tbl_set_group_id_arg_t {
bit<32> group_id
}

struct tbl_set_member_id_arg_t {
bit<32> member_id
}

struct user_meta_t {
bit<32> psa_ingress_input_metadata_ingress_port
bit<8> psa_ingress_output_metadata_drop
Expand Down Expand Up @@ -69,12 +73,18 @@ action tbl_set_group_id args instanceof tbl_set_group_id_arg_t {
return
}

action tbl_set_member_id args instanceof tbl_set_member_id_arg_t {
mov m.Ingress_as_member_id t.member_id
return
}

table tbl {
key {
h.ethernet.srcAddr exact
}
actions {
tbl_set_group_id
tbl_set_member_id
NoAction
}
default_action NoAction args none
Expand Down