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
Can't add more than one verify_checksum in Checksum Verification block #2057
Comments
Are you able to publicly share the complete P4 program for which you got this error? e.g. attach it as a file to a comment on this issue? Also if you could share the version of p4c you are using (the output of the command 'p4c --version'), that might help diagnose it. |
The version of p4c I am currently using is Sure, here is the complete P4 program. |
I can confirm that with the latest version of p4c as of today, built from this version of the source code:
the program attached to this comment gives the following error:
and it does not give an error when even only the second of the two verify_checksum calls is present (the one for the IPv4 header), so the root cause of the issue is not two Instead, it is something about the remaining A change made to the p4c v1model back end, I believe in March 2019 (this PR: #1769), that rejects programs that do anything except That March 2019 change is desirable and necessary for simple_switch to correctly interpret the BMV2 JSON file output by the compiler, so the real question is: why does the compiler introduce the assignment statements during the |
Additional question: what is different about the two I am a little surprised that there are not other existing test programs that make the same, or nearly the same, Regarding the second question, I just checked and found test program p4c/testdata/p4_16_samples/issue270-bmv2.p4 that has a similar |
I think I have got the root cause. The call to Most P4 programs leave the packet header checksum out of the list of fields over which to calculate the checksum. There is no reason for it to be there in a correct program. If you remove that field from the field list, the compilation error goes away. For P4 developers, though, doesn't it seem a bit odd that the
In particular, why is the |
Yes, perhaps the checksum should be only "in", and then the side-effects pass won't make that change. |
Yes, taking off the Also very thankful to your fast and complete response. Really apreciate it. |
@mbudiu-vmw @antoninbas I have read through the implementation of verify_checksum in behavioral-model code for the v1model architecture, and as far as I can tell it never modifies anything except the architecture-internal state of an error status bit. (That architecture-internal state is used just before ingress processing begins to choose what value to assign to the If that is all correct, then it seems like it would be a correct change to replace |
If such an It would also seem reasonable to change the signature of the VerifyChecksum control from the current:
to replace both |
If we make this change this will break all user programs that are written with the old prototype. |
I.e., different v1model header versions. |
Making the change I mention above to the VerifyChecksum control signature would definitely cause all v1model programs written for the current v1model.p4 include file to no longer compile, agreed, and I am definitely not here pushing for such a change. I only mentioned it as an observation of what would become possible, if the changes to the verify_checksum and verify_checksum_with_payload signatures were changed. Changing only the signatures of verify_checksum and verify_checksum_with_payload should not break anyone's v1model programs, unless I am missing something. |
I want to add checksum verification for two different headers. Here it is the code in the Checksum Verification block of my bmv2 simple switch:
This is the compiler output that I have:
I think it should be no problem for calling
verify_checksum
more than one time, but actually the compiler does not allow me to do it. I am missing something?Thank you in advance
The text was updated successfully, but these errors were encountered: