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: Connection tracking support #3290

Merged
merged 3 commits into from
May 16, 2022
Merged

Conversation

usha1830
Copy link
Contributor

@usha1830 usha1830 commented May 7, 2022

Connection tracking support for PNA needs the following extern functions to be supported.

  • add_entry extern with additional timeout parameter
  • restart_expire_timer
  • set_entry_expire_timer

DPDK provides the following corresponding instructions for connection tracking

  • learn instruction with timeout parameter (The second parameter of this instruction "action_params" is optional in DPDK)
  • rearm instruction
  • rearm instruction with timeout parameter

The timeout parameter is the index in timeout structure defined in the learner table.

All of the above instruction expect all the arguments in metadata and hence if any argument is constant, it should be moved to metadata.

These externs have constraints on where these externs can be called from. Added a new pass to check all these constraints.
The existing convertToDpdk pass is enhanced to process these new externs and generate equivalent assembly spec.

DPDK reference patch describing the rearm and learn instructions:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

@jafingerhut 's Connection tracking example from pna repo is added as a test here

}
}
}
if (!isValidExternCall) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be after the next brace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

backends/dpdk/dpdkArch.cpp Show resolved Hide resolved
@@ -108,6 +108,9 @@ set (P4_XFAIL_TESTS
# These programs uses conditional execution inside action body which is currently
# unsupported
testdata/p4_16_samples/psa-dpdk-action-jumpOpt.p4
testdata/p4_16_samples/pna-example-tcp-connection-tracking.p4
Copy link
Contributor

Choose a reason for hiding this comment

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

we could remove this check from p4test as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I misunderstood this comment and made the recent changes to midend/predication.h by removing the check for conditional execution inside action body.

Some of the tests added in this PR fail with p4test backend because of use of conditional execution within action. So, I added them to XFAIL list for p4test.

Shall I revert back to that, .i.e., no change to the predication.h and adding back the tests with conditional execution in action as XFAIL here?

backends/dpdk/dpdkHelpers.cpp Show resolved Hide resolved
} else if (a->method->name == "set_entry_expire_time") {
auto args = a->expr->arguments;
if (args->size() != 1) {
::error(ErrorType::ERR_UNEXPECTED, "Expected 1 arguments for %1%",
Copy link
Contributor

Choose a reason for hiding this comment

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

1 argument

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -113,10 +113,6 @@ class Predication final : public Transform {
// false for statements that are not dependent.
std::map<cstring, bool> isStatementDependent;
const IR::Statement* error(const IR::Statement* statement) const {
if (inside_action && ifNestingLevel > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to delete this code you should delete the whole function and its calls; the function does nothing now.
But I think this should be guided by a policy flag: "report errors when a statement cannot be converted".
Then invoke it with the flag set to "no" in your compiler.

Copy link
Contributor

Choose a reason for hiding this comment

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

Finally, you are not even using this pass in your backend, why are you modifying it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. DPDK backend does not use this pass. Wondering if I should still modify to use the policy flag and call it appropriately from p4test backend?

Copy link
Contributor

Choose a reason for hiding this comment

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

As you wish

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a closer look at predication pass, I think we can leave it as it is now because the error is thrown for the statements which prevent the if-else to Mux conversion.
I reverted the changes made to predication pass.

@@ -55,8 +55,6 @@ control cIngress(inout Parsed_packet hdr,
action foo() {
meta.b = meta.b + 5;
if (meta.b > 10) {
// Next line causes error for p4test: MethodCallStatement:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why delete this comment?
Why is the test still failing after your change?

@usha1830 usha1830 requested a review from mihaibudiu May 16, 2022 03:21
@mihaibudiu mihaibudiu merged commit 0495e49 into p4lang:main May 16, 2022
github-sajan pushed a commit to github-sajan/p4c that referenced this pull request May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants