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

Desugar valid matches correctly in p4RuntimeSerializer #319

Conversation

sethfowler
Copy link
Contributor

@sethfowler sethfowler commented Feb 18, 2017

Right now p4RuntimeSerializer doesn't correctly handle the valid match type (or isValid() in P4-16). There were several issues:

  • We serialized the synthesized valid field inconsistently; in one place, we used _valid, while in the other place, we used $valid$.

  • We didn't append the synthesized valid field when serializing exact match keys.

  • We appended it at the wrong time when serializing ternary match keys, which caused a crash.

All of this would've easily been avoided with a proper unit test suite. =\ I need to hurry up and add gtest to p4c.

@sethfowler sethfowler self-assigned this Feb 18, 2017
@@ -1372,13 +1374,14 @@ getMatchFields(const IR::P4Table* table, ReferenceMap* refMap, TypeMap* typeMap)
matchType = MatchField::TERNARY;

// If this is a ternary match on the result of an isValid() call, desugar
// that to a ternary match against the '$valid$' field of the appropriate
// that to a ternary match against the '_valid' field of the appropriate
Copy link
Contributor

Choose a reason for hiding this comment

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

_valid would seem problematic if a user defined a header with a _valid field. It would seem better to use something that can't collide with a user name ($valid as users can't use $ in names?)

Copy link
Member

Choose a reason for hiding this comment

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

We won't need to insert that field any more once we update p4info.proto to treat match fields differently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like we'll be revisiting that issue shortly.

@sethfowler sethfowler force-pushed the seth/desugar-valid-matches-correctly-in-p4runtimeserializer branch from b44d470 to 38198fe Compare February 21, 2017 20:02
@sethfowler sethfowler merged commit 3c9ac71 into p4lang:master Feb 21, 2017
@sethfowler sethfowler deleted the seth/desugar-valid-matches-correctly-in-p4runtimeserializer branch February 21, 2017 21:05
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.

3 participants