Skip to content

Use P4 annotations instead of heuristic in the code generator #276

@KrisNey-MSFT

Description

@KrisNey-MSFT

The current SAI API code generator https://github.com/Azure/DASH/blob/main/dash-pipeline/SAI/sai_api_gen.py reads the P4Info (derived from dash-pipeline.p4) and emits SAI header (.h) files. Some of the transformations are a bit involved and contain hidden assumptions, and the P4 code does not explicitly show the relationships between P4 and SAI headers, for example when is a SAI attribute mandatory. Using annotations would allow the P4 code to explicitly declare, for example, the SAI table name, or identify a mandatory SAI attribute. Using attributes would also greatly simplfy the code generator, since it would only have to do simple transformations without lots of special-case code.

This idea was originally suggested here: #240 (comment)

A sample experimental annotation is provided below. You can compile the P4 code using make p4 and read the resulting P4Info file dash-pipeline/bmv2/dash_pipeline.bmv2/dash_pipeline_bmv2_p4rt.txt in your build environment.

https://github.com/chrispsommers/DASH/blob/4ce46efa65bf49bd342efdf43f4b08d454cdb408/dash-pipeline/bmv2/dash_pipeline.p4#L39

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions