From patchwork Tue Aug 29 09:24:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827189 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=g8lSc8iK; 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 4RZhtp2rVzz1yZs for ; Tue, 29 Aug 2023 19:28:34 +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=g8lSc8iK; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhtp1mT2z2xqq for ; Tue, 29 Aug 2023 19:28:34 +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=g8lSc8iK; 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 4RZhns5wXlz3byP for ; Tue, 29 Aug 2023 19:24:17 +1000 (AEST) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T885GA024075 for ; Tue, 29 Aug 2023 09:24:15 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=polCjgtDBbvrXedEIQ5sBv/sUqXFf7E/w4gVOkhucHI=; b=g8lSc8iKAuk7rZJWQIHYH3YpDqN8ynmmZ+EPqwij+S7MScg8egxPsCU1FPMNqyYbVCU8 Q6ncYSl1YaRlp0tNpgofozfcgh+NCSS+zJdr1Em60Nd5SiuuI4d/Y5WN5eGM5H1VTElG 225fN2zHS9h0Dp/GyA+8uPza12Tm5xKvdqGaWmdDcB9nyAQw5oBcl2ti4kg2Cp0iH+p0 as7qMHX7CSEo70HeNOzg9IzUzmwNngAa9g7yIoXnz4/QMuoC2yi0UDjbWhmHgAPylvvQ pDiGn00ZZfwmQMP1WDSR5+Xsf89ouxlBLOi3AOnIsLbGV7KNEkdHTM/Y2eG80Hn22ccM pw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sr8q7xngw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:15 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37T93V1G004946 for ; Tue, 29 Aug 2023 09:24:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3squqsjk8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:14 +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 37T9OD7A21234404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Aug 2023 09:24:13 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E72B420040 for ; Tue, 29 Aug 2023 09:24:12 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AEA9920043 for ; Tue, 29 Aug 2023 09:24:12 +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:12 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 29 Aug 2023 11:24:01 +0200 Message-ID: <20230829092409.75899-8-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-GUID: Ez__3Z7Ivwi098Q3n87NqgaTzXls7H_I X-Proofpoint-ORIG-GUID: Ez__3Z7Ivwi098Q3n87NqgaTzXls7H_I 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 impostorscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V6 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 eeb202807..133873048 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -260,6 +260,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;