Skip to content

Commit

Permalink
Added new Platform APIs and modified APIs for supporting reboot on a …
Browse files Browse the repository at this point in the history
…SmartSwitch (#501)

* Modify APIs and add new APIs for supporting reboot on a SmartSwitch

* Rename dpu_name to module_name to address the review comments
  • Loading branch information
vvolam authored Sep 27, 2024
1 parent 174bbd4 commit daeed65
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 30 additions & 1 deletion sonic_platform_base/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ModuleBase(device_base.DeviceBase):
MODULE_REBOOT_CPU_COMPLEX = "CPU"
# Module reboot type to reboot FPGA complex
MODULE_REBOOT_FPGA_COMPLEX = "FPGA"
# Module reboot type to reboot DPU
MODULE_REBOOT_DPU = "DPU"

def __init__(self):
# List of ComponentBase-derived objects representing all components
Expand Down Expand Up @@ -166,7 +168,9 @@ def reboot(self, reboot_type):
Args:
reboot_type: A string, the type of reboot requested from one of the
predefined reboot types: MODULE_REBOOT_DEFAULT, MODULE_REBOOT_CPU_COMPLEX,
or MODULE_REBOOT_FPGA_COMPLEX
MODULE_REBOOT_FPGA_COMPLEX or MODULE_REBOOT_DPU
MODULE_REBOOT_DPU is only applicable for smartswitch chassis.
Returns:
bool: True if the request has been issued successfully, False if not
Expand Down Expand Up @@ -258,6 +262,31 @@ def get_state_info(self):
"""
raise NotImplementedError

def get_bus_info(self, module_name):
"""
Retrieves the bus information for the specified by "module_name" on a SmartSwitch.
Returns:
Returns the PCI bus information in BDF format like "[DDDD:]BB:SS:F"
"""
raise NotImplementedError

def pci_detach(self, module_name):
"""
Detaches the DPU PCI device specified by "module_name" on a SmartSwitch.
Returns: True once the PCI is successfully detached.
"""
raise NotImplementedError

def pci_reattach(self, module_name):
"""
Rescans and reconnects the DPU PCI device specified by "module_name" on a SmartSwitch.
Returns: True once the PCI is successfully reconnected.
"""
raise NotImplementedError

##############################################
# Component methods
##############################################
Expand Down
3 changes: 3 additions & 0 deletions tests/module_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def test_module_base(self):
[module.get_dpu_id],
[module.get_reboot_cause],
[module.get_state_info],
[module.get_bus_info, "module_name"],
[module.pci_detach, "module_name"],
[module.pci_reattach, "module_name"],
]

for method in not_implemented_methods:
Expand Down

0 comments on commit daeed65

Please sign in to comment.