From patchwork Tue Jun 20 15:00:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1797420 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=QS/hWuQY; 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 4QlqkF4gM8z20Xf for ; Wed, 21 Jun 2023 01:07:33 +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=QS/hWuQY; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4QlqkF0c4Vz3dH4 for ; Wed, 21 Jun 2023 01:07:33 +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=QS/hWuQY; 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 4QlqfZ13f8z3cgP for ; Wed, 21 Jun 2023 01:04:21 +1000 (AEST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35KEtOxq028691 for ; Tue, 20 Jun 2023 15:04:20 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=q3Fy2Hwif6tbFxMTyo+iRCeu1FCtzcw8M/Z8GfYRqNs=; b=QS/hWuQYp+XFEx1L5q6pltKjZhF2BWTGTLnYZSv7UFlZuWmAYMu9ffo0fbu0UFju63H/ UCMgOtq0lOuoyfZ0dtNDBJ/Q6a7WDOF4rF7vjCqYpZUtvPspOvvMz8hV+qpM+/Tr3EWM NNdFmiwSmNLg0OyXTfuR5/anioN9c8FlNb8zPS4dSoglYryw22KyrquHaQdyilMfXm4V J2FEDfzsTNXbNnAPqt9w/S+H5+T1reH+LtVoU7oOai3WxWIefIh7dVJXWK3JnrElx8Pv duJ7nkx7y3hizwDWUEJSbH0wKk77cjEhHwfai3Jw1AlA8c+wDCIdEyp0QlDF5RkVuSRR RQ== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rbea6g5kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 20 Jun 2023 15:04:15 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35K3KGac029809 for ; Tue, 20 Jun 2023 15:01:05 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3r94f5a51s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 20 Jun 2023 15:01:05 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35KF13b224052082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 20 Jun 2023 15:01:03 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 219B420043 for ; Tue, 20 Jun 2023 15:01:03 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0371E20049 for ; Tue, 20 Jun 2023 15:01:03 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.biot.fr.ibm.com (unknown [9.144.62.191]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 20 Jun 2023 15:01:02 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 20 Jun 2023 17:00:53 +0200 Message-ID: <20230620150101.88802-8-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620150101.88802-1-clombard@linux.ibm.com> References: <20230620150101.88802-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jJMb-EfB2Yx_jFTpeqdVeHGcP-nzJEhd X-Proofpoint-GUID: jJMb-EfB2Yx_jFTpeqdVeHGcP-nzJEhd 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-06-20_10,2023-06-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306200136 Subject: [Skiboot] [PATCH V4 07/15] core/pldm: Encode PLDM PDR Repository Change eventData 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" Encode the platform PDR repository change event message request that tells the BMC that a specific PDR entry has changed. Signed-off-by: Christophe Lombard --- core/pldm/pldm-platform-requests.c | 124 +++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c index dcf77823..141ffe96 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -258,6 +258,130 @@ int pldm_platform_restart(void) return set_state_effecter_states_req(effecter_id, &field, true); } +static int send_repository_changed_event(uint32_t num_changed_pdrs, + uint32_t *record_handle) +{ + size_t actual_change_records_size = 0; + uint8_t number_of_change_entries[1]; + size_t max_change_records_size = 0; + size_t response_len, payload_len; + uint8_t event_data_operation[1]; + uint32_t *change_entries[1]; + uint8_t *event_data = NULL; + struct pldm_tx_data *tx; + void *response_msg; + size_t data_size; + int rc, i; + + struct pldm_platform_event_message_req event_message_req = { + .format_version = PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION, + .tid = HOST_TID, + .event_class = PLDM_PDR_REPOSITORY_CHG_EVENT, + }; + + struct pldm_platform_event_message_resp response; + + prlog(PR_DEBUG, "%s - num_changed_pdrs: %d\n", __func__, num_changed_pdrs); + + if (num_changed_pdrs == 0) + return OPAL_PARAMETER; + + /* encode the platform change event data */ + event_data_operation[0] = PLDM_RECORDS_ADDED; + number_of_change_entries[0] = num_changed_pdrs; + change_entries[0] = record_handle; + + /* + * The first time around this loop, event_data is nullptr which + * instructs the encoder to not actually do the encoding, but + * rather fill out actual_change_records_size with the correct + * size, stop and return PLDM_SUCCESS. Then we allocate the + * proper amount of memory and call the encoder again, which + * will cause it to actually encode the message. + */ + for (i = 0; i < 2; i++) { + rc = encode_pldm_pdr_repository_chg_event_data( + FORMAT_IS_PDR_HANDLES, + 1, /* only one change record (RECORDS_ADDED) */ + event_data_operation, + number_of_change_entries, + (const uint32_t * const*)change_entries, + (struct pldm_pdr_repository_chg_event_data *)event_data, + &actual_change_records_size, + max_change_records_size); + if (rc) { + prlog(PR_ERR, "Encode PldmPdrRepositoryChgEventData Error, rc: %d\n", rc); + return OPAL_PARAMETER; + } + + if (event_data == NULL) { + max_change_records_size = actual_change_records_size; + event_data = zalloc(max_change_records_size); + if (!event_data) { + prlog(PR_ERR, "failed to allocate event data (size: 0x%lx)\n", max_change_records_size); + return OPAL_NO_MEM; + } + } + } + + /* Send the event request */ + payload_len = PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + max_change_records_size; + + data_size = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_platform_event_message_req) + + max_change_records_size; + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size - 1; + + /* Encode the platform event message request */ + rc = encode_platform_event_message_req( + DEFAULT_INSTANCE_ID, + event_message_req.format_version, + event_message_req.tid, + event_message_req.event_class, + (const uint8_t *)event_data, + max_change_records_size, + (struct pldm_msg *)tx->data, + payload_len); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc); + free(event_data); + free(tx); + return OPAL_PARAMETER; + } + free(event_data); + + /* Send and get the response message bytes */ + rc = pldm_requester_queue_and_wait(tx, &response_msg, &response_len); + if (rc) { + prlog(PR_ERR, "Communication Error, req: PlatformEventMessage, rc: %d\n", rc); + free(tx); + return rc; + } + free(tx); + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_platform_event_message_resp( + response_msg, + payload_len, + &response.completion_code, + &response.platform_event_status); + if (rc != PLDM_SUCCESS || response.completion_code != PLDM_SUCCESS) { + prlog(PR_ERR, "Decode PlatformEventMessage Error, rc: %d, cc: %d, pes: %d\n", + rc, response.completion_code, + response.platform_event_status); + free(response_msg); + return OPAL_PARAMETER; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + struct get_pdr_response { uint8_t completion_code; uint32_t next_record_hndl;