From patchwork Tue Aug 29 09:23:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827193 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=VNSTeCE1; 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 4RZhvW0RC2z1yZs for ; Tue, 29 Aug 2023 19:29: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=VNSTeCE1; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhvV6WMtz3c4L for ; Tue, 29 Aug 2023 19:29:10 +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=VNSTeCE1; 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 4RZhnv3QHZz30fk for ; Tue, 29 Aug 2023 19:24:19 +1000 (AEST) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T9DtTM004111 for ; Tue, 29 Aug 2023 09:24:17 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=FJMAXFZ1Uy9NxV8L8OPIwZQ5mRXtUSoz/5DH0ROQqg0=; b=VNSTeCE1oKrBj9ufKbBGyFXxNJ/LHfRCMSSCRu+yb5wnvpJBhgIHMlMoJYSvCM1TGBV+ 7qGhE7b1o7PPUjyd7NDP8ZMC18VwLDaee2jFPTd0Z/tFf/ZjQ7v2bu7YIap6tlQE4s70 WD8B2elqT0ItwY0OeOPvpqREVbOf7LgsAnoJmLHA7XikGyVEv1hM3/Z8UpKKHFdoBof8 PZJ0Y3R0BL6t0GH2pZa8x20ygJlQzma8e+wbtDRKRiqIy679UN8ogc7yfJ0+c5SZ6mQN V16pGDjokx2jb98tfokv2/vtOQwBIfGaEIE7B559CPDMVN6/B9a9fL90QnOJWIbxshaf fQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sr87hqh1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:17 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37T9HkRO020543 for ; Tue, 29 Aug 2023 09:24:16 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sqv3yafk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:16 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37T9OEig8651326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Aug 2023 09:24:14 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D0802004B for ; Tue, 29 Aug 2023 09:24:11 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4530A20040 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:57 +0200 Message-ID: <20230829092409.75899-4-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-ORIG-GUID: pmRTDn19mjC5rH4AsLxW0cMo6IG_Mg8J X-Proofpoint-GUID: pmRTDn19mjC5rH4AsLxW0cMo6IG_Mg8J 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 mlxlogscore=999 priorityscore=1501 clxscore=1015 impostorscore=0 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V6 03/15] core/pldm: Decode the PlatformEventMessage 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" PLDM Event Messages are sent as PLDM request messages to the Event Receiver using the PlatformEventMessage command. The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/pldm-platform-requests.c | 5 ++ core/pldm/pldm-responder.c | 118 ++++++++++++++++++++++++++++- core/pldm/pldm.h | 1 + 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c index c506bd4fc..568ed2323 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -436,6 +436,11 @@ static int pldm_platform_load_pdrs(void) return encode_and_queue_get_pdr_req(pdrs); } +int pldm_platform_reload_pdrs(void) +{ + return pldm_platform_load_pdrs(); +} + static int pdrs_init(void) { int rc; diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 656c38c0f..19164a6b7 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "pldm.h" @@ -418,7 +419,9 @@ static int base_get_version_handler(const struct pldm_rx_data *rx) } free(tx); - return OPAL_SUCCESS; + + /* BMC has certainly rebooted, so reload the PDRs */ + return pldm_platform_reload_pdrs(); } static struct pldm_cmd pldm_base_get_version = { @@ -510,6 +513,118 @@ static struct pldm_cmd pldm_platform_set_event_receiver = { .handler = platform_set_event_receiver_handler, }; +/* + * PlatformEventMessage (0x10) + * PLDM Event Messages are sent as PLDM request messages to the Event + * Receiver using the PlatformEventMessage command. + */ +static int platform_event_message(const struct pldm_rx_data *rx) +{ + size_t data_size = PLDM_MSG_SIZE(struct pldm_platform_event_message_resp); + struct pldm_bios_attribute_update_event_req *request; + uint8_t format_version, tid, event_class; + uint8_t *bios_attribute_handles; + uint8_t cc = PLDM_SUCCESS; + size_t event_data_offset; + struct pldm_tx_data *tx; + int rc, i; + + /* decode PlatformEventMessage request data */ + rc = decode_platform_event_message_req( + rx->msg, + sizeof(struct pldm_platform_event_message_req), + &format_version, + &tid, + &event_class, + &event_data_offset); + if (rc) { + prlog(PR_ERR, "Failed to decode PlatformEventMessage request, rc = %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + prlog(PR_DEBUG, "%s - format_version: %d, " + "tid: %d " + "event_class: %d " + "event_data: 0x%lx\n", + __func__, + format_version, tid, + event_class, event_data_offset); + + /* we don't support any other event than the PDR Repo Changed event */ + if ((event_class != PLDM_PDR_REPOSITORY_CHG_EVENT) && + (event_class != PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE)) { + prlog(PR_ERR, "%s - Invalid event class %d in platform event handler\n", + __func__, event_class); + cc = PLDM_ERROR; + } + + /* Encode the platform event request */ + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size; + tx->tag_owner = true; + tx->msg_tag = rx->msg_tag; + + rc = encode_platform_event_message_resp( + rx->hdrinf.instance, + cc, + PLDM_EVENT_NO_LOGGING, + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + free(tx); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_mctp_message_tx(tx); + if (rc) { + prlog(PR_ERR, "Failed to send PlatformEventMessage response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + /* invoke the appropriate callback handler */ + if (event_class == PLDM_PDR_REPOSITORY_CHG_EVENT) { + free(tx); + return pldm_platform_reload_pdrs(); + } + + /* When the attribute value changes for any BIOS attribute, then + * PlatformEventMessage command with OEM event type + * PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE is send to + * host with the list of BIOS attribute handles. + */ + if (event_class == PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE) { + request = (struct pldm_bios_attribute_update_event_req *)rx->msg->payload; + bios_attribute_handles = (uint8_t *)request->bios_attribute_handles; + + prlog(PR_DEBUG, "%s - OEM_EVENT_BIOS_ATTRIBUTE_UPDATE, handles: %d\n", + __func__, request->num_handles); + + /* list of BIOS attribute handles */ + for (i = 0; i < request->num_handles; i++) { + prlog(PR_DEBUG, "%s - OEM_EVENT_BIOS_ATTRIBUTE_UPDATE: handle(%d): %d\n", + __func__, i, *bios_attribute_handles); + bios_attribute_handles += sizeof(uint16_t); + } + } + + free(tx); + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_event_message = { + .name = "PLDM_PLATFORM_EVENT_MESSAGE", + .pldm_cmd_id = PLDM_PLATFORM_EVENT_MESSAGE, + .handler = platform_event_message, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -553,6 +668,7 @@ int pldm_responder_init(void) /* Register platform commands we'll respond to - DSP0248 */ add_type(&pldm_platform_type); add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); + add_cmd(&pldm_platform_type, &pldm_platform_event_message); return OPAL_SUCCESS; } diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index b0c756000..f4e1617ec 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -74,6 +74,7 @@ int pldm_bios_init(void); uint8_t pldm_base_get_bmc_tid(void); int pldm_base_get_tid_req(void); +int pldm_platform_reload_pdrs(void); int pldm_platform_init(void); void pldm_platform_exit(void);