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

Support for P4_16 enum type changes introduced in Version 1.2.2 of P4_16 language spec #430

Open
jafingerhut opened this issue May 14, 2023 · 2 comments
Labels
1.5 Issues and PRs that we want to go into 1.5 p4-language-compatibility An issue related to compatibility between P4_16 language spec and P4Runtime API spec

Comments

@jafingerhut
Copy link
Contributor

jafingerhut commented May 14, 2023

This issue should be closed exactly when the bullet item “Added support for additional enumeration types” in Section 1.1 "P4 Language Version Applicability" is addressed and removed.

This issue was created to address one of three changes in Version 1.2.2 of the P4_16 language specification, in particular the one summarized with the following line here: https://p4.org/p4-spec/docs/P4-16-v-1.2.3.html#sec-summary-of-changes-made-in-version-122-released-may-17-2021

  • "Added support for additional enumeration types (Section 7.2.1)."

Note: I have not yet investigated in detail what changes were made from version 1.2.1 to 1.2.2 of the language specification that the line above refers to. It seems to me that the first thing to do in resolving this issue is finding out and describing in a follow-up comment exactly what those changes were.

@jafingerhut
Copy link
Contributor Author

I believe that all of the changes to the Madoko source of the P4_16 language spec related to this change are in this one commit: p4lang/p4-spec@f2e815c

Before this change, a serializable enum could only have a representation type of bit<W> for some positive integer W.

After this change, the following representation types are allowed:

  • bit<W>
  • int<W>
  • a type name declared via typedef, where the base type of that type is either one of the types listed above, or another typedef name that meets these conditions.

I have no recollection of typedef types ever being explicitly represented anywhere in the P4Runtime API specification, so the last bullet item above appears to require no changes in the P4Runtime API spec.

The fact that a serializable enum can have a representation type of int<W> in addition to the former bit<W> seems like it might be important to represent in the P4Runtime API specification somehow.

For example, the P4Runtime message P4SerializableEnumTypeSpec is defined here: https://github.com/p4lang/p4runtime/blob/main/proto/p4/config/v1/p4types.proto#L237-L254
It contains a field named underlying_type with type P4BitTypeSpec, but it cannot also be P4IntTypeSpec, so it appears that the restriction of the underlying type to bit<W> is currently codified in parts of the P4Runtime specification.

There may be other places not mentioned above where this restriction is codified in the P4Runtime specification. I have not attempted to be exhaustive in looking for all possible places at this time.

@smolkaj
Copy link
Member

smolkaj commented May 22, 2023

I think int<W> is generally unsupported in P4Runtime v1 currently:

In the P4Runtime API version 1.0 (including minor version revisions), values of table key fields, action parameters, and fields in packet-in and packet-out headers between a device and the controller (see 6.4.6), may not be of type int. The rules for encoding signed values thus only apply to messages of type P4Data (see 8.4.3).

@jafingerhut jafingerhut added the p4-language-compatibility An issue related to compatibility between P4_16 language spec and P4Runtime API spec label Aug 15, 2023
@smolkaj smolkaj added the 1.4.0 Issues and PRs that we want to go into 1.4.0 label Jun 14, 2024
@smolkaj smolkaj added 1.5 Issues and PRs that we want to go into 1.5 and removed 1.4.0 Issues and PRs that we want to go into 1.4.0 labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Issues and PRs that we want to go into 1.5 p4-language-compatibility An issue related to compatibility between P4_16 language spec and P4Runtime API spec
Projects
None yet
Development

No branches or pull requests

2 participants