-
Notifications
You must be signed in to change notification settings - Fork 329
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
Where is the original p4 source code for recirc.json #1259
Comments
This test program is old enough that it is written in an older version of the P4 language called P4_14, whereas the current version is P4_16. They are quite different languages syntax-wise, i.e. neither is a subset of the other. Try adding the command line options Also note that if you do this, it might be that the file recirc.json produced may be different than the one checked into the behavioral-model repo, because the p4c source code has been enhanced noticeably since 2019 when the checked-in recirc.json was created. Hopefully they should be functionally equivalent to each other, but depending on how different they are textually, that might not be easy to determine quickly. |
Yes, that makes sense, the last modification for recirc.p4 seems like "Thu Feb 14 15:43:17 2019 -080". I failed to build it even with p4-14 option, here is the log: p4c --target bmv2 --arch v1model --std p4-14 ./recirc.p4 |
I tried commenting out those 4 metadata fields in recirc.p4, and the compilation produced a recirc.json file that was very similar, but not identical, to the one that is checked in. Realize that the recirc.p4 was compiled to recirc.json with a version of p4c from 2019, so if you were able to go back to a 2019 version of p4c, build it from source code, and use that to compile recirc.p4, it would probably produce the same recirc.json file that is checked in, but I would not recommend trying to build that older version of p4c from source code, unless you enjoy solving build command sequence puzzles with older versions of Ubuntu Linux. Out of curiosity, what is your reason for wanting to build recirc.p4 from source code? |
Yes, actually I am trying to figure out how BMv2 converts descriptions in JSON files into corresponding resources (e.g. PHV), and then further statistics will be conducted on the utilization and waste of resources to see if fine tuning can be performed. I want to start with a simple P4 source file, while the JSON file compiled from the exercises in tutorial repo seems to be much more complicated. Currently, recirc.P4 is what I want, so ... Do I have a better choice? Thank you in advance. |
BMv2 has no reason to convert its input into PHV resources, as there are no PHV resources in BMv2. At least, not Tofino-like PHV resources. There is a software data structure that holds all header fields in memory. I am not aware of anything in BMv2 that tries to optimize this memory use, since memory is plentiful in a general purpose CPU, and BMv2 has few performance optimizations. If you want the simplest JSON file you can get, I would recommend a P4 program that parses only an Ethernet header, and no other headers, and does one table lookup that does an exact match on one of those header fields, with a single action that sets the output port, in ingress. Egress is empty. |
@jafingerhut , Thank you very much for your great suggestion, I'm clear now and I'm going to close this topic. |
This comment was marked as off-topic.
This comment was marked as off-topic.
It is definitely true that the BMv2-JSON file read by BMv2 is not directly usable in any hardware target that I am aware of, nor was it intended to be. I could imagine that perhaps some designers responsible for a hardware target might choose to start from the BMv2-JSON file and transform that into something suitable to configure the hardware, but I am not aware of anyone that has chosen to do so. If they have an actual hardware target, they typically have customers and a budget large enough to hire a full time compiler engineer, or several, and they choose to create a new back end for the p4c compiler that starts with the in-memory IR (intermediate representation) data structures, and does calculations and optimizations on those to create the hardware confgiuration for that target. |
Hi,
I can find a recirc. json file in the folder of targets/simple.switch/tests/testdata/. I guess the corresponding p4 source code file should be recirc.p4 which is located in the same folder, but when I tried to recompile this file with command " p4c --target bmv2 --arch v1model ./recirc.p4", I got the following error:
./recirc.p4(16):syntax error, unexpected {, expecting (
header_type intrinsic_metadata_t {
^
[--Werror=overlimit] error: 1 errors encountered, aborting compilation
So how can I recompile and get recirc. json, please help with this, thank you very much!
The text was updated successfully, but these errors were encountered: