[Skiboot] [PATCH v3 7/9] core/pldm/test : Implement pldm platform restart and power off request test

Abhishek Singh Tomar abhishek at linux.ibm.com
Wed May 18 17:43:02 AEST 2022


The patch contains test for platform restart and platform
power off requests using PLDM Platform command
PLDM_SET_STATE_EFFECTER_STATES

Signed-off-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
---
 core/pldm/test/test-pldm-platform.c | 88 +++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/core/pldm/test/test-pldm-platform.c b/core/pldm/test/test-pldm-platform.c
index 8c852ad7..8b2e583a 100644
--- a/core/pldm/test/test-pldm-platform.c
+++ b/core/pldm/test/test-pldm-platform.c
@@ -189,6 +189,10 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
 	uint32_t record_hndl;
 	uint8_t format_version, tid, event_class;
 	size_t event_data_offset;
+	uint16_t effecter_id;
+	uint8_t comp_effecter_count;
+	set_effecter_state_field field;
+
 
 /* check pldm command received and reply with appropriate pldm response message */
 	switch (((struct pldm_msg *)request_msg)->hdr.command) {
@@ -269,6 +273,45 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
 
 		return PLDM_SUCCESS;
 
+	case PLDM_SET_STATE_EFFECTER_STATES:
+		payload_len = request_len - sizeof(struct pldm_msg_hdr);
+		rc = decode_set_state_effecter_states_req(request_msg, payload_len, &effecter_id,
+				&comp_effecter_count, &field);
+		if (rc != PLDM_SUCCESS)
+			return OPAL_PARAMETER;
+
+		/*
+		 * Test if request received from same effecter id passed
+		 * and also check field struct same as expected
+		 */
+		if (
+				(
+				 effecter_id == effecter_test_1.effecter_id &&
+				 field.effecter_state ==
+				 possible_states_effecter_1_test.states->byte &&
+				 field.set_request == PLDM_REQUEST_SET &&
+				 field.effecter_state == PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED
+				 ) ||
+				(
+				 effecter_id == effecter_test_2.effecter_id &&
+				 field.effecter_state ==
+				 possible_states_effecter_2_test.states->byte &&
+				 field.set_request == PLDM_REQUEST_SET &&
+				 field.effecter_state ==
+				 PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL
+				 )
+				) {
+			/*
+			 * BMC doesn't answer for these specific effecter states
+			 * (PLDM_SW_TERM_GRACEFUL_RESTART and PLDM_STATE_SET_SYS_POWER_STATE_OFF)
+			 * hence *response len = 0
+			 */
+			*response_len = 0;
+			return OPAL_SUCCESS;
+		} else
+			return OPAL_PARAMETER;
+		return OPAL_SUCCESS;
+
 	default:
 		return OPAL_PARAMETER;
 
@@ -283,6 +326,32 @@ int main(void)
 {
 	int rc;
 
+	/*
+	 * Attempt to call pldm_platform_restart()
+	 * before pldm_platform_init() return error
+	 * OPAL_HARDWARE
+	 */
+	rc = pldm_platform_restart();
+	if (rc != OPAL_HARDWARE) {
+		printf("PLDM_TEST failed : pldm_platform_restart",
+				" called before pldm_platform_init",
+				" expected=%d received=%d\n", OPAL_HARDWARE, rc);
+		return OPAL_PARAMETER;
+	}
+
+	/*
+	 * Attempt to call pldm_platform_power_off()
+	 * before pldm_platform_init() return error
+	 * OPAL_HARDWARE
+	 */
+	rc = pldm_platform_power_off();
+	if (rc != OPAL_HARDWARE) {
+		printf("PLDM_TEST failed : pldm_platform_power_off",
+				" called before pldm_platform_init",
+				" expected=%d received=%d\n", OPAL_HARDWARE, rc);
+		return OPAL_PARAMETER;
+	}
+
 
 	/* Inittialize pldm platform */
 	rc = pldm_platform_init();
@@ -291,6 +360,25 @@ int main(void)
 		return rc;
 	}
 
+	/*
+	 * Attempt to call pldm_platform_restart()
+	 * after pldm_platform_init() return PLDM_SUCCESS
+	 */
+	rc = pldm_platform_restart();
+	if (rc != PLDM_SUCCESS) {
+		printf("PLDM_TEST failed : pldm_platform_restart ends with %d\n", rc);
+		return rc;
+	}
+
+	/*
+	 * Attempt to call pldm_platform_power_off()
+	 * after pldm_platform_init() return PLDM_SUCCESS
+	 */
+	rc = pldm_platform_power_off();
+	if (rc != PLDM_SUCCESS) {
+		printf("PLDM_TEST failed : pldm_platform_power_off ends with %d\n", rc);
+		return rc;
+	}
 
 	return PLDM_SUCCESS;
 }
-- 
2.34.1



More information about the Skiboot mailing list