@@ -32,6 +32,74 @@ 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)
+{
+ char request_msg[PKT_SIZE(struct pldm_set_state_effecter_states_req)];
+ size_t response_len, payload_len;
+ void *response_msg;
+ int rc;
+
+ struct pldm_set_state_effecter_states_req states_req = {
+ .effecter_id = effecter_id,
+ .comp_effecter_count = 1
+ };
+
+ struct set_effecter_state_response response;
+
+ /* Encode the state effecter states request */
+ rc = encode_set_state_effecter_states_req(
+ DEFAULT_INSTANCE_ID,
+ states_req.effecter_id,
+ states_req.comp_effecter_count,
+ field,
+ (struct pldm_msg *)request_msg);
+ if (rc != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Encode SetStateEffecter Error (rc: %d)\n",
+ rc);
+ return OPAL_PARAMETER;
+ }
+
+ /* Send and get the response message bytes */
+ rc = pldm_do_request(BMC_EID, request_msg, sizeof(request_msg),
+ &response_msg, &response_len);
+ if (rc) {
+ /* it may happen that for some commands, the responder
+ * does not have time to respond
+ */
+ if (no_timeout && (rc == OPAL_TIMEOUT)) {
+ free(response_msg);
+ return OPAL_SUCCESS;
+ }
+ prlog(PR_ERR, "PLDM: Communication Error (req: SetStateEffecter, rc: %d)\n", rc);
+ return OPAL_PARAMETER;
+ }
+
+ /* 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);
+ return OPAL_PARAMETER;
+ }
+
+ free(response_msg);
+
+ return OPAL_SUCCESS;
+}
+
struct get_pdr_response {
uint8_t completion_code;
uint32_t next_record_hndl;