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

APIs to help in finding NPU SI settings #410

Merged
merged 2 commits into from
Dec 5, 2023
Merged
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: 13 additions & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
@@ -43,6 +43,18 @@ def get_model(self):
'''
return self.xcvr_eeprom.read(consts.VENDOR_PART_NO_FIELD)

def get_cable_length_type(self):
'''
This function returns the cable type of the module
'''
return "Length Cable Assembly(m)"
keboliu marked this conversation as resolved.
Show resolved Hide resolved

def get_cable_length(self):
'''
This function returns the cable length of the module
'''
return self.xcvr_eeprom.read(consts.LENGTH_ASSEMBLY_FIELD)

def get_vendor_rev(self):
'''
This function returns the revision level for part number provided by vendor
@@ -146,7 +158,6 @@ def get_transceiver_info(self):
"encoding": "N/A", # Not supported
"ext_identifier": "%s (%sW Max)" % (power_class, max_power),
"ext_rateselect_compliance": "N/A", # Not supported
"cable_type": "Length Cable Assembly(m)",
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
"nominal_bit_rate": 0, # Not supported
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
@@ -160,6 +171,7 @@ def get_transceiver_info(self):
xcvr_info['media_lane_count'] = self.get_media_lane_count()
xcvr_info['host_lane_assignment_option'] = self.get_host_lane_assignment_option()
xcvr_info['media_lane_assignment_option'] = self.get_media_lane_assignment_option()
xcvr_info['cable_type'] = self.get_cable_length_type()
apsel_dict = self.get_active_apsel_hostlane()
for lane in range(1, self.NUM_CHANNELS+1):
xcvr_info["%s%d" % ("active_apsel_hostlane", lane)] = \
13 changes: 13 additions & 0 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
@@ -32,6 +32,19 @@ def test_get_model(self, mock_response, expected):
result = self.api.get_model()
assert result == expected

def test_get_cable_length_type(self):
assert self.api.get_cable_length_type() == "Length Cable Assembly(m)"

@pytest.mark.parametrize("mock_response, expected", [
("0.0", "0.0"),
("1.2", "1.2")
])
def test_get_cable_length(self, mock_response, expected):
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = mock_response
result = self.api.get_cable_length()
assert result == expected

@pytest.mark.parametrize("mock_response, expected", [
("0.0", "0.0"),
("1.2", "1.2")