From 926d033226f93ffb7f2a79de812b72926e1560a4 Mon Sep 17 00:00:00 2001 From: Tomer Shalvi <116184476+tshalvi@users.noreply.github.com> Date: Thu, 13 Jun 2024 17:07:58 +0300 Subject: [PATCH] [Mellanox] Enhance is_module_host_management_mode to also check syncd's sai.profile (#19261) - Why I did it Two steps (among others) are required to enable the host CMIS management feature: enabling it in the switch's sai.profile and performing a config reload. During the timeframe between these two steps, the control sysfs might be accessed, but they will not be present on the system until the latter step, the config reload, is completed. The code should try to access the control sysfs only after the config reload step. A good indication that this has been done is to check if the relevant entry is included in syncd's sai.profile. In contrast to the switch's sai.profile, syncd's sai.profile is only updated with the Host CMIS management support flag after the reload is complete. - How I did it I updated the is_module_host_management_mode() implementation to first look for the Host CMIS management support flag in syncd's sai.profile, and only if it does not exist for some reason, look for it in the switch's sai.profile. - How to verify it Add the Host CMIS management support flag to the switch's sai.profile and verify that the following log does not appear: ERR pmon#xcvrd: Exception occured at DomInfoUpdateTask thread due to Exception('control sysfs for SFP 20 does not exist') --- .../mlnx-platform-api/sonic_platform/device_data.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py index 9ee37af9981d..35c40476b93a 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py @@ -267,12 +267,14 @@ def get_cpld_component_list(cls): @classmethod @utils.read_only_cache() def is_module_host_management_mode(cls): - from sonic_py_common import device_info - _, hwsku_dir = device_info.get_paths_to_platform_and_hwsku_dirs() - sai_profile_file = os.path.join(hwsku_dir, 'sai.profile') + sai_profile_file = '/tmp/sai.profile' + if not os.path.exists(sai_profile_file): + from sonic_py_common import device_info + _, hwsku_dir = device_info.get_paths_to_platform_and_hwsku_dirs() + sai_profile_file = os.path.join(hwsku_dir, 'sai.profile') data = utils.read_key_value_file(sai_profile_file, delimeter='=') return data.get('SAI_INDEPENDENT_MODULE_MODE') == '1' - + @classmethod def wait_platform_ready(cls): """