-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sai-gen] Update Sai attribute doc to include the latest support valu…
…es, also split it into SaiVal and SaiTable for better clarity. (#477)
- Loading branch information
Showing
5 changed files
with
60 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
# DASH Pipeline BM | ||
|
||
This directory contains the P4/BMv2-based behavior model implementation of the DASH Pipeline. | ||
|
||
At a high level, the DASH pipeline BM serves 2 purposes: | ||
|
||
1. It provides a behavior model for DASH pipeline, which can be used for testing in a simulated environment. | ||
2. It provides a generated P4 runtime definition, which can be used to generate the SAI API and SAI adapter code to the behavior model. | ||
|
||
## Writing P4/BMv2 code | ||
|
||
The workflow of developing the DASH pipeline BM is described in the [DASH workflows doc](../README-dash-workflows.md). | ||
|
||
The DASH pipeline BM is written in P4<sub>16</sub> with BMv2 v1model. For specs, please find the referenced docs here: | ||
|
||
- P4<sub>16</sub>, P4Runtime, PNA specs: <https://p4.org/specs/> | ||
- V1Model: <https://github.com/p4lang/p4c/blob/main/p4include/v1model.p4> | ||
|
||
### P4 annotations for SAI code generation | ||
|
||
SAI API generation now supports P4 annotations for documenting/providing necessary metadata to keys and action parameters. | ||
Currently, some of the SAI generation behavior is either controlled by using the `@name` attribute with a non-formalized format, or simplifying guessing in the `sai_api_gen.py`. This is hard to maintain and extend and highly not recommended. | ||
|
||
To deprecate the complicated `@name` attribute, we are moving towards using structured annotations in P4. This annotation can apply on keys, action parameters and tables to document and provide necessary metadata for SAI API generation. | ||
|
||
Use `@Sai["tag"="value", ...]` format for annotating attributes. Old mode, where `sai_api_gen.py` is guessing this information, is still supported. | ||
The old mode is still supported, but no more new features will be added to it and it will be deprecated in the future. | ||
|
||
#### `@SaiVal`: Keys and action parameters | ||
|
||
Use `@SaiVal["tag"="value", ...]` format for annotating keys and action parameters. | ||
|
||
Available tags are: | ||
|
||
- `type`: Specify which SAI object type should be used in generation, e.g. `sai_uint32_t`. | ||
- `isresourcetype`: When set to "true", we generate a corresponding SAI tag in SAI APIs: `@isresourcetype true`. | ||
- `objects`: Space separated list of SAI object type this value accepts. When set, we force this value to be a SAI object id, and generate a corresponding SAI tag in SAI APIs: `@objects <list>`. | ||
- `isreadonly`: When set to "true", we generate force this value to be read-only in SAI API using: `@flags READ_ONLY`, otherwise, we generate `@flags CREATE_AND_SET`. | ||
- `skipattr`: When set to "true", we skip this attribute in SAI API generation. | ||
|
||
#### `@SaiTable`: Tables | ||
|
||
Use `@SaiTable["tag"="value", ...]` format for annotating tables. | ||
|
||
Available tags are: | ||
* type - SAI type | ||
* isresourcetype - generates a corresponding SAI tag | ||
* objects - space separated list of SAI object types this attribute accepts | ||
|
||
More annotations may be added in the future. The infrastructure is extendable. | ||
- `isobject`: When set to "true", a top level objects in SAI that attached to switch will be generated. Otherwise, a new type of entry will be generated, if nothing else helps us to determine this table is an object table. | ||
- `ignoretable`: When set to "true", we skip this table in SAI API generation. | ||
|
||
For more details, please check the SAI API generation script: [sai_api_gen.py](../SAI/sai_api_gen.py). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters