[Skiboot] [PATCH V4 17/21] core/pldm: Update "bmc-firmware-version" device-tree field

Christophe Lombard clombard at linux.vnet.ibm.com
Thu Apr 14 23:44:00 AEST 2022


Use the GetFruRecordByOptionReq command to retrieve the bmc information
with: "FRU Field Type": Version
      "FRU Record Set Identifier": 1,
      "FRU Record Type": "General(1)"
and update the "bmc-firmware-version" device-tree field.

Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
---
 core/pldm/pldm-fru-requests.c | 36 +++++++++++++++++++++++++++++++++++
 include/pldm.h                |  5 +++++
 2 files changed, 41 insertions(+)

diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c
index 559529c6..eda8f939 100644
--- a/core/pldm/pldm-fru-requests.c
+++ b/core/pldm/pldm-fru-requests.c
@@ -110,3 +110,39 @@ int pldm_fru_get_record_by_option(uint16_t fru_table_handle,
 					    field_type,
 					    fru_structure_data);
 }
+
+int pldm_fru_dt_add_bmc_version(void)
+{
+	struct pldm_fru_record_data_format *record_data;
+	struct variable_field fru_structure_data;
+	struct pldm_fru_record_tlv *record_tlv;
+	struct dt_node *dt_fw_version;
+	int rc;
+
+	dt_fw_version = dt_find_by_name(dt_root, "ibm,firmware-versions");
+	if (!dt_fw_version)
+		return OPAL_SUCCESS;
+
+	/* retrieve the bmc information with
+	 * "FRU Field Type": Version
+	 * "FRU Record Set Identifier": 1,
+	 * "FRU Record Type": "General(1)"
+	 */
+	rc = get_fru_record_by_option_req(0,
+					  1,
+					  PLDM_FRU_RECORD_TYPE_GENERAL,
+					  PLDM_FRU_FIELD_TYPE_VERSION,
+					  &fru_structure_data);
+	if (rc)
+		return rc;
+
+	record_data = (struct pldm_fru_record_data_format *)fru_structure_data.ptr;
+	record_tlv = (struct pldm_fru_record_tlv *)record_data->tlvs;
+	prlog(PR_DEBUG, "%s - value: %s\n", __func__, record_tlv->value);
+
+	dt_add_property_string(dt_fw_version,
+			       "bmc-firmware-version",
+			       record_tlv->value);
+
+	return OPAL_SUCCESS;
+}
diff --git a/include/pldm.h b/include/pldm.h
index d14d6164..c3a549e5 100644
--- a/include/pldm.h
+++ b/include/pldm.h
@@ -25,4 +25,9 @@ int pldm_platform_power_off(void);
  */
 int pldm_platform_restart(void);
 
+/**
+ * Update the firmware version device-tree field
+ */
+int pldm_fru_dt_add_bmc_version(void);
+
 #endif /* __PLDM_H__ */
-- 
2.35.1



More information about the Skiboot mailing list