Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
KrisNey-MSFT opened this issue Nov 4, 2022 · 10 comments
Closed

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

KrisNey-MSFT opened this issue Nov 4, 2022 · 10 comments
Assignees

Comments

@KrisNey-MSFT
Copy link
Collaborator

KrisNey-MSFT commented Nov 4, 2022

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

@KrisNey-MSFT KrisNey-MSFT moved this from 😫 Backlog Needs Owner to 🏝 Backlog in DASH P4 Behavioral Model Nov 4, 2022
@yusefMS06
Copy link
Collaborator

@marian-pritsak Does this issue need to stay in the queue?

@chrispsommers
Copy link
Collaborator

@marian-pritsak Does this issue need to stay in the queue?

We need to keep this item open. It was agreed this is the long term solution.

Note, this is a great project for another volunteer, it mainly requires appropriate annotations to P4, and Python changes to https://github.com/Azure/DASH/blob/main/dash-pipeline/SAI/sai_api_gen.py which will become simpler as a result. It could be done incrementally.

@KrisNey-MSFT
Copy link
Collaborator Author

Annotations for tables, keys, action parameters - Marian will prepare a PR for next week.
Modify code generator for annotations in parallel.
Very straightforward, lookup key in annotation, pass to dictionary, then to templates.
0 logic.

@KrisNey-MSFT
Copy link
Collaborator Author

hi @chrispsommers - can this one be closed then, considering we have 473?

@chrispsommers
Copy link
Collaborator

No, as @r12f mentioned, the old way to name tables is still in place. This is a step towards the eventual solution.

@r12f
Copy link
Collaborator

r12f commented Dec 11, 2023

Yea, sorry. I probably gave my commit a really bad name... I have already started the work moving the annotation to Sai.

@r12f
Copy link
Collaborator

r12f commented Dec 11, 2023

The first PR is #477 . More PRs will come later, since I am taking today oof... :(

@KrisNey-MSFT
Copy link
Collaborator Author

Hi @r12f - should we close this one as finished, in favor of #477 ?
TY, Krisney-MSFT

@chrispsommers
Copy link
Collaborator

There are a series of MRs which all contributed to this, but I agree this can be closed. Perhaps @r12f can list the MRs for posterity in a closing comment. Thanks!

@KrisNey-MSFT
Copy link
Collaborator Author

Closing

@github-project-automation github-project-automation bot moved this from 🏝 Backlog (assigned) to 🏃 In Progress in DASH P4 Behavioral Model Feb 8, 2024
@KrisNey-MSFT KrisNey-MSFT moved this from 🏃 In Progress to ✔Done in DASH P4 Behavioral Model Feb 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants