[Skiboot] [PATCH v2 7/9] core/pldm/test : pldm platform restart and platform power off self test
Abhishek Singh Tomar
abhishek at linux.ibm.com
Sat May 7 16:36:00 AEST 2022
The patch contains PLDM platform implementation self test for
pldm platform restart and platform power off
The patch test PLDM Platfrm command PLDM_SET_STATE_EFFECTER_STATES
Signed-off-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
---
core/pldm/test/test_pldm-platform.c | 89 +++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/core/pldm/test/test_pldm-platform.c b/core/pldm/test/test_pldm-platform.c
index 05cc53f0..67146a8d 100644
--- a/core/pldm/test/test_pldm-platform.c
+++ b/core/pldm/test/test_pldm-platform.c
@@ -189,6 +189,9 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
uint16_t request_cnt;
uint16_t record_chg_num;
uint32_t record_hndl;
+ uint16_t effecter_id;
+ uint8_t comp_effecter_count;
+ set_effecter_state_field field;
uint8_t format_version, tid, event_class;
size_t event_data_offset;
@@ -237,6 +240,44 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
if (ret != PLDM_SUCCESS)
return ret;
break;
+ case PLDM_SET_STATE_EFFECTER_STATES:
+
+ payload_len = request_len - sizeof(struct pldm_msg_hdr);
+ ret = decode_set_state_effecter_states_req(request_msg, payload_len, &effecter_id,
+ &comp_effecter_count, &field);
+
+ /*
+ * 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 PLDM_SUCCESS;
+ } else
+ return OPAL_PARAMETER;
+ return PLDM_SUCCESS;
case PLDM_PLATFORM_EVENT_MESSAGE:
payload_len = request_len - sizeof(struct pldm_msg_hdr);
@@ -274,6 +315,31 @@ int main(void)
int ret;
+ /*
+ * Attempt to call pldm_platform_restart()
+ * before pldm_platform_init() return error
+ * OPAL_HARDWARE
+ */
+ ret = pldm_platform_restart();
+ printf("pldm_platform_restart ends with %d\n", ret);
+ if (ret != OPAL_HARDWARE) {
+ perror("pldm_platform_restart");
+ return ret;
+ }
+
+
+ /*
+ * Attempt to call pldm_platform_power_off()
+ * before pldm_platform_init() return error
+ * OPAL_HARDWARE
+ */
+ ret = pldm_platform_power_off();
+ printf("pldm_platform_power_off ends with %d\n", ret);
+ if (ret != OPAL_HARDWARE) {
+ perror("pldm_platform_restart");
+ return ret;
+ }
+
/* Inittialize pldm platform */
ret = pldm_platform_init();
printf("pldm_platform_init ends with %d\n", ret);
@@ -283,6 +349,29 @@ int main(void)
}
+ /*
+ * Attempt to call pldm_platform_restart()
+ * after pldm_platform_init() return PLDM_SUCCESS
+ */
+ ret = pldm_platform_restart();
+ printf("pldm_platform_restart ends with %d\n", ret);
+ if (ret != PLDM_SUCCESS) {
+ perror("pldm_platform_restart");
+ return ret;
+ }
+
+
+ /*
+ * Attempt to call pldm_platform_power_off()
+ * after pldm_platform_init() return PLDM_SUCCESS
+ */
+ ret = pldm_platform_power_off();
+ printf("pldm_platform_power_off ends with %d\n", ret);
+ if (ret != PLDM_SUCCESS) {
+ perror("pldm_platform_restart");
+ return ret;
+ }
+
return PLDM_SUCCESS;
}
--
2.34.1
More information about the Skiboot
mailing list