Skip to content
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

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

fruffy-g
Copy link
Contributor

@fruffy-g fruffy-g commented Nov 1, 2023

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:

  1. Copy the ir.proto to the P4Testgen BMv2 proto folder since we do not want to depend on the large pins repository.
  2. Add code.proto to control-plane/google/rpc/code.proto and refresh status.proto
  3. Add a new PROTOBUF_IR back end and start to deprecate the original PROTOBUF back end. Much of the functionality of PROTOBUF is covered by PROTOBUF_IR.

@fruffy-g fruffy-g force-pushed the protobuf-ir branch 3 times, most recently from 2ae0d88 to e37ed27 Compare November 2, 2023 16:42
@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Nov 3, 2023
@fruffy-g fruffy-g marked this pull request as ready for review November 6, 2023 23:20
@fruffy-g fruffy-g changed the title [P4Testgen] Introduce a new Protobuf backend which uses the P4 PDPI instead of P4Runtime [P4Testgen] Introduce a new Protobuf backend which uses P4 PDPI instead of P4Runtime Nov 14, 2023
@fruffy-g fruffy-g force-pushed the protobuf-ir branch 2 times, most recently from 58131b4 to bf964c5 Compare November 21, 2023 20:17
Copy link
Member

@smolkaj smolkaj left a 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.

# Match field {{r.field_name}}
matches {
name: "{{r.field_name}}"
exact: { hex_str: "{{r.value}}" }
Copy link
Member

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, or str, 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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

control-plane/google/rpc/code.proto Outdated Show resolved Hide resolved
Copy link
Member

@smolkaj smolkaj left a 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.

@fruffy fruffy merged commit 4fe8934 into p4lang:main Nov 30, 2023
13 checks passed
@fruffy-g fruffy-g deleted the protobuf-ir branch December 7, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants