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
11 changes: 9 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,18 @@ def get_media_interface_technology(self):
'''
return self.xcvr_eeprom.read(consts.MEDIA_INTERFACE_TECH)

def get_host_lane_assignment_option(self):
def get_host_lane_assignment_option(self, appl=1):
'''
This function returns the host lane that the application begins on
Args:
app:
Integer, desired application for which host_lane_assignment_options are requested
'''
return self.xcvr_eeprom.read(consts.HOST_LANE_ASSIGNMENT_OPTION)
if (appl <= 0):
return 0

appl_advt = self.get_application_advertisement()
return appl_advt[appl]['host_lane_assignment_options'] if len(appl_advt) >= appl else 0

def get_media_lane_assignment_option(self):
'''
Expand Down
32 changes: 26 additions & 6 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import patch
from mock import MagicMock
import pytest
from sonic_platform_base.sonic_xcvr.api.public.cmis import CmisApi
Expand Down Expand Up @@ -675,13 +676,32 @@ def test_get_media_interface_technology(self, mock_response, expected):
result = self.api.get_media_interface_technology()
assert result == expected

@pytest.mark.parametrize("mock_response, expected", [
(1, 1)
@pytest.mark.parametrize("appl, expected", [
(0, 0),
(1, 1),
(2, 17),
(3, 0)
])
def test_get_host_lane_assignment_option(self, mock_response, expected):
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = mock_response
result = self.api.get_host_lane_assignment_option()
@patch('sonic_platform_base.sonic_xcvr.api.public.cmis.CmisApi.get_application_advertisement', MagicMock(return_value =
{
1: {
'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)',
'module_media_interface_id': '400GBASE-DR4 (Cl 124)',
'media_lane_count': 4,
'host_lane_count': 8,
'host_lane_assignment_options': 1
},
2: {
'host_electrical_interface_id': 'CAUI-4 C2M (Annex 83E)',
'module_media_interface_id': 'Active Cable assembly with BER < 5x10^-5',
'media_lane_count': 4,
'host_lane_count': 4,
'host_lane_assignment_options': 17
}
}
))
def test_get_host_lane_assignment_option(self, appl, expected):
result = self.api.get_host_lane_assignment_option(appl)
assert result == expected

@pytest.mark.parametrize("mock_response, expected", [
Expand Down