Skip to content

Commit c8617b8

Browse files
mihirpat1mssonicbld
authored andcommitted
APIs to help in finding NPU SI settings (#410)
* APIs to help in finding NPU SI settings Signed-off-by: Mihir Patel <[email protected]> * Renamed get_cable_type to get_cable_length_type --------- Signed-off-by: Mihir Patel <[email protected]>
1 parent 7c2ad66 commit c8617b8

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

sonic_platform_base/sonic_xcvr/api/public/cmis.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ def get_model(self):
4343
'''
4444
return self.xcvr_eeprom.read(consts.VENDOR_PART_NO_FIELD)
4545

46+
def get_cable_length_type(self):
47+
'''
48+
This function returns the cable type of the module
49+
'''
50+
return "Length Cable Assembly(m)"
51+
52+
def get_cable_length(self):
53+
'''
54+
This function returns the cable length of the module
55+
'''
56+
return self.xcvr_eeprom.read(consts.LENGTH_ASSEMBLY_FIELD)
57+
4658
def get_vendor_rev(self):
4759
'''
4860
This function returns the revision level for part number provided by vendor
@@ -146,7 +158,6 @@ def get_transceiver_info(self):
146158
"encoding": "N/A", # Not supported
147159
"ext_identifier": "%s (%sW Max)" % (power_class, max_power),
148160
"ext_rateselect_compliance": "N/A", # Not supported
149-
"cable_type": "Length Cable Assembly(m)",
150161
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
151162
"nominal_bit_rate": 0, # Not supported
152163
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
@@ -160,6 +171,7 @@ def get_transceiver_info(self):
160171
xcvr_info['media_lane_count'] = self.get_media_lane_count()
161172
xcvr_info['host_lane_assignment_option'] = self.get_host_lane_assignment_option()
162173
xcvr_info['media_lane_assignment_option'] = self.get_media_lane_assignment_option()
174+
xcvr_info['cable_type'] = self.get_cable_length_type()
163175
apsel_dict = self.get_active_apsel_hostlane()
164176
for lane in range(1, self.NUM_CHANNELS+1):
165177
xcvr_info["%s%d" % ("active_apsel_hostlane", lane)] = \

tests/sonic_xcvr/test_cmis.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ def test_get_model(self, mock_response, expected):
3232
result = self.api.get_model()
3333
assert result == expected
3434

35+
def test_get_cable_length_type(self):
36+
assert self.api.get_cable_length_type() == "Length Cable Assembly(m)"
37+
38+
@pytest.mark.parametrize("mock_response, expected", [
39+
("0.0", "0.0"),
40+
("1.2", "1.2")
41+
])
42+
def test_get_cable_length(self, mock_response, expected):
43+
self.api.xcvr_eeprom.read = MagicMock()
44+
self.api.xcvr_eeprom.read.return_value = mock_response
45+
result = self.api.get_cable_length()
46+
assert result == expected
47+
3548
@pytest.mark.parametrize("mock_response, expected", [
3649
("0.0", "0.0"),
3750
("1.2", "1.2")

0 commit comments

Comments
 (0)