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] Clean up the implementation of the BMv2 clone externs. #3976

Merged
merged 4 commits into from
May 2, 2023

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Apr 10, 2023

Fixes #3863.

  • Calling clone again in the ingress control will override any previous clone calls. We were not modelling this behavior. Now, we use a clone info test object which contains the execution state at the time the clone call was made. This clone info object is converted into a clone info spec after the deparser.
  • We were also not respecting the session ID. If we are able to control the session ID, we have to limit ourselves to a particular range of values.
  • Introduce a weak notion of a "traffic manager" extern, which handles calls such as recirculate or clone.
  • Refactor the clone class in BMV2's expression stepper, add more comments, and clean up the code.
  • Factor the test object class out of the test objects file and introduce a test object map.
  • Various little fixes here and there.

With this pull request, pins_middleblock.p4 should be testable without any errors.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Apr 10, 2023
@fruffy fruffy force-pushed the fruffy/clone_fixes branch 3 times, most recently from c09f4d5 to c59311f Compare April 10, 2023 23:19
@fruffy fruffy marked this pull request as ready for review April 11, 2023 14:19
@@ -372,7 +372,7 @@ control routing(in headers_t headers, inout local_metadata_t local_metadata, ino
local_metadata.route_metadata = route_metadata;
}
@id(0x0100000F) action trap() {
clone(CloneType.I2E, 1024);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@smolkaj Just a quick clarification question. Is the session ID value here intentional? I had to change it to 511 because the open-source P4Runtime server only allows session IDs numbering lower than 512.

Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

This is a pretty old version of our programs. In the latest version, we use

#define COPY_TO_CPU_SESSION_ID 255

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah great, that makes things easier. Do you know whether or when there is a refresh coming to the files at
https://github.com/sonic-net/sonic-pins/tree/main/sai_p4/instantiations/google
?

Copy link
Member

Choose a reason for hiding this comment

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

@rhalstea do you know the answer?

Copy link
Member

Choose a reason for hiding this comment

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

Generally we would be happy to have our up-to-date programs upstreamed to p4c, we should just keep a copyright notice.

Copy link
Contributor

Choose a reason for hiding this comment

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

We usually only update the programs in https://github.com/sonic-net/sonic-pins/tree/main/sai_p4/instantiations/google when we're upstreaming new features into a SONiC release which have around a 6 month cadence. However, we don't always upstream new P4 features each release.

If we want to have up-to-date programs I like @smolkaj's suggestion of p4c. The copies in sonic-pins need to be kept in sync with the P4RT App so as to not break the component tests, and that dependency would be the bottleneck.

Copy link
Contributor

@rhalstea rhalstea Apr 12, 2023

Choose a reason for hiding this comment

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

I guess I didn't explicitly answer @fruffy's question about the next refresh ... It won't be anytime soon. The feature's we're targeting for the May SONiC release don't require a P4 program updates, and we haven't decided on the features to upstream for the next November release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, that makes sense. In the meantime we can fix issues manually until the next refresh. Or we could update out-of-band (directly from the private repo to p4c's versions) , if necessary. Currently, there is no pressing need.

@fruffy fruffy changed the title [P4Testgen] Clean up the implementation of the BMv2 clone implementation. [P4Testgen] Clean up the implementation of the BMv2 clone externs. Apr 12, 2023
@fruffy
Copy link
Collaborator Author

fruffy commented Apr 14, 2023

@nikil21 @abhinav2sri

This will make the implementation of recirculation functions easier.

@fruffy fruffy force-pushed the fruffy/clone_fixes branch 2 times, most recently from 7742e13 to d6c6d7d Compare April 19, 2023 00:22
@fruffy fruffy merged commit 7be200d into main May 2, 2023
@fruffy fruffy deleted the fruffy/clone_fixes branch May 2, 2023 12:21
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.

P4Testgen does not support sequential clone calls in BMv2.
4 participants