Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xcvrd] Skip to get dom/threshold/pm for flat memory #458

Merged
merged 2 commits into from
Apr 22, 2024
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
14 changes: 14 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,20 @@ def test_wrapper_get_sfp_error_description(self, mock_chassis):
mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError)
assert not _wrapper_get_sfp_error_description(1)

@patch('xcvrd.xcvrd.platform_chassis')
def test_wrapper_is_flat_memory(self, mock_chassis):
mock_api = MagicMock()
mock_api.is_flat_memory = MagicMock(return_value=True)
mock_object = MagicMock()
mock_object.get_xcvr_api = MagicMock(return_value=mock_api)
mock_chassis.get_sfp = MagicMock(return_value=mock_object)

from xcvrd.xcvrd import _wrapper_is_flat_memory
assert _wrapper_is_flat_memory(1) == True

mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError)
assert not _wrapper_is_flat_memory(1)

def test_check_port_in_range(self):
range_str = '1 - 32'
physical_port = 1
Expand Down
18 changes: 18 additions & 0 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ def _wrapper_get_transceiver_pm(physical_port):
pass
return {}

def _wrapper_is_flat_memory(physical_port):
if platform_chassis is not None:
try:
sfp = platform_chassis.get_sfp(physical_port)
api = sfp.get_xcvr_api()
return api.is_flat_memory()
except NotImplementedError:
pass
return None

# Soak SFP insert event until management init completes
def _wrapper_soak_sfp_insert_event(sfp_insert_events, port_dict):
Expand Down Expand Up @@ -584,6 +593,9 @@ def post_port_dom_threshold_info_to_db(logical_port_name, port_mapping, table,
if not _wrapper_get_presence(physical_port):
continue

if _wrapper_is_flat_memory(physical_port) == True:
continue

port_name = get_physical_port_name(logical_port_name,
ganged_member_num, ganged_port)
ganged_member_num += 1
Expand Down Expand Up @@ -619,6 +631,9 @@ def post_port_dom_info_to_db(logical_port_name, port_mapping, table, stop_event=
if not _wrapper_get_presence(physical_port):
continue

if _wrapper_is_flat_memory(physical_port) == True:
Copy link
Contributor

Choose a reason for hiding this comment

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

So, no DOM (TRANSCEIVER_DOM_SENSOR) STATE_DB info is populated for xcvrs with flat memory?

continue

try:
if dom_info_cache is not None and physical_port in dom_info_cache:
# If cache is enabled and dom information is in cache, just read from cache, no need read from EEPROM
Expand Down Expand Up @@ -650,6 +665,9 @@ def post_port_pm_info_to_db(logical_port_name, port_mapping, table, stop_event=t
if not _wrapper_get_presence(physical_port):
continue

if _wrapper_is_flat_memory(physical_port) == True:
continue

if pm_info_cache is not None and physical_port in pm_info_cache:
# If cache is enabled and pm info is in cache, just read from cache, no need read from EEPROM
pm_info_dict = pm_info_cache[physical_port]
Expand Down
Loading