From patchwork Wed May 18 07:42: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: 1632637 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=WiP8V99h; 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 4L34jv56n9z9sBB for ; Wed, 18 May 2022 17:43:47 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34jv4J8gz3bxn for ; Wed, 18 May 2022 17:43:47 +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=WiP8V99h; 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=WiP8V99h; 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 4L34jp5H9jz3bpr for ; Wed, 18 May 2022 17:43:42 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7Ngxv005725 for ; Wed, 18 May 2022 07:43: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=m/6OFWqOwrbTNIWfdKXIaGq5QqRand2L712u3cUEIkA=; b=WiP8V99hFGHkZq2HTbwR+/vRH4rLQK5sJ5D8Y3P3xF7UPVcJ1fZUX9M9C6hF0e/WVlzr MbetSkOlqND9lzthXyDy12eFfydz+o3D2/hKeiqo/15tGHa7dTUPw5+pXvLjoIuKyJd+ /Y5RojJnKroTKClDNrr+n4NmkUXYd+XuegGkQcY7L8elODdDjaPo49rIJHlcvVkMYVur 72uYdb02zxJ71y2ESX67vESN2yKCgiy4pZa97dPLJvETjz2Tbxs+db1XjfmW8FOPC80o tZ9h3JDH59j7Fg0r3lPJ0oakUBXWopHXoqAu0Wae4ys80bdtYRwtZ5cvEZzLvTExtiJh GA== 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 3g4vcercvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:39 +0000 Received: from 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 24I7gXTG002868 for ; Wed, 18 May 2022 07:43:37 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 3g2429dayq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7hYll40829376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5AA8C11C052; Wed, 18 May 2022 07:43:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A02E311C04C; Wed, 18 May 2022 07:43:33 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.in.ibm.com (unknown [9.109.222.255]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 May 2022 07:43:33 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:56 +0530 Message-Id: <20220518074304.42497-2-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5uPEhydb6zCgPd1Pyiqw-_L94qhQSNip X-Proofpoint-ORIG-GUID: 5uPEhydb6zCgPd1Pyiqw-_L94qhQSNip X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_02,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 1/9] core/pldm/test : Implement PLDM self test common api 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 bypasses hardware-dependent implementation for PLDM test. This patch provides API that will bypass the need to exchange messages with BMC over the LPC bus whereas messages are handled by the same program for self test. It also contains common functions and declarations that are used to implement the PLDM self test. Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/common/test-pldm-common.c | 190 +++++++++++++++++++++++ 1 file changed, 190 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..4acbfd35 --- /dev/null +++ b/core/pldm/test/common/test-pldm-common.c @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +// Copyright 2022 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 OPAL_SUCCESS; + return OPAL_PARAMETER; +} + +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 != OPAL_SUCCESS) + return ret; + } + + /* Reply to requests */ + else if (((struct pldm_msg *)pldm_received_msg)->hdr.request == PLDM_REQUEST) { + ret = pldm_test_reply_request(pldm_received_msg, len-1, + &response_msg, &response_len); + if (ret != OPAL_SUCCESS) + return ret; + + + /* + * If response length > 0 then response back + * else if response length == 0 then no need to response + */ + if (response_len > 0) { + vmsg = malloc(response_len+1); + /* TYPE: PLDM = 0x01 (000_0001b) as per MCTP - DSP0240 */ + vmsg[0] = 1; + memcpy(vmsg + 1, response_msg, response_len); + free(response_msg); + pldm_rx_message(BMC_EID, 0, 0, NULL, vmsg, response_len+1); + free(vmsg); + } + } + + return OPAL_SUCCESS; +} + +void ast_mctp_exit(void) +{ +} + +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 OPAL_SUCCESS; + +} + + +void unlock(struct lock *l) +{ + assert(l->lock_val); + l->lock_val = 0; +} + +void prd_occ_reset(uint32_t proc) +{ + (void)proc; +} +