SAI Switch Temperature Attributes for Sub-degree Precision#2306
SAI Switch Temperature Attributes for Sub-degree Precision#2306bp899348 wants to merge 1 commit into
Conversation
SAI Switch Temperature Attributes for Sub-degree Precision `SAI_SWITCH_ATTR_TEMP_LIST` returns temperature values rounded to whole degrees Celsius. This discards sub-degree precision that is available from the hardware, making it unsuitable for applications that require finer thermal granularity. Signed-off-by: Barmesh Pandey <barmeshwar.pandey@broadcom.com>
| * | ||
| * @type sai_s32_list_t | ||
| * @flags READ_ONLY | ||
| */ |
There was a problem hiding this comment.
The commit added a new tag @precision. You can define the precision in SAI_SWITCH_ATTR_TEMP_LIST_RAW and no need SAI_SWITCH_ATTR_TEMP_BASE_TEN_PRECISION. You can get the precision from the meta data attr->valuePrecision.
See the examples in https://github.com/opencomputeproject/SAI/blob/master/experimental/saiexperimentalotnoa.h
There was a problem hiding this comment.
Thank you for the suggestion. The @precision tag is a compile-time constant in the metadata — it is hardcoded at attribute definition time and cannot change at runtime.
In our case, the temperature resolution is hardware and platform dependent and must be queried at runtime. SAI_SWITCH_ATTR_TEMP_BASE_TEN_PRECISION is a READ_ONLY attribute that the driver reports dynamically, allowing consumers to adapt without any code or metadata change as platforms evolve.
So yes, @precision would still be hardcoded — just in a different place.
There was a problem hiding this comment.
I see. But we can always put a conservative @precision, like 6 to cover all the vendors. Two attributes for one value implies much semantics and is error prone. Just my 2 cents.
There was a problem hiding this comment.
I understand the point, but a conservative fixed @precision like 6 means every consumer always multiplies by 10^-6 - even when the hardware only reports tenths of a degree. This would silently produce incorrect values on platforms that don't match that precision, with no way to detect the mismatch at runtime.
With SAI_SWITCH_ATTR_TEMP_BASE_TEN_PRECISION, the driver reports exactly what the hardware delivers — no guessing, no silent error. The cost is one extra attribute query; the benefit is guaranteed correctness across all platforms without any consumer-side assumptions.
SAI Switch Temperature Attributes for Sub-degree Precision
SAI_SWITCH_ATTR_TEMP_LISTreturns temperature values rounded to whole degrees Celsius. This discards sub-degree precision that is available from the hardware, making it unsuitable for applications that require finer thermal granularity.