From patchwork Tue Sep 13 10:27:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1677236 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=112.213.38.117; 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=SXlapiSi; dkim-atps=neutral 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 (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MRfqC5qjDz1ynm for ; Tue, 13 Sep 2022 20:29:59 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MRfqC5KLkz3cDb for ; Tue, 13 Sep 2022 20:29:59 +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=SXlapiSi; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=clombard@linux.vnet.ibm.com; receiver=) 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=SXlapiSi; dkim-atps=neutral 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 4MRfmN343bz3bVB for ; Tue, 13 Sep 2022 20:27:32 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28D9p6Lq002793 for ; Tue, 13 Sep 2022 10:27:30 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=dyEaSwr2QgJc5r086tt1zXjST1KiTCxs1lBxMKoKksc=; b=SXlapiSi030ny85QVpiypO9lwAvKi3w2ugh10L7D4ibdWj2hWZ5hha+91HXPMach4Y3Q VFYmLlGE1dqsJ995qbb9p3ezJTLUJXJk52jrUVtv1Sk33DUMa8Oh04eYOQNNTpm4Ddzu DWMQUhuQFADnza9aV1LvpeRuBDIpdE/g/0iZk5HqVo0JJIFeIShtQuZII1boimWeyd0r YIr02vPytPzpU1lTdArC90Ix8hd0emNG9wfgUk6Y+AIPqJIiDrVpJk+dZUUfTa0D8wx+ ptxhhQEzQD1eynBBrcx3CUlXkT0v2cCtLxNdr1+pmz7Izi8oRx0ip+ZhkHvi5G65Te+X UA== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jjmjay1p7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Sep 2022 10:27:30 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28DAKrx9001416 for ; Tue, 13 Sep 2022 10:27:28 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 3jgj78tpt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Sep 2022 10:27:28 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28DARPpE36700420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 13 Sep 2022 10:27:25 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5AD311C050 for ; Tue, 13 Sep 2022 10:27:25 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E8F711C04A for ; Tue, 13 Sep 2022 10:27:25 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.ibm.com.com (unknown [9.171.35.136]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 13 Sep 2022 10:27:25 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 13 Sep 2022 12:27:14 +0200 Message-Id: <20220913102724.65563-6-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913102724.65563-1-clombard@linux.vnet.ibm.com> References: <20220913102724.65563-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GcStyGSiNRyK8rYgX0R7wG1zc5FibDtO X-Proofpoint-ORIG-GUID: GcStyGSiNRyK8rYgX0R7wG1zc5FibDtO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-13_03,2022-09-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209130045 Subject: [Skiboot] [PATCH V3 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 | 130 +++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 0224ea75..bbfd167d 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include #include #include "pldm.h" @@ -660,6 +662,132 @@ 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 + +struct effecter_states_req { + uint16_t effecter_id; + uint8_t comp_effecter_count; + set_effecter_state_field field[8]; +}; + +/* + * 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 *req) +{ + struct effecter_states_req states_req; + set_effecter_state_field *field; + int rc, i; + + /* decode SetStateEffecterStates request data */ + rc = decode_set_state_effecter_states_req( + req->msg, + PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES, + &states_req.effecter_id, + &states_req.comp_effecter_count, + states_req.field); + if (rc) { + prlog(PR_ERR, "Failed to decode SetStateEffecterStates request, rc = %d\n", rc); + cc_resp(req, req->hdrinf.pldm_type, + req->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__, + states_req.effecter_id, + states_req.comp_effecter_count); + + for (i = 0; i < states_req.comp_effecter_count; i++) { + field = states_req.field; + + /* other set_request not supported */ + if (field->set_request != PLDM_REQUEST_SET) { + prlog(PR_ERR, "Got invalid set request 0x%x in " + "SetStateEffecterStates request\n", + field->set_request); + cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + + switch (field->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(req, 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(req, 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(req, 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->effecter_state); + cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + + /* next */ + field++; + } + + 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; @@ -704,6 +832,8 @@ int pldm_responder_init(void) add_type(&pldm_platform_type); 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; }