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
Add support for parser value sets (PVS) to runtime_CLI #859
Conversation
Codecov Report
@@ Coverage Diff @@
## master #859 +/- ##
=========================================
- Coverage 74.55% 74.36% -0.2%
=========================================
Files 115 115
Lines 10207 10235 +28
=========================================
+ Hits 7610 7611 +1
- Misses 2597 2624 +27
Continue to review full report at Codecov.
|
The JSON generated by bmv2 has a unique id for each parse_vset. Why don't you use the id to search before add or delete? Thanks for working on these changes so quick. |
docs/runtime_CLI.md
Outdated
``` | ||
When adding or removing an entry, you must provide a single integer value, which | ||
must fit within the value set's "compressed bitwidth", or the CLI will display | ||
an error. When a value set's entries consitute of multiple individual fields, as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "consist of" instead of "consitute of" ? "consitute" is not a word, in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks for pointing this out
I can look into this in more detail to see if I can figure it out, but it is currently confusing me how this implementation can work, when the "compile time constant" entries of parser transitions of a select must have each field padded out to a whole number of bytes, but the parser value set entries must not be padded out to a whole number of bytes. For example, if there are two fields in a select expression like How does simple_switch know to take a 6+3=9-bit value from a |
OK, looking more closely, I guess the value of the BMv2 JSON key "transition_key" is a list of fields that each have an exact bit width that need not be a multiple of 8, and matches what is in the P4 source code. That answers my question of how simple_switch can have enough information to interpret a compressed bit string correctly, and also the other constant select expressions in the BMv2 JSON file. |
We now provide the following commands: pvs_add, pvs_remove, pvs_get, pvs_clear. Implementing pvs_get and pvs_clear required adding the equivalent RPCs to the Thrift API. This commit also adds a bmv2 JSON sanity check for the "mask" attribute, when it is used in a PVS parser transition. The included JSON file, pvs_struct_2.json, was used to test the implementation of the CLI commands. It was generated from a P4 program written by @jafingerhut for the compiler testsuite. Fixes #855
9329021
to
1b74a02
Compare
@jafingerhut yes that's correct. And I believe the rationale for the current implementation is that it was introduced for P4_14 parser value sets, which were initialized with a single bitwidth, and while you could combine multiple fields when performing a lookup on the set, the declaration of the pvs itself didn't impose any structure. I think the PVS implementation in bmv2 could benefit from a major overhaul (maybe #857 should be a more general issue). The implementation really caters to P4_14 at the moment. It even accommodates for the case where a single PVS is used in 2 different parser states with different lookup keys. |
To illustrate what I meant at the end of my previous comment. I believe the following program is a valid P4_14 program but cannot be translated easily in a P4_16 program and is rejected by p4c:
P4_16 requires |
You should submit the p4-14 program as an issue to p4c so we can fix it. |
We now provide the following commands: pvs_add, pvs_remove, pvs_get,
pvs_clear. Implementing pvs_get and pvs_clear required adding the
equivalent RPCs to the Thrift API.
This commit also adds a bmv2 JSON sanity check for the "mask" attribute,
when it is used in a PVS parser transition.
The included JSON file, pvs_struct_2.json, was used to test the
implementation of the CLI commands. It was generated from a P4 program
written by @jafingerhut for the compiler testsuite.
Fixes #855