From patchwork Tue Sep 13 10:27:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1677238 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=gFD1QRZv; 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 4MRfqR74VZz1ync for ; Tue, 13 Sep 2022 20:30:11 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MRfqR6cZkz3cLb for ; Tue, 13 Sep 2022 20:30:11 +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=gFD1QRZv; 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.156.1; helo=mx0a-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=gFD1QRZv; dkim-atps=neutral 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 4MRfmP0Jzhz3bqY for ; Tue, 13 Sep 2022 20:27:32 +1000 (AEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28DA9CIc005959 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=+PJmSs5qLN26aHo58MhZsDbMIKxhYRevrdA81n0ubjk=; b=gFD1QRZv0wojkoEjs1q5a1enASu8SqL/11c0Z+dGHTS8I7xSC1lAzhQ53cjhg0FQWa49 NL92BvjuOTZusEV3+K/1+eVM/KmC2QDHmJ9uULtUx1rz6/4/GGsyqtB00Zo/7L91jeAc Drw4fwYJR6IF9eQAF9o4mGtHf5UuUAMljcQM2e2S/oa/yHBkveoI/Iw9s0Vd6xUU0Asu InUNQLqEJ1vnsjvGxFkKJSsr9vZ2EbUAcsAVI8m276IPQQb7mhcUSQnvs7OnVQiIXUQr Tgbgt2Qk9z7isxKL/IabIdgvtTSQSrlEI2lvG2TEBHspkOZJq49UDRfuN//OD9Z2otEM sw== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jjq7a1sg7-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 (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28DAKcKr029930 for ; Tue, 13 Sep 2022 10:27:28 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma01fra.de.ibm.com with ESMTP id 3jgj78tp3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Sep 2022 10:27:27 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28DARP0f39649568 (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 7BB8411C050 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 5406411C04A 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:13 +0200 Message-Id: <20220913102724.65563-5-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-ORIG-GUID: 4IuILZdZv4B3ULA-7AyT942XoT8WYaMj X-Proofpoint-GUID: 4IuILZdZv4B3ULA-7AyT942XoT8WYaMj 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 clxscore=1015 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 spamscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209130045 Subject: [Skiboot] [PATCH V3 04/15] core/pldm: Decode the GetStateSensorReadings 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 GetStateSensorReadings command can return readings for multiple state sensors (a PLDM State Sensor that returns more than one set of state information is called a composite state sensor). 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 | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index a1a19220..0224ea75 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -577,6 +577,89 @@ static struct pldm_cmd pldm_platform_event_message = { .handler = platform_event_message, }; +struct get_state_sensor_readings_req { + uint16_t sensor_id; + bitfield8_t sensor_rearm; + uint8_t reserved; +}; + +/* + * GetStateSensorReadings (0x21) + * The GetStateSensorReadings command can return readings for multiple + * state sensors (a PLDM State Sensor that returns more than one set of + * state information is called a composite state sensor). + */ +static int platform_get_state_sensor_readings(const struct pldm_rx_data *req) +{ + struct get_state_sensor_readings_req readings_req; + size_t response_length; + char *response_msg; + int rc; + + get_sensor_state_field sensor_state = { + .sensor_op_state = PLDM_SENSOR_UNKNOWN, + .present_state = 0, + .previous_state = 0, + .event_state = 0 + }; + + /* decode GetStateSensorReadings request data */ + rc = decode_get_state_sensor_readings_req( + req->msg, + PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES, + &readings_req.sensor_id, + &readings_req.sensor_rearm, + &readings_req.reserved); + if (rc) { + prlog(PR_ERR, "Failed to decode GetStateSensorReadings request, rc = %d\n", rc); + cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + prlog(PR_DEBUG, "%s - sensor_id: %d, sensor_rearm: %x\n", + __func__, readings_req.sensor_id, + readings_req.sensor_rearm.byte); + + /* send state sensor reading response */ + response_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_state_sensor_readings_resp) + + (sizeof(get_sensor_state_field) * 1); + response_msg = zalloc(response_length); + + rc = encode_get_state_sensor_readings_resp( + req->hdrinf.instance, + PLDM_SUCCESS, + 1, /* sensor count of 1 */ + &sensor_state, + (struct pldm_msg *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetStateSensorReadings response Error, rc: %d\n", rc); + cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + free(response_msg); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_mctp_message_tx(req->source_eid, response_msg, sizeof(response_msg)); + if (rc) { + prlog(PR_ERR, "Failed to send GetStateSensorReadings response, rc = %d\n", rc); + free(response_msg); + return OPAL_HARDWARE; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_get_state_sensor_readings = { + .name = "PLDM_GET_STATE_SENSOR_READINGS", + .pldm_cmd_id = PLDM_GET_STATE_SENSOR_READINGS, + .handler = platform_get_state_sensor_readings, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type;