How opencomputeproject/sai works
Main Components
• Core API & Interface Layer:
• Represented by the “inc” folder (with header files like sai.h, saiacl.h, etc.) which defines the SAI API.
• The “meta” folder contains support for metadata, RPC generators, and code that supports the API implementation.
• RPC and Thrift Interfaces:
• The “meta/rpc” directory and the dedicated “test/saithrift” and “test/saithriftv2” directories indicate that the SAI API is exposed via an RPC interface, with Thrift-based components generating server stubs and client proxies.
• P4 Backend and Extensions:
• The “flexsai/p4” directory contains a complete P4 compilable backend implementation that adapts SAI calls for programmable hardware.
• Testing and Validation:
• The “ptf” directory and “test” directories provide functional and unit test frameworks (using PTF and C++ based tests) to validate that the API and its implementations work correctly.
• Documentation and Proposals:
• The “doc” folder holds extensive documentation on various SAI proposals and design documents which describe architecture, extensions (ACL, ARS, etc.), and vendor-specific enhancements.
• Packaging and Integration:
• There are directories such as “debian”, “.github” and CI configuration files (azure-pipelines.yml) showing build, test, and packaging pipelines.
Relationships and Data Flows
• Link the P4 Backend component (flexsai/p4) to the SAI API to show that some implementations or emulations for programmable switches are mapped from SAI abstractions.
• Test Framework component (ptf and test directories) that invokes SAI functions and verifies behavior, clearly showing the flow from test client → RPC interface → SAI Core.
• CI/Packaging pipelines (via “.github”, “debian”, and “azure-pipelines”) which are used for building and deploying the software.
Architectural Patterns & Design Principles
• Abstraction and Layering: The clear separation between API definitions, RPC interface generation (meta/rpc and saithrift), and diverse test implementations emphasizes a layered architecture.
• Extensibility: The presence of many “doc” subdirectories (covering proposals on ACL, FEC, ECMP, etc.) and “experimental” directories signifies that the design is intended to support multiple features and vendor-specific extensions without altering the core API.
• Modularity: Components like the flexsai backend, RPC layer, and testing suites serve as modular parts that interact via well-defined interfaces.
Elements
• SAI Core API (headers and meta definitions)
• RPC/Thrift Interface Layer
• P4 / FlexSai Backend
• Testing Framework (PTF and Unit Tests)
• CI/CD & Packaging (build systems, deployment scripts)
• Documentation & Proposals (for context)
• How API calls propagate from test clients or external management systems through the RPC interface down to the core API.
• Build/test pipelines feeding into library updates.
• Clear Labels: