[Skiboot] [PATCH V3 03/15] core/pldm: Decode the PlatformEventMessage request
Christophe Lombard
clombard at linux.vnet.ibm.com
Tue Sep 13 20:27:12 AEST 2022
PLDM Event Messages are sent as PLDM request messages to the Event Receiver
using the PlatformEventMessage command.
The Event Receiver acknowledges receiving the PLDM Event Message in the
response to this command.
Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
---
core/pldm/pldm-platform-requests.c | 15 ++++
core/pldm/pldm-responder.c | 110 ++++++++++++++++++++++++++++-
core/pldm/pldm.h | 1 +
3 files changed, 125 insertions(+), 1 deletion(-)
diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
index ca66157c..e7c54e65 100644
--- a/core/pldm/pldm-platform-requests.c
+++ b/core/pldm/pldm-platform-requests.c
@@ -390,6 +390,21 @@ static int encode_and_queue_get_pdr_req(struct pldm_pdrs *pdrs)
return rc;
}
+int pldm_platform_reload_pdrs(void)
+{
+ struct pldm_pdrs *pdrs = zalloc(sizeof(struct pldm_pdrs));
+
+ /* destroy current repo and mark repo not ready */
+ pdr_init_complete(false);
+
+ /* make a new PDR repository */
+ pdrs_repo = pldm_pdr_init();
+
+ /* collect all PDrs into a PDR Repository */
+ pdrs->record_hndl = 0;
+ return encode_and_queue_get_pdr_req(pdrs);
+}
+
static int pdrs_init(void)
{
struct pldm_pdrs pdrs;
diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c
index 4e5b0378..a1a19220 100644
--- a/core/pldm/pldm-responder.c
+++ b/core/pldm/pldm-responder.c
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>
#include <debug_descriptor.h>
+#include <pldm/ibm/libpldm/platform_oem_ibm.h>
#include <pldm/libpldm/platform.h>
#include <pldm/libpldm/utils.h>
#include "pldm.h"
@@ -370,7 +371,7 @@ static int base_get_version_handler(const struct pldm_rx_data *req)
return OPAL_HARDWARE;
}
- return OPAL_SUCCESS;
+ return pldm_platform_reload_pdrs();
}
static struct pldm_cmd pldm_base_get_version = {
@@ -470,6 +471,112 @@ static struct pldm_cmd pldm_platform_set_event_receiver = {
.handler = platform_set_event_receiver_handler,
};
+struct event_message_req {
+ uint8_t format_version;
+ uint8_t tid;
+ uint8_t event_class;
+ size_t event_data_offset;
+};
+
+/*
+ * PlatformEventMessage (0x10)
+ * PLDM Event Messages are sent as PLDM request messages to the Event
+ * Receiver using the PlatformEventMessage command.
+ */
+static int platform_event_message(const struct pldm_rx_data *req)
+{
+ char response_msg[PKT_SIZE(struct pldm_platform_event_message_resp)];
+ struct pldm_bios_attribute_update_event_req *request;
+ struct event_message_req message_req;
+ uint8_t *bios_attribute_handles;
+ uint8_t cc = PLDM_SUCCESS;
+ int rc, i;
+
+ /* decode PlatformEventMessage request data */
+ rc = decode_platform_event_message_req(
+ req->msg,
+ sizeof(struct event_message_req),
+ &message_req.format_version,
+ &message_req.tid,
+ &message_req.event_class,
+ &message_req.event_data_offset);
+ if (rc) {
+ prlog(PR_ERR, "Failed to decode PlatformEventMessage request, rc = %d\n", rc);
+ cc_resp(req, req->hdrinf.pldm_type,
+ req->hdrinf.command, PLDM_ERROR);
+ return OPAL_INTERNAL_ERROR;
+ }
+
+ prlog(PR_DEBUG, "%s - format_version: %d, "
+ "tid: %d "
+ "event_class: %d "
+ "event_data_offset: 0x%lx\n",
+ __func__,
+ message_req.format_version,
+ message_req.tid,
+ message_req.event_class,
+ message_req.event_data_offset);
+
+ /* we don't support any other event than the PDR Repo Changed event */
+ if ((message_req.event_class != PLDM_PDR_REPOSITORY_CHG_EVENT) &&
+ (message_req.event_class != PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE)) {
+ prlog(PR_ERR, "%s - Invalid event class %d in platform event handler\n",
+ __func__, message_req.event_class);
+ cc = PLDM_ERROR;
+ }
+
+ rc = encode_platform_event_message_resp(
+ req->hdrinf.instance,
+ cc,
+ PLDM_EVENT_NO_LOGGING,
+ (struct pldm_msg *)response_msg);
+ if (rc != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc);
+ cc_resp(req, req->hdrinf.pldm_type,
+ req->hdrinf.command, PLDM_ERROR);
+ return OPAL_PARAMETER;
+ }
+
+ /* send PLDM message over MCTP */
+ rc = pldm_mctp_message_tx(req->source_eid, response_msg, sizeof(response_msg));
+ if (rc) {
+ prlog(PR_ERR, "Failed to send PlatformEventMessage response, rc = %d\n", rc);
+ return OPAL_HARDWARE;
+ }
+
+ /* invoke the appropriate callback handler */
+ if (message_req.event_class == PLDM_PDR_REPOSITORY_CHG_EVENT)
+ return pldm_platform_reload_pdrs();
+
+ /* When the attribute value changes for any BIOS attribute, then
+ * PlatformEventMessage command with OEM event type
+ * PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE is send to
+ * host with the list of BIOS attribute handles.
+ */
+ if (message_req.event_class == PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE) {
+ request = (struct pldm_bios_attribute_update_event_req *)req->msg->payload;
+ bios_attribute_handles = (uint8_t *)request->bios_attribute_handles;
+
+ prlog(PR_DEBUG, "%s - OEM_EVENT_BIOS_ATTRIBUTE_UPDATE, handles: %d\n",
+ __func__, request->num_handles);
+
+ /* list of BIOS attribute handles */
+ for (i = 0; i < request->num_handles; i++) {
+ prlog(PR_DEBUG, "%s - OEM_EVENT_BIOS_ATTRIBUTE_UPDATE: handle(%d): %d\n",
+ __func__, i, *bios_attribute_handles);
+ bios_attribute_handles += sizeof(uint16_t);
+ }
+ }
+
+ return OPAL_SUCCESS;
+}
+
+static struct pldm_cmd pldm_platform_event_message = {
+ .name = "PLDM_PLATFORM_EVENT_MESSAGE",
+ .pldm_cmd_id = PLDM_PLATFORM_EVENT_MESSAGE,
+ .handler = platform_event_message,
+};
+
int pldm_responder_handle_request(struct pldm_rx_data *rx)
{
const struct pldm_type *type;
@@ -513,6 +620,7 @@ int pldm_responder_init(void)
/* Register platform commands we'll respond to - DSP0248 */
add_type(&pldm_platform_type);
add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver);
+ add_cmd(&pldm_platform_type, &pldm_platform_event_message);
return OPAL_SUCCESS;
}
diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h
index 8c7d79af..688b767c 100644
--- a/core/pldm/pldm.h
+++ b/core/pldm/pldm.h
@@ -69,6 +69,7 @@ int pldm_bios_init(void);
uint8_t pldm_base_get_bmc_tid(void);
int pldm_base_get_tid_req(void);
+int pldm_platform_reload_pdrs(void);
int pldm_platform_init(void);
void pldm_platform_exit(void);
--
2.37.3
More information about the Skiboot
mailing list