Comments (8)
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 --std p4-14
to the command line you have tried, mentioned in the issue.
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.
from behavioral-model.
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
./recirc.p4(20): [--Werror=not-found] error: mcast_hash: no such field in standard_metadata
mcast_hash : 16;
^^^^^^^^^^
./recirc.p4(21): [--Werror=not-found] error: lf_field_list: no such field in standard_metadata
lf_field_list: 32;
^^^^^^^^^^^^^
./recirc.p4(23): [--Werror=not-found] error: resubmit_flag: no such field in standard_metadata
resubmit_flag : 16;
^^^^^^^^^^^^^
./recirc.p4(24): [--Werror=not-found] error: recirculate_flag: no such field in standard_metadata
recirculate_flag : 16;
^^^^^^^^^^^^^^^^
[--Werror=overlimit] error: 4 errors encountered, aborting compilation
from behavioral-model.
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?
from behavioral-model.
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.
from behavioral-model.
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.
from behavioral-model.
@jafingerhut , Thank you very much for your great suggestion, I'm clear now and I'm going to close this topic.
from behavioral-model.
You raised another topic that I am curious about.
Since BMv2 has already parsed the JSON input file into data structures including parser, deparser and pipeline etc., I'm thinking it is a good start from these data structures to ultimately output machine codes which can be executed by specific hardware (e.g. Tofino as you mentioned previously).
It seems that BMv2 is a pure P4 software simulator, which is very different from the hardware. Raise Hardware that follows the v1model architecture as example , their parsers, match action units, and parsers are actually driven by instructions (e.g. VLIW instructions), In these instructions, it may be necessary to fill in resource information, for example, the extracting offset of phv that a hdr field is going to be extracted to.
from behavioral-model.
You raised another topic that I am curious about. Since BMv2 has already parsed the JSON input file into data structures including parser, deparser and pipeline etc., I'm thinking it is a good start from these data structures to ultimately output machine codes which can be executed by specific hardware (e.g. Tofino as you mentioned previously). It seems that BMv2 is a pure P4 software simulator, which is very different from the hardware. Raise Hardware that follows the v1model architecture as example , their parsers, match action units, and parsers are actually driven by instructions (e.g. VLIW instructions), In these instructions, it may be necessary to fill in resource information, for example, the extracting offset of phv that a hdr field is going to be extracted to.
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.
from behavioral-model.
Related Issues (20)
- import thrift
- TCP packets seem not to be processed correctly by bmv2 HOT 2
- Problem using multicast in runtime HOT 1
- Empty action-parameter vector is always accessed in ActionFnEntry::execute HOT 3
- How to build behavioral-model on the MacOS(Apple M1 Pro(13.5)) HOT 1
- How to track fileds of metadata with p4dbg? HOT 2
- Approximate conversion of bmv2 p4 performance to hardware performance HOT 3
- Applying the same table twice HOT 2
- Required to set forwarding pipeline before using the dataplane for streaming packets HOT 10
- Update project to require C++17 HOT 9
- Race conditions when passing in a BMv2 JSON config HOT 12
- To Add PNA support into BMv2. HOT 5
- How to build simple_switch / simple_switch_grpc on Ubuntu 24.04 ? HOT 4
- Why bmi_port.c is a C code? HOT 2
- Race conditions when processing packet in the egress pipeline. HOT 6
- Heap Buffer Overflow when installing many table entries HOT 1
- CMake support HOT 2
- Queue metadata with multiqueue HOT 2
- Consider implementing something like Tuple Space Search for ternary table lookups
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behavioral-model.