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

Improve diagnostics for MethodCallExpression #4354

Merged
merged 7 commits into from
Feb 8, 2024

Conversation

kfcripps
Copy link
Contributor

@kfcripps kfcripps commented Jan 23, 2024

No description provided.

@kfcripps kfcripps force-pushed the improve-diagnostics-mce branch 5 times, most recently from e12dba2 to 509b3c7 Compare January 25, 2024 02:57
@kfcripps kfcripps marked this pull request as draft January 25, 2024 06:35
@kfcripps kfcripps changed the title Improve diagnostics for MethodCallExpression (WIP) Improve diagnostics for MethodCallExpression Jan 25, 2024
@kfcripps
Copy link
Contributor Author

Does anybody know what these *.p4.spec files are used for, and if it's a problem that this PR changes their contents? I changed them by just running P4TEST_REPLACE=1 make check, but I don't really know what they are used for.

@fruffy
Copy link
Collaborator

fruffy commented Jan 28, 2024

This doesn't look right to me, I think this could lead to broken code because the DPDK back end relies on toString compare methods. It probably should not do that.

@usha1830 Do you have any other comments?

@jafingerhut
Copy link
Contributor

@kfcripps The .spec files are the output of the p4c-dpdk back end. These .spec files can be loaded into a P4-DPDK software switch, which at a high level my understanding is that they are first translated into C source files, then compiled with a C compiler.

For the purposes of the p4c repository, they are expected output files for CI runs that if they change, someone working on the p4c-dpdk back end should verify whether that change is correct.

It seems like we have enough back ends and enough cases in how the automated p4c testing works that it might be nice to have a summary of the files in the p4c/testdata subdirectories, and how they are used during tests.

@usha1830
Copy link
Contributor

Yes. there are several places where toString() is used in dpdk backend.
This current PR affects the places where hdr.isvalid() is used as table key. I can fix this specific case, however fixing all occurrences of toString() will need more time.

@kfcripps
Copy link
Contributor Author

kfcripps commented Jan 29, 2024

Thanks @fruffy @jafingerhut @usha1830. @usha1830 Let me know when you've fixed this, and I will rebase this PR. Or you can just add these changes to your PR and I will close this one.

@usha1830
Copy link
Contributor

Thanks @fruffy @jafingerhut @usha1830. @usha1830 Let me know when you've fixed this, and I will rebase this PR. Or you can just add these changes to your PR and I will close this one.

@kfcripps I created a PR to fix the dpdk backend to use method->toString() instead of toString() directly on MCE #4383

@kfcripps kfcripps force-pushed the improve-diagnostics-mce branch 3 times, most recently from a9a2d63 to 04037a7 Compare February 7, 2024 20:48
@kfcripps kfcripps changed the title (WIP) Improve diagnostics for MethodCallExpression Improve diagnostics for MethodCallExpression Feb 7, 2024
@kfcripps
Copy link
Contributor Author

kfcripps commented Feb 7, 2024

This is ready for review.

@kfcripps kfcripps marked this pull request as ready for review February 7, 2024 22:04
$TC p4template create table/calculator/MainControlImpl/calculate entry op 26 action calculator/MainControlImpl/operation_and permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 7c action calculator/MainControlImpl/operation_or permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 5e action calculator/MainControlImpl/operation_xor permissions 0x1024
$TC p4template create table/calculator/MainControlImpl/calculate entry op 2b action calculator/MainControlImpl/operation_add() permissions 0x1024
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar error as with the DPDK back end here?

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 assumed these were just log messages, are they not?

The entry action may vary based on the parameters of the action call, so just printing the action name here doesn't seem like enough information anyway.

For example: https://github.com/p4lang/p4c/pull/4354/files#diff-26cbcf98a38e0ae0e3e2de079be734bbda20fee14fb5c39cd6517e7c34d68d85R22-R24

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@kfcripps kfcripps Feb 7, 2024

Choose a reason for hiding this comment

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

Oh, this is a bash script. @komaljai @usha1830 Should the tc commands be updated to somehow take the action param values for each entry action, or is the action name enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like a command to me so in any case the formatting seems wrong here.

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 have updated the p4tc backend to continue using just the action's name here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is a bash script. @komaljai @usha1830 Should the tc commands be updated to somehow take the action param values for each entry action, or is the action name enough?

I presume we only expect the action name here. @vbnogueira @komaljai can comment further.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is a bash script. @komaljai @usha1830 Should the tc commands be updated to somehow take the action param values for each entry action, or is the action name enough?

I presume we only expect the action name here. @vbnogueira @komaljai can comment further.

So, @kfcripps is right. It should pass the parameters also.
The format would be the following (imagine that operation_add had two parameters "a" and "b" in the calc example). So something like:

action operation_add(bit<32> a, bit<32> b) {
        send_back(a + b);
}

The const entry declaration would look like:

const entries = {
            0x2b : operation_add(1 + 42);
           ...
}

And the template script should generate:

$TC p4template create table/calc/MainControlImpl/calculate entry op 0x2b permissions 0x1024 action calc/MainControlImpl/operation_test param a 1 param b 42

@kfcripps kfcripps marked this pull request as draft February 7, 2024 23:04
@kfcripps kfcripps marked this pull request as ready for review February 7, 2024 23:09
@kfcripps kfcripps requested a review from fruffy February 7, 2024 23:09
@kfcripps kfcripps enabled auto-merge (squash) February 8, 2024 14:21
@kfcripps kfcripps merged commit e6d0af5 into p4lang:main Feb 8, 2024
16 checks passed
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.

5 participants