From d1cd0fd9f8a31ad9a99165ca030c85c082309bf7 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Tue, 25 May 2021 07:20:08 +0800 Subject: [PATCH] Fix error msg due to not supported "SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS" attributes (#1745) **What I did** 1. Add more conditions to capture SAI return code due to not supported SAI attributes. Original code only judge: `status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED` Add more conditions: `SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) || SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status)` 2. Print the error code in hex instead of dec to make it more readable. **Why I did it** To eliminate below error msg on the platform which not support "SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS" `May 10 13:02:59.806194 sonic ERR swss#orchagent: :- initSensorsTable: ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS: -196608` **How I verified it** On the Mellanox platform, in the reboot process, the above error msg will not be observed. --- orchagent/switchorch.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index 8b105384cdec..cc4e103fee7f 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -431,14 +431,15 @@ void SwitchOrch::initSensorsTable() m_numTempSensors = attr.value.u8; m_numTempSensorsInitialized = true; } - else if (status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED) + else if (SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) || SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status) + || status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED) { m_numTempSensorsInitialized = true; SWSS_LOG_INFO("ASIC sensors : SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS is not supported"); } else { - SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS: %d", status); + SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS: 0x%x", status); } }