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 direct counters and direct meters in p4RuntimeSerializer #317

Conversation

sethfowler
Copy link
Contributor

This PR adds support for direct counters and direct meters in p4RuntimeSerializer and addresses something other existing issues along the way.

455c196 fixes #302 by adding an ExternInstance help class, akin to MethodInstance, which provides information about the extern instance referenced by an expression. It handles both PathExpressions which refer to a Declaration_Instance by name and ConstructorCallExpressions which create an anonymous extern instance. These are the two common cases that we need to support in p4RuntimeSerializer, though it's possible that in the future there would be others which would be useful to add.

3d3ce5c fixes #311 by actually adding support for serializing direct counters and meters in p4RuntimeSerializer. A little bit of metaprogramming is used to make this less repetitive, since the two cases are almost exactly the same.

Finally, a04ad31 is a small additional patch that fixes an issue Mihai noticed in #296: the existing action profile support in p4RuntimeSerializer handles only ConstructorCallExpressions, but we need to support Declaration_Instance references as well. The previous two commits add code that abstracts over the two cases; you can simply pass getExternInstanceFromProperty() a table and a property name and it will do the right thing. a04ad31 changes the action profile code to leverage getExternInstanceFromProperty(), which both simplifies the code and adds support for the case we previously didn't handle.

@sethfowler
Copy link
Contributor Author

The Travis job just failed due to a trivial cpplint error. I'll fix it after review.

Copy link
Member

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

Looks good to me, I also ran this code on a couple P4 programs and output was as expected

@sethfowler sethfowler force-pushed the seth/support-direct-counters-in-p4runtimeserializer branch from a04ad31 to 8ef05ee Compare February 21, 2017 21:06
@sethfowler sethfowler force-pushed the seth/support-direct-counters-in-p4runtimeserializer branch from 8ef05ee to 37dea21 Compare February 21, 2017 21:07
@sethfowler sethfowler merged commit ab4eb32 into p4lang:master Feb 21, 2017
@sethfowler sethfowler deleted the seth/support-direct-counters-in-p4runtimeserializer branch February 21, 2017 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants