-
Notifications
You must be signed in to change notification settings - Fork 82
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
PSA - define what P4_16 lists mean when passed as arguments to certain externs #746
Comments
The attached program is P4_16 + v1model, not PSA, but is being added at the request of Hemant Singh, who was curious to see it. It demonstrates that with the latest p4c as of 2019-Mar-24, it fails to compile calls to update_checksum() in v1model's updateChecksum control. I do not intend this program to greatly affect the decision on the issue above, unless this example demonstrates some very subtle or expensive-to-change aspect of p4c's behavior that should affect the decision. The example is intended to point out an aspect of today's p4c implementation that would need to be changed if we do wish to support values of type header in a P4_16 list argument to a v1model verify_checksum or update_checksum call in the limited-functionality controls where v1model supports those. I believe that the corresponding extern calls in PSA are expected to be made inside of ingress and egress controls. PSA does not have separate controls limited to making only calls to checksum verify/update functions. Thus this example should perhaps have little or no bearing on a PSA implementation. Version of p4c source code used:
Commands I ran to compile and get extra debug output to show what is going on in one compiler intermediate step:
Here is the original contents of the
and here is how it looks after the last step of p4c's front end:
The resulting code fails in the p4c bmv2 back end for the v1model architecture, I believe because it does not support any statements except calls to update_checksum() and update_checksum_with_payload(). |
The transformation by p4c frontend for the update_checksum extern is correct. If one looks at the API for update_checksum in
The transformation by the frontend has changed the In summary, I think we will have to discuss in the LDWG to see if externs should be extended to support a list. |
Externs today already support lists, e.g. update_checksum and verify_checksum support lists of values of type The issue with that particular example P4_16 program for the v1model architecture is some transformations made by passes in p4c, that end up violating the limitations imposed by the v1model back end code on what it supports inside of an updateChecksum control. If people look at that program and the current v1model.p4 docs and say "Yep, that is a limitation we want to keep", then no changes are needed, although a clearer error message would be nice. Even a clearer error message would likely require surgery on the passes of the compiler, though, at least for the ones that are permitted to be used on the updateChecksum control. |
Ok, got it. I agree the error message could be better. |
... and what types of values are permitted inside of those lists.
For example, there are code examples that demonstrate calling the InternetChecksum add() method with a P4_16 list of values, each of which is type
bit<W>
. The assumption when I wrote that example, and I think the way that most people interpret it, is that all of those individualbit<W>
values are concatenated together, with no alignment or padding done by the extern. It would be good to explicitly state that, if that is the intended behavior. For the InternetChecksum in particular, most of its intended use cases are made worthless if an implementation can add extra bits to those given in the list.What types of values should be allowed in such lists?
bit<W>
definitelyint<W>
and serializable enumenum bit<W> ...
types probably, and should be treated as if cast to the corresponding same-widthbit<W>
type.The same or similar answers could apply for the Hash extern, although for most uses of the Hash extern I am aware of, portability of results are not often required or expected, e.g. for LAG or ECMP load balancing. Thus the restriction of no alignment and no padding could perhaps be relaxed here.
The text was updated successfully, but these errors were encountered: