From patchwork Fri Jul 21 09:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1810815 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=112.213.38.117; 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=bK1xZ/+p; dkim-atps=neutral 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 (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R6kLn38cmz1yYc for ; Fri, 21 Jul 2023 19:11:13 +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=bK1xZ/+p; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4R6kLn20Vzz3dKp for ; Fri, 21 Jul 2023 19:11:13 +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=bK1xZ/+p; 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 4R6kGW5Jscz3cWW for ; Fri, 21 Jul 2023 19:07:31 +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 36L970pC022107 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=xKa0t9ZwChKbCv2S3CPGaphO/oEp/nQh8OrX/CR1hmw=; b=bK1xZ/+p5pM5NDCVACYmcsI2evqj0pBvsVxXVfJZrMf7Ex5ElimBg7l46hT+Dt5U6ur9 b3NbNL4+dI76BaZULNKP6lC88eYn+Ps1NIpor93ZEfgsXrqOw/nJX3tCA4u4n8XgFKPT mquyrY4kcBFb50Gi6yuUUI4g7s2zjop4+wHpaENOWj9cDax9YFdFitbiWoQG4nTFHLWc tMKwR3ggzuU5cFW29VBkmksJAGeWe7IVmC2RpnLKq1DD/YiDhoYvRyJuFHpLpk6WpcKE YLE/KTYco/l8nbAY7Qnt7FCBMow3XYzwGY+7RAt4JFXUc0jUCCw6Ixnxh9IBg7OV2sRS ZQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ry9q8kh7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 09:07:29 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36L7TuAL030687 for ; Fri, 21 Jul 2023 09:07:28 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv79k2vwk-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 smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36L97Q5v47514008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 21 Jul 2023 09:07:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF5E420040 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 AD3EB20076 for ; Fri, 21 Jul 2023 09:07:25 +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:25 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 21 Jul 2023 11:07:15 +0200 Message-ID: <20230721090721.26050-10-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: NNeBLp8Vqm53f9M5pexMQKFBW0nTha7i X-Proofpoint-GUID: NNeBLp8Vqm53f9M5pexMQKFBW0nTha7i 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 09/15] core/pldm: Decode the GetPDR 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 GetPDR command is used to retrieve individual PDRs from a PDR repository. The record is identified by the PDR recordHandle value that is passed in the request. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 123 +++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 1589514e..3eba2e9b 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -824,6 +824,128 @@ static struct pldm_cmd pldm_platform_set_state_effecter_states = { .handler = platform_set_state_effecter_states_handler, }; +/* + * GetPDR (0x51) + * The GetPDR command is used to retrieve individual PDRs from a PDR + * Repository. The record is identified by the PDR recordHandle value + * that is passed in the request. + */ +static int platform_get_pdr_handle(const struct pldm_rx_data *rx) +{ + uint32_t data_transfer_handle, pdr_data_size = 0; + uint32_t record_handle, next_record_handle; + uint16_t request_count, record_change_number; + uint8_t transfer_op_flag, *pdr_data = NULL; + size_t payload_len, data_size; + struct pldm_tx_data *tx; + int rc; + + payload_len = rx->msg_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_pdr_req(rx->msg, + payload_len, + &record_handle, + &data_transfer_handle, + &transfer_op_flag, + &request_count, + &record_change_number); + if (rc) { + prlog(PR_ERR, "Failed to decode GetPDR request, rc = %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + if (data_transfer_handle != 0) { + /* We don't support multipart transfers */ + prlog(PR_ERR, "Got invalid data transfer handle 0x%x in GetPDR request\n", + data_transfer_handle); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE); + return OPAL_PARAMETER; + } + + if (transfer_op_flag != PLDM_GET_FIRSTPART) { + prlog(PR_ERR, "Got invalid transfer op flag 0x%x in GetPDR request\n", + transfer_op_flag); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG); + return OPAL_PARAMETER; + } + + if (record_change_number != 0) { + prlog(PR_ERR, "Got invalid record change number 0x%x in GetPDR request\n", + record_change_number); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER); + return OPAL_PARAMETER; + } + + /* find PDR record by record handle */ + prlog(PR_INFO, "BMC requesting PDR handle %d\n", record_handle); + + rc = pldm_platform_pdr_find_record(record_handle, + &pdr_data, + &pdr_data_size, + &next_record_handle); + if (rc) { + prlog(PR_ERR, "Got invalid record handle 0x%x in GetPDR request\n", + record_handle); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, + PLDM_PLATFORM_INVALID_RECORD_HANDLE); + return OPAL_PARAMETER; + } + + /* create a PLDM response message for GetPDR */ + data_size = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_pdr_resp) + + pdr_data_size; + + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size - 1; + tx->tag_owner = true; + tx->msg_tag = rx->msg_tag; + + rc = encode_get_pdr_resp(rx->hdrinf.instance, + PLDM_SUCCESS, + next_record_handle, + 0, /* No remaining data */ + PLDM_START_AND_END, + pdr_data_size, + pdr_data, + 0, /* CRC not used for START_AND_END */ + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetPDR 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 GetPDR response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + free(tx); + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_get_pdr = { + .name = "PLDM_GET_PDR", + .pldm_cmd_id = PLDM_GET_PDR, + .handler = platform_get_pdr_handle, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -870,6 +992,7 @@ int pldm_responder_init(void) add_cmd(&pldm_platform_type, &pldm_platform_event_message); add_cmd(&pldm_platform_type, &pldm_platform_get_state_sensor_readings); add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); + add_cmd(&pldm_platform_type, &pldm_platform_get_pdr); return OPAL_SUCCESS; }