From patchwork Fri Jul 21 09:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1810813 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=QE1d/fMV; 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 4R6kLR6R6pz1yYc for ; Fri, 21 Jul 2023 19:10:55 +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=QE1d/fMV; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4R6kLR5MQ4z3dJ8 for ; Fri, 21 Jul 2023 19:10:55 +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=QE1d/fMV; 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 4R6kGV4xwRz3cWk for ; Fri, 21 Jul 2023 19:07:30 +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 36L96tpt021590 for ; Fri, 21 Jul 2023 09:07:29 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=eqjngO2+pMIM1Bag/m16S1o0psmP01eEsmnAIf55spQ=; b=QE1d/fMVkiTmoUqmJJtsCdwft/T+xEJPF45HAMX1FmsL5rBPvDYd4Fg3NchLJOhrAvrq roV9sUMOOnND0opjCoNfXQ5q0sPrLj4joIq+4DWCgik757USscyYw3I6DiI7FsXLXalN sdCvvApACzp1rzhj7YsAbzHMJUR/Pw20LJAngASmHES0uNFfxg6n39Vrnbc2NMb+fshm f+KUydIlC9laxJ78gEMx57HpA0c2bGRKcX761A3hRs0ZMUMo0bA3AaBihMbKE7x7iH8z BpD5esNIkjmfHvzjnyPtZFvMFn8o9yUhv1LkBwXe/vxILT6gjcLwH07jSz5aYuRoAxI3 Jg== 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 3ry9q8kh6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 09:07:28 +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 36L8aL7n003394 for ; Fri, 21 Jul 2023 09:07:27 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv65xw7f4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 09:07:27 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36L97P7T12059186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 21 Jul 2023 09:07:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30FD120040 for ; Fri, 21 Jul 2023 09:07:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAF8F20074 for ; Fri, 21 Jul 2023 09:07:24 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.ibm.com.com (unknown [9.179.31.149]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Fri, 21 Jul 2023 09:07:24 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 21 Jul 2023 11:07:13 +0200 Message-ID: <20230721090721.26050-8-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230721090721.26050-1-clombard@linux.ibm.com> References: <20230721090721.26050-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7eYHQ4A0cK381JBu83TMu7B3UxPcl66d X-Proofpoint-GUID: 7eYHQ4A0cK381JBu83TMu7B3UxPcl66d 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-07-21_05,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 clxscore=1015 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210081 Subject: [Skiboot] [PATCH V5 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 eeb20280..13387304 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;