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

adds metadata remapping #4

Merged
merged 1 commit into from
May 1, 2017
Merged

adds metadata remapping #4

merged 1 commit into from
May 1, 2017

Conversation

cc10512
Copy link

@cc10512 cc10512 commented May 1, 2017

Defines the mapping for the metadata defined in p4d2model to the bmv2
simple switch intrinsic/standard metadata and provides a read function
for the file that returns the remapping (map of string to string).

We need to hook this up with p4c such that it knows which file to load
depending on the architecture and the target. And probably just simply
visit all the metadata declarations in the program and add a name
annotation to remap the name. I hope that fields can take qualified
names.

Defines the mapping for the metadata defined in p4d2model to the bmv2
simple switch intrinsic/standard metadata and provides a read function
for the file that returns the remapping (map of string to string).

We need to hook this up with p4c such that it knows which file to load
depending on the architecture and the target. And probably just simply
visit all the metadata declarations in the program and add a name
annotation to remap the name. I hope that fields can take qualified
names.
# This file maps p4d2 metadata to the bmv2 simple switch standard and intrinsic metadata

# parser
parser_input_t.ingress_port -> standard_metadata.ingress_port
Copy link

@vgurevich vgurevich May 1, 2017

Choose a reason for hiding this comment

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

Why do you map type.field into instance.field? In other words why this mapping instead of
parser_input_t.ingress_port -> stadnard_metadata_t.ingress_port

Copy link
Author

Choose a reason for hiding this comment

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

because simple switch calls it standard_metadata and v1model actually renames standard_metadata_t to standard_metadata with a @name annotation

Choose a reason for hiding this comment

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

I think the problem might be that in the original compiler (and specifically in p4-hlir) standard_metadata was instantiated automatically, without the corresponding "header_type" being explicitly declared. Similarly, in simple_switch standard_metadata is instantiated in a very "back-door"-ish way without the type being declared first.

But going forward, I suggest we should be more formal about these things, otherwise it is too confusing.

@hanw
Copy link
Owner

hanw commented May 1, 2017

Thanks for writing this up, I will merge it and improve the code on my branch.

@hanw hanw merged commit bd959f1 into hanw:hanw/psa May 1, 2017
hanw pushed a commit that referenced this pull request May 4, 2017
hanw pushed a commit that referenced this pull request May 11, 2017
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