-
Notifications
You must be signed in to change notification settings - Fork 447
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
[P4Testgen] Introduce a new Protobuf backend which uses P4 PDPI instead of P4Runtime #4221
Conversation
2ae0d88
to
e37ed27
Compare
264c18f
to
00ff70c
Compare
58131b4
to
bf964c5
Compare
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.
Thanks Fabian! I initially reviewed this together with a bunch of other changes that have already been submitted, so please ignore comments that no longer apply.
backends/p4tools/modules/testgen/targets/bmv2/test/BMV2ProtobufIrXfail.cmake
Outdated
Show resolved
Hide resolved
backends/p4tools/modules/testgen/targets/bmv2/test_backend/protobuf_ir.h
Show resolved
Hide resolved
backends/p4tools/modules/testgen/targets/bmv2/test_backend/protobuf_ir.cpp
Outdated
Show resolved
Hide resolved
backends/p4tools/modules/testgen/targets/bmv2/test_backend/protobuf_ir.cpp
Outdated
Show resolved
Hide resolved
# Match field {{r.field_name}} | ||
matches { | ||
name: "{{r.field_name}}" | ||
exact: { hex_str: "{{r.value}}" } |
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.
Two small points here:
hex_str
must be a string of the form "0x....". Do we need to add an "0x"-prefix here?- This can be
hex_str
,ipv4
,ipv6
,mac
, orstr
, and PDPI currently enforces that you use the format that is specified in the program using annotations of the form@format(IPV4_ADDRESS)
etc (default is hex). So we would need to either branch on the format here (which you can obtain easily from the IrP4Info). Or we would need to add a PDPI post-processing step that corrects the format, or perhaps extend PDPI with an option to be more lenient.
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.
Yes, the hex string is already prefixed. Not sure about the second point: Do you mean that a generic input hex string is not supported and that we always need some form of ipv4, ipv6, etc assignment?
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.
Yes, that's right.
PDPI has different formats, and accepts only the one that is specified in the P4 program.
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.
Perhaps can be solved in a follow up.
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.
How is that specified? With an annotation?
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.
Yes, see my first comment.
a9f7462
to
7590e9a
Compare
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.
Thanks, this looks good to me.
There are still some open comments, but they are either optional or can be solved as a follow up, so approving early.
This test back end reuses much of the PTF test back end code, but instead produces a text protobuf file. This text protobuf file uses the p4_pdpi format. This format uses human-readable control-plane names (similar to STF and PTF) instead of requiring P4Runtime IDs for configuration.
A couple changes were necessary for this to work:
ir.proto
to the P4Testgen BMv2proto
folder since we do not want to depend on the large pins repository.code.proto
tocontrol-plane/google/rpc/code.proto
and refreshstatus.proto
PROTOBUF_IR
back end and start to deprecate the original PROTOBUF back end. Much of the functionality of PROTOBUF is covered by PROTOBUF_IR.