aboutsummaryrefslogtreecommitdiff
path: root/core/pldm/pldm-base-requests.c
diff options
context:
space:
mode:
authorChristophe Lombard <clombard@linux.ibm.com>2023-08-29 11:23:27 +0200
committerReza Arbab <arbab@linux.ibm.com>2023-09-12 14:22:11 -0500
commitce16acd4390aba8661b6a9f41d025c25895a8371 (patch)
treef2548286e3fca2a0690582b319a851a527e6f635 /core/pldm/pldm-base-requests.c
parent819a4145a85f05c465899d5777d8f94dc3619052 (diff)
downloadskiboot-ce16acd4390aba8661b6a9f41d025c25895a8371.zip
skiboot-ce16acd4390aba8661b6a9f41d025c25895a8371.tar.gz
skiboot-ce16acd4390aba8661b6a9f41d025c25895a8371.tar.bz2
core/pldm: PLDM for Platform Monitoring and Control Specification
This specification defines the functions and data structures used for discovering, describing, initializing, and accessing sensors and effecters within the management controllers and management devices of a platform management subsystem using PLDM messaging. A PDR (Platform Descriptor Record) is a set of data that is used to provide semantic information about sensors, effecters, monitored or controller entities, and functions and services within a PLDM implementation. PDRs are mostly used to support PLDM monitoring and control and platform events. The PDRs for a PLDM subsystem are collected into a single, central PDR Repository. A central repository provides a single place from which PDR information can be retrieved. The GetPDR command is used to retrieve individual PDRs from a PDR Repository. The record is identified by the PDR recordHandle value that is passed in the request. The patch dump all the PDRs within a PDR Repository. 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>
Diffstat (limited to 'core/pldm/pldm-base-requests.c')
-rw-r--r--core/pldm/pldm-base-requests.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/core/pldm/pldm-base-requests.c b/core/pldm/pldm-base-requests.c
new file mode 100644
index 0000000..d898427
--- /dev/null
+++ b/core/pldm/pldm-base-requests.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+// Copyright 2022 IBM Corp.
+
+#define pr_fmt(fmt) "PLDM: " fmt
+
+#include <cpu.h>
+#include <opal.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <libpldm/base.h>
+#include "pldm.h"
+
+static uint8_t bmc_tid = -1;
+
+uint8_t pldm_base_get_bmc_tid(void)
+{
+ return bmc_tid;
+}
+
+/*
+ * Create a PLDM request message for GetTID.
+ */
+int pldm_base_get_tid_req(void)
+{
+ size_t data_size = PLDM_MSG_SIZE(0); /* the command doesn't have a message payload */
+ size_t response_len, payload_len;
+ struct pldm_tx_data *tx = NULL;
+ void *response_msg;
+ int rc;
+
+ struct pldm_get_tid_resp response;
+
+ /* Encode the get tid request */
+ tx = zalloc(sizeof(struct pldm_tx_data) + data_size);
+ if (!tx)
+ return OPAL_NO_MEM;
+ tx->data_size = data_size;
+
+ rc = encode_get_tid_req(DEFAULT_INSTANCE_ID,
+ (struct pldm_msg *)tx->data);
+ if (rc != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Encode GetTID Error, rc: %d\n", rc);
+ free(tx);
+ return OPAL_PARAMETER;
+ }
+
+ /* Send and get the response message bytes */
+ rc = pldm_requester_queue_and_wait(tx, &response_msg, &response_len);
+ if (rc) {
+ prlog(PR_ERR, "Communication Error, req: GetTID, rc: %d\n", rc);
+ free(tx);
+ return rc;
+ }
+
+ /* Decode the message */
+ payload_len = response_len - sizeof(struct pldm_msg_hdr);
+
+ rc = decode_get_tid_resp(response_msg, payload_len,
+ &response.completion_code,
+ &response.tid);
+ if ((rc != PLDM_SUCCESS) || (response.completion_code != PLDM_SUCCESS)) {
+ prlog(PR_ERR, "Decode GetTID Error, rc: %d, cc: %d\n",
+ rc, response.completion_code);
+ free(tx);
+ free(response_msg);
+ return OPAL_PARAMETER;
+ }
+
+ prlog(PR_INFO, "BMC's TID is %d\n", response.tid);
+ bmc_tid = response.tid;
+ free(tx);
+ free(response_msg);
+
+ return OPAL_SUCCESS;
+}