-
Notifications
You must be signed in to change notification settings - Fork 90
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
Changes for language spec update? Clarified behavior of table with no key property, or if its list of keys is empty #455
Comments
2023-Sep-08: Decision made that no P4Runtime spec changes needed, so remove this item from bullet list in spec. |
@jafingerhut I didn't see a note about this in the meeting minutes (I may have missed it). Is the consensus that such tables have a size of 0 and that the server should return |
@antoninbas The discussion was brief on this topic, and I do not believe that anyone thought to raise these questions there about precisely which error code the server should return on an attempted insert to such a table. I did some quick experiments with a table having either an explicit empty The results were not quite what I was expecting:
When I tried inserting an entry into the It seems worth filing a PR on p4c to always consistently output a size of 0 for such tables. When I tried manually editing the P4Info file to delete the |
I also found that if you give This p4c PR introduced the warning and the "no warning if size 1 is given explicitly" logic: p4lang/p4c#1503 It was in response to this issue: p4lang/p4c#1478 In the comments on that PR, Antonin did explicitly mention that size 0 seemed like a better choice for the back-end to see for such tables. Mihai mentioned creating a separate issue for something related to this, but I do not know if that ever occurred. It does seem worth letting as many p4c back-end writers know about such a front/mid-end change, if we change the size to 0 for such tables, since it has been forced to be non-0 since 2018. |
And this is the code in p4c that generates the size used for a table in the P4Info file, I believe: https://github.com/p4lang/p4c/blob/main/control-plane/p4RuntimeArchHandler.cpp#L91-L117 There are TODO comments from Antonin in several places in this file regarding the table size. I'd suggest a scrub of TODO messages in the p4c compiler throughout, but there are 342 of them :-) |
OK, it took a bit longer than I expected to come up with a survey of various kinds of P4 table definitions, what size that today's (2023-Sep-13) version of p4c source code generates for each of them, and a proposal for what I think would be an improvement for consideration by others, but here it is: It seems worth getting consensus amongst interested folks before creating a PR for the p4c compiler to change this behavior, especially since the current behavior has been either completely the same, or changed very little, since 2018. @antoninbas @smolkaj @chrispsommers Please take a look at the link above if you have some time. It is not exactly a quick read, I know, but it does seem worth changing the behavior of some of the cases here. |
This issue should be closed exactly when the bullet item “Clarified behavior of table with no key property, or if its list of keys is empty” in Section 1.1 "P4 Language Version Applicability" is addressed and removed.
This issue is related to the following change made from v1.2.3 to v1.2.4 of the P4_16 language specification:
In the following paragraph, the emphasized text was added in version 1.2.4 of the language spec:
If a table has no key property, or if the value of its key property is the empty tuple, i.e. key = {}, then it contains no look-up table, just a default action—i.e., the associated lookup table is always the empty map.
(see https://p4.org/p4-spec/docs/P4-16-v1.2.4.html#sec-summary-of-changes-made-in-version-124 for the item in context of the full list of changes, but there are separate Github issues for each that might impact the P4Runtime API specification).
I believe this is only a clarification of what existing implementations did, but good to discuss in API work group to make sure. At least BMv2 and/or p4lang/PI may have a bug in this area, according to p4lang/behavioral-model#1208
The text was updated successfully, but these errors were encountered: