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

create dpdk specific pna.p4 and extend it #3658

Merged
merged 11 commits into from
Nov 11, 2022
Prev Previous commit
Next Next commit
replace execute with dpdk_execute
  • Loading branch information
kamleshbhalui committed Nov 11, 2022
commit c2a2dc8b6a8dbef4943557a32aa91c19bb1896fd
2 changes: 1 addition & 1 deletion backends/dpdk/DpdkXfail.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ p4c_add_xfail_reason("dpdk"
"Expected default action .* to have .* method call for .* extern instance"
testdata/p4_16_samples/pna-dpdk-direct-counter-err-1.p4
testdata/p4_16_samples/pna-dpdk-direct-meter-err-4.p4
testdata/p4_16_samples/pna-dpdk-direct-meter-err-3.p4
)

p4c_add_xfail_reason("dpdk"
".* method for different .* instances (.*) called within same action"
testdata/p4_16_samples/pna-dpdk-direct-counter-err-4.p4
testdata/p4_16_samples/pna-dpdk-direct-meter-err-3.p4
)

p4c_add_xfail_reason("dpdk"
Expand Down
6 changes: 3 additions & 3 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2465,13 +2465,13 @@ bool CollectDirectCounterMeter::ifMethodFound(const IR::P4Action *a,
return methodCallFound;
}

/* ifMethodFound() is called from here to make sure that an action only contains count/execute
/* ifMethodFound() is called from here to make sure that an action only contains count/dpdk_execute
* method calls for only one Direct counter/meter instance. The error for the same is emitted
* in the ifMethodFound function itself and return value is not required to be checked here.
*/
bool CollectDirectCounterMeter::preorder(const IR::P4Action* a) {
ifMethodFound(a, "count");
ifMethodFound(a, "execute");
ifMethodFound(a, "dpdk_execute");
return false;
}

Expand Down Expand Up @@ -2529,7 +2529,7 @@ bool CollectDirectCounterMeter::preorder(const IR::P4Table* tbl) {
if (!ifMethodFound(defaultActionDecl, "dpdk_execute", meterExternName)) {
if (meterInstance) {
::error(ErrorType::ERR_EXPECTED, "Expected default action %1% to have "
"'execute' method call for DirectMeter extern instance %2%",
"'dpdk_execute' method call for DirectMeter extern instance %2%",
defaultActionDecl->name, *meterInstance->name);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions backends/dpdk/dpdkHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ bool ConvertStatementToDpdk::preorder(const IR::AssignmentStatement *a) {
e->object->getName(), index, length, color_in, left);
}
} else if (e->originalExternType->getName().name == "DirectMeter") {
if (e->method->getName().name == "execute") {
if (e->method->getName().name == "dpdk_execute") {
auto argSize = e->expr->arguments->size();

// DPDK target needs packet length as mandatory parameters
Expand Down Expand Up @@ -1066,7 +1066,7 @@ bool ConvertStatementToDpdk::preorder(const IR::MethodCallStatement *s) {
a->method->getName());
}
} else if (a->originalExternType->getName().name == "DirectMeter") {
if (a->method->getName().name != "execute") {
if (a->method->getName().name != "dpdk_execute") {
BUG("Direct Meter function %1% not implemented.", a->method->getName().name);
}
} else if (a->originalExternType->getName().name == "DirectCounter") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct main_metadata_t {
bit<8> local_metadata_timeout
bit<32> local_metadata_port_out
bit<32> pna_main_output_metadata_output_port
bit<32> table_entry_index
bit<32> MainControlT_tmp
bit<32> MainControlT_tmp_0
bit<32> MainControlT_color_out
Expand All @@ -55,6 +56,8 @@ action next_hop args instanceof next_hop_arg_t {
}

action add_on_miss_action args none {
entryid m.table_entry_index
meter meter0_0 m.table_entry_index 0x400 m.MainControlT_color_in m.MainControlT_color_out
jmpneq LABEL_FALSE_0 m.MainControlT_color_out 0x1
mov m.MainControlT_tmp_1 0x1
jmp LABEL_END_0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct metadata_t {
bit<8> psa_ingress_output_metadata_drop
bit<32> psa_ingress_output_metadata_egress_port
bit<32> local_metadata_port_out
bit<32> table_entry_index
bit<32> Ingress_color_out
bit<32> Ingress_color_in
bit<32> Ingress_tmp
Expand All @@ -46,6 +47,8 @@ action NoAction args none {
}

action execute_meter args none {
entryid m.table_entry_index
meter meter0_0 m.table_entry_index 0x400 m.Ingress_color_in m.Ingress_color_out
jmpneq LABEL_FALSE m.Ingress_color_out 0x0
mov m.Ingress_tmp 0x1
jmp LABEL_END
Expand Down