From patchwork Tue Aug 29 09:23:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=lcRmwXlK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZhtd2gBHz1yZs for ; Tue, 29 Aug 2023 19:28:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=lcRmwXlK; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhtd1ZBTz3c9G for ; Tue, 29 Aug 2023 19:28:25 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=lcRmwXlK; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=clombard@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RZhns4y2cz3bxH for ; Tue, 29 Aug 2023 19:24:17 +1000 (AEST) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T9Fq6J023238 for ; Tue, 29 Aug 2023 09:24:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=wL2m/Zc5ZqjtUwgVyc2vpuolfYltWrjVDFOhXqjXubU=; b=lcRmwXlKfJorG5p2xLiXXDUA2UwNkO1eBdW+OQaPPFDrvjyWSYLli+gcgHKS50MkpmsD Ux6Exnp5tT/9OxrsDkLrl+TxldrTlosLrXTGF7HjLVCwe5m+8Wlf/b7zn3HGf9g+Z3Zd Eae4BmBj09sy0UZszstjJukRO2Sl84LVemQgWmDdAnyeUNICvnlR6VmHO++w99anm36t wOY0JjvF3Sj9DZGr479SxctwQaIoe1mPnackp45QsIAJwJz6mjrJmgaNmhMUva/CqVfp ALPcSAEpqBJRsk8OhWcw6d5SD7xro+whCJrMmR2ddjCtippdIDJKgmL+OfURUY1wT5Nf Cw== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ssdqgrt3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:15 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37T7BNPR014392 for ; Tue, 29 Aug 2023 09:24:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sqvqn295j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:14 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37T9OCjf21234398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Aug 2023 09:24:12 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3774120040 for ; Tue, 29 Aug 2023 09:24:12 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F385820043 for ; Tue, 29 Aug 2023 09:24:11 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.home (unknown [9.171.88.232]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 29 Aug 2023 09:24:11 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 29 Aug 2023 11:23:59 +0200 Message-ID: <20230829092409.75899-6-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230829092409.75899-1-clombard@linux.ibm.com> References: <20230829092409.75899-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JjCqeIuCumyAqpmC5aZeD_tzXyO5sbB6 X-Proofpoint-ORIG-GUID: JjCqeIuCumyAqpmC5aZeD_tzXyO5sbB6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_06,2023-08-28_04,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 spamscore=0 adultscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V6 05/15] core/pldm: Decode the SetStateEffecterStates request X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The SetStateEffecterStates command is used to set the state of one or more effecters within a PLDM State Effecter. The field comp_effecter_count indicates the number of individual sets of state effecter information that are accessed by this command. The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 117 +++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 9183b097c..1589514ec 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -6,11 +6,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include "pldm.h" @@ -708,6 +710,120 @@ static struct pldm_cmd pldm_platform_get_state_sensor_readings = { .handler = platform_get_state_sensor_readings, }; +#define SOFT_OFF 0x00 +#define SOFT_REBOOT 0x01 +#define CHASSIS_PWR_DOWN 0x00 +#define DEFAULT_CHIP_ID 0 + +/* + * SetStateEffecterStates (0x39) + * The SetStateEffecterStates command is used to set the state of one + * or more effecters within a PLDM State Effecter. + */ +static int platform_set_state_effecter_states_handler(const struct pldm_rx_data *rx) +{ + set_effecter_state_field field[8]; + uint8_t comp_effecter_count; + uint16_t effecter_id; + int rc, i; + + /* decode SetStateEffecterStates request data */ + rc = decode_set_state_effecter_states_req( + rx->msg, + PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES, + &effecter_id, + &comp_effecter_count, + field); + if (rc) { + prlog(PR_ERR, "Failed to decode SetStateEffecterStates request, rc = %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + /* invoke the appropriate callback handler */ + prlog(PR_DEBUG, "%s - effecter_id: %d, comp_effecter_count: %d\n", + __func__, effecter_id, comp_effecter_count); + + for (i = 0; i < comp_effecter_count; i++) { + /* other set_request not supported */ + if (field[i].set_request != PLDM_REQUEST_SET) { + prlog(PR_ERR, "Got invalid set request 0x%x in " + "SetStateEffecterStates request\n", + field[i].set_request); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + + switch (field[i].effecter_state) { + case PLDM_SW_TERM_GRACEFUL_SHUTDOWN_REQUESTED: + case PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL: + prlog(PR_NOTICE, "Soft shutdown requested\n"); + cc_resp(rx, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + if (opal_booting() && platform.cec_power_down) { + prlog(PR_NOTICE, "Host not up, shutting down now\n"); + platform.cec_power_down(CHASSIS_PWR_DOWN); + } else { + opal_queue_msg(OPAL_MSG_SHUTDOWN, + NULL, NULL, + cpu_to_be64(SOFT_OFF)); + } + + break; + + case PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED: + prlog(PR_NOTICE, "Soft reboot requested\n"); + cc_resp(rx, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + if (opal_booting() && platform.cec_reboot) { + prlog(PR_NOTICE, "Host not up, rebooting now\n"); + platform.cec_reboot(); + } else { + opal_queue_msg(OPAL_MSG_SHUTDOWN, + NULL, NULL, + cpu_to_be64(SOFT_REBOOT)); + } + + break; + + case PLDM_STATE_SET_BOOT_RESTART_CAUSE_WARM_RESET: + case PLDM_STATE_SET_BOOT_RESTART_CAUSE_HARD_RESET: + prlog(PR_NOTICE, "OCC reset requested\n"); + cc_resp(rx, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + /* invoke the appropriate callback handler */ + prd_occ_reset(DEFAULT_CHIP_ID); /* FIXME, others chip ? */ + break; + + default: + prlog(PR_ERR, "Got invalid effecter state 0x%x in " + "SetStateEffecterStates request\n", + field[i].effecter_state); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + } + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_set_state_effecter_states = { + .name = "PLDM_SET_STATE_EFFECTER_STATES", + .pldm_cmd_id = PLDM_SET_STATE_EFFECTER_STATES, + .handler = platform_set_state_effecter_states_handler, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -753,6 +869,7 @@ int pldm_responder_init(void) add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); add_cmd(&pldm_platform_type, &pldm_platform_event_message); add_cmd(&pldm_platform_type, &pldm_platform_get_state_sensor_readings); + add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); return OPAL_SUCCESS; }