[Skiboot] [PATCH V2 12/21] core/pldm: Send a system firmware Graceful Restart request

Abhishek SIngh Tomar abhishek at linux.ibm.com
Wed Mar 16 22:42:50 AEDT 2022


On Fri, Mar 04, 2022 at 02:11:45PM +0100, Christophe Lombard wrote:
> Set the state information of the PLDM effecter identified by:
> the entity type (PLDM_ENTITY_SYS_FIRMWARE) and the state set
> PLDM_STATE_SET_SW_TERMINATION_STATUS with the effecter state:
> PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED to request a platform restart.
> 
> Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
Reviewed-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>

> ---
>  core/pldm/pldm-platform-requests.c | 74 ++++++++++++++++++++++++++++++
>  include/pldm.h                     |  5 ++
>  2 files changed, 79 insertions(+)
> 
> diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
> index 725d1a2e..f223121e 100644
> --- a/core/pldm/pldm-platform-requests.c
> +++ b/core/pldm/pldm-platform-requests.c
> @@ -32,6 +32,49 @@ static void pdr_init_complete(bool success)
>  	pdr_ready = true;
>  }
>  
> +/*
> + * Search the matching record and return the effecter id.
> + * PDR type = PLDM_STATE_EFFECTER_PDR
> + */
> +static int find_effecter_id_by_state_set_Id(uint16_t entity_type,
> +					    uint16_t state_set_id,
> +					    uint16_t *effecter_id)
> +{
> +	struct state_effecter_possible_states *possible_states;
> +	struct pldm_state_effecter_pdr *state_effecter_pdr;
> +	const pldm_pdr_record *record = NULL;
> +	uint8_t *outData = NULL;
> +	uint32_t size;
> +
> +	do {
> +		/* Find (first) PDR record by PLDM_STATE_EFFECTER_PDR type
> +		 * if record not NULL, then search will begin from this
> +		 * record's next record
> +		 */
> +		record = pldm_pdr_find_record_by_type(
> +				repo, /* PDR repo handle */
> +				PLDM_STATE_EFFECTER_PDR,
> +				record, /* PDR record handle */
> +				&outData, &size);
> +
> +		if (record) {
> +			state_effecter_pdr = (struct pldm_state_effecter_pdr *) outData;
> +
> +			*effecter_id = le16_to_cpu(state_effecter_pdr->effecter_id);
> +
> +			possible_states = (struct state_effecter_possible_states *)
> +				state_effecter_pdr->possible_states;
> +
> +			if ((le16_to_cpu(state_effecter_pdr->entity_type) == entity_type) &&
> +			    (le16_to_cpu(possible_states->state_set_id) == state_set_id))
> +				return OPAL_SUCCESS;
> +		}
> +
> +	} while (record);
> +
> +	return OPAL_PARAMETER;
> +}
> +
>  struct set_effecter_state_response {
>  	uint8_t completion_code;
>  };
> @@ -102,6 +145,37 @@ static int set_state_effecter_states_req(uint16_t effecter_id,
>  	return OPAL_SUCCESS;
>  }
>  
> +/*
> + * entity_type:  System Firmware
> + * state_set:    Software Termination Status(129)
> + * states:       Graceful Restart Requested(6)
> + */
> +int pldm_platform_restart(void)
> +{
> +	set_effecter_state_field field;
> +	uint16_t effecter_id;
> +	int rc;
> +
> +	if (!pdr_ready)
> +		return OPAL_HARDWARE;
> +
> +	rc = find_effecter_id_by_state_set_Id(
> +				PLDM_ENTITY_SYS_FIRMWARE,
> +				PLDM_STATE_SET_SW_TERMINATION_STATUS,
> +				&effecter_id);
> +	if (rc) {
> +		prlog(PR_ERR, "%s, effecter id not found\n", __func__);
> +		return rc;
> +	}
> +
> +	field.set_request = PLDM_REQUEST_SET;
> +	field.effecter_state = PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED;
> +
> +	prlog(PR_INFO, "sending system firmware Graceful Restart request\n");
> +
> +	return set_state_effecter_states_req(effecter_id, &field, true);
> +}
> +
>  struct get_pdr_response {
>  	uint8_t completion_code;
>  	uint32_t next_record_hndl;
> diff --git a/include/pldm.h b/include/pldm.h
> index d542e0eb..e8f70eb0 100644
> --- a/include/pldm.h
> +++ b/include/pldm.h
> @@ -10,4 +10,9 @@
>   */
>  int pldm_mctp_init(void);
>  
> +/**
> + * Send a system firmware Graceful Restart request
> + */
> +int pldm_platform_restart(void);
> +
>  #endif /* __PLDM_H__ */
> -- 
> 2.35.1
> 
> _______________________________________________
> Skiboot mailing list
> Skiboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot


More information about the Skiboot mailing list