From patchwork Fri Jul 21 09:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1810811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) 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=CG3XemUw; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R6kL63K5Hz1yYc for ; Fri, 21 Jul 2023 19:10:38 +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=CG3XemUw; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4R6kL628F3z3dGf for ; Fri, 21 Jul 2023 19:10:38 +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=CG3XemUw; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=clombard@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 4R6kGT6TFjz3cWk for ; Fri, 21 Jul 2023 19:07:29 +1000 (AEST) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36L93BCW008911 for ; Fri, 21 Jul 2023 09:07:28 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=6uC6HmkAqya6sb2ue8TumjSf5ILGjHWopQzMUM8kmMw=; b=CG3XemUw2I5roS2Ob3s8nWreLUoNTeh7c+C/SafAkguy4qu/oRzYt/zPBQaJiek8tbYZ 6MOVXwntpJlDKrCCoKpk4FmAVrHiME0rLDK6Sdp+tNsr87jeKl5inuJyIZ4V7A/BjTc6 GGUzENlbDym6Mnj9umWP0O/H90hUpXu/anBrK7atQbiDOc5MvrHGYFHuqVWiU9M7kmtg 4osaYmY9cb8I9lD0PoHGVfnAZQr01Vqu78bJiQni8ugG4NW1lGvD76vhJdLuj6acNbYk ZNx91gTNgal7SxHgD4RsgjG27QYOcOLqoO/t2Vg+/WyU6UK3dtMSnKLAAROPokNm5Fyd IQ== 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 3rypxsgc8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 09:07:27 +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 36L8f7ZX029141 for ; Fri, 21 Jul 2023 09:07:26 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv6smw7u2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 09:07:26 +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 36L97O6q26083906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 21 Jul 2023 09:07:24 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72B5820071 for ; Fri, 21 Jul 2023 09:07:24 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3839A20065 for ; Fri, 21 Jul 2023 09:07:24 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.ibm.com.com (unknown [9.179.31.149]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Fri, 21 Jul 2023 09:07:24 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 21 Jul 2023 11:07:11 +0200 Message-ID: <20230721090721.26050-6-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230721090721.26050-1-clombard@linux.ibm.com> References: <20230721090721.26050-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RBSEzEQIIPsUc51RVyZvK6NKzh_kt_gx X-Proofpoint-ORIG-GUID: RBSEzEQIIPsUc51RVyZvK6NKzh_kt_gx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-21_05,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210081 Subject: [Skiboot] [PATCH V5 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 9183b097..1589514e 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; }