From 186d851380f2807222daceecb54048ce8634fb89 Mon Sep 17 00:00:00 2001 From: Sujin Kang Date: Sun, 27 Jun 2021 20:02:51 -0700 Subject: [PATCH] Pcieutil to load the platform api first instead of using common api (#1672) What I did Pcieutil to load the platform api first instead of using common api Some platform device with different BIOS version needs more than one pcie configuration to check the pcie devices properly. Please refer to the platform api support : Azure/sonic-platform-common#195 How I did it Load the platform pcie api first prior to use the common api --- pcieutil/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pcieutil/main.py b/pcieutil/main.py index 807675493b06..ad6a1ebfa463 100644 --- a/pcieutil/main.py +++ b/pcieutil/main.py @@ -49,13 +49,18 @@ def load_platform_pcieutil(): global platform_path # Load platform module from source + platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs() try: - platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs() - from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil - platform_pcieutil = PcieUtil(platform_path) + from sonic_platform.pcie import Pcie + platform_pcieutil = Pcie(platform_path) except ImportError as e: - log.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) - raise e + log.log_warning("Failed to load platform Pcie module. Error : {}, fallback to load Pcie common utility.".format(str(e)), True) + try: + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil + platform_pcieutil = PcieUtil(platform_path) + except ImportError as e: + log.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) + raise e # ==================== CLI commands and groups ====================