Skip to content

Commit daeed65

Browse files
authored
Added new Platform APIs and modified APIs for supporting reboot on a 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
1 parent 174bbd4 commit daeed65

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

sonic_platform_base/module_base.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ModuleBase(device_base.DeviceBase):
5050
MODULE_REBOOT_CPU_COMPLEX = "CPU"
5151
# Module reboot type to reboot FPGA complex
5252
MODULE_REBOOT_FPGA_COMPLEX = "FPGA"
53+
# Module reboot type to reboot DPU
54+
MODULE_REBOOT_DPU = "DPU"
5355

5456
def __init__(self):
5557
# List of ComponentBase-derived objects representing all components
@@ -166,7 +168,9 @@ def reboot(self, reboot_type):
166168
Args:
167169
reboot_type: A string, the type of reboot requested from one of the
168170
predefined reboot types: MODULE_REBOOT_DEFAULT, MODULE_REBOOT_CPU_COMPLEX,
169-
or MODULE_REBOOT_FPGA_COMPLEX
171+
MODULE_REBOOT_FPGA_COMPLEX or MODULE_REBOOT_DPU
172+
173+
MODULE_REBOOT_DPU is only applicable for smartswitch chassis.
170174
171175
Returns:
172176
bool: True if the request has been issued successfully, False if not
@@ -258,6 +262,31 @@ def get_state_info(self):
258262
"""
259263
raise NotImplementedError
260264

265+
def get_bus_info(self, module_name):
266+
"""
267+
Retrieves the bus information for the specified by "module_name" on a SmartSwitch.
268+
269+
Returns:
270+
Returns the PCI bus information in BDF format like "[DDDD:]BB:SS:F"
271+
"""
272+
raise NotImplementedError
273+
274+
def pci_detach(self, module_name):
275+
"""
276+
Detaches the DPU PCI device specified by "module_name" on a SmartSwitch.
277+
278+
Returns: True once the PCI is successfully detached.
279+
"""
280+
raise NotImplementedError
281+
282+
def pci_reattach(self, module_name):
283+
"""
284+
Rescans and reconnects the DPU PCI device specified by "module_name" on a SmartSwitch.
285+
286+
Returns: True once the PCI is successfully reconnected.
287+
"""
288+
raise NotImplementedError
289+
261290
##############################################
262291
# Component methods
263292
##############################################

tests/module_base_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def test_module_base(self):
88
[module.get_dpu_id],
99
[module.get_reboot_cause],
1010
[module.get_state_info],
11+
[module.get_bus_info, "module_name"],
12+
[module.pci_detach, "module_name"],
13+
[module.pci_reattach, "module_name"],
1114
]
1215

1316
for method in not_implemented_methods:

0 commit comments

Comments
 (0)