Switch Abstraction Interface (SAI)

repository·master·Indexed 20 days ago

https://github.com/opencomputeproject/sai

A standardized, vendor-independent API for controlling forwarding elements such as switching ASICs, NPUs, and software switches. The project includes tools for metadata generation, an RPC interface generator (gensairpc.pl), and a p4_16 backend for compiling P4_16 programs into SAI headers.

Tokens
298.5K
Snippets
492
Records
845
Agent score
69%

What's inside SAI

  1. Overview of SAI PTF (Packet Testing Framework)

    master

    SAI PTF is an auto-generated, Python-based dataplane testing framework. It uses Thrift wrapper functions to call C-based SAI functions from Python scripts. The framework's primary goal is to automate the creation of wrapper functions by generating them directly from SAI headers, reducing manual effort when testing new SAI versions.

    Key components include:

    • Autogeneration framework: Uses existing SAI meta infrastructure to generate code.
    • PTF tests: Functional tests for L2, L3, tunnels, and mirroring.
    • DASH support: Optimized tests for platforms with limited port counts.
  2. Overview of SAI for Optical Transport Network (OTN)

    master

    The SAI for OTN extension provides technical specifications for managing optical components on Optical Transport Network (OTN) devices within the SONiC ecosystem. It allows for end-to-end management across both packet and optical layers (L0–L4).

    Core functions provided by the OTN SAI include:

    • Creation and removal of OTN components.
    • Retrieval of current operational status of OTN components.
    • Notification handling for failures and hardware data reporting.
    • Execution of hardware-specific operations (e.g., optical path switching, triggering optical measurements).

    All OTN objects are subobjects of the switch root element and are designed to be isolated from existing non-OTN SAI objects to prevent impact on packet switch functionality.

  3. New features in SAI 1.18.1

    master

    SAI 1.18.1 introduces several new features and enhancements across networking protocols, hardware monitoring, and hashing algorithms. Key additions include:

    • Seamless BFD (S-BFD) support.
    • SRv6 SID Marking capabilities.
    • Port Monitoring: Introduction of SAI_PORT_ATTR_PORT_PG_PKT_DROP_STATUS to track packet drop status.
    • Link Layer: Support for Link Layer Retry and Link Debounce features.
    • IPMC: Bulk IPMC group APIs.
    • Protocols: UEC CSIG Protocol support and SAI PTP enhancements.
    • ACLs: Custom range base for SAI_ACL_ACTION_TYPE.
    • Hashing: Addition of Jenkins hash to supported algorithms and the SAI_HASH_ALGORITHM_END enum member.
    • MACSec: Attribute enhancements for MACSec.
    • QoS: Support for QoS Map on Router Interfaces.
    • DASH: Updates to DASH eni & port counters.
    • Diagnostics: SAI_PORT_ATTR_PRBS_PATTERN and an associated enum list of polynomials.
    • Interfaces: New CEILR and CEILR_ER interfaces.
  4. New APIs and features in SAI 1.15.1

    master

    SAI version 1.15.1 introduces several new functional areas and API enhancements. Key additions include:

    • Tunneling & Routing: New Tunnel API, Routing Group API, and support for Next Hop to be an IPMC Group Member.
    • DASH (Dynamic Abstraction Switching Hardware) Enhancements:
      • DASH flow resimulation APIs.
      • DASH HA (High Availability) session APIs for state management and inline sync.
      • DASH appliance object APIs.
      • DASH Flow API support for connection tracking.
      • Conversion of DASH meter bucket objects to table entries.
      • Support for ENI mac selection and tunnel learning attributes.
    • Synchronization & Bulk Operations: New bulk sync API, flow reconcile API, and bulk APIs for ingress priority group and queue.
    • Port & Hardware Management:
      • Support for 8 lanes breakout mode via a new enum.
      • Extended port operational status including error and fault status.
      • Port attribute to retrieve maximum debug data size.
      • SER (Serial) Support.
    • Other Features:
      • ICMP echo offload proposal.
      • sFlow Truncation support.
      • HW Based FRR (Fast Reroute).
  5. Understand the gensairpc.pl architecture and workflow

    master

    gensairpc.pl is a tool that scans SAI headers to generate RPC components. The workflow consists of two main phases:

    1. Parsing:
      • Generates Doxygen XML files from SAI headers using SAI/meta tools.
      • Uses SAI/meta utilities to extract data.
      • Creates Perl objects representing SAI code elements (Attributes, Enums, Functions, Statistics, Structures, Typedefs, Types, and Variables).
    2. Generation:
      • Generates sai.thrift using Template Toolkit (TT).
      • Uses Thrift to generate sai_rpc_server.skeleton.cpp.
      • Converts the skeleton into a sai_rpc_server.cpp.tt template.
      • Generates sai_rpc_server.cpp and sai_adapter.py using Template Toolkit.

    Finally, the tool performs optional formatting and cleanup.

  6. What is Prefix Compression in SAI?

    master

    Prefix Compression is a feature that enables mapping an IP prefix/mask (the longest prefix) to a specific meta-data value. These mappings are stored in a SAI_OBJECT_TYPE_PREFIX_COMPRESSION_TABLE.

    Key capabilities include:

    • Creating tables that support both IPv4 and IPv6 entries.
    • Grouping prefixes to enhance features like ACLs by matching against the associated meta-data.
    • Configuring tables for specific stages (Ingress/Egress) and types (Source addresses, Destination addresses, or both).
  7. What is SAI Metadata?

    master
    SAI Metadata is a set of auto-generated ANSI C source and header files derived from SAI headers. It provides the data and functions necessary to perform SAI attribute validation and other metadata-related operations within the Switch Abstraction Interface.
  8. What is Credit Based Flow Control (CBFC)?

    master

    Credit Based Flow Control (CBFC) is a link-layer mechanism designed for high-performance Ethernet networks (AI/HPC workloads) to ensure lossless frame delivery. It prevents packet loss due to buffer congestion at the receiver by ensuring a sender only transmits frames if there is sufficient buffer space (represented as "credits") available at the receiver.

    Key concepts include:

    • Credit: A token representing a unit of receiver data storage. Consumed by the sender during transmission and returned as frames drain from the receiver.
    • Virtual Channel (VC): A logical separation of traffic on a port with dedicated buffering and credit accounting. CBFC applies to lossless VCs, and up to 32 VCs are supported per port.
    • Lossless Operation: Achieved by checking available credits before packet dequeue at the sender and updating credit counters (Consumed, Freed, Limit, In-Use) at both ends.
  9. What is the Switch Abstraction Interface (SAI)?

    master

    The Switch Abstraction Interface (SAI) is a vendor-independent API designed to provide a uniform way of controlling network forwarding elements, such as switching ASICs, NPUs, or software switches. It allows the Control stack (the software managing the network) to be written independently of the underlying hardware (the Forwarding Element).

    Key characteristics include:

    • OS-agnostic: Designed to work across different operating systems (e.g., *nix, Windows).
    • Attribute-based: Uses attributes to minimize compatibility issues with structure versioning and to allow for API extensibility.
    • CRUD-based: Uses Create, Read, Update, and Delete operations to manage SAI objects.
    • Managed API: Supports versioning to maintain backward compatibility. If a function's signature or semantics change, a new function with a unique versioned ID (e.g., SAI_API_VLAN2) is created.
  10. Overview of SAI objects for CBFC

    master

    The SAI implementation of CBFC introduces several new objects and attributes to manage credit-based flow control without altering the existing logical forwarding pipeline.

    New SAI Objects

    • Virtual Channel: Manages per-VC attributes for both CBFC Sender and CBFC Receiver functions on a port.
    • CBFC Credit Profile: Manages receiver credit (buffer) attributes on a per-VC basis.
    • CBFC Credit Pool: Provides isolation of credits (receiver buffer) between groups of VCs.

    New Attributes and Mapping

    • SAI Port Object: Extended with CBFC Sender attributes (negotiated parameters, receiver management controls), CBFC Receiver attributes, statistics, QoS mapping controls, and read-only LLDP query attributes.
    • QoS Maps: New map types allow deriving VCs from Traffic Class (TC), Queue, or packet headers (dot1p+DEI).
    • Queue Attributes: New attributes to enable/disable enqueue/dequeue, necessary for initializing and deinitializing lossless VCs.
  11. Overview of SAI IPsec API

    master

    The SAI IPsec API provides a software interface for IPsec ESP tunnel mode (RFC-4303) and UDP-encapsulated IPsec ESP tunnel mode (RFC-3948). It specifically supports the GCM-AES ciphersuite.

    Key responsibilities include:

    • Egress Transformation (Tunnel Origination): Switching a packet to an IP tunnel, adding tunnel headers (IP and optionally UDP-ESP), and applying egress packet security (adding ESP header/trailer, ICV, and optional encryption).
    • Ingress Transformation (Tunnel Termination): Decrypting payload, verifying integrity/authenticity, removing ESP headers/trailers/ICV, and removing the tunnel header to switch the inner packet.

    Note: Key exchange protocols are outside the scope of this API.

  12. Understand the SAI PTF autogeneration process

    master

    The autogeneration process is written in Perl and uses SAI headers (processed via SAI meta into Doxygen XML) and templates to produce the following files:

    Output FileDescription
    sai.thriftThrift RPC "header" generated from scratch; used to generate the C++ skeleton.
    sai_rpc_server.cppThe Thrift server containing functions that call SAI functions via the adapter.
    sai_adapter.pyThe Thrift client and the main SAI PTF test library used in Python scripts.

    All files are generated using the gensairpc.pl script.