Skip to content

Commit 251a7ca

Browse files
dgsudharsanxumia
authored andcommitted
[Mellanox]Fix lpmode set when logical port is larger than 64 (sonic-net#14138)
- Why I did it In sfplpm API, the number of logical ports is hardcoded as 64. When a system contains more port than this, the SDK APIs would fail with a syslog as below Mar 7 03:53:58.105980 r-leopard-58 ERR syncd#SDK: [MGMT_LIB.ERR] Slot [0] Module [0] has logport [0x00010069] in enabled state Mar 7 03:53:58.105980 r-leopard-58 ERR syncd#SDK: [SDK_MGMT_LIB.ERR] Failed in __sdk_mgmt_phy_module_pwr_attr_set, error: Internal Error Mar 7 03:53:58.106118 r-leopard-58 ERR pmon#-c: Error occurred when setting power mode for SFP module 0, slot 0, error code 1 - How I did it Remove the hardcoded value of 64. Obtained the number of logical ports from SDK - How to verify it Manual testing
1 parent 17c7964 commit 251a7ca

File tree

1 file changed

+6
-3
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
REGISTER_NUM = 1
9090
DEVICE_ID = 1
9191
SWITCH_ID = 0
92-
SX_PORT_ATTR_ARR_SIZE = 64
9392

9493
PMAOS_ASE = 1
9594
PMAOS_EE = 1
@@ -529,9 +528,13 @@ def set_port_admin_status_by_log_port(cls, sdk_handle, log_port, admin_status):
529528
@classmethod
530529
def get_logical_ports(cls, sdk_handle, sdk_index, slot_id):
531530
# Get all the ports related to the sfp, if port admin status is up, put it to list
532-
port_attributes_list = new_sx_port_attributes_t_arr(SX_PORT_ATTR_ARR_SIZE)
533531
port_cnt_p = new_uint32_t_p()
534-
uint32_t_p_assign(port_cnt_p, SX_PORT_ATTR_ARR_SIZE)
532+
uint32_t_p_assign(port_cnt_p, 0)
533+
rc = sx_api_port_device_get(sdk_handle, DEVICE_ID, SWITCH_ID, None, port_cnt_p)
534+
535+
assert rc == SX_STATUS_SUCCESS, "sx_api_port_device_get failed, rc = %d" % rc
536+
port_cnt = uint32_t_p_value(port_cnt_p)
537+
port_attributes_list = new_sx_port_attributes_t_arr(port_cnt)
535538

536539
rc = sx_api_port_device_get(sdk_handle, DEVICE_ID , SWITCH_ID, port_attributes_list, port_cnt_p)
537540
assert rc == SX_STATUS_SUCCESS, "sx_api_port_device_get failed, rc = %d" % rc

0 commit comments

Comments
 (0)