From patchwork Wed May 18 07:42:58 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: 1632640 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=m1LgeDzS; 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 4L34kG2y9Tz9sBB for ; Wed, 18 May 2022 17:44:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kG1kmwz2xDY for ; Wed, 18 May 2022 17:44:06 +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=m1LgeDzS; 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=mx0a-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=m1LgeDzS; dkim-atps=neutral Received: from mx0a-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 4L34jr4X8cz3bjq for ; Wed, 18 May 2022 17:43:44 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7JUQY021923 for ; Wed, 18 May 2022 07:43:41 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=X4Oh9As8sEcEZSq0GFY0oLpkAKB4QZ27UOqdhUs4LWM=; b=m1LgeDzS8Ly31WmTf7Sb6jS5xbKPNLfcHdniB2ZwJDu5E6qJH86+IreotGTl+2zKd9+X IFTnZxzYbBKH8u1GpwWLRX5cVTgUYjdoM0boWTj6Lh+CRjPsSmCrh6tpFngKwHRBX/mt eYi/9wPCn8YCLDQYTsTacttWEf01ZjXTnWEVSvAGXaIQngHWd7bdswSNCxmBb6f+OPYf F+1XqOGqIfHtfhEWJ/s4zYR1wnBztzMwfWP69nFSSTgN/a8LR4QVkE2O6AnCFsUw7WoV EHWM2sUjiUifl1v8Pa6kqDZ1XVQ/jLB/ECagwIY/09KyfAGqzRw67Z6DqgdhzvMAKnHW ww== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vaf8h8m-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 pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7gBZv025169 for ; Wed, 18 May 2022 07:43:39 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 3g23pjdb1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:39 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7TiXI27525518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:29:44 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AEF711C050; Wed, 18 May 2022 07:43:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D262B11C04C; Wed, 18 May 2022 07:43:35 +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:35 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:58 +0530 Message-Id: <20220518074304.42497-4-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-GUID: 5aPh6HPJs9NQy2OqO3Hc1A2XxPLcXliz X-Proofpoint-ORIG-GUID: 5aPh6HPJs9NQy2OqO3Hc1A2XxPLcXliz 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 bulkscore=0 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=957 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 3/9] core/pldm/test : Write 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 write request implementation using PLDM command PLDM_WRITE_FILE Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-fileio.c | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/core/pldm/test/test-pldm-fileio.c b/core/pldm/test/test-pldm-fileio.c index e14f6df7..924db86e 100644 --- a/core/pldm/test/test-pldm-fileio.c +++ b/core/pldm/test/test-pldm-fileio.c @@ -8,6 +8,7 @@ #define TEST_FILE_IO_LENGTH 50 #define TEST_FILE_IO_BUF1 "This is Test buffer Open power Foundation" +void *pldm_file_io_buff[TEST_FILE_IO_LENGTH]; uint32_t get_test_filetable_entry(uint8_t **file_attr_table, int *size); int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, void **response_msg, size_t *response_len); @@ -102,7 +103,13 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, void **response_msg, size_t *response_len) { int rc; + void *payload_data; + uint32_t offset; //!< Offset to file where write starts + uint32_t length; + uint32_t file_handle; //!< Handle to file int payload_len = 0; + size_t file_data_offset = 0; + struct pldm_write_file_req file_req; uint32_t transfer_handle; uint8_t transfer_opflag; uint8_t table_type; @@ -143,6 +150,52 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, free(file_attr_table); break; + case PLDM_WRITE_FILE: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + + rc = decode_write_file_req(request_msg, payload_len, &file_handle, + &offset, &length, &file_data_offset); + 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 received without any distortion in path. + */ + if (file_handle != TEST_FILE_IO_HANDLE) + return OPAL_PARAMETER; + + payload_data = ((struct pldm_msg *)request_msg)->payload + + sizeof(file_req.file_handle) + + sizeof(file_req.offset) + + sizeof(file_req.length); + + memcpy(pldm_file_io_buff, payload_data, length); + + /* + * TEST if file buff received is same as that we send while making + * call to pldm request (i.e TEST_FILE_IO_BUF1). + * Then PLDM message are transferred without distortion in path. + */ + if (strncmp(TEST_FILE_IO_BUF1, (char *)payload_data, length) != 0) { + perror("PLDM_TEST :strncmp"); + return OPAL_PARAMETER; + } + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_write_file_resp); + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + rc = encode_write_file_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, length, *response_msg); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + break; + default: return OPAL_PARAMETER; @@ -159,7 +212,18 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t rc; + char buf_write[TEST_FILE_IO_LENGTH] = TEST_FILE_IO_BUF1; + uint64_t size = strlen(buf_write); + /* Initialize test buffer for represent file with 0 */ + bzero(pldm_file_io_buff, TEST_FILE_IO_LENGTH); + + /* Attempt to write using pldm file io before init should return error OPAL_PARAMETER */ + rc = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, 0, size); + if (rc != OPAL_PARAMETER) { + printf("PLDM_TEST : pldm_file_io_write_file failed expect=OPAL_PARAMETER\n"); + return OPAL_PARAMETER; + } /* Init PLDM File IO */ rc = pldm_file_io_init(); @@ -168,6 +232,15 @@ int main(void) return rc; } + /* Attempt to write using pldm file io should return OPAL SUCCESS after init */ + rc = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, + 0, size); + + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST : pldm_file_io_write_file failed expect=OPAL_SUCCESS\n"); + return rc; + } + return OPAL_SUCCESS; }