From fcb0126a4572f7b37b936c75ae54d2fd0150ad02 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Tue, 15 Jan 2019 10:45:37 +0700 Subject: [PATCH 1/7] [platform/ali] - Add cpld online upgrade tool --- platform/broadcom/sonic-platform-modules-cel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-cel b/platform/broadcom/sonic-platform-modules-cel index 459b435447d4..8e7c7689db17 160000 --- a/platform/broadcom/sonic-platform-modules-cel +++ b/platform/broadcom/sonic-platform-modules-cel @@ -1 +1 @@ -Subproject commit 459b435447d4e64d06893f2ba7417e8e8815080f +Subproject commit 8e7c7689db1759c1e2f03d0ada101c50a1fc4c2f From 1ef935acb9cd8b6ebf647e1efc5c36b57e64cb94 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Mon, 14 Jan 2019 14:39:51 +0700 Subject: [PATCH 2/7] [device/alibaba] - Init fwmgrutil --- .../plugins/fwmgrutil.py | 69 +++++++++++++++++++ .../plugins/fwmgrutil.py | 69 +++++++++++++++++++ .../plugins/fwmgrutil.py | 69 +++++++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py create mode 100644 device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py create mode 100644 device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py new file mode 100644 index 000000000000..1f4d22c28834 --- /dev/null +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -0,0 +1,69 @@ +# fwmgrutil.py +# +# Platform-specific firmware management interface for SONiC +# + +try: + from sonic_fwmgr.fwgmr_base import FwMgrUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + + +class FwMgrUtil(FwMgrUtilBase): + + """Platform-specific FwMgrUtil class""" + + def __init__(self): + """TODO: to be defined1. """ + self.onie_config_file = "/host/machine.conf" + + def get_bmc_version(self): + """Get BMC version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_cpld_version(self): + """Get CPLD version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_bios_version(self): + """Get BIOS version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_onie_version(self): + """Get ONiE version from SONiC + :returns: version string + + """ + onie_verison = 'None' + + onie_version_keys = "onie_version" + onie_config_file = open(self.onie_config_file, "r") + for line in onie_config_file.readlines(): + if onie_version_keys in line: + onie_version_raw = line.split('=') + onie_verison = onie_version_raw[1].strip() + break + return onie_verison + + def get_pcie_version(self): + """Get PCiE version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_fpga_version(self): + """Get FPGA version from SONiC + :returns: TODO + + """ + return '0.0.0' diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py new file mode 100644 index 000000000000..1f4d22c28834 --- /dev/null +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py @@ -0,0 +1,69 @@ +# fwmgrutil.py +# +# Platform-specific firmware management interface for SONiC +# + +try: + from sonic_fwmgr.fwgmr_base import FwMgrUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + + +class FwMgrUtil(FwMgrUtilBase): + + """Platform-specific FwMgrUtil class""" + + def __init__(self): + """TODO: to be defined1. """ + self.onie_config_file = "/host/machine.conf" + + def get_bmc_version(self): + """Get BMC version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_cpld_version(self): + """Get CPLD version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_bios_version(self): + """Get BIOS version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_onie_version(self): + """Get ONiE version from SONiC + :returns: version string + + """ + onie_verison = 'None' + + onie_version_keys = "onie_version" + onie_config_file = open(self.onie_config_file, "r") + for line in onie_config_file.readlines(): + if onie_version_keys in line: + onie_version_raw = line.split('=') + onie_verison = onie_version_raw[1].strip() + break + return onie_verison + + def get_pcie_version(self): + """Get PCiE version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_fpga_version(self): + """Get FPGA version from SONiC + :returns: TODO + + """ + return '0.0.0' diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py new file mode 100644 index 000000000000..1f4d22c28834 --- /dev/null +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py @@ -0,0 +1,69 @@ +# fwmgrutil.py +# +# Platform-specific firmware management interface for SONiC +# + +try: + from sonic_fwmgr.fwgmr_base import FwMgrUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + + +class FwMgrUtil(FwMgrUtilBase): + + """Platform-specific FwMgrUtil class""" + + def __init__(self): + """TODO: to be defined1. """ + self.onie_config_file = "/host/machine.conf" + + def get_bmc_version(self): + """Get BMC version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_cpld_version(self): + """Get CPLD version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_bios_version(self): + """Get BIOS version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_onie_version(self): + """Get ONiE version from SONiC + :returns: version string + + """ + onie_verison = 'None' + + onie_version_keys = "onie_version" + onie_config_file = open(self.onie_config_file, "r") + for line in onie_config_file.readlines(): + if onie_version_keys in line: + onie_version_raw = line.split('=') + onie_verison = onie_version_raw[1].strip() + break + return onie_verison + + def get_pcie_version(self): + """Get PCiE version from SONiC + :returns: version string + + """ + return '0.0.0' + + def get_fpga_version(self): + """Get FPGA version from SONiC + :returns: TODO + + """ + return '0.0.0' From 875d270ac2bd89f19148075f4823da6ad5423de2 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Mon, 14 Jan 2019 17:12:08 +0700 Subject: [PATCH 3/7] [device/alibaba] - Update fishbone32 fwmgrutil --- .../plugins/fwmgrutil.py | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py index 1f4d22c28834..787b3c09fc99 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -3,6 +3,9 @@ # Platform-specific firmware management interface for SONiC # +import subprocess +import requests + try: from sonic_fwmgr.fwgmr_base import FwMgrUtilBase except ImportError as e: @@ -16,13 +19,22 @@ class FwMgrUtil(FwMgrUtilBase): def __init__(self): """TODO: to be defined1. """ self.onie_config_file = "/host/machine.conf" + self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" def get_bmc_version(self): """Get BMC version from SONiC :returns: version string """ - return '0.0.0' + bmc_version = "None" + + bmc_version_key = "OpenBMC Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + bmc_version = bmc_info.get(bmc_version_key) + + return bmc_version def get_cpld_version(self): """Get CPLD version from SONiC @@ -36,7 +48,16 @@ def get_bios_version(self): :returns: version string """ - return '0.0.0' + bios_version = 'None' + + p = subprocess.Popen( + ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) + raw_data = str(p.communicate()[0]) + raw_data_list = raw_data.split("\n") + bios_version = raw_data_list[0] if len( + raw_data_list) == 1 else raw_data_list[-2] + + return bios_version def get_onie_version(self): """Get ONiE version from SONiC From ae168429b2d9606551c931a5936a2367c6bc650e Mon Sep 17 00:00:00 2001 From: Pradchaya P Date: Mon, 14 Jan 2019 19:25:16 +0700 Subject: [PATCH 4/7] [device/alibaba] - Implement fishbone32 fpga & cpld firmware read API --- .../plugins/fwmgrutil.py | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py index 787b3c09fc99..fd64eea5ae6d 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -17,9 +17,23 @@ class FwMgrUtil(FwMgrUtilBase): """Platform-specific FwMgrUtil class""" def __init__(self): - """TODO: to be defined1. """ + self.platform_name = "AS1332h" self.onie_config_file = "/host/machine.conf" self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" + self.onie_config_file = "/host/machine.conf" + self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name + self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name + + def __get_register_value(self, path, register): + cmd = "echo {1} > {0}; cat {0}".format(path, register) + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + return raw_data.strip() def get_bmc_version(self): """Get BMC version from SONiC @@ -38,10 +52,26 @@ def get_bmc_version(self): def get_cpld_version(self): """Get CPLD version from SONiC - :returns: version string - + :returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string} """ - return '0.0.0' + + CPLD_B = self.__get_register_value(self.cpldb_version_path, '0xA100') + CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0') + CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00') + CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00') + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) + + cpld_version_dict = {} + cpld_version_dict.update({'CPLD_B':CPLD_B}) + cpld_version_dict.update({'CPLD_C':CPLD_C}) + cpld_version_dict.update({'CPLD_1':CPLD_1}) + cpld_version_dict.update({'CPLD_2':CPLD_2}) + + return cpld_version_dict def get_bios_version(self): """Get BIOS version from SONiC @@ -78,13 +108,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - + TODO: Need SDK integrated """ return '0.0.0' def get_fpga_version(self): """Get FPGA version from SONiC - :returns: TODO + :returns: version string """ - return '0.0.0' + version = self.__get_register_value(self.fpga_version_path, '0x00') + if version is not 'None': + version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + return str(version) From bd3cc7d75e541063dceb9dc860962a7aba2240cd Mon Sep 17 00:00:00 2001 From: Pradchaya P Date: Mon, 14 Jan 2019 19:25:39 +0700 Subject: [PATCH 5/7] [device/alibaba] - Implement fishbone48 fpga & cpld firmware read API --- .../plugins/fwmgrutil.py | 72 ++++++++++++++++--- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py index 1f4d22c28834..cb24e3b0c450 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py @@ -3,6 +3,9 @@ # Platform-specific firmware management interface for SONiC # +import subprocess +import requests + try: from sonic_fwmgr.fwgmr_base import FwMgrUtilBase except ImportError as e: @@ -14,29 +17,77 @@ class FwMgrUtil(FwMgrUtilBase): """Platform-specific FwMgrUtil class""" def __init__(self): - """TODO: to be defined1. """ + self.platform_name = "AS1348f8h" + self.onie_config_file = "/host/machine.conf" + self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" self.onie_config_file = "/host/machine.conf" + self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name + self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name + + def __get_register_value(self, path, register): + cmd = "echo {1} > {0}; cat {0}".format(path, register) + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + return raw_data.strip() def get_bmc_version(self): """Get BMC version from SONiC :returns: version string """ - return '0.0.0' + bmc_version = "None" + + bmc_version_key = "OpenBMC Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + bmc_version = bmc_info.get(bmc_version_key) + + return bmc_version def get_cpld_version(self): """Get CPLD version from SONiC - :returns: version string - + :returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string} """ - return '0.0.0' + + CPLD_B = self.__get_register_value(self.cpldb_version_path, '0xA100') + CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0') + CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00') + CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00') + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) + + cpld_version_dict = {} + cpld_version_dict.update({'CPLD_B':CPLD_B}) + cpld_version_dict.update({'CPLD_C':CPLD_C}) + cpld_version_dict.update({'CPLD_1':CPLD_1}) + cpld_version_dict.update({'CPLD_2':CPLD_2}) + + return cpld_version_dict def get_bios_version(self): """Get BIOS version from SONiC :returns: version string """ - return '0.0.0' + bios_version = 'None' + + p = subprocess.Popen( + ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) + raw_data = str(p.communicate()[0]) + raw_data_list = raw_data.split("\n") + bios_version = raw_data_list[0] if len( + raw_data_list) == 1 else raw_data_list[-2] + + return bios_version def get_onie_version(self): """Get ONiE version from SONiC @@ -57,13 +108,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - + TODO: Need SDK integrated """ return '0.0.0' def get_fpga_version(self): """Get FPGA version from SONiC - :returns: TODO + :returns: version string """ - return '0.0.0' + version = self.__get_register_value(self.fpga_version_path, '0x00') + if version is not 'None': + version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + return str(version) From c92f26a0fd9e7f2362ae83b39183477d196f2248 Mon Sep 17 00:00:00 2001 From: Pradchaya P Date: Mon, 14 Jan 2019 19:31:37 +0700 Subject: [PATCH 6/7] [device/alibaba] - Implement phalanx fpga & cpld firmware read API --- .../plugins/fwmgrutil.py | 80 ++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py index 1f4d22c28834..cb987428acb9 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py @@ -3,6 +3,9 @@ # Platform-specific firmware management interface for SONiC # +import subprocess +import requests + try: from sonic_fwmgr.fwgmr_base import FwMgrUtilBase except ImportError as e: @@ -14,29 +17,85 @@ class FwMgrUtil(FwMgrUtilBase): """Platform-specific FwMgrUtil class""" def __init__(self): - """TODO: to be defined1. """ + self.platform_name = "AS23128h" + self.onie_config_file = "/host/machine.conf" + self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" self.onie_config_file = "/host/machine.conf" + self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name + self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name + self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name + self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name + + def __get_register_value(self, path, register): + cmd = "echo {1} > {0}; cat {0}".format(path, register) + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + return raw_data.strip() def get_bmc_version(self): """Get BMC version from SONiC :returns: version string """ - return '0.0.0' + bmc_version = "None" + + bmc_version_key = "OpenBMC Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + bmc_version = bmc_info.get(bmc_version_key) + + return bmc_version def get_cpld_version(self): """Get CPLD version from SONiC - :returns: version string - + :returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string} """ - return '0.0.0' + + CPLD_B = self.__get_register_value(self.cpldb_version_path, '0xA100') + CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0') + CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00') + CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00') + CPLD_3 = self.__get_register_value(self.switchboard_cpld3_path, '0x00') + CPLD_4 = self.__get_register_value(self.switchboard_cpld4_path, '0x00') + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) + CPLD_3 = 'None' if CPLD_3 is 'None' else "{}.{}".format(int(CPLD_3[2],16),int(CPLD_3[3],16)) + CPLD_4 = 'None' if CPLD_4 is 'None' else "{}.{}".format(int(CPLD_4[2],16),int(CPLD_4[3],16)) + + cpld_version_dict = {} + cpld_version_dict.update({'CPLD_B':CPLD_B}) + cpld_version_dict.update({'CPLD_C':CPLD_C}) + cpld_version_dict.update({'CPLD_1':CPLD_1}) + cpld_version_dict.update({'CPLD_2':CPLD_2}) + cpld_version_dict.update({'CPLD_3':CPLD_3}) + cpld_version_dict.update({'CPLD_4':CPLD_4}) + + return cpld_version_dict def get_bios_version(self): """Get BIOS version from SONiC :returns: version string """ - return '0.0.0' + bios_version = 'None' + + p = subprocess.Popen( + ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) + raw_data = str(p.communicate()[0]) + raw_data_list = raw_data.split("\n") + bios_version = raw_data_list[0] if len( + raw_data_list) == 1 else raw_data_list[-2] + + return bios_version def get_onie_version(self): """Get ONiE version from SONiC @@ -57,13 +116,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - + TODO: Need SDK integrated """ return '0.0.0' def get_fpga_version(self): """Get FPGA version from SONiC - :returns: TODO + :returns: version string """ - return '0.0.0' + version = self.__get_register_value(self.fpga_version_path, '0x00') + if version is not 'None': + version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + return str(version) From 7e794afdc202a33eb34b1899d0bd4484a53e5813 Mon Sep 17 00:00:00 2001 From: Pradchaya P Date: Tue, 15 Jan 2019 11:36:52 +0700 Subject: [PATCH 7/7] [device/alibaba] - Implement phalanx/fishbones BCM pcie read version --- .../plugins/fwmgrutil.py | 11 +++++++++-- .../plugins/fwmgrutil.py | 11 +++++++++-- .../plugins/fwmgrutil.py | 11 +++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py index fd64eea5ae6d..32a509202b9c 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -108,9 +108,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - TODO: Need SDK integrated """ - return '0.0.0' + cmd = "sudo bcmcmd 'pciephy fw version'" + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + lines = raw_data.split('\n') + version = lines[0].split(':')[1].strip() + return str(version) def get_fpga_version(self): """Get FPGA version from SONiC diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py index cb24e3b0c450..fcd28b028a96 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py @@ -108,9 +108,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - TODO: Need SDK integrated """ - return '0.0.0' + cmd = "sudo bcmcmd 'pciephy fw version'" + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + lines = raw_data.split('\n') + version = lines[0].split(':')[1].strip() + return str(version) def get_fpga_version(self): """Get FPGA version from SONiC diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py index cb987428acb9..8c7029b32466 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py @@ -116,9 +116,16 @@ def get_onie_version(self): def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string - TODO: Need SDK integrated """ - return '0.0.0' + cmd = "sudo bcmcmd 'pciephy fw version'" + p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err is not '': + return 'None' + else: + lines = raw_data.split('\n') + version = lines[0].split(':')[1].strip() + return str(version) def get_fpga_version(self): """Get FPGA version from SONiC