From 960f63f5835527d305ea8d7021991f56c2791532 Mon Sep 17 00:00:00 2001 From: Vasundhara Volam Date: Tue, 24 Sep 2024 19:21:00 +0000 Subject: [PATCH 1/2] Modify APIs and add new APIs for supporting reboot on a SmartSwitch --- sonic_platform_base/module_base.py | 31 +++++++++++++++++++++++++++++- tests/module_base_test.py | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sonic_platform_base/module_base.py b/sonic_platform_base/module_base.py index 0067f116f..25136ada9 100644 --- a/sonic_platform_base/module_base.py +++ b/sonic_platform_base/module_base.py @@ -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 @@ -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 @@ -258,6 +262,31 @@ def get_state_info(self): """ raise NotImplementedError + def get_dpu_bus_info(self, dpu_name): + """ + Retrieves the DPU bus information for the specified by "dpu_name" on a SmartSwitch. + + Returns: + Returns the PCI bus information in BDF format like "[DDDD:]BB:SS:F" + """ + raise NotImplementedError + + def pci_detach_dpu(self, dpu_name): + """ + Detaches the DPU PCI device specified by "dpu_name" on a SmartSwitch. + + Returns: True once the PCI is successfully detached. + """ + raise NotImplementedError + + def pci_reattach_dpu(self, dpu_name): + """ + Rescans and reconnects the DPU PCI device specified by "dpu_name" on a SmartSwitch. + + Returns: True once the PCI is successfully reconnected. + """ + raise NotImplementedError + ############################################## # Component methods ############################################## diff --git a/tests/module_base_test.py b/tests/module_base_test.py index b4b9519e3..16b53eff1 100644 --- a/tests/module_base_test.py +++ b/tests/module_base_test.py @@ -8,6 +8,9 @@ def test_module_base(self): [module.get_dpu_id], [module.get_reboot_cause], [module.get_state_info], + [module.get_dpu_bus_info, "dpu_name"], + [module.pci_detach_dpu, "dpu_name"], + [module.pci_reattach_dpu, "dpu_name"], ] for method in not_implemented_methods: From 614dc7106f107e93164e0ae605a0946375dfa235 Mon Sep 17 00:00:00 2001 From: Vasundhara Volam Date: Wed, 25 Sep 2024 01:10:27 +0000 Subject: [PATCH 2/2] Rename dpu_name to module_name to address the review comments --- sonic_platform_base/module_base.py | 12 ++++++------ tests/module_base_test.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sonic_platform_base/module_base.py b/sonic_platform_base/module_base.py index 25136ada9..5ca847e88 100644 --- a/sonic_platform_base/module_base.py +++ b/sonic_platform_base/module_base.py @@ -262,26 +262,26 @@ def get_state_info(self): """ raise NotImplementedError - def get_dpu_bus_info(self, dpu_name): + def get_bus_info(self, module_name): """ - Retrieves the DPU bus information for the specified by "dpu_name" on a SmartSwitch. + 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_dpu(self, dpu_name): + def pci_detach(self, module_name): """ - Detaches the DPU PCI device specified by "dpu_name" on a SmartSwitch. + 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_dpu(self, dpu_name): + def pci_reattach(self, module_name): """ - Rescans and reconnects the DPU PCI device specified by "dpu_name" on a SmartSwitch. + Rescans and reconnects the DPU PCI device specified by "module_name" on a SmartSwitch. Returns: True once the PCI is successfully reconnected. """ diff --git a/tests/module_base_test.py b/tests/module_base_test.py index 16b53eff1..cdccd5ffd 100644 --- a/tests/module_base_test.py +++ b/tests/module_base_test.py @@ -8,9 +8,9 @@ def test_module_base(self): [module.get_dpu_id], [module.get_reboot_cause], [module.get_state_info], - [module.get_dpu_bus_info, "dpu_name"], - [module.pci_detach_dpu, "dpu_name"], - [module.pci_reattach_dpu, "dpu_name"], + [module.get_bus_info, "module_name"], + [module.pci_detach, "module_name"], + [module.pci_reattach, "module_name"], ] for method in not_implemented_methods: