diff mbox series

[V2,13/21] core/pldm: Send a system chassis Off-Soft Graceful request

Message ID 20220304131154.58409-14-clombard@linux.vnet.ibm.com
State Superseded
Headers show
Series Implement MCTP and PLDM features | expand

Commit Message

Christophe Lombard March 4, 2022, 1:11 p.m. UTC
Set the state information of the PLDM effecter identified by:
the entity type (PLDM_ENTITY_SYSTEM_CHASSIS) and the state set
PLDM_STATE_SET_SYSTEM_POWER_STATE with the effecter state:
PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL to request a platform off.

Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
---
 core/pldm/pldm-platform-requests.c | 31 ++++++++++++++++++++++++++++++
 include/pldm.h                     |  5 +++++
 2 files changed, 36 insertions(+)

Comments

Abhishek Singh Tomar March 16, 2022, 12:44 p.m. UTC | #1
On Fri, Mar 04, 2022 at 02:11:46PM +0100, Christophe Lombard wrote:
> Set the state information of the PLDM effecter identified by:
> the entity type (PLDM_ENTITY_SYSTEM_CHASSIS) and the state set
> PLDM_STATE_SET_SYSTEM_POWER_STATE with the effecter state:
> PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL to request a platform off.
> 
> Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Reviewed-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
> ---
>  core/pldm/pldm-platform-requests.c | 31 ++++++++++++++++++++++++++++++
>  include/pldm.h                     |  5 +++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
> index f223121e..b8902309 100644
> --- a/core/pldm/pldm-platform-requests.c
> +++ b/core/pldm/pldm-platform-requests.c
> @@ -145,6 +145,37 @@ static int set_state_effecter_states_req(uint16_t effecter_id,
>  	return OPAL_SUCCESS;
>  }
>  
> +/*
> + * entity_type:  System chassis (main enclosure)
> + * state_set:    System Power State (260)
> + * states:       Off-Soft Graceful(9)
> + */
> +int pldm_platform_power_off(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_SYSTEM_CHASSIS,
> +				PLDM_STATE_SET_SYSTEM_POWER_STATE,
> +				&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_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL;
> +
> +	prlog(PR_INFO, "sending system chassis Off-Soft Graceful request\n");
> +
> +	return set_state_effecter_states_req(effecter_id, &field, true);
> +}
> +
>  /*
>   * entity_type:  System Firmware
>   * state_set:    Software Termination Status(129)
> diff --git a/include/pldm.h b/include/pldm.h
> index e8f70eb0..e1b60f67 100644
> --- a/include/pldm.h
> +++ b/include/pldm.h
> @@ -10,6 +10,11 @@
>   */
>  int pldm_mctp_init(void);
>  
> +/**
> + * Send a system chassis Off-Soft Graceful request
> + */
> +int pldm_platform_power_off(void);
> +
>  /**
>   * Send a system firmware Graceful Restart request
>   */
> -- 
> 2.35.1
> 
> _______________________________________________
> Skiboot mailing list
> Skiboot@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
diff mbox series

Patch

diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
index f223121e..b8902309 100644
--- a/core/pldm/pldm-platform-requests.c
+++ b/core/pldm/pldm-platform-requests.c
@@ -145,6 +145,37 @@  static int set_state_effecter_states_req(uint16_t effecter_id,
 	return OPAL_SUCCESS;
 }
 
+/*
+ * entity_type:  System chassis (main enclosure)
+ * state_set:    System Power State (260)
+ * states:       Off-Soft Graceful(9)
+ */
+int pldm_platform_power_off(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_SYSTEM_CHASSIS,
+				PLDM_STATE_SET_SYSTEM_POWER_STATE,
+				&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_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL;
+
+	prlog(PR_INFO, "sending system chassis Off-Soft Graceful request\n");
+
+	return set_state_effecter_states_req(effecter_id, &field, true);
+}
+
 /*
  * entity_type:  System Firmware
  * state_set:    Software Termination Status(129)
diff --git a/include/pldm.h b/include/pldm.h
index e8f70eb0..e1b60f67 100644
--- a/include/pldm.h
+++ b/include/pldm.h
@@ -10,6 +10,11 @@ 
  */
 int pldm_mctp_init(void);
 
+/**
+ * Send a system chassis Off-Soft Graceful request
+ */
+int pldm_platform_power_off(void);
+
 /**
  * Send a system firmware Graceful Restart request
  */