aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lombard <clombard@linux.ibm.com>2023-08-29 11:23:34 +0200
committerReza Arbab <arbab@linux.ibm.com>2023-09-12 14:22:11 -0500
commit20e0ca75caa69ddd0dce24737eb0196c72871882 (patch)
treea597a8a408f226292a2a6f0cd59579a8834fa6ad
parent86c3ac6109790d2f1f723c75e09b11c3c7fd19e0 (diff)
downloadskiboot-20e0ca75caa69ddd0dce24737eb0196c72871882.zip
skiboot-20e0ca75caa69ddd0dce24737eb0196c72871882.tar.gz
skiboot-20e0ca75caa69ddd0dce24737eb0196c72871882.tar.bz2
core/pldm: Update "bmc-firmware-version" device-tree field
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. Reviewed-by: Abhishek Singh Tomar <abhishek@linux.ibm.com> Signed-off-by: Christophe Lombard <clombard@linux.ibm.com> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
-rw-r--r--core/pldm/pldm-fru-requests.c85
-rw-r--r--core/pldm/pldm.h1
-rw-r--r--include/pldm.h5
3 files changed, 91 insertions, 0 deletions
diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c
index ae1d9fa..ab517e9 100644
--- a/core/pldm/pldm-fru-requests.c
+++ b/core/pldm/pldm-fru-requests.c
@@ -15,6 +15,7 @@ static void *fru_record_table;
static size_t fru_record_length;
static bool fru_ready;
+static char *bmc_version;
static void fru_init_complete(bool success)
{
@@ -33,6 +34,22 @@ static void fru_init_complete(bool success)
fru_ready = true;
}
+int pldm_fru_get_bmc_version(void *bv, int len)
+{
+ if (bv == NULL)
+ return OPAL_PARAMETER;
+
+ if (bmc_version == NULL)
+ return OPAL_PARAMETER;
+
+ if (strlen(bmc_version) > (len + 1))
+ return OPAL_PARAMETER;
+
+ memcpy(bv, bmc_version, strlen(bmc_version) + 1);
+
+ return OPAL_SUCCESS;
+}
+
static int get_fru_record_table_req(void **record_table_data,
size_t *record_table_length)
{
@@ -126,6 +143,74 @@ out:
return rc;
}
+int pldm_fru_dt_add_bmc_version(void)
+{
+ struct pldm_fru_record_data_format *data;
+ struct pldm_fru_record_tlv *tlv;
+ struct dt_node *dt_fw_version;
+ uint8_t *record_table;
+ int rc = OPAL_SUCCESS;
+ size_t record_size;
+
+ if (!fru_ready)
+ return OPAL_HARDWARE;
+
+ if (!fru_record_table)
+ return OPAL_HARDWARE;
+
+ dt_fw_version = dt_find_by_name(dt_root, "ibm,firmware-versions");
+ if (!dt_fw_version)
+ return OPAL_HARDWARE;
+
+ /* retrieve the bmc information with
+ * "FRU Record Set Identifier": 1,
+ * "FRU Record Type": "General(1)"
+ * "FRU Field Type": Version
+ *
+ * we can not know size of the record table got by options
+ * in advance, but it must be less than the source table. So
+ * it's safe to use sizeof the source table.
+ */
+ record_table = zalloc(fru_record_length);
+ if (!record_table)
+ return OPAL_NO_MEM;
+
+ record_size = fru_record_length;
+ get_fru_record_by_option(
+ fru_record_table,
+ fru_record_length,
+ record_table,
+ &record_size,
+ 1,
+ PLDM_FRU_RECORD_TYPE_GENERAL,
+ PLDM_FRU_FIELD_TYPE_VERSION);
+
+ if (record_size == 0) {
+ prlog(PR_ERR, "%s - no FRU type version found\n", __func__);
+ rc = OPAL_PARAMETER;
+ goto out;
+ }
+
+ /* get tlv value */
+ data = (struct pldm_fru_record_data_format *)record_table;
+ tlv = (struct pldm_fru_record_tlv *)data->tlvs;
+ prlog(PR_DEBUG, "%s - value: %s\n", __func__, tlv->value);
+
+ dt_add_property_string(dt_fw_version, "bmc-firmware-version",
+ tlv->value);
+
+ /* store the bmc version */
+ bmc_version = zalloc(tlv->length + 1);
+ if (!bmc_version)
+ rc = OPAL_NO_MEM;
+ else
+ memcpy(bmc_version, tlv->value, tlv->length);
+
+out:
+ free(record_table);
+ return rc;
+}
+
int pldm_fru_init(void)
{
int rc;
diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h
index dbc19ab..59155fb 100644
--- a/core/pldm/pldm.h
+++ b/core/pldm/pldm.h
@@ -52,6 +52,7 @@ int pldm_responder_handle_request(struct pldm_rx_data *rx);
int pldm_responder_init(void);
/* Requester support */
+int pldm_fru_get_bmc_version(void *bv, int len);
int pldm_fru_init(void);
int pldm_bios_find_lid_by_attr_name(const char *name, char **lid);
diff --git a/include/pldm.h b/include/pldm.h
index 55a4e14..3c23dc9 100644
--- a/include/pldm.h
+++ b/include/pldm.h
@@ -31,4 +31,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__ */