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

[sai-gen] Deprecate the name annotations in favor of SaiTable #479

Merged
merged 6 commits into from
Dec 13, 2023

Conversation

r12f
Copy link
Collaborator

@r12f r12f commented Dec 12, 2023

This PR has 2 updates:

  1. Deprecate the @name annotations in favor of @SaiTable.
  2. Add api_order attribute in @SaiTable annotation to help us enforce the order of the generated APIs.

The second change is a must have, otherwise for any API set that contains multiple type of entries (generated from multiple tables), the order could be changed between changes and break the ABI compatibility as the screenshot shows below:

Snipaste_2023-12-12_12-24-41

The doc is also updated to capture the use of this new attribute.

For generated content updates:

  1. No updates on SAI header files:

    r12f@r12f-dl380:~/data/code/sonic/DASH/dash-pipeline
    $ diff SAI/SAI/experimental/ ~/data/code/sonic/DASH-exp/dash-pipeline/SAI/SAI/experimental/
    r12f@r12f-dl380:~/data/code/sonic/DASH/dash-pipeline
  2. For libsai, table id will be updated as previous change.

    r12f@r12f-dl380:~/data/code/sonic/DASH/dash-pipeline
    $ diff SAI/SAI/experimental/ ~/data/code/sonic/DASH-exp/dash-pipeline/SAI/SAI/experimental/
    r12f@r12f-dl380:~/data/code/sonic/DASH/dash-pipeline
    $ diff SAI/lib/ ~/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/
    diff SAI/lib/saidashacl.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashacl.cpp
    31c31
    <     tableId = 50200087;
    ---
    >     tableId = 45323240;
    diff SAI/lib/saidashdirectionlookup.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashdirectionlookup.cpp
    19c19
    <     pi_p4_id_t tableId = 45670434;
    ---
    >     pi_p4_id_t tableId = 38960243;
    110c110
    <     pi_p4_id_t tableId = 45670434;
    ---
    >     pi_p4_id_t tableId = 38960243;
    diff SAI/lib/saidasheni.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidasheni.cpp
    19c19
    <     pi_p4_id_t tableId = 46804748;
    ---
    >     pi_p4_id_t tableId = 38612462;
    118c118
    <     pi_p4_id_t tableId = 46804748;
    ---
    >     pi_p4_id_t tableId = 38612462;
    212c212
    <     tableId = 45859274;
    ---
    >     tableId = 47336097;
    diff SAI/lib/saidashinboundrouting.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashinboundrouting.cpp
    19c19
    <     pi_p4_id_t tableId = 38920290;
    ---
    >     pi_p4_id_t tableId = 42758350;
    152c152
    <     pi_p4_id_t tableId = 38920290;
    ---
    >     pi_p4_id_t tableId = 42758350;
    diff SAI/lib/saidashmeter.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashmeter.cpp
    31c31
    <     tableId = 38547152;
    ---
    >     tableId = 49926129;
    244c244
    <     tableId = 39168708;
    ---
    >     tableId = 48776568;
    425c425
    <     tableId = 34535910;
    ---
    >     tableId = 47787652;
    diff SAI/lib/saidashoutboundcatopa.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashoutboundcatopa.cpp
    19c19
    <     pi_p4_id_t tableId = 39175949;
    ---
    >     pi_p4_id_t tableId = 48860231;
    219c219
    <     pi_p4_id_t tableId = 39175949;
    ---
    >     pi_p4_id_t tableId = 48860231;
    diff SAI/lib/saidashoutboundrouting.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashoutboundrouting.cpp
    19c19
    <     pi_p4_id_t tableId = 44067785;
    ---
    >     pi_p4_id_t tableId = 42788937;
    308c308
    <     pi_p4_id_t tableId = 44067785;
    ---
    >     pi_p4_id_t tableId = 42788937;
    diff SAI/lib/saidashpavalidation.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashpavalidation.cpp
    19c19
    <     pi_p4_id_t tableId = 35526612;
    ---
    >     pi_p4_id_t tableId = 48948181;
    118c118
    <     pi_p4_id_t tableId = 35526612;
    ---
    >     pi_p4_id_t tableId = 48948181;
    diff SAI/lib/saidashvip.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashvip.cpp
    19c19
    <     pi_p4_id_t tableId = 45245089;
    ---
    >     pi_p4_id_t tableId = 38937816;
    110c110
    <     pi_p4_id_t tableId = 45245089;
    ---
    >     pi_p4_id_t tableId = 38937816;
    diff SAI/lib/saidashvnet.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/saidashvnet.cpp
    31c31
    <     tableId = 34815711;
    ---
    >     tableId = 34579306;
    diff SAI/lib/sairoute.cpp /home/r12f/data/code/sonic/DASH-exp/dash-pipeline/SAI/lib/sairoute.cpp
    19c19
    <     pi_p4_id_t tableId = 49279256;
    ---
    >     pi_p4_id_t tableId = 36513740;
    124c124
    <     pi_p4_id_t tableId = 49279256;
    ---
    >     pi_p4_id_t tableId = 36513740;

@r12f
Copy link
Collaborator Author

r12f commented Dec 12, 2023

Ok, the PR is ready for review.

@chrispsommers , with this all tables are off the @name annotation.
@jafingerhut and @fruffy, this change should help solving the issue #347 . (@KrisNey-MSFT as FYI as well)

@name("route|route")
// TODO: To add structural annotations (example: @SaiTable[skipHeaderGen=true])
@SaiTable[name = "route", api = "route"]
// TODO: To add structural annotations (example: @SaiTable[skipHeaderGen=true]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment can be deleted. The idea of a new attribute skipHeaderGen was not followed, instead the api name omits the dash which is kind of a heuristic in the api_gen code, see here:

if "dash" in sai_api.app_name:
. The purpose was to use existing underlay SAI headers, not try to generate new ones. It was convenient to look for dash in the table name but IMO it's still a hidden assumption.

Do you think it'd be more consistent to use the attribute skipHeaderGen or some other aptly-named one to explicitly direct the codegen not to emit header code for a table? It would default to false.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

of course! will update the PR soon. (will be afk for a hour or so.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks a lot for capturing this! i totally missed this one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's obscure, and in full disclosure, I oversaw the addition of underlay API so it is incumbent on me - thanks for offering to address it!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since essentially, the dash prefix affects the generation of both the header files and implementation files, instead of using "skiopHeaderGen", I added a new attribute called "api_type" and set to "underlay" to more precisely reflect what we are doing.

The changes are commited now. Please let me know what you think! :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and of course, no SAI header file change and only table id updates in lib files.

Copy link
Collaborator Author

@r12f r12f Dec 12, 2023

Choose a reason for hiding this comment

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

ok, test passed now. @chrispsommers , it should be good to take another look now.

@KrisNey-MSFT
Copy link
Collaborator

KrisNey-MSFT commented Dec 12, 2023 via email

@r12f
Copy link
Collaborator Author

r12f commented Dec 13, 2023

Since #480 is approved, which contains all changes in this PR. For keeping the changes clean, I am going to merge this PR first, rebase #480 , then merge #480 afterwards.

@r12f r12f merged commit 01ac82e into sonic-net:main Dec 13, 2023
5 checks passed
@r12f r12f deleted the user/r12f/table branch December 13, 2023 17:20
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