sonic-net / DASH

Disaggregated APIs for SONiC Hosts
Apache License 2.0
78 stars 88 forks source link

[sai-gen] Add support for generating SAI stats APIs for counters. #514

Closed r12f closed 5 months ago

r12f commented 5 months ago

Problem

DASH has scaling requirement that requires technology providers to support huge number of objects, e.g. 8M of CA-PA mappings. If we need to add counters for these objects by using generic SAI counters, we will generate large number of counter ids, which might not be ideal.

Also some counters we are collecting are not data path counters, but more like hit counts, which is not what generic SAI counter is modeling.

For these cases, we can support generating the counters as SAI stats and leverage existing SAI stats API design for querying the counters back.

What we are doing in this change

This change updated sai_api_gen.py with 2 changes:

  1. Rename as_attr to attr_type for supporting more types of counter generation.
  2. Updated the counter generation logic and its templates for generating SAI stats APIs.

This feature will be used in the incoming fast path API generations.

Take metering bucket as an example to illustrate this change, say we updated its counters to capture both packet and bytes, change its type to stats, then add another counter for tracking all traffic, not on metering bucket level: image

This will results in the both metering bucket counter being generated as stats enum: image

Once an table as any stats enum, we will generate the stats APIs: image image

On port level, it will generate the overall counters: image

However, we are not generating a working libsai at this moment, which is the same as the counters today. This work will be postponed to later time. image

image

r12f commented 5 months ago

Here is the preview of the fast path SAI API change that built on top of this feature (for header generation only):

r12f commented 5 months ago

thanks for the review, Marian! will get this merged and sharing the fast path SAI update out.