From 2bbc22cfddd8ef72f907778ad5b51fc28edb21be Mon Sep 17 00:00:00 2001 From: keboliu Date: Tue, 12 Mar 2019 10:48:01 +0200 Subject: [PATCH 1/2] fix lpmode set failure issue by skipping nvport --- .../x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py index 9713873ed264..b4ef5a7f29dd 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py @@ -18,6 +18,14 @@ PMAOS_ENABLE = 1 PMAOS_DISABLE = 2 +PORT_TYPE_NVE = 8 +PORT_TYPE_OFFSET = 28 +PORT_TYPE_MASK = 0xF0000000 + +def check_nve(port): + port_type = (port & PORT_TYPE_MASK) >> PORT_TYPE_OFFSET + return port_type & PORT_TYPE_NVE + def get_port_admin_status_by_log_port(log_port): oper_state_p = new_sx_port_oper_state_t_p() admin_state_p = new_sx_port_admin_state_t_p() @@ -48,6 +56,9 @@ def get_log_ports(handle, sfp_module): log_port_list = [] for i in range(0, port_cnt): port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list, i) + is_nve = check_nve(int(port_attributes.log_port)) + if is_nve: + continue if port_attributes.port_mapping.module_port == sfp_module: if get_port_admin_status_by_log_port(port_attributes.log_port): log_port_list.append(port_attributes.log_port) From 1a034e974687fd36a64c6063f31d48b44c18a1a6 Mon Sep 17 00:00:00 2001 From: keboliu Date: Fri, 15 Mar 2019 10:53:08 +0200 Subject: [PATCH 2/2] fix internal review comments --- .../plugins/sfplpmset.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py index b4ef5a7f29dd..c11675766d3f 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py @@ -21,12 +21,12 @@ PORT_TYPE_NVE = 8 PORT_TYPE_OFFSET = 28 PORT_TYPE_MASK = 0xF0000000 +NVE_MASK = PORT_TYPE_MASK & (PORT_TYPE_NVE << PORT_TYPE_OFFSET) -def check_nve(port): - port_type = (port & PORT_TYPE_MASK) >> PORT_TYPE_OFFSET - return port_type & PORT_TYPE_NVE +def is_nve(port): + return (port & NVE_MASK) != 0 -def get_port_admin_status_by_log_port(log_port): +def is_port_admin_status_up(log_port): oper_state_p = new_sx_port_oper_state_t_p() admin_state_p = new_sx_port_admin_state_t_p() module_state_p = new_sx_port_module_state_t_p() @@ -56,12 +56,10 @@ def get_log_ports(handle, sfp_module): log_port_list = [] for i in range(0, port_cnt): port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list, i) - is_nve = check_nve(int(port_attributes.log_port)) - if is_nve: - continue - if port_attributes.port_mapping.module_port == sfp_module: - if get_port_admin_status_by_log_port(port_attributes.log_port): - log_port_list.append(port_attributes.log_port) + if is_nve(int(port_attributes.log_port)) == False \ + and port_attributes.port_mapping.module_port == sfp_module \ + and is_port_admin_status_up(port_attributes.log_port): + log_port_list.append(port_attributes.log_port) return log_port_list