Skip to content

Commit 1f1ae60

Browse files
vadymhlushko-mlnxmssonicbld
authored andcommitted
[Mellanox] Change SDK API sx_mgmt_phy_module_info_get() to sysfs (#15963)
- Why I did it Change Mellanox platform API implementation to use ASIC driver sysfs for the module operational state and status error fields. - How I did it Modify the platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py file by change the call of sx_mgmt_phy_module_info_get() SDK API to sysfs - How to verify it Simulate the unplug cable event Check the CLI output sfputil show presence sfputil show error-status -hw Simulate the plug cable event Repeat 2 step Signed-off-by: vadymhlushko-mlnx <[email protected]>
1 parent 7b89066 commit 1f1ae60

File tree

1 file changed

+9
-13
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+9
-13
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
SFP_A2H_PAGE0_PATH = '0/i2c-0x51/data'
135135
SFP_SDK_MODULE_SYSFS_ROOT_TEMPLATE = '/sys/module/sx_core/asic0/module{}/'
136136
SFP_EEPROM_ROOT_TEMPLATE = SFP_SDK_MODULE_SYSFS_ROOT_TEMPLATE + 'eeprom/pages'
137+
SFP_SYSFS_STATUS = 'status'
138+
SFP_SYSFS_STATUS_ERROR = 'statuserror'
137139
SFP_SYSFS_PRESENT = 'present'
138140
SFP_SYSFS_RESET = 'reset'
139141
SFP_SYSFS_POWER_MODE = 'power_mode'
@@ -215,24 +217,18 @@ def sdk_handle(self):
215217
@classmethod
216218
def _get_module_info(self, sdk_handle, sdk_index):
217219
"""
218-
Get error code of the SFP module
220+
Get oper state and error code of the SFP module
219221
220222
Returns:
221-
The error code fetch from SDK API
223+
The oper state and error code fetched from sysfs
222224
"""
223-
module_id_info_list = new_sx_mgmt_module_id_info_t_arr(1)
224-
module_info_list = new_sx_mgmt_phy_module_info_t_arr(1)
225+
status_file_path = SFP_SDK_MODULE_SYSFS_ROOT_TEMPLATE.format(sdk_index) + SFP_SYSFS_STATUS
226+
oper_state = utils.read_int_from_file(status_file_path)
225227

226-
module_id_info = sx_mgmt_module_id_info_t()
227-
module_id_info.slot_id = 0
228-
module_id_info.module_id = sdk_index
229-
sx_mgmt_module_id_info_t_arr_setitem(module_id_info_list, 0, module_id_info)
228+
status_error_file_path = SFP_SDK_MODULE_SYSFS_ROOT_TEMPLATE.format(sdk_index) + SFP_SYSFS_STATUS_ERROR
229+
error_type = utils.read_int_from_file(status_error_file_path)
230230

231-
rc = sx_mgmt_phy_module_info_get(sdk_handle, module_id_info_list, 1, module_info_list)
232-
assert SX_STATUS_SUCCESS == rc, "sx_mgmt_phy_module_info_get failed, error code {}".format(rc)
233-
234-
mod_info = sx_mgmt_phy_module_info_t_arr_getitem(module_info_list, 0)
235-
return mod_info.module_state.oper_state, mod_info.module_state.error_type
231+
return oper_state, error_type
236232

237233

238234
class SFP(NvidiaSFPCommon):

0 commit comments

Comments
 (0)