Skip to content

Commit 1485079

Browse files
committed
Merge remote-tracking branch 'base/202411' into code-sync-202412
2 parents 01b23d9 + 7c70958 commit 1485079

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

sonic_platform_base/sonic_xcvr/api/public/cmis.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def _update_vdm_dict(self, dict_to_update, new_key, vdm_raw_dict, vdm_observable
165165
def freeze_vdm_stats(self):
166166
'''
167167
This function freeze all the vdm statistics reporting registers.
168-
When raised by the host, causes the module to freeze and hold all
169-
reported statistics reporting registers (minimum, maximum and
168+
When raised by the host, causes the module to freeze and hold all
169+
reported statistics reporting registers (minimum, maximum and
170170
average values)in Pages 24h-27h.
171171
172172
Returns True if the provision succeeds and False incase of failure.
@@ -184,9 +184,9 @@ def get_vdm_freeze_status(self):
184184
def unfreeze_vdm_stats(self):
185185
'''
186186
This function unfreeze all the vdm statistics reporting registers.
187-
When freeze is ceased by the host, releases the freeze request, allowing the
187+
When freeze is ceased by the host, releases the freeze request, allowing the
188188
reported minimum, maximum and average values to update again.
189-
189+
190190
Returns True if the provision succeeds and False incase of failure.
191191
'''
192192
return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_UNFREEZE)
@@ -378,7 +378,7 @@ def get_transceiver_info_firmware_versions(self):
378378
( _, _, _, _, _, _, _, _, ActiveFirmware, InactiveFirmware) = result['result']
379379
except (ValueError, TypeError):
380380
return return_dict
381-
381+
382382
return_dict["active_firmware"] = ActiveFirmware
383383
return_dict["inactive_firmware"] = InactiveFirmware
384384
return return_dict
@@ -589,6 +589,13 @@ def get_voltage(self):
589589
return None
590590
return float("{:.3f}".format(voltage))
591591

592+
def is_copper(self):
593+
'''
594+
Returns True if the module is copper, False otherwise
595+
'''
596+
media_intf = self.get_module_media_type()
597+
return media_intf == "passive_copper_media_interface" if media_intf else None
598+
592599
@read_only_cached_api_return
593600
def is_flat_memory(self):
594601
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD) is not False
@@ -1068,10 +1075,10 @@ def get_media_lane_count(self, appl=1):
10681075
'''
10691076
if self.is_flat_memory():
10701077
return 0
1071-
1078+
10721079
if (appl <= 0):
10731080
return 0
1074-
1081+
10751082
appl_advt = self.get_application_advertisement()
10761083
return appl_advt[appl]['media_lane_count'] if len(appl_advt) >= appl else 0
10771084

@@ -1104,10 +1111,10 @@ def get_media_lane_assignment_option(self, appl=1):
11041111
'''
11051112
if self.is_flat_memory():
11061113
return 'N/A'
1107-
1114+
11081115
if (appl <= 0):
11091116
return 0
1110-
1117+
11111118
appl_advt = self.get_application_advertisement()
11121119
return appl_advt[appl]['media_lane_assignment_options'] if len(appl_advt) >= appl else 0
11131120

@@ -2348,7 +2355,7 @@ def get_transceiver_vdm_real_value(self):
23482355
biasyq{lane_num} = FLOAT ; modulator bias yq in percentage
23492356
biasyp{lane_num} = FLOAT ; modulator bias yq in percentage
23502357
cdshort{lane_num} = FLOAT ; chromatic dispersion, high granularity, short link in ps/nm
2351-
cdlong{lane_num} = FLOAT ; chromatic dispersion, high granularity, long link in ps/nm
2358+
cdlong{lane_num} = FLOAT ; chromatic dispersion, high granularity, long link in ps/nm
23522359
dgd{lane_num} = FLOAT ; differential group delay in ps
23532360
sopmd{lane_num} = FLOAT ; second order polarization mode dispersion in ps^2
23542361
soproc{lane_num} = FLOAT ; state of polarization rate of change in krad/s
@@ -2377,7 +2384,7 @@ def get_transceiver_vdm_thresholds(self):
23772384
Returns:
23782385
A dict containing the following keys/values :
23792386
========================================================================
2380-
xxx refers to HALARM/LALARM/HWARN/LWARN threshold
2387+
xxx refers to HALARM/LALARM/HWARN/LWARN threshold
23812388
;Defines Transceiver VDM high/low alarm/warning threshold for a port
23822389
key = TRANSCEIVER_VDM_XXX_THRESHOLD|ifname ; information module VDM high/low alarm/warning threshold on port
23832390
; field = value
@@ -2700,7 +2707,7 @@ def decommission_all_datapaths(self):
27002707
name = "DP{}State".format(lane + 1)
27012708
if dp_state[name] != 'DataPathDeactivated':
27022709
return False
2703-
2710+
27042711
name = "ConfigStatusLane{}".format(lane + 1)
27052712
if config_state[name] != 'ConfigSuccess':
27062713
return False

tests/sonic_xcvr/test_cmis.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ def test_get_voltage(self, mock_response, expected):
188188
result = self.api.get_voltage()
189189
assert result == expected
190190

191+
def test_is_copper(self):
192+
with patch.object(self.api, 'xcvr_eeprom') as mock_eeprom:
193+
mock_eeprom.read = MagicMock()
194+
mock_eeprom.read.return_value = None
195+
assert self.api.is_copper() is None
196+
self.api.get_module_media_type = MagicMock()
197+
self.api.get_module_media_type.return_value = "passive_copper_media_interface"
198+
assert self.api.is_copper()
199+
self.api.get_module_media_type.return_value = "active_cable_media_interface"
200+
assert not self.api.is_copper()
201+
self.api.get_module_media_type.return_value = "sm_media_interface"
202+
assert not self.api.is_copper()
203+
191204
@pytest.mark.parametrize("mock_response, expected", [
192205
(False, False)
193206
])

0 commit comments

Comments
 (0)