From patchwork Sat May 7 06:35:54 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: 1627832 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=HaDs0XuB; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHlP2JPvz9sGV for ; Sat, 7 May 2022 16:36:33 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHlP161Hz3bxk for ; Sat, 7 May 2022 16:36:33 +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=HaDs0XuB; 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.156.1; 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=HaDs0XuB; dkim-atps=neutral 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 4KwHlB3pmSz3bhK for ; Sat, 7 May 2022 16:36:22 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2475pwPA021471 for ; Sat, 7 May 2022 06:36:18 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=mVDXBTB5Qr8nCppJ8yptJ1/liy2S/zVVV975zu8ue/4=; b=HaDs0XuBfp6QGW7IzsHf0wCvDRovvQ+HM9w+0Opt7LLFS1yIN2p+OMffhy7LgPkaWWaQ 0LAf01v2tVE7UiYukq2tXa2T8/fDBHHi69ZB/DTL7Y6gHBdd1DDVy2YoK7RrTF8iW1tn 2Q5M4jOkcml4ElqMtq8yYfHi/oY3g7o0ZQXpuSfUXUDfkWHVuoS9Vo4lL0UA8O2x5d/g YXjcanwh+umaGm83v/NM2f7PD00yRDcv3nrsn9zPEFWLgWN0sxzOVqDcwqxSa9Wf6b9t BckgTwkBWpkwCZjm2rzRT96lPQQ5/8j/AunxIrh7El7CvckcXtnxBPugmmPJDs+oX7xk 1g== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwk0c0fgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:18 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476Ybvj020320 for ; Sat, 7 May 2022 06:36:16 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06fra.de.ibm.com with ESMTP id 3fwg1hr4v3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:15 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476Mk3w52756922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:22:46 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A016152051; Sat, 7 May 2022 06:36:12 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5B0EF52050; Sat, 7 May 2022 06:36:11 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:54 +0530 Message-Id: <20220507063602.66309-2-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 62tQxwLWI-nf_4QswWYa1GvIute4tEZ_ X-Proofpoint-ORIG-GUID: 62tQxwLWI-nf_4QswWYa1GvIute4tEZ_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 spamscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 1/9] core/pldm/test : pldm self test common 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 contain common file to be used for PLDM self test. It bypass hardware dependent code for PLDM implementation. Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/common/test_pldm-common.c | 187 +++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 core/pldm/test/common/test_pldm-common.c diff --git a/core/pldm/test/common/test_pldm-common.c b/core/pldm/test/common/test_pldm-common.c new file mode 100644 index 00000000..33671150 --- /dev/null +++ b/core/pldm/test/common/test_pldm-common.c @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* + * Copyright 2013-2019 IBM Corp. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __LITTLE_ENDIAN_BITFIELD +#define __TEST__ +#define __SKIBOOT__ +#define zalloc(bytes) calloc((bytes), 1) +static inline unsigned long mftb(void); +#include +#include +#include +#include "../../pldm.h" +#include +#include +#ifdef ARRAY_SIZE +#undef ARRAY_SIZE +#endif + + +#include +#include +#undef pr_fmt +#include "../../pldm-bios-requests.c" +#include +#include +#include +#include +#include +#include +#include +#include "../../pldm-file-io-requests.c" +#include "../../pldm-requester.c" +#include "../../pldm-common.c" +#include "../../pldm-responder.c" +#include "../../pldm-base-requests.c" +#include "../../pldm-watchdog.c" +#include "../../pldm-fru-requests.c" +#include "../../pldm-platform-requests.c" +#include "../../../device.c" + + + +char __rodata_start[1], __rodata_end[1]; +unsigned long tb_hz = 512000000; +struct dt_node *dt_root; +struct debug_descriptor debug_descriptor; +struct platform platform; + +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); +int pldm_test_verify_response(void *response_msg, size_t response_len); + +void time_wait_ms(unsigned long ms) +{ + usleep(ms * 1000); +} +void init_timer(struct timer *t, timer_func_t expiry, void *data) +{ + t->link.next = t->link.prev = NULL; + t->target = 0; + t->expiry = expiry; + t->user_data = data; + t->running = NULL; +} +uint64_t schedule_timer(struct timer *t, uint64_t how_long) +{ + if (t != NULL) + return how_long; + return 0; +} +void cancel_timer(struct timer *t) +{ + t->link.next = t->link.prev = NULL; +} + +static inline unsigned long mftb(void) +{ + unsigned long clk; + + clk = clock(); + return clk; +} + +int ast_mctp_init(void (*fn)(uint8_t src_eid, bool tag_owner, uint8_t msg_tag, void *data, + void *msg, size_t len)) +{ + if (fn != NULL) + return PLDM_SUCCESS; + return PLDM_ERROR_INVALID_DATA; +} + +int ast_mctp_message_tx(uint8_t eid, uint8_t *msg, int len) +{ + int ret; + uint8_t *pldm_received_msg = msg+1; + void *response_msg; + char *vmsg; + size_t response_len; + + /* TEST eid is BMC_ID */ + if (eid != BMC_EID) + return OPAL_PARAMETER; + + /* TEST Message TYPE: PLDM = 0x01 (000_0001b) as per MCTP - DSP0240 */ + if (msg[0] != 0x01) { + printf("TEST : %s : request MCTP message type not set for PLDM\n", __func__); + return OPAL_PARAMETER; + } + + if (((struct pldm_msg *)pldm_received_msg)->hdr.request == PLDM_RESPONSE) { + ret = pldm_test_verify_response(pldm_received_msg, len-1); + if (ret != PLDM_SUCCESS) + return ret; + } + + /* Reply to requests */ + else if (((struct pldm_msg *)pldm_received_msg)->hdr.request == PLDM_REQUEST) { + ret = pldm_test_verify_response(pldm_received_msg, len-1); + ret = pldm_test_reply_request(pldm_received_msg, len-1, + &response_msg, &response_len); + if (ret != PLDM_SUCCESS) + return ret; + vmsg = malloc(response_len+1); + /* TYPE: PLDM = 0x01 (000_0001b) as per MCTP - DSP0240 */ + vmsg[0] = 0x01; + + memcpy(vmsg + 1, response_msg, response_len); + + pldm_rx_message(BMC_EID, 0, 0, NULL, vmsg, response_len+1); + } + + return PLDM_SUCCESS; +} + +void ast_mctp_exit(void) +{ + return; +} + +void lock_caller(struct lock *l, const char *caller) +{ + (void)caller; + assert(!l->lock_val); + l->lock_val++; +} + +int _opal_queue_msg(enum opal_msg_type msg_type, void *data, + void (*consumed)(void *data, int status), + size_t params_size, const void *params) +{ + (void)msg_type; + if (data != NULL || consumed != NULL) + return OPAL_PARAMETER; + if (params != NULL && params_size > 0) + return OPAL_PARAMETER; + return PLDM_SUCCESS; + +} + + +void unlock(struct lock *l) +{ + assert(l->lock_val); + l->lock_val = 0; +} + +void prd_occ_reset(uint32_t proc) +{ + (void)proc; +} + From patchwork Sat May 7 06:35:55 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: 1627833 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=qdaQfHmb; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHlX3whWz9sGV for ; Sat, 7 May 2022 16:36:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHlX2lD1z3brq for ; Sat, 7 May 2022 16:36:40 +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=qdaQfHmb; 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=qdaQfHmb; 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 4KwHlF4v7bz3bhK for ; Sat, 7 May 2022 16:36:25 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2473iJWc006457 for ; Sat, 7 May 2022 06:36:22 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=pfaV/kXyOKhKge9d3WHyeXlWZJ9yJbK3K0tQQnErvGE=; b=qdaQfHmbgVS7nxGjQ42qFginliuMgGXSnlaz4IU875CsmmrZT4a93Llz4BZkTbjEosje nKz3hdfVxbY+F3EXqFNT2lnKYLkk7Qs8GkcahqTFbTOsLiBpWqrV0oikZoBx3Up1dWTt AfD8NpSwec26PdCP2jyd41o2r4Orxl85M666fMsCSDkuXe6eaLI+B4Yb6bAeivqwPF7k VfbxDOuSd7jC/WyVrgBzgJuhahA2ZslK+8iYy6l6+jht1vbfsdp4S+ryrL5X115s2kal r6gEi1CDtJWHl6V8rabore6b7j3VyGX9pTjpln5ZBb7/tK8VlY9aJrY4vlOopFQPQSDn qg== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwh4esq2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:22 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476XQU0011075 for ; Sat, 7 May 2022 06:36:20 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3fwgd8r5tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:20 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476aH4K17760760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:17 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EEF152059; Sat, 7 May 2022 06:36:17 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D665452050; Sat, 7 May 2022 06:36:15 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:55 +0530 Message-Id: <20220507063602.66309-3-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8ecPb5mZFPYZRzyOVjuY83eDnMFevCXx X-Proofpoint-ORIG-GUID: 8ecPb5mZFPYZRzyOVjuY83eDnMFevCXx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 2/9] core/pldm/test : pldm file I/O init Self test 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 self test for PLDM file I/O function "pldm_file_io_init()". This patch test codeflow for PLDM command PLDM_GET_FILE_TABLE. Signed-off-by: Abhishek Singh Tomar --- core/pldm/pldm-file-io-requests.c | 12 ++- core/pldm/pldm.h | 2 +- core/pldm/test/Makefile.check | 42 ++++++++ core/pldm/test/test_pldm-fileio.c | 174 ++++++++++++++++++++++++++++++ 4 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 core/pldm/test/Makefile.check create mode 100644 core/pldm/test/test_pldm-fileio.c diff --git a/core/pldm/pldm-file-io-requests.c b/core/pldm/pldm-file-io-requests.c index 94828fcd..50ddb0e4 100644 --- a/core/pldm/pldm-file-io-requests.c +++ b/core/pldm/pldm-file-io-requests.c @@ -155,9 +155,15 @@ static int read_file_req(uint32_t file_handle, uint32_t file_length, file_req.length = MAX_TRANSFER_SIZE_BYTES; } +#ifndef __TEST__ prlog(PR_TRACE, "%s - file_handle: %d, offset: 0x%x, size: 0x%llx num_transfers: %d\n", __func__, file_handle, file_req.offset, size, num_transfers); +#else + prlog(PR_TRACE, "%s - file_handle: %d, offset: 0x%x, size: 0x%lx num_transfers: %d\n", + __func__, file_handle, file_req.offset, + size, num_transfers); +#endif for (i = 0; i < num_transfers; i++) { file_req.offset = offset + (i * MAX_TRANSFER_SIZE_BYTES); @@ -210,9 +216,13 @@ static int read_file_req(uint32_t file_handle, uint32_t file_length, total_read += resp_length; curr_buf += resp_length; free(response_msg); - +#ifndef __TEST__ prlog(PR_TRACE, "%s - file_handle: %d, resp_length: 0x%x, total_read: 0x%llx\n", __func__, file_handle, resp_length, total_read); +#else + prlog(PR_TRACE, "%s - file_handle: %d, resp_length: 0x%x, total_read: 0x%lx\n", + __func__, file_handle, resp_length, total_read); +#endif if (total_read == size) break; diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index 81df9f8b..5ac9c443 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -45,7 +45,7 @@ extern int watchdog_period_sec; * @example enum_bit(1) = 0x00000002 * @example enum_bit(4) = 0x00000010 */ -inline uint32_t enum_bit(unsigned int enumeration) +extern inline uint32_t enum_bit(unsigned int enumeration) { return 1 << enumeration; } diff --git a/core/pldm/test/Makefile.check b/core/pldm/test/Makefile.check new file mode 100644 index 00000000..42d60993 --- /dev/null +++ b/core/pldm/test/Makefile.check @@ -0,0 +1,42 @@ +# -*-Makefile-*- +PLDM_TEST := core/pldm/test/test_pldm-fileio \ + +LCOV_EXCLUDE += $(PLDM_TEST:%=%.c) + +.PHONY : core-pldm-check core-pldm-coverage +core-pldm-check: $(PLDM_TEST:%=%-check) +core-pldm-coverage: $(PLDM_TEST:%=%-gcov-run) +HOSTCFLAG_PLDM:= $(filter-out -Wdeclaration-after-statement,$(HOSTCFLAGS)) +HOSTCFLAG_PLDM:= $(filter-out -Wstrict-prototypes,$(HOSTCFLAG_PLDM)) +HOSTCFLAG_PLDM:= $(filter-out -Wjump-misses-init,$(HOSTCFLAG_PLDM)) +HOSTCFLAG_PLDM:= $(filter-out -Wmissing-prototypes,$(HOSTCFLAG_PLDM)) +HOSTCFLAG_PLDM:= $(filter-out -Wmissing-declarations,$(HOSTCFLAG_PLDM)) + +check: core-pldm-check +coverage: core-pldm-coverage + +$(PLDM_TEST:%=%-gcov-run) : %-run: % + $(call Q, TEST-COVERAGE ,$< , $<) + +$(PLDM_TEST:%=%-check) : %-check: % + $(call Q, RUN-TEST ,$(VALGRIND) $<, $<) + +core/test/stubs.o: core/test/stubs.c + $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -I . -I include -Wno-error=attributes -g -c -o core/test/stubs.o core/test/stubs.c, $<) + +$(PLDM_TEST) : % : %.c core/test/stubs.o + $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAG_PLDM) -O0 -g -I include -I . -I pldm/libpldm/ -I libfdt -o $@ $< core/test/stubs.o -g, $<) + +$(PLDM_TEST:%=%-gcov): %-gcov : %.c % + $(call Q, HOSTCC ,$(HOSTCC) $(HOSTFLAG_PLDM) $(HOSTGCOVCFLAGS) -I include -I . -I pldm/libpldm/ -I libfdt -lgcov -o $@ $<, $<) + +$(PLDM_TEST:%=%-gcov): % : $(%.d:-gcov=) + +-include $(wildcard core/pldm/test/*.d) + +clean: pldm-test-clean + +pldm-test-clean: + $(RM) -f core/pldm/test/*.[od] $(PLDM_TEST) $(PLDM_TEST:%=%-gcov) + $(RM) -f *.gcda *.gcno skiboot.info + $(RM) -rf coverage-report diff --git a/core/pldm/test/test_pldm-fileio.c b/core/pldm/test/test_pldm-fileio.c new file mode 100644 index 00000000..722a8bf6 --- /dev/null +++ b/core/pldm/test/test_pldm-fileio.c @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* + * Copyright 2013-2019 IBM Corp. + */ + + +#include "common/test_pldm-common.c" + +#define TEST_FILE_IO_NAME "81e0066b.lid" +#define TEST_FILE_IO_HANDLE 11 +#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 test_Filetable_entry_generate(uint8_t **file_attr_table); +int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); + +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will handle pldm response message + * For now we don't have any response + */ +int pldm_test_verify_response(void *response_msg, size_t response_len) +{ + if (response_len > 0 || response_msg != NULL) + return OPAL_PARAMETER; + + return OPAL_PARAMETER; + +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * This Genrate Filetable entry for self test + * The file table contains the list of files available and + * their attributes. + * + * Ex: + * { + * "FileHandle": "11", + * "FileNameLength": 12, + * "FileName": "81e0066b.lid", + * "FileSize": 589824, + * "FileTraits": 6 + * } + */ +uint32_t test_Filetable_entry_generate(uint8_t **file_attr_table) +{ + struct pldm_file_attr_table_entry *pldm_file_attr_table_entry; + uint8_t FileName[] = TEST_FILE_IO_NAME; + uint32_t file_length = TEST_FILE_IO_LENGTH; + int size; + + /* calculate sizeof whole struct */ + size = sizeof(struct pldm_file_attr_table_entry *) + strlen(FileName) + + sizeof(file_length) - 1; + *file_attr_table = malloc(size); + + pldm_file_attr_table_entry = (struct pldm_file_attr_table_entry *)*file_attr_table; + pldm_file_attr_table_entry->file_handle = TEST_FILE_IO_HANDLE; + pldm_file_attr_table_entry->file_name_length = strlen(FileName); + memcpy(pldm_file_attr_table_entry->file_attr_table_nst, FileName, + strlen(FileName)); + + memcpy(pldm_file_attr_table_entry->file_attr_table_nst + strlen(FileName), + (uint8_t *)&file_length, sizeof(file_length)); + + return size; +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will only handle PLDM_OEM type request + * As fileio test will have only pldm request of type = PLDM_OEM + */ +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + + switch (((struct pldm_msg *)request_msg)->hdr.type) { + case PLDM_OEM: + return pldm_test_reply_request_file_io(request_msg, request_len, + response_msg, response_len); + default: + printf("PLDM_TEST: Not equal to PLDM_OEM\n"); + return OPAL_PARAMETER; + } + + +} + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * it tries to handle PLDM_REQUEST for fileio and reply with appropriate PLDM_RESPONSE + * message + */ +int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + int ret; + int payload_len = 0; + uint32_t transfer_handle; + uint8_t transfer_opflag; + uint8_t table_type; + uint8_t *file_attr_table; + uint32_t table_size; + + + /* check command received and reply with appropriate pldm response message */ + switch (((struct pldm_msg *)request_msg)->hdr.command) { + case PLDM_GET_FILE_TABLE: + + payload_len = request_len - sizeof(struct pldm_msg_hdr); + + ret = decode_get_file_table_req(request_msg, payload_len, &transfer_handle, + &transfer_opflag, &table_type); + if (ret != PLDM_SUCCESS) + return ret; + + /* Generate Filetable entry for self test */ + table_size = test_Filetable_entry_generate(&file_attr_table); + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_file_table_resp) + + table_size - 1; + *response_msg = malloc(*response_len); + + ret = encode_get_file_table_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, PLDM_GET_NEXTPART, PLDM_START_AND_END, + file_attr_table, table_size, *response_msg); + if (ret != PLDM_SUCCESS) + return ret; + + free(file_attr_table); + + break; + + default: + return PLDM_ERROR_INVALID_DATA; + + } + + return PLDM_SUCCESS; + + + +} + + +int main(void) +{ + size_t ret; + + /* Initialize test buffer for represent file with 0 */ + bzero(pldm_file_io_buff, TEST_FILE_IO_LENGTH); + + + /* Init PLDM File IO */ + ret = pldm_file_io_init(); + if (ret != PLDM_SUCCESS) { + perror("pldm_file_io_write_file"); + return ret; + } + + return PLDM_SUCCESS; +} + + From patchwork Sat May 7 06:35:56 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: 1627834 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=CPWAp9rR; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHlg0W5wz9sGV for ; Sat, 7 May 2022 16:36:47 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHlf6Bt5z3brM for ; Sat, 7 May 2022 16:36:46 +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=CPWAp9rR; 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=CPWAp9rR; 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 4KwHlJ2hvKz3c8P for ; Sat, 7 May 2022 16:36:28 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2475wReV011243 for ; Sat, 7 May 2022 06:36:25 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=Dl3C5H9t6khSD8nwy4RM89IeRAFNxq7b3LV9u3swhnE=; b=CPWAp9rRX983tFJVig/nzOc1WleLP6PaJW/4kE/ovN9B/kcVS04l2FOLjjd8cCOUNob5 OVBf7Sl4G7JAgj0BgST0ArxCpWnnhlVswv0msUzZrOms4qrd4P6j7CBSTMM1fXW2pr5S S4ybELDaByZjfQU93xYrgyILmkOr17hE6fxZm5q0LDEYyXo/RDwhTbT0zZljcTCZ5wZD 9E/Ejfu9RfFxlg9tK2xpLOavtvlhCXMVrXu3UkCKiVZ73EB2weEnLJK61Thff5qWjdWx T/Tv1NhoWoSZIg6aBmhxOkzlgVxFIyeXeFzjzbbmsHXnOnx+6vXpWQIIgu7FZ8qr8C4K cA== 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 3fwk310dyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:25 +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 2476ZGR1002468 for ; Sat, 7 May 2022 06:36:23 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3fwg1j06cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:23 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476aKnP42140140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B36FB5204E; Sat, 7 May 2022 06:36:20 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7179D5204F; Sat, 7 May 2022 06:36:19 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:56 +0530 Message-Id: <20220507063602.66309-4-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yWR-yK9GsAJy6SE4oTc9Pxm6sG-j-KIv X-Proofpoint-ORIG-GUID: yWR-yK9GsAJy6SE4oTc9Pxm6sG-j-KIv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 mlxscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 3/9] core/pldm/test : pldm file I/O write file Self test 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 self test for PLDM file I/O write message. This patch test codeflow for PLDM command PLDM_WRITE_FILE. Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test_pldm-fileio.c | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/core/pldm/test/test_pldm-fileio.c b/core/pldm/test/test_pldm-fileio.c index 722a8bf6..10011740 100644 --- a/core/pldm/test/test_pldm-fileio.c +++ b/core/pldm/test/test_pldm-fileio.c @@ -103,13 +103,20 @@ int pldm_test_reply_request(void *request_msg, size_t request_len, int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, void **response_msg, size_t *response_len) { + int size = 0; int ret; + void *payload_data; int payload_len = 0; + uint32_t offset; //!< Offset to file where write starts + uint32_t length; + uint32_t file_handle; //!< Handle to file + size_t file_data_offset = 0; uint32_t transfer_handle; uint8_t transfer_opflag; uint8_t table_type; uint8_t *file_attr_table; uint32_t table_size; + struct pldm_write_file_req file_req; /* check command received and reply with appropriate pldm response message */ @@ -140,6 +147,51 @@ 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); + + + ret = decode_write_file_req(request_msg, payload_len, &file_handle, + &offset, &length, &file_data_offset); + if (ret != PLDM_SUCCESS) + return ret; + + /* + * 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 recieved without any distortion in path. + */ + if (file_handle != TEST_FILE_IO_HANDLE) + return PLDM_ERROR_INVALID_DATA; + + 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("TEST :: String not matched"); + return PLDM_ERROR_INVALID_DATA; + } + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_write_file_resp); + *response_msg = malloc(*response_len); + + ret = encode_write_file_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, size, *response_msg); + if (ret != PLDM_SUCCESS) + return ret; + + break; default: return PLDM_ERROR_INVALID_DATA; @@ -156,11 +208,21 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t ret; + 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_PARAMTER */ + ret = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, 0, size); + if (ret != OPAL_PARAMETER) { + perror("pldm_file_io_write_file"); + return ret; + } + + /* Init PLDM File IO */ ret = pldm_file_io_init(); if (ret != PLDM_SUCCESS) { @@ -168,6 +230,15 @@ int main(void) return ret; } + /* Attempt to write using pldm file io should return PLDM SUCCESS after init */ + ret = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, + 0, size); + if (ret != PLDM_SUCCESS) { + perror("pldm_file_io_write_file"); + return ret; + } + + return PLDM_SUCCESS; } From patchwork Sat May 7 06:35:57 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: 1627835 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=AF0tMFh2; 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 4KwHlp2K8hz9sGV for ; Sat, 7 May 2022 16:36:54 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHlp0nKRz3c9H for ; Sat, 7 May 2022 16:36:54 +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=AF0tMFh2; 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=AF0tMFh2; 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 4KwHlM3hZBz3c8n for ; Sat, 7 May 2022 16:36:31 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2473q1cR013550 for ; Sat, 7 May 2022 06:36:29 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=bQSyNXZTYJNm5fwXQeEIcVUbAMAe01ID2zyRZwou4+8=; b=AF0tMFh2IuLQJUygseGDu1pkNFb3hszQtYkm1LGQzYA6dgsPNXTJ6JR3teXxTn0ViLvg N9vbxfpdm4B0ICg9kx4OZnSL262XOrUtVPg2/VLnknTuFtRQtji5ddEezNlpvkRvQ4W+ ZIEiuQal4VYrdfl8nGanVtUF5aL69c7KGh/S1jlCol0RAPnOousgr7BAEV67XDTmgATe Se2UYUGRoupP98Q4ZByoRgAR6+gFcZhrbBJ7iurKZPosPOGAgn3Jc6aW7xV8LlADecZy 8uw7No8h16ptQDORXdBHmW0MkETNiTshE+qFzfBIaiQJIkQ3zDYAfGLGTkxKYZtOCvLG +Q== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwh859my5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:28 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476Z65j019677 for ; Sat, 7 May 2022 06:36:27 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3fwgd8r4j5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:26 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476aNfm59113870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:24 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC18E52050; Sat, 7 May 2022 06:36:23 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id B50385204F; Sat, 7 May 2022 06:36:22 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:57 +0530 Message-Id: <20220507063602.66309-5-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: XJMNK7MWh0fEEpzj80-Tfqhg_CSHvl4m X-Proofpoint-ORIG-GUID: XJMNK7MWh0fEEpzj80-Tfqhg_CSHvl4m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 spamscore=0 mlxlogscore=933 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 4/9] core/pldm/test : pldm file I/O read file Self test 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 self test for PLDM file I/O read message. This patch test codeflow for PLDM command PLDM_READ_FILE. Signed-off-by: Abhishek Singh Tomar TEST_FILE_IO_LENGTH) { + perror("TEST : length+offset Invalid"); + return PLDM_ERROR_INVALID_DATA; + } + + size = length; + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_read_file_resp) + size - 1; + *response_msg = malloc(*response_len); + + + + encode_read_file_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, size, *response_msg); + + if (ret != PLDM_SUCCESS) + return ret; + + struct pldm_read_file_resp *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, size); + break; default: return PLDM_ERROR_INVALID_DATA; @@ -208,6 +258,7 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t ret; + char buf_read[TEST_FILE_IO_LENGTH]; char buf_write[TEST_FILE_IO_LENGTH] = TEST_FILE_IO_BUF1; uint64_t size = strlen(buf_write); @@ -222,6 +273,12 @@ int main(void) return ret; } + /* Attempt to read using pldm file io before init should return error OPAL_PARAMTER */ + ret = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (ret != OPAL_PARAMETER) { + perror("pldm_file_io_write_file"); + return ret; + } /* Init PLDM File IO */ ret = pldm_file_io_init(); @@ -238,6 +295,19 @@ int main(void) return ret; } + /* Attempt to read: using pldm file io should return PLDM SUCCESS after init */ + ret = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (ret != PLDM_SUCCESS) { + perror("pldm_file_io_write_file"); + return ret; + } + + /* Test if buffer read same as buffer send */ + if (strncmp(buf_read, TEST_FILE_IO_BUF1, size) != 0) { + + perror("pldm read string mismatch"); + return OPAL_PARAMETER; + } return PLDM_SUCCESS; } From patchwork Sat May 7 06:35: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: 1627836 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=mmoWWNZU; 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 4KwHlx1J2Kz9sGV for ; Sat, 7 May 2022 16:37:01 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHlw6z9Wz3c9v for ; Sat, 7 May 2022 16:37:00 +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=mmoWWNZU; 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.156.1; 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=mmoWWNZU; dkim-atps=neutral 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 4KwHlY03Mrz3c7v for ; Sat, 7 May 2022 16:36:40 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 247683hQ024339 for ; Sat, 7 May 2022 06:36:37 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=irKhmkKcf1syjvx1WFZNOoaI/PP6JCee+1d6jciu2Ag=; b=mmoWWNZUcohYQhMh4FRTWmgoKKXUjoJ+zzexdros6Eoq48dpDfQciglk9oR+V6Uhp+ao AjWnhV+0PpsmWnL7JjVsFMV28JrxTznImw6eSL4hhs4OxAzCqzl9QC3y7IdeCS1Lbijd WyjVbBUK7mSknPRV7PcHrPluYWLSDrXzqHngVLVS9v522S9FyOOY8kvI/3rkgGVPTKn5 ody1FuA8EksQ6hSYDTEfsXRQ/Nw13M/+TwkDQm7dkPaibUXasU6sSG+qi/xrXVXEIRWw TdQW99P1NRCUse+6oxmwdlBqLfRS2yEdVIyVqs+nDeHc89+6gWO8JpjHmw5m8GXFbbbt eg== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwe4ubp2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:36 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476YN8M013792 for ; Sat, 7 May 2022 06:36:34 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma02fra.de.ibm.com with ESMTP id 3fwgd8r4h1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:34 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476aVv953608844 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:31 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76A855204F; Sat, 7 May 2022 06:36:31 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3526552050; Sat, 7 May 2022 06:36:29 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:58 +0530 Message-Id: <20220507063602.66309-6-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _UJJuRItatRdvitXcrmXGzumIuG5DvEW X-Proofpoint-ORIG-GUID: _UJJuRItatRdvitXcrmXGzumIuG5DvEW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 5/9] core/pldm/test : pldm BIOS Specification Self test 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 self test for PLDM Bios Specification implementation Signed-off-by: Abhishek Singh Tomar --- core/pldm/pldm-lid-files.c | 16 +- core/pldm/test/Makefile.check | 1 + core/pldm/test/common/test_pldm-common.c | 1 + core/pldm/test/test_pldm-bios.c | 259 +++++++++++++++++++++++ 4 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 core/pldm/test/test_pldm-bios.c diff --git a/core/pldm/pldm-lid-files.c b/core/pldm/pldm-lid-files.c index e8122268..2d8685d2 100644 --- a/core/pldm/pldm-lid-files.c +++ b/core/pldm/pldm-lid-files.c @@ -261,8 +261,11 @@ static int lid_files_read(struct blocklevel_device *bl __unused, /* LPC is only 32bit */ if (pos > UINT_MAX || len > UINT_MAX) return FLASH_ERR_PARM_ERROR; - +#ifndef __TEST__ prlog(PR_TRACE, "lid files read at 0x%llx for 0x%llx\n", pos, len); +#else + prlog(PR_TRACE, "lid files read at 0x%lx for 0x%lx\n", pos, len); +#endif if (pos == 0) { /* return a 'fake' header flash */ @@ -290,9 +293,11 @@ static int lid_files_write(struct blocklevel_device *bl __unused, /* LPC is only 32bit */ if (pos > UINT_MAX || len > UINT_MAX) return FLASH_ERR_PARM_ERROR; - +#ifndef __TEST__ prlog(PR_TRACE, "lid files write at 0x%llx for 0x%llx\n", pos, len); - +#else + prlog(PR_TRACE, "lid files write at 0x%lx for 0x%lx\n", pos, len); +#endif /* convert offset to lid id */ lid = vaddr_to_lid_id(pos); if (!lid) @@ -306,8 +311,11 @@ static int lid_files_write(struct blocklevel_device *bl __unused, static int lid_files_erase(struct blocklevel_device *bl __unused, uint64_t pos, uint64_t len) { - +#ifndef __TEST__ prlog(PR_TRACE, "lid files erase at 0x%llx for 0x%llx\n", pos, len); +#else + prlog(PR_TRACE, "lid files erase at 0x%lx for 0x%lx\n", pos, len); +#endif return OPAL_UNSUPPORTED; } diff --git a/core/pldm/test/Makefile.check b/core/pldm/test/Makefile.check index 42d60993..ce43dea0 100644 --- a/core/pldm/test/Makefile.check +++ b/core/pldm/test/Makefile.check @@ -1,5 +1,6 @@ # -*-Makefile-*- PLDM_TEST := core/pldm/test/test_pldm-fileio \ + core/pldm/test/test_pldm-bios \ LCOV_EXCLUDE += $(PLDM_TEST:%=%.c) diff --git a/core/pldm/test/common/test_pldm-common.c b/core/pldm/test/common/test_pldm-common.c index 33671150..0333937c 100644 --- a/core/pldm/test/common/test_pldm-common.c +++ b/core/pldm/test/common/test_pldm-common.c @@ -52,6 +52,7 @@ static inline unsigned long mftb(void); #include "../../pldm-watchdog.c" #include "../../pldm-fru-requests.c" #include "../../pldm-platform-requests.c" +#include "../../pldm-lid-files.c" #include "../../../device.c" diff --git a/core/pldm/test/test_pldm-bios.c b/core/pldm/test/test_pldm-bios.c new file mode 100644 index 00000000..2e6330ac --- /dev/null +++ b/core/pldm/test/test_pldm-bios.c @@ -0,0 +1,259 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* + * Copyright 2013-2019 IBM Corp. + */ + + +#include "common/test_pldm-common.c" + + +#define TEST_BIOS_STRING "hb_lid_ids" +#define TEST_BIOS_STRING_HANDLE 60 +#define TEST_ATTR_HANDLE 0 +#define TEST_ATTR_STRING_MIN_LEN 0 +#define TEST_ATTR_STRING_MAX_LEN 0 +#define TEST_ATTR_STRING_DEFAULT_LEN 0 +#define TEST_ATTR_STRING_DEFAULT "" +#define TEST_VALUE_TABLE_CURRENT_STR "ATTR_PERM=81e00663,ATTR_TMP=81e00664,NVRAM=81e0066b" +#define TEST_VALID_ATTR_NAME "ATTR_TMP" + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will handle pldm response message + * For now we don't have any response + */ +int pldm_test_verify_response(void *response_msg, size_t response_len) +{ + if (response_len > 0 || response_msg != NULL) + return OPAL_PARAMETER; + + return OPAL_PARAMETER; + +} + + +int pldm_test_reply_request_bios(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It generate bios table for self test based on input parameter tabletype + */ +uint32_t test_table_entry_generate(uint8_t **bios_table, uint8_t tableType) +{ + uint32_t bios_table_length = 0; + int pad_len = 0; + uint32_t checksum = 0; + + switch (tableType) { + + case PLDM_BIOS_STRING_TABLE: + bios_table_length = sizeof(struct pldm_bios_string_table_entry) + + strlen(TEST_BIOS_STRING) - 1; + + /* calculate padding length */ + if (bios_table_length % 4) + pad_len = 4 - (bios_table_length % 4); + else + pad_len = 0; + bios_table_length += sizeof(uint32_t) + pad_len; + + *bios_table = malloc(bios_table_length); + memset(*bios_table, 0, bios_table_length); + struct pldm_bios_string_table_entry *string_entry = + (struct pldm_bios_string_table_entry *)(*bios_table); + string_entry->string_handle = htole16(TEST_BIOS_STRING_HANDLE); + string_entry->string_length = htole16(strlen(TEST_BIOS_STRING)); + memcpy(string_entry->name, TEST_BIOS_STRING, string_entry->string_length); + break; + + case PLDM_BIOS_ATTR_TABLE: + struct pldm_bios_table_attr_entry_string_info info; + + bios_table_length = sizeof(struct pldm_bios_attr_table_entry) + + sizeof(struct attr_table_string_entry_fields) + + strlen(TEST_ATTR_STRING_DEFAULT); + + /* calculate padding length */ + if (bios_table_length % 4) + pad_len = 4 - (bios_table_length % 4); + else + pad_len = 0; + bios_table_length += sizeof(uint32_t) + pad_len; + + *bios_table = malloc(bios_table_length); + memset(*bios_table, 0, bios_table_length); + + info.name_handle = TEST_BIOS_STRING_HANDLE; + info.read_only = 0; + info.string_type = PLDM_BIOS_STRING; + info.min_length = TEST_ATTR_STRING_MIN_LEN; + info.max_length = TEST_ATTR_STRING_MAX_LEN; + info.def_length = TEST_ATTR_STRING_DEFAULT_LEN; + info.def_string = malloc(strlen(TEST_ATTR_STRING_DEFAULT)); + memcpy((uint8_t *)info.def_string, TEST_ATTR_STRING_DEFAULT, + strlen(TEST_ATTR_STRING_DEFAULT)); + pldm_bios_table_attr_entry_string_encode(*bios_table, bios_table_length, &info); + free((uint8_t *)info.def_string); + break; + + case PLDM_BIOS_ATTR_VAL_TABLE: + bios_table_length = sizeof(struct pldm_bios_attr_val_table_entry) + + sizeof(uint16_t) + sizeof(TEST_VALUE_TABLE_CURRENT_STR) - 1; + + /* calculate padding length */ + if (bios_table_length % 4) + pad_len = 4 - (bios_table_length % 4); + else + pad_len = 0; + bios_table_length += sizeof(uint32_t) + pad_len; + + *bios_table = malloc(bios_table_length); + memset(*bios_table, 0, bios_table_length); + + pldm_bios_table_attr_value_entry_encode_string(*bios_table, bios_table_length, + TEST_ATTR_HANDLE, PLDM_BIOS_STRING, + sizeof(TEST_VALUE_TABLE_CURRENT_STR), + TEST_VALUE_TABLE_CURRENT_STR); + break; + default: + printf("PLDM_TEST: INvalid Table type"); + return OPAL_PARAMETER; + + } + + /* Add padding data */ + memset(*bios_table + bios_table_length - sizeof(uint32_t) - pad_len, 0, pad_len); + + + checksum = htole32(pldm_crc32(*bios_table, bios_table_length - sizeof(uint32_t) + - pad_len)); + memcpy(*bios_table + bios_table_length - sizeof(uint32_t), (void *)&checksum, + sizeof(uint32_t)); + + return bios_table_length; + +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will only handle PLDM_BIOS type request + * As bios test will have only pldm request of type = PLDM_BIOS + */ +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + switch (((struct pldm_msg *)request_msg)->hdr.type) { + case PLDM_BIOS: + return pldm_test_reply_request_bios(request_msg, request_len, + response_msg, response_len); + + default: + printf("PLDM_TEST : Not equal to PLDM_BIOS\n"); + return OPAL_PARAMETER; + } + +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * it tries to handle PLDM_REQUEST for PLDM_BIOS and reply with appropriate + * PLDM_RESPONSE message + */ +int pldm_test_reply_request_bios(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + int ret; + uint32_t transfer_handle; + uint8_t transfer_op_flag, table_type; + uint8_t *bios_table; + size_t payload_length; + + + + /* + * check if command send is PLDM_GET_BIOS_TABLE then only + * reply response message and return PLDM_SUCCESS + * else return error + */ + if (((struct pldm_msg *)request_msg)->hdr.command == PLDM_GET_BIOS_TABLE) { + payload_length = request_len - sizeof(struct pldm_msg_hdr); + ret = decode_get_bios_table_req(request_msg, payload_length, &transfer_handle, + &transfer_op_flag, &table_type); + if (ret != PLDM_SUCCESS) + return ret; + + /* generate the table to reply request on behalf on BMC for PLDM self test */ + ret = test_table_entry_generate(&bios_table, table_type); + if (ret < PLDM_SUCCESS) + return ret; + payload_length = ret + sizeof(struct pldm_get_bios_table_resp) - 1; + + *response_len = sizeof(struct pldm_msg_hdr) + + payload_length - 1; + *response_msg = malloc(*response_len); + + ret = encode_get_bios_table_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, PLDM_GET_NEXTPART, PLDM_START_AND_END, + bios_table, payload_length, *response_msg); + free(bios_table); + if (ret != PLDM_SUCCESS) + return ret; + + return OPAL_SUCCESS; + } else + return OPAL_PARAMETER; + + return OPAL_SUCCESS; +} + + +int main(void) +{ + size_t ret; + char *lid; + char name[] = "Error"; + struct blocklevel_device *bl; + + /* + * Attempt to call pldm_bios_find_lid_by_attr_name() + * before pldm_bios_init() return error OPAL_HARDWARE + */ + ret = pldm_bios_find_lid_by_attr_name(name, &lid); + if (ret != OPAL_HARDWARE) + return ret; + + /* Init Pldm bios */ + ret = pldm_bios_init(); + if (ret != PLDM_SUCCESS) + return ret; + + + /* + * Attempt to call pldm_bios_find_lid_by_attr_name() + * when name argument not present return error OPAL_PARAMETER + */ + ret = pldm_bios_find_lid_by_attr_name(TEST_VALID_ATTR_NAME, &lid); + if (ret != PLDM_SUCCESS) + return ret; + + + /* + * Attempt to call pldm_bios_find_lid_by_attr_name() + * when name argument present return PLDM_SUCCESS + */ + ret = pldm_bios_find_lid_by_attr_name(TEST_VALID_ATTR_NAME, &lid); + if (ret != PLDM_SUCCESS) + return ret; + + + /* Init pldm_lid_files_init */ + ret = pldm_lid_files_init(&bl); + if (ret != PLDM_SUCCESS) + return ret; + + return 0; +} + + From patchwork Sat May 7 06:35: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: 1627837 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=pj+Odjy7; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHm428b4z9sGV for ; Sat, 7 May 2022 16:37:08 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHm40jZLz3cCN for ; Sat, 7 May 2022 16:37:08 +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=pj+Odjy7; 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.156.1; 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=pj+Odjy7; dkim-atps=neutral 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 4KwHlZ4FNvz3c9S for ; Sat, 7 May 2022 16:36:42 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2475pr4m021413 for ; Sat, 7 May 2022 06:36:40 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=XDCR4dkzCyQUclrTix0hIo2xwAMq1rJmgkU89+uBSgU=; b=pj+Odjy7n1S8V7op74noLfWDWCaPtEqaOyVRha+5SO4znV8LENMc/qpQLrQ7ZnS6bRs+ 1EG7PmIPPc7/f3dGbkExHmmtuFp5vQtKTQYokEkMuTTLr/6J0y2TfesAXdetsmvrwkwy OmHjnl6aaPrKPFwSxeowUiFGjDYTxmlk/8Y1dWjALEfo95iKBQZZNJCAV1DKKCxgYWHY kSWPo14oMHHV0DMKrfmymZCgjkQJKO+H3j+JZPXk+ONolfcD3/PECJGTUNT619zj2HGL C76+D/X3yYdFTPP9ucIzm/yh7um7dNEyUwUxTlLeDpwZllHAEJx2J0oSDVCecm12QIFA cg== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwk0c0fkt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:40 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476YHIM013773 for ; Sat, 7 May 2022 06:36:38 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma02fra.de.ibm.com with ESMTP id 3fwgd8r4h3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:37 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476aYDh42139928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:35 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3AFE52050; Sat, 7 May 2022 06:36:34 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 908625204F; Sat, 7 May 2022 06:36:33 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:05:59 +0530 Message-Id: <20220507063602.66309-7-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kQF-UlQhu6iVe2XtNkPKHyC7hP8ZUTLY X-Proofpoint-ORIG-GUID: kQF-UlQhu6iVe2XtNkPKHyC7hP8ZUTLY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 spamscore=0 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 6/9] core/pldm/test : pldm platform specification Init self test 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" This patch test for PLDM platform Init implementation This patch test platform commands: 1. PLDM_PLATFORM_EVENT_MESSAGE 2. PLDM_GET_PDR Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/Makefile.check | 1 + core/pldm/test/common/test_pldm-common.c | 19 +- core/pldm/test/test_pldm-platform.c | 289 +++++++++++++++++++++++ 3 files changed, 303 insertions(+), 6 deletions(-) create mode 100644 core/pldm/test/test_pldm-platform.c diff --git a/core/pldm/test/Makefile.check b/core/pldm/test/Makefile.check index ce43dea0..c184702f 100644 --- a/core/pldm/test/Makefile.check +++ b/core/pldm/test/Makefile.check @@ -1,6 +1,7 @@ # -*-Makefile-*- PLDM_TEST := core/pldm/test/test_pldm-fileio \ core/pldm/test/test_pldm-bios \ + core/pldm/test/test_pldm-platform \ LCOV_EXCLUDE += $(PLDM_TEST:%=%.c) diff --git a/core/pldm/test/common/test_pldm-common.c b/core/pldm/test/common/test_pldm-common.c index 0333937c..7d0203dc 100644 --- a/core/pldm/test/common/test_pldm-common.c +++ b/core/pldm/test/common/test_pldm-common.c @@ -137,13 +137,20 @@ int ast_mctp_message_tx(uint8_t eid, uint8_t *msg, int len) &response_msg, &response_len); if (ret != PLDM_SUCCESS) return ret; - vmsg = malloc(response_len+1); - /* TYPE: PLDM = 0x01 (000_0001b) as per MCTP - DSP0240 */ - vmsg[0] = 0x01; - memcpy(vmsg + 1, response_msg, response_len); - - pldm_rx_message(BMC_EID, 0, 0, NULL, vmsg, response_len+1); + /* + * If response length > 0 then response back + * else if response length == 0 then no need to response + * if response length > 0 then error + */ + if (response_len > 0) { + vmsg = malloc(response_len+1); + + // TYPE: PLDM = 0x01 (000_0001b) as per MCTP - DSP0240 + vmsg[0] = 0x01; + memcpy(vmsg + 1, response_msg, response_len); + pldm_rx_message(BMC_EID, 0, 0, NULL, vmsg, response_len+1); + } } return PLDM_SUCCESS; diff --git a/core/pldm/test/test_pldm-platform.c b/core/pldm/test/test_pldm-platform.c new file mode 100644 index 00000000..05cc53f0 --- /dev/null +++ b/core/pldm/test/test_pldm-platform.c @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* + * Copyright 2013-2019 IBM Corp. + */ + + +#include "common/test_pldm-common.c" + + +#define EFFECTER1_RECORD_HANDLE 120 +#define EFFECTER1_POSSIBLE_STATES PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED +#define EFFECTER2_RECORD_HANDLE 160 +#define EFFECTER2_POSSIBLE_STATES PLDM_STATE_SET_SYSTEM_POWER_STATE + + +/* + * These stucturs duplicate BMC functionality for Pldm self test + * It include PDR 1st entry to be send on behalf of BMC + */ +struct pldm_state_effecter_pdr effecter_test_1 = { + .hdr = { + .record_handle = EFFECTER1_RECORD_HANDLE + }, + .terminus_handle = 1, + .effecter_id = 38, + .entity_type = PLDM_ENTITY_SYS_FIRMWARE, + .entity_instance = 1, + .container_id = 1, + .effecter_semantic_id = 0, + .effecter_init = 0, + .has_description_pdr = 0, + .composite_effecter_count = 1 +}; +struct state_effecter_possible_states possible_states_effecter_1_test = { + .state_set_id = PLDM_STATE_SET_SW_TERMINATION_STATUS, + .possible_states_size = 1, + .states = { + {.byte = PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED} + } + +}; + + +/* + * These stucturs duplicate BMC functionality for Pldm self test + * It include PDR 2nd entry to be send on behalf of BMC + */ +struct pldm_state_effecter_pdr effecter_test_2 = { + .hdr = { + .record_handle = EFFECTER2_RECORD_HANDLE + }, + .terminus_handle = 1, + .effecter_id = 38, + .entity_type = PLDM_ENTITY_SYSTEM_CHASSIS, + .entity_instance = 1, + .container_id = 1, + .effecter_semantic_id = 0, + .effecter_init = 0, + .has_description_pdr = 0, + .composite_effecter_count = 1 +}; +struct state_effecter_possible_states possible_states_effecter_2_test = { + .state_set_id = PLDM_STATE_SET_SYSTEM_POWER_STATE, + .possible_states_size = 1, + .states = { + {.byte = PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL} + } +}; + + +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); +int pldm_test_reply_request_platform(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); +uint32_t test_pdr_entry_generate(uint8_t **pdr, uint32_t record_hndl); + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will handle pldm response message + * For now we don't have any response + */ +int pldm_test_verify_response(void *response_msg, size_t response_len) +{ + if (response_len > 0 || response_msg != NULL) + return OPAL_PARAMETER; + return OPAL_PARAMETER; + +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * This Genrate pdr entry for self test + */ +uint32_t test_pdr_entry_generate(uint8_t **pdr, + uint32_t record_hndl) +{ + int size; + size_t possible_states_size = 0; + struct pldm_state_effecter_pdr *effecter = NULL; + size_t actual_size; + struct pldm_state_effecter_pdr *effecter_test; + struct state_effecter_possible_states *possible_states_effecter_test; + + + /* calculate sizeof whole struct */ + size = sizeof(struct pldm_state_effecter_pdr) + + sizeof(struct state_effecter_possible_states) - 1; + + if (record_hndl == 0) { + effecter_test = &effecter_test_1; + possible_states_effecter_test = &possible_states_effecter_1_test; + } else if (record_hndl == effecter_test_1.hdr.record_handle) { + effecter_test = &effecter_test_1; + possible_states_effecter_test = &possible_states_effecter_1_test; + } else if (record_hndl == effecter_test_2.hdr.record_handle) { + effecter_test = &effecter_test_2; + possible_states_effecter_test = &possible_states_effecter_2_test; + } else + return OPAL_PARAMETER; + + + *pdr = malloc(size); + memset(*pdr, 0, size); + effecter = (struct pldm_state_effecter_pdr *)(*pdr); + if (effecter == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); + } + effecter->terminus_handle = effecter_test->terminus_handle; + effecter->effecter_id = effecter_test->effecter_id; + effecter->entity_type = effecter_test->entity_type; + effecter->entity_instance = effecter_test->entity_instance; + effecter->container_id = effecter_test->container_id; + effecter->effecter_semantic_id = effecter_test->effecter_semantic_id; + effecter->effecter_init = effecter_test->effecter_init; + effecter->has_description_pdr = effecter_test->has_description_pdr; + effecter->composite_effecter_count = effecter_test->composite_effecter_count; + + /* For PLDM Test consider only 1 possible state */ + possible_states_size = sizeof(struct state_effecter_possible_states) + + possible_states_effecter_test->possible_states_size - 1; + encode_state_effecter_pdr(effecter, size, + possible_states_effecter_test, + possible_states_size, &actual_size); + + return actual_size; + +} + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * it tries to handle PLDM_REQUEST for PLDM_PLATFORM and reply with appropriate + * PLDM_RESPONSE message + * As pldm platfom test it will have only pldm request of type = PLDM_PLATFORM + */ +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + + switch (((struct pldm_msg *)request_msg)->hdr.type) { + case PLDM_PLATFORM: + return pldm_test_reply_request_platform(request_msg, request_len, + response_msg, response_len); + + default: + printf("PLDM_TEST: Not equal to PLDM_PLATFORM\n"); + return OPAL_PARAMETER; + } + + +} + + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * it tries to handle PLDM_REQUEST for PLDM_PLATFORM and reply with appropriate + * PLDM_RESPONSE message + */ +int pldm_test_reply_request_platform(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + uint8_t *pdr = NULL; + int ret = 0; + int payload_len = 0; + uint32_t transfer_handle; + uint8_t transfer_opflag; + uint16_t request_cnt; + uint16_t record_chg_num; + uint32_t record_hndl; + uint8_t format_version, tid, event_class; + size_t event_data_offset; + +/* check pldm command received and reply with appropriate pldm response message */ + switch (((struct pldm_msg *)request_msg)->hdr.command) { + case PLDM_GET_PDR: + + payload_len = request_len - sizeof(struct pldm_msg_hdr); + ret = decode_get_pdr_req(request_msg, payload_len, &record_hndl, &transfer_handle, + &transfer_opflag, &request_cnt, &record_chg_num); + if (ret != PLDM_SUCCESS) + return ret; + + /* Generate pdr entry for self test */ + ret = test_pdr_entry_generate(&pdr, record_hndl); + if (ret < PLDM_SUCCESS) + return ret; + payload_len = (sizeof(struct pldm_get_pdr_resp) - 1) + + ret; + *response_len = sizeof(struct pldm_msg_hdr) + + payload_len; + *response_msg = malloc(*response_len); + + /* + * if record_handle is equal to first record handle or 0 + * the encode next data transfer handle with 2nd record handle + */ + if (record_hndl == EFFECTER1_RECORD_HANDLE || record_hndl == 0) { + ret = encode_get_pdr_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, EFFECTER2_RECORD_HANDLE, + PLDM_GET_NEXTPART, PLDM_START_AND_END, ret, pdr, 0, + *response_msg); + } + /* + * if record_handle is equal to last record handle + * the encode next data transfer handle with 0 + */ + else if (record_hndl == EFFECTER2_RECORD_HANDLE) { + ret = encode_get_pdr_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, 0, PLDM_GET_NEXTPART, PLDM_START_AND_END, + ret, pdr, 0, *response_msg); + } else + return OPAL_PARAMETER; + + free(pdr); + if (ret != PLDM_SUCCESS) + return ret; + break; + + case PLDM_PLATFORM_EVENT_MESSAGE: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + ret = decode_platform_event_message_req(request_msg, payload_len, &format_version, + &tid, &event_class, &event_data_offset); + + /* Test: if tid and event class same as that expected */ + if (tid != HOST_TID || event_class != PLDM_PDR_REPOSITORY_CHG_EVENT) + return OPAL_PARAMETER; + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_platform_event_message_resp); + *response_msg = malloc(*response_len); + ret = encode_platform_event_message_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, 0, *response_msg); + return PLDM_SUCCESS; + + + + default: + return PLDM_ERROR_INVALID_DATA; + + } + + return PLDM_SUCCESS; + + + +} + + +int main(void) +{ + int ret; + + + /* Inittialize pldm platform */ + ret = pldm_platform_init(); + printf("pldm_platform_init ends with %d\n", ret); + if (ret != PLDM_SUCCESS) { + perror("pldm_platform_init"); + return ret; + } + + + return PLDM_SUCCESS; +} + + From patchwork Sat May 7 06:36:00 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: 1627838 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=bJSV/cZw; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHmD2CKgz9sGV for ; Sat, 7 May 2022 16:37:16 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHmD15Glz3cCP for ; Sat, 7 May 2022 16:37:16 +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=bJSV/cZw; 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=bJSV/cZw; 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 4KwHlf1b9xz3c7h for ; Sat, 7 May 2022 16:36:46 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24762e5A003015 for ; Sat, 7 May 2022 06:36: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=V1vA+uDiyRkC6K/xdBjZwZaNwX5fPygKcxwFFGJjfXc=; b=bJSV/cZwQ8YS7mGq81pm3vgcRGJYOJJYBCAQ8YsZBM8UFhC/9IRqsEurSuWwO74lBpUa SvTA1iIdLSWZ9mkAbBFdJ3h61OV6OXSzFZlnxQzFqhc766XcSVgCFwItoAKqMVRryh19 9skUKpWr/7oQA0bCI57BCDLzUGCQ9QYE+y0jBXNHDxk/tPH6kXL6mOJ6gvncnOGc7J9s 8H8bP59SDdpJsSfwkqBySz5Ahz6kkiJVR3VOl15lVp+CNN0woYWdPH3Rg190mAWkXO65 uapVzhp6X3VmXRj3Ej42tMWUF/io73VQFodJLFwfywF49Wzh5sP2gxhCzzqC0iBEce4L MQ== 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 3fwk5e0c0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:43 +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 2476ZFXt002463 for ; Sat, 7 May 2022 06:36:41 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3fwg1j06d2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:41 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476acDX16843036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:38 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 372D952050; Sat, 7 May 2022 06:36:38 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id EDAC25204F; Sat, 7 May 2022 06:36:36 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:06:00 +0530 Message-Id: <20220507063602.66309-8-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hijsrxlxe7TBEOEJGdUz62WVlyPB6aKh X-Proofpoint-ORIG-GUID: hijsrxlxe7TBEOEJGdUz62WVlyPB6aKh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 impostorscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 7/9] core/pldm/test : pldm platform restart and platform power off self test 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 PLDM platform implementation self test for pldm platform restart and platform power off The patch test PLDM Platfrm command PLDM_SET_STATE_EFFECTER_STATES Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test_pldm-platform.c | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/core/pldm/test/test_pldm-platform.c b/core/pldm/test/test_pldm-platform.c index 05cc53f0..67146a8d 100644 --- a/core/pldm/test/test_pldm-platform.c +++ b/core/pldm/test/test_pldm-platform.c @@ -189,6 +189,9 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len, uint16_t request_cnt; uint16_t record_chg_num; uint32_t record_hndl; + uint16_t effecter_id; + uint8_t comp_effecter_count; + set_effecter_state_field field; uint8_t format_version, tid, event_class; size_t event_data_offset; @@ -237,6 +240,44 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len, if (ret != PLDM_SUCCESS) return ret; break; + case PLDM_SET_STATE_EFFECTER_STATES: + + payload_len = request_len - sizeof(struct pldm_msg_hdr); + ret = decode_set_state_effecter_states_req(request_msg, payload_len, &effecter_id, + &comp_effecter_count, &field); + + /* + * Test if request received from same effecter id passed + * and also check field struct same as expected + */ + if ( + ( + effecter_id == effecter_test_1.effecter_id && + field.effecter_state == + possible_states_effecter_1_test.states->byte && + field.set_request == PLDM_REQUEST_SET && + field.effecter_state == PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED + + ) || + ( + effecter_id == effecter_test_2.effecter_id && + field.effecter_state == + possible_states_effecter_2_test.states->byte && + field.set_request == PLDM_REQUEST_SET && + field.effecter_state == + PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL + ) + ) { + /* + * BMC doesn't answer for these specific effecter states + * (PLDM_SW_TERM_GRACEFUL_RESTART and PLDM_STATE_SET_SYS_POWER_STATE_OFF) + * hence *response len = 0 + */ + *response_len = 0; + return PLDM_SUCCESS; + } else + return OPAL_PARAMETER; + return PLDM_SUCCESS; case PLDM_PLATFORM_EVENT_MESSAGE: payload_len = request_len - sizeof(struct pldm_msg_hdr); @@ -274,6 +315,31 @@ int main(void) int ret; + /* + * Attempt to call pldm_platform_restart() + * before pldm_platform_init() return error + * OPAL_HARDWARE + */ + ret = pldm_platform_restart(); + printf("pldm_platform_restart ends with %d\n", ret); + if (ret != OPAL_HARDWARE) { + perror("pldm_platform_restart"); + return ret; + } + + + /* + * Attempt to call pldm_platform_power_off() + * before pldm_platform_init() return error + * OPAL_HARDWARE + */ + ret = pldm_platform_power_off(); + printf("pldm_platform_power_off ends with %d\n", ret); + if (ret != OPAL_HARDWARE) { + perror("pldm_platform_restart"); + return ret; + } + /* Inittialize pldm platform */ ret = pldm_platform_init(); printf("pldm_platform_init ends with %d\n", ret); @@ -283,6 +349,29 @@ int main(void) } + /* + * Attempt to call pldm_platform_restart() + * after pldm_platform_init() return PLDM_SUCCESS + */ + ret = pldm_platform_restart(); + printf("pldm_platform_restart ends with %d\n", ret); + if (ret != PLDM_SUCCESS) { + perror("pldm_platform_restart"); + return ret; + } + + + /* + * Attempt to call pldm_platform_power_off() + * after pldm_platform_init() return PLDM_SUCCESS + */ + ret = pldm_platform_power_off(); + printf("pldm_platform_power_off ends with %d\n", ret); + if (ret != PLDM_SUCCESS) { + perror("pldm_platform_restart"); + return ret; + } + return PLDM_SUCCESS; } From patchwork Sat May 7 06:36:01 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: 1627839 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=WzLeZ/M+; 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 4KwHmM3TStz9sGV for ; Sat, 7 May 2022 16:37:23 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHmM0936z3c5C for ; Sat, 7 May 2022 16:37:23 +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=WzLeZ/M+; 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=WzLeZ/M+; 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 4KwHlk46C2z3c94 for ; Sat, 7 May 2022 16:36:50 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2475fBGL022138 for ; Sat, 7 May 2022 06:36:48 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=N+XN3reJ/lGfocHnkov8ju/yNb4wpCcmuOFu9vsHrA8=; b=WzLeZ/M+mGhiUH7U9+mkWBAXNKHxdJfaA4jvVqdwxKU7DUsSjRGOH0+J1bjaXN9tm7WT 2fMOf0jgsy89POm8HCZ5Ri45Il6rZjb8yW0nM6UToNIjpdpU7buYzD/pBLmgCWL6S3cZ ToCFf1qZnse+FJIM9xNYRNAmgjEPKltPmOkl7Dhu6Pv4hbCdzZn4wdjgnsXCanrqCHIi lWjyswBuDkRF/WEJ0Dc1a6/0x73n90A2nBTKv3mGPFWQEnwbvn22eZGJ3DbUTspbtboR DrZYe/sDCqPJxuFl3EhC3iCjiU7nQ26fKLKhSc/NEX0ij5YvvfqEelpsD+NVZ50dSzrv kw== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwe6puq0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:47 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2476Ybvk020320 for ; Sat, 7 May 2022 06:36:46 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3fwg1hr4vd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:45 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476agwt42860920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:42 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D101952050; Sat, 7 May 2022 06:36:42 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 904105204E; Sat, 7 May 2022 06:36:41 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:06:01 +0530 Message-Id: <20220507063602.66309-9-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SBYpB52fm-Ibl4ynkCR81898U8JV48er X-Proofpoint-ORIG-GUID: SBYpB52fm-Ibl4ynkCR81898U8JV48er X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 8/9] core/pldm/test : pldm FRU Table selftest 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" This patch contains: 1. PLDM FRU self test by sending PLDM_GET_FRU_RECORD_TABLE_METADATA request on behalf of BMC. 2. Test pldm_fru_get_table() response before and after fru table created Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/Makefile.check | 1 + core/pldm/test/test_pldm-fru.c | 224 +++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 core/pldm/test/test_pldm-fru.c diff --git a/core/pldm/test/Makefile.check b/core/pldm/test/Makefile.check index c184702f..2295a99b 100644 --- a/core/pldm/test/Makefile.check +++ b/core/pldm/test/Makefile.check @@ -2,6 +2,7 @@ PLDM_TEST := core/pldm/test/test_pldm-fileio \ core/pldm/test/test_pldm-bios \ core/pldm/test/test_pldm-platform \ + core/pldm/test/test_pldm-fru LCOV_EXCLUDE += $(PLDM_TEST:%=%.c) diff --git a/core/pldm/test/test_pldm-fru.c b/core/pldm/test/test_pldm-fru.c new file mode 100644 index 00000000..049dbce8 --- /dev/null +++ b/core/pldm/test/test_pldm-fru.c @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* + * Copyright 2013-2019 IBM Corp. + */ + + +#include "common/test_pldm-common.c" + + +#define TEST_BMC_VERSION "tes_t_1.0" + +bool get_fru_record_table_in_progress; +int pldm_test_verify_response(void *response_msg, size_t response_len); +int pldm_test_verify_response_fru(void *response_msg, size_t response_len); +int test_fru_table_metadata_request(void); +int pldm_test_reply_request_fru(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); +int pldm_test_generate_reply_field_type_version(uint8_t record_type, uint8_t field_type, + uint8_t **fru_table, size_t *fru_table_size); + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will only handle PLDM_FRU type response + */ +int pldm_test_verify_response(void *response_msg, size_t response_len) +{ + switch (((struct pldm_msg *)response_msg)->hdr.type) { + + case PLDM_FRU: + return pldm_test_verify_response_fru(response_msg, response_len); + + default: + printf("PLDM_TEST: Not equal to PLDM_FRU\n"); + return OPAL_PARAMETER; + } + + +} + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will only handle PLDM_FRU type response and tries to verify that + * PLDM response is same as expected + */ +int pldm_test_verify_response_fru(void *response_msg, size_t response_len) +{ + uint8_t completion_code; + int ret = 0; + int payload_len = 0; + uint8_t fru_data_major_version; + uint8_t fru_data_minor_version; + uint32_t fru_table_maximum_size; + uint32_t fru_table_length; + uint16_t total_record_set_identifiers; + uint16_t total_table_records; + uint32_t checksum; + + switch (((struct pldm_msg *)response_msg)->hdr.command) { + case PLDM_GET_FRU_RECORD_TABLE_METADATA: + + /* + * Test that response receive for + * PLDM_GET_FRU_RECORD_TABLE_METADATA + * only when specific request in progress + */ + if (get_fru_record_table_in_progress != true) + return OPAL_PARAMETER; + + payload_len = response_len - sizeof(struct pldm_msg_hdr); + ret = decode_get_fru_record_table_metadata_resp(response_msg, payload_len, + &(completion_code), &fru_data_major_version, + &fru_data_minor_version, + &fru_table_maximum_size, + &fru_table_length, + &total_record_set_identifiers, + &total_table_records, + &checksum); + + /* + * Test if PLDM request completed with success i.e. completion code = PLDM_SUCCESS + * and test if other parameter as expected then return PLDM_SUCCESS + * else return error PLDM_ERROR_INVALID_DATA + */ + if (ret == OPAL_SUCCESS && completion_code == PLDM_SUCCESS && + total_record_set_identifiers == 1 + && total_table_records == 1) + return PLDM_SUCCESS; + else + return PLDM_ERROR_INVALID_DATA; + break; + + default: + return PLDM_ERROR_INVALID_DATA; + + } + + return PLDM_SUCCESS; + + + +} + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It will only handle PLDM_FRU type request + */ +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + switch (((struct pldm_msg *)request_msg)->hdr.type) { + + case PLDM_FRU: + return pldm_test_reply_request_fru(request_msg, request_len, + response_msg, response_len); + + default: + printf("PLDM_TEST: Not equal to PLDM_FRU \n"); + return OPAL_PARAMETER; + } + +} + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * it tries to handle PLDM_REQUEST for PLDM_FRU and reply with appropriate + * PLDM_RESPONSE message + */ +int pldm_test_reply_request_fru(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + switch (((struct pldm_msg *)request_msg)->hdr.command) { + case PLDM_GET_FRU_RECORD_BY_OPTION: + (void)request_len; + *response_msg = NULL; + *response_len = 0; + + break; + default: + return PLDM_ERROR_INVALID_DATA; + } + + return PLDM_SUCCESS; + +} + + + +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It tries to send PLDM_GET_FRU_RECORD_TABLE_METADATA on behalf of BMC + */ +int test_fru_table_metadata_request(void) +{ + void *pldm_req; + int size, ret; + + size = sizeof(struct pldm_msg_hdr); + pldm_req = malloc(size); + /* + * Enable flag that indicate PLDM_GET_FRU_RECORD_TABLE_METADATA + * request in progress. + * This flag is used only for test + */ + get_fru_record_table_in_progress = true; + + /* Encode request on behalf of BMC */ + ret = encode_get_fru_record_table_metadata_req(0, pldm_req, 0); + if (ret != PLDM_SUCCESS) + return ret; + + /* initialize responder */ + ret = pldm_mctp_responder_init(); + if (ret != PLDM_SUCCESS) + return ret; + + /* skip mctp layer directly call handle */ + ret = pldm_handle(BMC_EID, pldm_req, size); + if (ret != PLDM_SUCCESS) + return ret; + + /* + * Disable flag that indicate PLDM_GET_FRU_RECORD_TABLE_METADATA + * request in progress. + * This flag is used only for test + */ + get_fru_record_table_in_progress = false; + + return ret; + +} + + +int main(void) +{ + int ret; + void *fru_record_table; + uint32_t fru_record_table_size; + + /* + * Trying to get fru table when fru table not created + * @return error OPAL_PARAMETER + */ + ret = pldm_fru_get_table(&fru_record_table, &fru_record_table_size); + if (ret != OPAL_PARAMETER) + return OPAL_PARAMETER; + + /* Sending request in behalf of bmc and checking response */ + ret = test_fru_table_metadata_request(); + if (ret != PLDM_SUCCESS) { + perror("encode_get_fru_record_table_metadata_req"); + return ret; + } + + /* Trying to get fru table when fru table created */ + ret = pldm_fru_get_table(&fru_record_table, &fru_record_table_size); + if (ret != PLDM_SUCCESS) + return OPAL_PARAMETER; + +} + From patchwork Sat May 7 06:36:02 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: 1627840 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=ASA6gyHn; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KwHmV4CXWz9sGV for ; Sat, 7 May 2022 16:37:30 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KwHmV2jGDz3cCJ for ; Sat, 7 May 2022 16:37:30 +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=ASA6gyHn; 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.156.1; 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=ASA6gyHn; dkim-atps=neutral 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 4KwHlp55mnz3c9Q for ; Sat, 7 May 2022 16:36:54 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2476Ejtj011607 for ; Sat, 7 May 2022 06:36:52 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=CBWs6Cls2RP+qOwHtMV2lgSUOpGL+7XFRCGe4xRnTLc=; b=ASA6gyHnbb5X4NFUQkFD7ezQInBLO6tE+38UUcv3z/mt08sN4ibFCLbeq4BBVY1Gq/JK kZrdIS6EUCFqP/Or0zlrjwyM+bekkbD8izEOT8Ml5isOD7ik6C+VKcjHvne5TKQYoj2v DUZ4+w5Ee6T0zmJFpuPzUbp+pi2lhWxmZLtVWajejZz7WN3y9Zmegz6fzEtCSqrmSS+4 fVyOi6hrZiS2LXIcxsm5gmrcmXrx6IKcHGOF+Q1HRK0GsI5n9e9oI0atDJFiSRWnSNks RoY+RqKCq9DqBo7YPZPHhTCkey+lOZ4J1BR57snEEAJCcBtBfcY9CQsx20P4pbvYrFaW uw== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fwkb406h7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:51 +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 2476ZJkk002478 for ; Sat, 7 May 2022 06:36:49 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3fwg1j06d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 07 May 2022 06:36:49 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2476abZt29032758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 May 2022 06:36:37 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 841E85204F; Sat, 7 May 2022 06:36:46 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.ibm.com.com (unknown [9.43.76.43]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 41A275204E; Sat, 7 May 2022 06:36:44 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Sat, 7 May 2022 12:06:02 +0530 Message-Id: <20220507063602.66309-10-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220507063602.66309-1-abhishek@linux.ibm.com> References: <20220507063602.66309-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: PxPdIcomulCNe52z1cmdeZ4761nH0Xlk X-Proofpoint-GUID: PxPdIcomulCNe52z1cmdeZ4761nH0Xlk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-07_01,2022-05-06_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205070041 Subject: [Skiboot] [PATCH v2 9/9] core/pldm/test : pldm FRU implementation to retrieve the bmc information 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" This patch do self test to retrive BMC version information Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test_pldm-fru.c | 118 ++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 3 deletions(-) diff --git a/core/pldm/test/test_pldm-fru.c b/core/pldm/test/test_pldm-fru.c index 049dbce8..53232399 100644 --- a/core/pldm/test/test_pldm-fru.c +++ b/core/pldm/test/test_pldm-fru.c @@ -124,6 +124,56 @@ int pldm_test_reply_request(void *request_msg, size_t request_len, } +/* + * This function tries to duplicate BMC functionality for Pldm self test + * It generate reply for PLDM_GET_FRU_RECORD_BY_OPTION for self test. + * It generates fru Dta structure with BMC version tlv + */ +int pldm_test_generate_reply_field_type_version(uint8_t record_type, uint8_t field_type, + uint8_t **fru_table, size_t *fru_table_size) +{ + struct pldm_fru_record_tlv *tlv; + int tlv_size, ret; + size_t curr_size = 0; + size_t pad_bytes = 0; + uint32_t checksum; + + if (field_type == PLDM_FRU_FIELD_TYPE_VERSION && + record_type == PLDM_FRU_RECORD_TYPE_GENERAL) { + + tlv_size = sizeof(struct pldm_fru_record_tlv) + strlen(TEST_BMC_VERSION) - 1; + tlv = malloc(tlv_size); + tlv->type = PLDM_FRU_FIELD_TYPE_VERSION; + tlv->length = strlen(TEST_BMC_VERSION); + memcpy(tlv->value, TEST_BMC_VERSION, tlv->length); + *fru_table_size = sizeof(struct pldm_fru_record_data_format) + tlv->length - 1; + + /* Culculate pad bytes in fru */ + if (*fru_table_size % 4) + pad_bytes = 4 - (*fru_table_size % 4); + else + pad_bytes = 0; + + *fru_table = malloc(*fru_table_size + pad_bytes + sizeof(uint32_t)); + ret = encode_fru_record(*fru_table, *fru_table_size, &curr_size, 0, + PLDM_FRU_RECORD_TYPE_GENERAL, 1, 1, (uint8_t *)tlv, tlv_size); + if (ret != PLDM_SUCCESS) + return ret; + *fru_table_size += pad_bytes + sizeof(uint32_t); + + /* Pad with 0 */ + memset(*fru_table + curr_size, 0, pad_bytes); + + checksum = htole32(pldm_crc32(*fru_table, *fru_table_size - sizeof(uint32_t))); + memcpy(*fru_table + curr_size + pad_bytes, (void *)&checksum, sizeof(uint32_t)); + free(tlv); + } else + return OPAL_PARAMETER; + + return PLDM_SUCCESS; +} + + /* * This function tries to duplicate BMC functionality for Pldm self test * it tries to handle PLDM_REQUEST for PLDM_FRU and reply with appropriate @@ -132,12 +182,60 @@ int pldm_test_reply_request(void *request_msg, size_t request_len, int pldm_test_reply_request_fru(void *request_msg, size_t request_len, void **response_msg, size_t *response_len) { + int ret, payload_len = 0; + uint32_t transfer_handle; + uint16_t fru_table_handle; + uint16_t record_set_identifier; + uint8_t record_type; + uint8_t field_type; + uint8_t transfer_op_flag; + uint8_t *fru_ds; + size_t fru_ds_size; + + /* Check PLDM command and reply with appropriate reply */ switch (((struct pldm_msg *)request_msg)->hdr.command) { case PLDM_GET_FRU_RECORD_BY_OPTION: - (void)request_len; - *response_msg = NULL; - *response_len = 0; + payload_len = request_len - sizeof(struct pldm_msg_hdr); + ret = decode_get_fru_record_by_option_req(request_msg, payload_len, + &transfer_handle, &fru_table_handle, &record_set_identifier, + &record_type, &field_type, &transfer_op_flag); + if (ret != PLDM_SUCCESS) + return ret; + /* + * Test if field type and record type is as expected i.e. + * field type = PLDM_FRU_FIELD_TYPE_VERSION and + * record_type == PLDM_FRU_RECORD_TYPE_GENERAL + * else return error + */ + if (field_type == PLDM_FRU_FIELD_TYPE_VERSION && + record_type == PLDM_FRU_RECORD_TYPE_GENERAL) { + + /* + * generate the fru data structure to reply request + * on behalf on BMC for PLDM self test + */ + ret = pldm_test_generate_reply_field_type_version( + PLDM_FRU_RECORD_TYPE_GENERAL, + PLDM_FRU_FIELD_TYPE_VERSION, &fru_ds, &fru_ds_size); + if (ret != PLDM_SUCCESS) + return ret; + + payload_len = fru_ds_size + + sizeof(struct pldm_get_fru_record_by_option_resp) - 1; + *response_len = sizeof(struct pldm_msg_hdr) + payload_len; + *response_msg = malloc(*response_len); + + ret = encode_get_fru_record_by_option_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, PLDM_GET_NEXTPART, PLDM_START_AND_END, + fru_ds, fru_ds_size, *response_msg, payload_len); + if (ret != PLDM_SUCCESS) + return ret; + free(fru_ds); + return PLDM_SUCCESS; + } else + return OPAL_PARAMETER; break; default: return PLDM_ERROR_INVALID_DATA; @@ -199,6 +297,7 @@ int main(void) int ret; void *fru_record_table; uint32_t fru_record_table_size; + struct variable_field fru_structure_data; /* * Trying to get fru table when fru table not created @@ -220,5 +319,18 @@ int main(void) if (ret != PLDM_SUCCESS) return OPAL_PARAMETER; + /* retrieve the bmc information with + * "FRU Field Type": Version + * "FRU Record Set Identifier": 1, + * "FRU Record Type": "General(1)" + */ + ret = pldm_fru_get_record_by_option(0, 1, PLDM_FRU_RECORD_TYPE_GENERAL, + PLDM_FRU_FIELD_TYPE_VERSION, &fru_structure_data); + if (ret != PLDM_SUCCESS) { + perror("encode_get_fru_record_table_metadata_req"); + return ret; + } + + }