Skip to content

Commit 759862e

Browse files
authored
[Xcvrd] Skip to get dom/threshold/pm for flat memory (#458)
* [Xcvrd] Skip to get dom/threshold/pm for flat memory Signed-off-by: chiourung_huang <[email protected]> * Add test case --------- Signed-off-by: chiourung_huang <[email protected]>
1 parent 4533780 commit 759862e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

sonic-xcvrd/tests/test_xcvrd.py

+14
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,20 @@ def test_wrapper_get_sfp_error_description(self, mock_chassis):
24752475
mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError)
24762476
assert not _wrapper_get_sfp_error_description(1)
24772477

2478+
@patch('xcvrd.xcvrd.platform_chassis')
2479+
def test_wrapper_is_flat_memory(self, mock_chassis):
2480+
mock_api = MagicMock()
2481+
mock_api.is_flat_memory = MagicMock(return_value=True)
2482+
mock_object = MagicMock()
2483+
mock_object.get_xcvr_api = MagicMock(return_value=mock_api)
2484+
mock_chassis.get_sfp = MagicMock(return_value=mock_object)
2485+
2486+
from xcvrd.xcvrd import _wrapper_is_flat_memory
2487+
assert _wrapper_is_flat_memory(1) == True
2488+
2489+
mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError)
2490+
assert not _wrapper_is_flat_memory(1)
2491+
24782492
def test_check_port_in_range(self):
24792493
range_str = '1 - 32'
24802494
physical_port = 1

sonic-xcvrd/xcvrd/xcvrd.py

+18
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ def _wrapper_get_transceiver_pm(physical_port):
308308
pass
309309
return {}
310310

311+
def _wrapper_is_flat_memory(physical_port):
312+
if platform_chassis is not None:
313+
try:
314+
sfp = platform_chassis.get_sfp(physical_port)
315+
api = sfp.get_xcvr_api()
316+
return api.is_flat_memory()
317+
except NotImplementedError:
318+
pass
319+
return None
311320

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

596+
if _wrapper_is_flat_memory(physical_port) == True:
597+
continue
598+
587599
port_name = get_physical_port_name(logical_port_name,
588600
ganged_member_num, ganged_port)
589601
ganged_member_num += 1
@@ -619,6 +631,9 @@ def post_port_dom_info_to_db(logical_port_name, port_mapping, table, stop_event=
619631
if not _wrapper_get_presence(physical_port):
620632
continue
621633

634+
if _wrapper_is_flat_memory(physical_port) == True:
635+
continue
636+
622637
try:
623638
if dom_info_cache is not None and physical_port in dom_info_cache:
624639
# If cache is enabled and dom information is in cache, just read from cache, no need read from EEPROM
@@ -650,6 +665,9 @@ def post_port_pm_info_to_db(logical_port_name, port_mapping, table, stop_event=t
650665
if not _wrapper_get_presence(physical_port):
651666
continue
652667

668+
if _wrapper_is_flat_memory(physical_port) == True:
669+
continue
670+
653671
if pm_info_cache is not None and physical_port in pm_info_cache:
654672
# If cache is enabled and pm info is in cache, just read from cache, no need read from EEPROM
655673
pm_info_dict = pm_info_cache[physical_port]

0 commit comments

Comments
 (0)