Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .utils import load_json_file, extract_RJ45_ports_index
from . import utils
from .device_data import DeviceDataManager
from .sfp import SFP, deinitialize_sdk_handle
from .sfp import SFP, RJ45Port, deinitialize_sdk_handle
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

Expand Down Expand Up @@ -252,7 +252,7 @@ def initialize_single_sfp(self, index):
if not self._sfp_list[index]:
from .sfp import SFP
if self.RJ45_port_list and index in self.RJ45_port_list:
self._sfp_list[index] = SFP(index, RJ45_TYPE)
self._sfp_list[index] = RJ45Port(index)
else:
self._sfp_list[index] = SFP(index)
self.sfp_initialized_count += 1
Expand All @@ -263,7 +263,7 @@ def initialize_sfp(self):
sfp_count = self.get_num_sfps()
for index in range(sfp_count):
if self.RJ45_port_list and index in self.RJ45_port_list:
sfp_module = SFP(index, RJ45_TYPE)
sfp_module = RJ45Port(index) #SFP(index, RJ45_TYPE)
else:
sfp_module = SFP(index)
self._sfp_list.append(sfp_module)
Expand All @@ -273,7 +273,7 @@ def initialize_sfp(self):
for index in range(len(self._sfp_list)):
if self._sfp_list[index] is None:
if self.RJ45_port_list and index in self.RJ45_port_list:
self._sfp_list[index] = SFP(index, RJ45_TYPE)
self._sfp_list[index] = RJ45Port(index) # SFP(index, RJ45_TYPE)
else:
self._sfp_list[index] = SFP(index)
self.sfp_initialized_count = len(self._sfp_list)
Expand Down Expand Up @@ -358,7 +358,33 @@ def get_change_event(self, timeout=0):
status = self.sfp_event.check_sfp_status(port_dict, error_dict, timeout)

if status:
self.reinit_sfps(port_dict)
if self.RJ45_port_list:
# Translate any plugin/plugout event into error dict
unknown_port = set()
unplug_port = set()
for index, event in port_dict.items():
if index in self.RJ45_port_list:
# Remove it from port event
# check if it's unknown event
if event == '0': # Remove event
unplug_port.add(index)
elif event != '1':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the "unkown" status also reported from PMPE or need to get it by calling "sx_api_port_status"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be. Otherwise there is inconvenience between PMPE and PMAOS, which IMO is a bug. Anyway, let’s double check.
The only exception AFAIK is the initialization flow. I don’t know whether the status change occurring before registered to the PMPE channel will be reported after registered. If not, we need to fetch the statuses for all the ports and report events for the ports that are unknown or not present when get_change_event is called for the first time.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's perform some tests for this after the holiday and I am merging your change for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there is a bug in sdk. No matter which port is unplugged, it always reports port 2. Need to check it as well

unknown_port.add(index)
# This is to leverage TRANSCEIVER_STATUS table to represent 'Not present' and 'Unknown' state
# The event should satisfies:
# - Vendor specific error bit
# - Non-blocking bit
# Currently, the 2 MSBs are reserved for this since they are most unlikely to be used in the near future
for index in unknown_port:
# Bit 31 for unknown
port_dict[index] = '2147483648'
error_dict[index] = 'Unknown'
for index in unplug_port:
# Bit 30 for not present
port_dict[index] = '1073741824'
error_dict[index] = 'Not present'
if port_dict:
self.reinit_sfps(port_dict)
result_dict = {'sfp':port_dict}
if error_dict:
result_dict['sfp_error'] = error_dict
Expand Down
Loading