p4lang / p4c

P4_16 reference compiler
https://p4.org/
Apache License 2.0
670 stars 441 forks source link

Is this the intended effect of `@name` annotations when generating P4Info files? #2716

Open jafingerhut opened 3 years ago

jafingerhut commented 3 years ago

I was inspired by a recent issue asking about compiler internal passes renaming action parameters (or not) to find out what the P4Info file generated contains when @name annotations are used on (directionless) action parameters, and several other language constructs, including tables, table key fields, table action names in the actions list, an action definition itself, and a control definition.

The attached program name_annotations_to_p4info.p4.txt is a v1model architecture P4_16 program, and name_annotations_to_p4info.p4.p4info.txt is the P4Info file generated via the following command:

$ p4c --version
p4c 1.2.0 (SHA: e3f36f6d9 BUILD: DEBUG)

$ p4c --target bmv2 --arch v1model --p4runtime-files name_annotations_to_p4info.p4.p4info.txt name_annotations_to_p4info.p4

@antoninbas @vgurevich (and anyone else interested) Looking at the generated P4Info file, are these the names you would expect the control plane API to see from this P4 source program?

name_annotations_to_p4info.p4.txt

name_annotations_to_p4info.p4.p4info.txt

antoninbas commented 3 years ago

Yes, this is more or less the P4Info I would expect. But my P4 is a bit rusty...

Besides these 2 points, I don't think anything else is contentious. The @name annotations are handled as they should for match fields, action parameters, actions, tables, etc.

antoninbas commented 3 years ago

I feel like an update to https://github.com/p4lang/p4runtime/blob/main/docs/v1/guidance-for-generating-p4info.md is coming :)