aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lombard <clombard@linux.ibm.com>2023-08-29 11:23:28 +0200
committerReza Arbab <arbab@linux.ibm.com>2023-09-12 14:22:11 -0500
commitfdf104ea741ee8c0d575c61f75db8b49bbfced2b (patch)
treea547000219509a2f3d0c80962c884af282fde043
parentce16acd4390aba8661b6a9f41d025c25895a8371 (diff)
downloadskiboot-fdf104ea741ee8c0d575c61f75db8b49bbfced2b.zip
skiboot-fdf104ea741ee8c0d575c61f75db8b49bbfced2b.tar.gz
skiboot-fdf104ea741ee8c0d575c61f75db8b49bbfced2b.tar.bz2
core/pldm: Encode state effecter request
PLDM effecters provide a general mechanism for controlling or configuring a state or numeric setting of an entity. The entity state and numeric setting values are written into an effecter. PLDM commands are specified for writing the state or numeric setting to an effecter. Effecters are identified by and accessed using an EffecterID that is unique for each effecter within a given terminus. PLDM State Effecters provide a regular command structure for setting state information in order to change the state of an entity. The SetStateEffecterStates command is used to set the state of one or more effecters within a PLDM State Effecter. 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-platform-requests.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
index 6c01918..5bbdd01 100644
--- a/core/pldm/pldm-platform-requests.c
+++ b/core/pldm/pldm-platform-requests.c
@@ -44,6 +44,88 @@ static void pdr_init_complete(bool success)
pdr_ready = true;
}
+struct set_effecter_state_response {
+ uint8_t completion_code;
+};
+
+/*
+ * Create and send a PLDM request message for SetStateEffecterStates.
+ */
+static int set_state_effecter_states_req(uint16_t effecter_id,
+ set_effecter_state_field *field,
+ bool no_timeout)
+{
+ size_t data_size = PLDM_MSG_SIZE(struct pldm_set_state_effecter_states_req);
+ struct set_effecter_state_response response;
+ size_t response_len, payload_len;
+ struct pldm_tx_data *tx = NULL;
+ void *response_msg;
+ int rc;
+
+ struct pldm_set_state_effecter_states_req states_req = {
+ .effecter_id = effecter_id,
+ .comp_effecter_count = 1
+ };
+
+ /* Encode the state effecter states request */
+ tx = zalloc(sizeof(struct pldm_tx_data) + data_size);
+ if (!tx)
+ return OPAL_NO_MEM;
+ tx->data_size = data_size;
+
+ rc = encode_set_state_effecter_states_req(
+ DEFAULT_INSTANCE_ID,
+ states_req.effecter_id,
+ states_req.comp_effecter_count,
+ field,
+ (struct pldm_msg *)tx->data);
+ if (rc != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Encode SetStateEffecter Error, rc: %d\n",
+ rc);
+ free(tx);
+ return OPAL_PARAMETER;
+ }
+
+ /* Send and get the response message bytes.
+ * It may happen that for some commands, the responder does not
+ * have time to respond.
+ */
+ if (no_timeout) {
+ rc = pldm_mctp_message_tx(tx);
+ if (rc)
+ prlog(PR_ERR, "Failed to send SetStateEffecter request, rc = %d\n", rc);
+ free(tx);
+ return rc;
+ }
+
+ /* 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: SetStateEffecter, rc: %d\n", rc);
+ free(tx);
+ return rc;
+ }
+
+ /* Decode the message */
+ payload_len = response_len - sizeof(struct pldm_msg_hdr);
+
+ rc = decode_set_state_effecter_states_resp(
+ response_msg,
+ payload_len,
+ &response.completion_code);
+ if (rc != PLDM_SUCCESS || response.completion_code != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Decode SetStateEffecter Error, rc: %d, cc: %d\n",
+ rc, response.completion_code);
+ free(tx);
+ free(response_msg);
+ return OPAL_PARAMETER;
+ }
+
+ free(tx);
+ free(response_msg);
+ return OPAL_SUCCESS;
+}
+
struct get_pdr_response {
uint8_t completion_code;
uint32_t next_record_hndl;