diff --git a/backends/dpdk/dpdkArch.cpp b/backends/dpdk/dpdkArch.cpp index ddf2f34c91..94e4709223 100644 --- a/backends/dpdk/dpdkArch.cpp +++ b/backends/dpdk/dpdkArch.cpp @@ -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 +std::tuple 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"); } @@ -1699,8 +1700,12 @@ SplitP4TableCommon::create_match_table(const IR::P4Table *tbl) { } IR::IndexedVector 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()) { @@ -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* @@ -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"; @@ -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); diff --git a/backends/dpdk/dpdkArch.h b/backends/dpdk/dpdkArch.h index fb97c4d6ef..ba74f26895 100644 --- a/backends/dpdk/dpdkArch.h +++ b/backends/dpdk/dpdkArch.h @@ -849,7 +849,8 @@ class SplitP4TableCommon : public Transform { const IR::Node* postorder(IR::IfStatement*) override; const IR::Node* postorder(IR::SwitchStatement*) override; - std::tuple create_match_table(const IR::P4Table* /* tbl */); + std::tuple + 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); diff --git a/testdata/p4_16_samples_outputs/pna-action-selector-1.p4.spec b/testdata/p4_16_samples_outputs/pna-action-selector-1.p4.spec index a613e984a3..759c2a3f8c 100644 --- a/testdata/p4_16_samples_outputs/pna-action-selector-1.p4.spec +++ b/testdata/p4_16_samples_outputs/pna-action-selector-1.p4.spec @@ -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 @@ -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 diff --git a/testdata/p4_16_samples_outputs/pna-action-selector.p4.spec b/testdata/p4_16_samples_outputs/pna-action-selector.p4.spec index da51ecfca8..f198a3b697 100644 --- a/testdata/p4_16_samples_outputs/pna-action-selector.p4.spec +++ b/testdata/p4_16_samples_outputs/pna-action-selector.p4.spec @@ -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 @@ -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 diff --git a/testdata/p4_16_samples_outputs/psa-action-selector1.p4.spec b/testdata/p4_16_samples_outputs/psa-action-selector1.p4.spec index cf47cf1037..ea853830a6 100644 --- a/testdata/p4_16_samples_outputs/psa-action-selector1.p4.spec +++ b/testdata/p4_16_samples_outputs/psa-action-selector1.p4.spec @@ -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 @@ -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 diff --git a/testdata/p4_16_samples_outputs/psa-action-selector2.p4.spec b/testdata/p4_16_samples_outputs/psa-action-selector2.p4.spec index 259462563f..83eadfe143 100644 --- a/testdata/p4_16_samples_outputs/psa-action-selector2.p4.spec +++ b/testdata/p4_16_samples_outputs/psa-action-selector2.p4.spec @@ -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 @@ -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 diff --git a/testdata/p4_16_samples_outputs/psa-action-selector4.p4.spec b/testdata/p4_16_samples_outputs/psa-action-selector4.p4.spec index c85bf5756f..65883e39ff 100644 --- a/testdata/p4_16_samples_outputs/psa-action-selector4.p4.spec +++ b/testdata/p4_16_samples_outputs/psa-action-selector4.p4.spec @@ -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 @@ -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 diff --git a/testdata/p4_16_samples_outputs/psa-action-selector5.p4.spec b/testdata/p4_16_samples_outputs/psa-action-selector5.p4.spec index c0cfc11536..09ef2d6e2d 100644 --- a/testdata/p4_16_samples_outputs/psa-action-selector5.p4.spec +++ b/testdata/p4_16_samples_outputs/psa-action-selector5.p4.spec @@ -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 @@ -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