From patchwork Wed May 18 07:42:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Singh Tomar X-Patchwork-Id: 1632641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=FiiNU22s; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L34kP4KgLz9sBB for ; Wed, 18 May 2022 17:44:13 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kP3Cfgz3c8y for ; Wed, 18 May 2022 17:44: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=FiiNU22s; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org 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=abhishek@linux.ibm.com; receiver=) 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=FiiNU22s; dkim-atps=neutral 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 4L34jt0tn0z3bjq for ; Wed, 18 May 2022 17:43:45 +1000 (AEST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7hFs5007006 for ; Wed, 18 May 2022 07:43:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=2IXx2qwFnCJmhzg/7lKc7761T24drJJ4/PWXX6CJszg=; b=FiiNU22sQKVTcXXMZfUnVFjCHcjFiCIdonAsuZOIi7YtqRTaaw4R5Z0D8FjUpoK0B55i ps9pDbJ4fmIMbFNlloeSvEtrzVS1teRP1iIUw3RZGqAxqzTkgSnunjsKiviSG24qUfes G+GdezCBuxna4I6aSlvpdMxUnEIvVxgI4xCr3bhrZ6n8zPU5soNHgO3hcHwnWTl75PAH uGYCwWrJNutaD4RrCYiqWfxI0NLev8E3Es4+Ba1OVVF37sVfXXAHaL1RHWCVP9EmiFX5 o9RDh2rIti3D9eKGZvHvN9Vcp7N+lZ+Av1J4WapuEOS8Y8nhB67gB6pyct5bKeaC5MVn 5Q== 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 3g4vndg059-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:43 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7hf01001362 for ; Wed, 18 May 2022 07:43:41 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3g2429db8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:41 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7hbq249152490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:37 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8CBC11C050; Wed, 18 May 2022 07:43:37 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F147B11C04C; Wed, 18 May 2022 07:43:36 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.in.ibm.com (unknown [9.109.222.255]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 May 2022 07:43:36 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:59 +0530 Message-Id: <20220518074304.42497-5-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DoQEV6ENH4GJiYORwmeyq3UYGI_aw1SP X-Proofpoint-GUID: DoQEV6ENH4GJiYORwmeyq3UYGI_aw1SP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_02,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 4/9] core/pldm/test : Read file with PLDM file I/O message 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: , Cc: Abhishek Singh Tomar Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The patch contains a test for PLDM read request implementation using PLDM command PLDM_READ_FILE Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-fileio.c | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/core/pldm/test/test-pldm-fileio.c b/core/pldm/test/test-pldm-fileio.c index 924db86e..53a2f811 100644 --- a/core/pldm/test/test-pldm-fileio.c +++ b/core/pldm/test/test-pldm-fileio.c @@ -115,6 +115,7 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, uint8_t table_type; uint8_t *file_attr_table; uint32_t table_size; + struct pldm_read_file_resp *response; /* check command received and reply with appropriate pldm response message */ @@ -195,6 +196,57 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, return OPAL_PARAMETER; break; + case PLDM_READ_FILE: + + payload_len = request_len - sizeof(struct pldm_msg_hdr); + rc = decode_read_file_req(request_msg, payload_len, &file_handle, &offset, + &length); + + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + + /* + * TEST : if file handle received is same as that we send while making + * call to pldm request (i.e. TEST_FILE_IO_HANDLE). + * then PLDM message are transferred without any distortion in path. + */ + if (file_handle != TEST_FILE_IO_HANDLE) { + printf("PLDM_TEST : File Handle not matched"); + return OPAL_PARAMETER; + } + + /* + * check if length + offset < TEST_FILE_IO_LENGTH + * so required data length can be readed + */ + if (file_handle != TEST_FILE_IO_HANDLE || + length + offset > TEST_FILE_IO_LENGTH) { + perror("TEST : length+offset Invalid"); + return OPAL_PARAMETER; + } + + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_read_file_resp) + length - 1; + + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + + rc = encode_read_file_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, length, *response_msg); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + + response = (struct pldm_read_file_resp *) + ((struct pldm_msg *)*response_msg)->payload; + + /* Copy required buffer to end of PLDM response */ + memcpy(response->file_data, pldm_file_io_buff + offset, length); + break; default: @@ -212,6 +264,7 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t rc; + char buf_read[TEST_FILE_IO_LENGTH]; char buf_write[TEST_FILE_IO_LENGTH] = TEST_FILE_IO_BUF1; uint64_t size = strlen(buf_write); @@ -225,6 +278,13 @@ int main(void) return OPAL_PARAMETER; } + /* Attempt to read using pldm file io before init should return error OPAL_PARAMETER */ + rc = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (rc != OPAL_PARAMETER) { + printf("PLDM_TEST : pldm_file_io_read_file failed expect=OPAL_PARAMETER\n"); + return OPAL_PARAMETER; + } + /* Init PLDM File IO */ rc = pldm_file_io_init(); if (rc != OPAL_SUCCESS) { @@ -241,6 +301,20 @@ int main(void) return rc; } + + /* Attempt to read: using pldm file io should return OPAL SUCCESS after init */ + rc = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST : pldm_file_io_read_file failed expect=OPAL_PARAMETER\n"); + return rc; + } + + /* Test if buffer read same as buffer send */ + if (strncmp(buf_read, TEST_FILE_IO_BUF1, size) != 0) { + perror("PLDM_TEST pldm read string mismatch"); + return OPAL_PARAMETER; + } + return OPAL_SUCCESS; }