Skip to content

Commit

Permalink
filter out CPU ports to avoid any operation on them (#4197)
Browse files Browse the repository at this point in the history
  • Loading branch information
keboliu authored Mar 3, 2020
1 parent 41ae7a2 commit 7a9c8ee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
PMAOS_ENABLE = 1
PMAOS_DISABLE = 2

PORT_TYPE_CPU = 4
PORT_TYPE_NVE = 8
PORT_TYPE_OFFSET = 28
PORT_TYPE_MASK = 0xF0000000
NVE_MASK = PORT_TYPE_MASK & (PORT_TYPE_NVE << PORT_TYPE_OFFSET)
CPU_MASK = PORT_TYPE_MASK & (PORT_TYPE_CPU << PORT_TYPE_OFFSET)

def is_nve(port):
return (port & NVE_MASK) != 0

def is_cpu(port):
return (port & CPU_MASK) != 0

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()
Expand Down Expand Up @@ -57,6 +62,7 @@ def get_log_ports(handle, sfp_module):
for i in range(0, port_cnt):
port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list, i)
if is_nve(int(port_attributes.log_port)) == False \
and is_cpu(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)
Expand Down

0 comments on commit 7a9c8ee

Please sign in to comment.