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
6 changes: 3 additions & 3 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

VDM_FREEZE = 128
VDM_FREEZE = 1
VDM_UNFREEZE = 0

DATAPATH_INIT_DURATION_MULTIPLIER = 10
Expand Down Expand Up @@ -211,7 +211,7 @@ def freeze_vdm_stats(self):

Returns True if the provision succeeds and False incase of failure.
'''
return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_FREEZE)
return self.xcvr_eeprom.write(consts.VDM_FREEZE_REQUEST, VDM_FREEZE)

def get_vdm_freeze_status(self):
'''
Expand All @@ -229,7 +229,7 @@ def unfreeze_vdm_stats(self):

Returns True if the provision succeeds and False incase of failure.
'''
return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_UNFREEZE)
return self.xcvr_eeprom.write(consts.VDM_FREEZE_REQUEST, VDM_UNFREEZE)

def get_vdm_unfreeze_status(self):
'''
Expand Down
2 changes: 0 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
THRSH_SPACING = 8
VDM_SIZE = 2
VDM_FLAG_PAGE = 0x2c
VDM_FREEZE = 128
VDM_UNFREEZE = 0

class CmisVdmApi(XcvrApi):

Expand Down
4 changes: 4 additions & 0 deletions sonic_platform_base/sonic_xcvr/fields/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,13 @@
VDM_SUPPORTED = "VdmSupported"
VDM_SUPPORTED_PAGE = "VdmSupportedPage"
VDM_CONTROL = "VdmControl"
VDM_FREEZE_REQUEST = "VdmFreezeRequest"
VDM_POWER_SAVING_MODE = "VdmPowerSavingMode"
VDM_MON_DUTY_CYCLE = "VdmMonDutyCycle"
VDM_STATUS = "VdmStatus"
VDM_FREEZE_DONE = "VdmFreezeDone"
VDM_UNFREEZE_DONE = "VdmUnfreezeDone"
VDM_RESERVED = "VdmReserved"

MEDIA_LANE_FEC_PM = "Media Lane FEC Performance Monitoring"
MEDIA_LANE_LINK_PM = "Media Lane Link Performance Monitoring"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .....fields.xcvr_field import (
NumberRegField,
RegBitField,
RegBitsField,
)
from .....fields import consts

Expand All @@ -22,7 +23,13 @@ def __init__(self, codes, bank=0, page=VDM_ADVERTISING_CTRL_PAGE):
NumberRegField(consts.VDM_SUPPORTED_PAGE, self.getaddr(128),
*(RegBitField("Bit%d" % (bit), bit) for bit in range (0, 2))
),
NumberRegField(consts.VDM_CONTROL, self.getaddr(144), size=1, ro=False),
NumberRegField(consts.VDM_CONTROL, self.getaddr(144),
RegBitsField(consts.VDM_FREEZE_REQUEST, bitpos=7, size=1, ro=False),
RegBitsField(consts.VDM_POWER_SAVING_MODE, bitpos=6, size=1, ro=False),
RegBitsField(consts.VDM_MON_DUTY_CYCLE, bitpos=2, size=4, ro=False),
RegBitsField(consts.VDM_RESERVED, bitpos=0, size=2, ro=True),
ro=False
),
NumberRegField(consts.VDM_STATUS, self.getaddr(145),
RegBitField(consts.VDM_UNFREEZE_DONE, 6),
RegBitField(consts.VDM_FREEZE_DONE, 7),
Expand Down
19 changes: 19 additions & 0 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ def test_linear_offset_specific_worked_examples(self, bank, page, offset, expect
future reader can verify the formula without redoing the arithmetic."""
assert CmisPage.linear_offset(page, bank, offset) == expected

@pytest.mark.parametrize("api_method, initial_value, expected_value", [
("freeze_vdm_stats", 0x55, 0xD5),
("unfreeze_vdm_stats", 0xD5, 0x55),
])
def test_vdm_freeze_request_preserves_other_control_bits(
self, api_method, initial_value, expected_value):
"""FreezeRequest is Page 2Fh byte 144 bit 7 in CMIS 5.4."""
mem_map = CmisMemMap(self.codes)
freeze_request = mem_map.get_field(consts.VDM_FREEZE_REQUEST)
reader = MagicMock(return_value=bytes([initial_value]))
writer = MagicMock(return_value=True)
api = CmisApi(XcvrEeprom(reader, writer, mem_map))
reader.reset_mock()

assert getattr(api, api_method)() is True
reader.assert_called_once_with(freeze_request.get_offset(), 1)
writer.assert_called_once_with(
freeze_request.get_offset(), 1, bytearray([expected_value]))


class TestCmis(object):
codes = CmisCodes
Expand Down