Skip to content

Commit

Permalink
Separate common code for remote target FW upgrade supported optics (s…
Browse files Browse the repository at this point in the history
…onic-net#453)

* Separate common code for remote side FW upgrade supported optics

Signed-off-by: Mihir Patel <[email protected]>

* Added newline to EOF

* Moved TARGET_MODE to Credo specific memmap

---------

Signed-off-by: Mihir Patel <[email protected]>
  • Loading branch information
mihirpat1 authored Apr 14, 2024
1 parent de130c4 commit dff8d48
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
9 changes: 4 additions & 5 deletions sonic_platform_base/sonic_xcvr/api/credo/aec_800g.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
Implementation of Credo AEC cable specific in addition to the CMIS specification.
"""

from ...fields import consts
from ..public.cmis import CmisApi
from ..public.cmisTargetFWUpgrade import CmisTargetFWUpgradeAPI

class CmisAec800gApi(CmisApi):
def set_firmware_download_target_end(self, target):
return self.xcvr_eeprom.write(consts.TARGET_MODE, target)
class CmisAec800gApi(CmisTargetFWUpgradeAPI):
# Vendor specific implementation to be added here
pass
13 changes: 13 additions & 0 deletions sonic_platform_base/sonic_xcvr/api/public/cmisTargetFWUpgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
cmisTargetFWUpgrade.py
Implementation of XcvrApi for CMIS based modules supporting firmware
upgrade of remote target from the local target itself.
"""

from ...fields import consts
from .cmis import CmisApi

class CmisTargetFWUpgradeAPI(CmisApi):
def set_firmware_download_target_end(self, target):
return self.xcvr_eeprom.write(consts.TARGET_MODE, target)
11 changes: 4 additions & 7 deletions sonic_platform_base/sonic_xcvr/codes/credo/aec_800g.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from ..public.cmis import CmisCodes
from ..public.cmisTargetFWUpgrade import CmisTargetFWUpgradeCodes

class CmisAec800gCodes(CmisCodes):
TARGET_MODE = {
0: 'local',
1: 'remote-A',
2: 'remote-B'
}
class CmisAec800gCodes(CmisTargetFWUpgradeCodes):
# Vendor specific implementation to be added here
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .cmis import CmisCodes

class CmisTargetFWUpgradeCodes(CmisCodes):
TARGET_MODE = {
0: 'local',
1: 'remote-A',
2: 'remote-B'
}
14 changes: 3 additions & 11 deletions sonic_platform_base/sonic_xcvr/mem_maps/credo/aec_800g.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@
Implementation of Credo AEC cable specific XcvrMemMap for CMIS Rev 5.0
"""

from ..public.cmis import CmisMemMap
from ..public.cmisTargetFWUpgrade import CmisTargetFWUpgradeMemMap
from ...fields.xcvr_field import (
CodeRegField,
DateField,
HexRegField,
NumberRegField,
RegBitField,
RegGroupField,
StringRegField,
)
from ...fields import consts

class CmisAec800gMemMap(CmisMemMap):
class CmisAec800gMemMap(CmisTargetFWUpgradeMemMap):
def __init__(self, codes):
super(CmisAec800gMemMap, self).__init__(codes)
super().__init__(codes)

self.VENDOR_CUSTOM = RegGroupField(consts.VENDOR_CUSTOM,
NumberRegField(consts.TARGET_MODE, self.getaddr(0x0, 64), ro=False)
)

def getaddr(self, page, offset, page_size=128):
return page * page_size + offset
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
cmisTargetFWUpgrade.py
Implementation of memory map for CMIS based modules supporting firmware
upgrade of remote target from the local target itself.
"""

from .cmis import CmisMemMap

class CmisTargetFWUpgradeMemMap(CmisMemMap):
# Vendor agnostic implementation to be added here
pass

0 comments on commit dff8d48

Please sign in to comment.