Skip to content

Conversation

@verios-google
Copy link
Contributor

The Any protobuf message would allow parties to experiment with new capability responses before proposing them for standardization. This provides a convenient way to try experimental features while remaining in sync with the repo.

A quick guide for how to use the Any message can be found here

An example of how this may be used:

// A user would like to experiment with a new capability, so they define a proto
message ToasterCapabilities {
  int max_bread = 1;
  bool water_resistant = 2;
}


// The hardware (a toaster in this case) can then populate the response:
ToasterCapabilites toaster;
toaster.set_max_bread(2);
toaster.set_water_resistant(false);
CapabilitiesResponse response;
response.mutable_experimental->PackFrom(toaster);


// The consumer (typically a controller) can then use the info:
ToasterCapabilites toaster;
response.experimental.UnpackTo(toaster);
if (toaster.max_bread < 10)
  std::cout << "This toaster sucks";

This example is for fun but one could imagine a plethora of capabilities a switch/NIC/hardware may advertise. The P4 runtime specification does advertise some capabilities (e.g. table sizes) and the p4 constraints repo allows for more complex restrictions on entries, but there is still a large number of capabilities that cannot be captured by current solutions (e.g. two tables sharing resources).

NOTE: In the future, it would super nice to migrate p4runtime.proto from proto3 to proto editions. When that happens, this (and possibly other existing) Any protobuf message(s) should be replaced with proto extensions. I added a comment in the spec for awareness.

…mental features before proposing them for standardization

Signed-off-by: verios-google <[email protected]>
@chrispsommers
Copy link
Collaborator

Looks interesting, let's discuss at the next P4-APi WG meeting!

Copy link
Collaborator

@chrispsommers chrispsommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@verios-google
Copy link
Contributor Author

@chrispsommers can you merge this, I'm not authorized to do this. Unless you're waiting on someone else's approval

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.

A few nits

Copy link
Contributor

@jonathan-dilorenzo jonathan-dilorenzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Victor. Basically just what Steffen said.

Copy link
Contributor

@jonathan-dilorenzo jonathan-dilorenzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

Final nit, approving early.

@smolkaj
Copy link
Member

smolkaj commented Apr 17, 2025

Chris already approved, so I'll go ahead and submit.

@smolkaj smolkaj merged commit 5e6138d into p4lang:main Apr 17, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants