diff mbox series

[V3,17/21] core/pldm: Update "bmc-firmware-version" device-tree field

Message ID 20220318143619.83489-18-clombard@linux.vnet.ibm.com
State Superseded
Headers show
Series Implement MCTP and PLDM features | expand

Commit Message

Christophe Lombard March 18, 2022, 2:36 p.m. UTC
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@linux.vnet.ibm.com>
---
 core/pldm/pldm-fru-requests.c | 36 +++++++++++++++++++++++++++++++++++
 include/pldm.h                |  5 +++++
 2 files changed, 41 insertions(+)
diff mbox series

Patch

diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c
index a2665c41..b4111c94 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 e1b60f67..aa7ea9c4 100644
--- a/include/pldm.h
+++ b/include/pldm.h
@@ -20,4 +20,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__ */