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; +} + From patchwork Wed May 18 07:42: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: 1632639 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=kKI6eGXh; 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 4L34k718Jrz9sGC for ; Wed, 18 May 2022 17:43:59 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34k70L7Wz3c1K for ; Wed, 18 May 2022 17:43:59 +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=kKI6eGXh; 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=kKI6eGXh; 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 4L34jq28Mlz3bjq for ; Wed, 18 May 2022 17:43:43 +1000 (AEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7g0Uf012611 for ; Wed, 18 May 2022 07:43:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=we36Z+6fPtl3MBr6ua2kKr9ND/ItO7k64d2FoYOpQKQ=; b=kKI6eGXhUJ9Tv8lbUyKHdrp8ouod3hGYCXhGiqGmKBjzwHbwzWAtlO4Dn6OU7+qk23Ix EB8oh6pjReBlMQYk+wbC2oWYNkH2gqgtB4oCj2+EVRvkeELpwJNLStG7N3NN3+efuvS5 BtsqIoXQBsKfbtwBnnjTd6lmPvoCA29OJIBP7TY5X0zOGOvmhQ9azWzo5yhyut//OzYp 8jI1UnAsCGrvcEeGRtUEsvcgeE6lqhbVkf6XeNANZlLIbUrRJdYl8oqjZOn+yr/BV92w 4FqLXoiycrzAEjdNYQGI4x5NbXGbZy3syxB+l99FN9/beGVQzlFDRoUmg5QsrxO6fuAk wA== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vms80tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:40 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7grCr001572 for ; Wed, 18 May 2022 07:43:38 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 3g2428vafg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7h0Hh34537960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8802E11C050; Wed, 18 May 2022 07:43:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCC8411C04C; Wed, 18 May 2022 07:43:34 +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:34 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:57 +0530 Message-Id: <20220518074304.42497-3-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: uKUqtWGWUwb9njRxD-Vn85SqDP5LynBE X-Proofpoint-ORIG-GUID: uKUqtWGWUwb9njRxD-Vn85SqDP5LynBE 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 mlxscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 2/9] core/pldm/test : Initialize pldm file I/O 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 a self-test implementation for PLDM_OEM type message support that is used for inband file I/O. This patch tests code flow for the PLDM command PLDM_GET_FILE_TABLE that is used to retrieve the file table which contains the list of lid files available and their attributes. Signed-off-by: Abhishek Singh Tomar --- core/pldm/pldm.h | 2 +- core/pldm/test/Makefile.check | 43 ++++++++ core/pldm/test/test-pldm-fileio.c | 174 ++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 core/pldm/test/Makefile.check create mode 100644 core/pldm/test/test-pldm-fileio.c 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..7af66ccf --- /dev/null +++ b/core/pldm/test/Makefile.check @@ -0,0 +1,43 @@ +# -*-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)) +HOSTCFLAG_PLDM += -Wno-format + +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..e14f6df7 --- /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 2022 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" + +uint32_t get_test_filetable_entry(uint8_t **file_attr_table, int *size); +int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); + +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len); + + +/* + * This function duplicates 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 duplicates 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 get_test_filetable_entry(uint8_t **file_attr_table, int *size) +{ + 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; + + /* calculate sizeof whole struct */ + *size = sizeof(struct pldm_file_attr_table_entry *) + strlen(FileName) + + sizeof(file_length) - 1; + *file_attr_table = malloc(*size); + if (*file_attr_table == NULL) + return OPAL_RESOURCE; + + 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 OPAL_SUCCESS; +} + +/* + * This function duplicates 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 : hdr type %d not expected\n", + ((struct pldm_msg *)request_msg)->hdr.type); + return OPAL_PARAMETER; + } + + +} + + +/* + * This function duplicates 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 rc; + 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); + + rc = decode_get_file_table_req(request_msg, payload_len, &transfer_handle, + &transfer_opflag, &table_type); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* Get Filetable entry for self test */ + rc = get_test_filetable_entry(&file_attr_table, &table_size); + if (rc != OPAL_SUCCESS) + return OPAL_PARAMETER; + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_file_table_resp) + + table_size - 1; + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + + rc = 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 (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + free(file_attr_table); + + break; + + default: + return OPAL_PARAMETER; + + } + + return OPAL_SUCCESS; + + + +} + + +int main(void) +{ + size_t rc; + + + /* Init PLDM File IO */ + rc = pldm_file_io_init(); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST : pldm_file_io_init failed"); + return rc; + } + + return OPAL_SUCCESS; +} + + From patchwork Wed May 18 07:42:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Singh Tomar X-Patchwork-Id: 1632640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m1LgeDzS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L34kG2y9Tz9sBB for ; Wed, 18 May 2022 17:44:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kG1kmwz2xDY for ; Wed, 18 May 2022 17:44:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m1LgeDzS; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=abhishek@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m1LgeDzS; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4L34jr4X8cz3bjq for ; Wed, 18 May 2022 17:43:44 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7JUQY021923 for ; Wed, 18 May 2022 07:43:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=X4Oh9As8sEcEZSq0GFY0oLpkAKB4QZ27UOqdhUs4LWM=; b=m1LgeDzS8Ly31WmTf7Sb6jS5xbKPNLfcHdniB2ZwJDu5E6qJH86+IreotGTl+2zKd9+X IFTnZxzYbBKH8u1GpwWLRX5cVTgUYjdoM0boWTj6Lh+CRjPsSmCrh6tpFngKwHRBX/mt eYi/9wPCn8YCLDQYTsTacttWEf01ZjXTnWEVSvAGXaIQngHWd7bdswSNCxmBb6f+OPYf F+1XqOGqIfHtfhEWJ/s4zYR1wnBztzMwfWP69nFSSTgN/a8LR4QVkE2O6AnCFsUw7WoV EHWM2sUjiUifl1v8Pa6kqDZ1XVQ/jLB/ECagwIY/09KyfAGqzRw67Z6DqgdhzvMAKnHW ww== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vaf8h8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:41 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7gBZv025169 for ; Wed, 18 May 2022 07:43:39 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 3g23pjdb1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:39 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7TiXI27525518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:29:44 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AEF711C050; Wed, 18 May 2022 07:43:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D262B11C04C; Wed, 18 May 2022 07:43:35 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.in.ibm.com (unknown [9.109.222.255]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 May 2022 07:43:35 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:58 +0530 Message-Id: <20220518074304.42497-4-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5aPh6HPJs9NQy2OqO3Hc1A2XxPLcXliz X-Proofpoint-ORIG-GUID: 5aPh6HPJs9NQy2OqO3Hc1A2XxPLcXliz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_02,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=957 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 3/9] core/pldm/test : Write file with PLDM file I/O message X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Abhishek Singh Tomar Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The patch contains a test for PLDM write request implementation using PLDM command PLDM_WRITE_FILE Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-fileio.c | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/core/pldm/test/test-pldm-fileio.c b/core/pldm/test/test-pldm-fileio.c index e14f6df7..924db86e 100644 --- a/core/pldm/test/test-pldm-fileio.c +++ b/core/pldm/test/test-pldm-fileio.c @@ -8,6 +8,7 @@ #define TEST_FILE_IO_LENGTH 50 #define TEST_FILE_IO_BUF1 "This is Test buffer Open power Foundation" +void *pldm_file_io_buff[TEST_FILE_IO_LENGTH]; uint32_t get_test_filetable_entry(uint8_t **file_attr_table, int *size); int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, void **response_msg, size_t *response_len); @@ -102,7 +103,13 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, void **response_msg, size_t *response_len) { int rc; + void *payload_data; + uint32_t offset; //!< Offset to file where write starts + uint32_t length; + uint32_t file_handle; //!< Handle to file int payload_len = 0; + size_t file_data_offset = 0; + struct pldm_write_file_req file_req; uint32_t transfer_handle; uint8_t transfer_opflag; uint8_t table_type; @@ -143,6 +150,52 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, free(file_attr_table); break; + case PLDM_WRITE_FILE: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + + rc = decode_write_file_req(request_msg, payload_len, &file_handle, + &offset, &length, &file_data_offset); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* + * TEST if file handle received is same as that we send while making + * call to pldm request (i.e. TEST_FILE_IO_HANDLE). + * then PLDM message are received without any distortion in path. + */ + if (file_handle != TEST_FILE_IO_HANDLE) + return OPAL_PARAMETER; + + payload_data = ((struct pldm_msg *)request_msg)->payload + + sizeof(file_req.file_handle) + + sizeof(file_req.offset) + + sizeof(file_req.length); + + memcpy(pldm_file_io_buff, payload_data, length); + + /* + * TEST if file buff received is same as that we send while making + * call to pldm request (i.e TEST_FILE_IO_BUF1). + * Then PLDM message are transferred without distortion in path. + */ + if (strncmp(TEST_FILE_IO_BUF1, (char *)payload_data, length) != 0) { + perror("PLDM_TEST :strncmp"); + return OPAL_PARAMETER; + } + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_write_file_resp); + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + rc = encode_write_file_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, length, *response_msg); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + break; + default: return OPAL_PARAMETER; @@ -159,7 +212,18 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t rc; + char buf_write[TEST_FILE_IO_LENGTH] = TEST_FILE_IO_BUF1; + uint64_t size = strlen(buf_write); + /* Initialize test buffer for represent file with 0 */ + bzero(pldm_file_io_buff, TEST_FILE_IO_LENGTH); + + /* Attempt to write using pldm file io before init should return error OPAL_PARAMETER */ + rc = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, 0, size); + if (rc != OPAL_PARAMETER) { + printf("PLDM_TEST : pldm_file_io_write_file failed expect=OPAL_PARAMETER\n"); + return OPAL_PARAMETER; + } /* Init PLDM File IO */ rc = pldm_file_io_init(); @@ -168,6 +232,15 @@ int main(void) return rc; } + /* Attempt to write using pldm file io should return OPAL SUCCESS after init */ + rc = pldm_file_io_write_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_BUF1, + 0, size); + + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST : pldm_file_io_write_file failed expect=OPAL_SUCCESS\n"); + return rc; + } + return OPAL_SUCCESS; } From patchwork Wed May 18 07:42:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Singh Tomar X-Patchwork-Id: 1632641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=FiiNU22s; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L34kP4KgLz9sBB for ; Wed, 18 May 2022 17:44:13 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kP3Cfgz3c8y for ; Wed, 18 May 2022 17:44:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=FiiNU22s; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=abhishek@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=FiiNU22s; dkim-atps=neutral Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4L34jt0tn0z3bjq for ; Wed, 18 May 2022 17:43:45 +1000 (AEST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7hFs5007006 for ; Wed, 18 May 2022 07:43:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=2IXx2qwFnCJmhzg/7lKc7761T24drJJ4/PWXX6CJszg=; b=FiiNU22sQKVTcXXMZfUnVFjCHcjFiCIdonAsuZOIi7YtqRTaaw4R5Z0D8FjUpoK0B55i ps9pDbJ4fmIMbFNlloeSvEtrzVS1teRP1iIUw3RZGqAxqzTkgSnunjsKiviSG24qUfes G+GdezCBuxna4I6aSlvpdMxUnEIvVxgI4xCr3bhrZ6n8zPU5soNHgO3hcHwnWTl75PAH uGYCwWrJNutaD4RrCYiqWfxI0NLev8E3Es4+Ba1OVVF37sVfXXAHaL1RHWCVP9EmiFX5 o9RDh2rIti3D9eKGZvHvN9Vcp7N+lZ+Av1J4WapuEOS8Y8nhB67gB6pyct5bKeaC5MVn 5Q== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vndg059-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:43 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7hf01001362 for ; Wed, 18 May 2022 07:43:41 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3g2429db8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:41 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7hbq249152490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:37 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8CBC11C050; Wed, 18 May 2022 07:43:37 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F147B11C04C; Wed, 18 May 2022 07:43:36 +0000 (GMT) Received: from li-22421c4c-355e-11b2-a85c-fdc6c782cba9.in.ibm.com (unknown [9.109.222.255]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 18 May 2022 07:43:36 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:12:59 +0530 Message-Id: <20220518074304.42497-5-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DoQEV6ENH4GJiYORwmeyq3UYGI_aw1SP X-Proofpoint-GUID: DoQEV6ENH4GJiYORwmeyq3UYGI_aw1SP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_02,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 4/9] core/pldm/test : Read file with PLDM file I/O message X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Abhishek Singh Tomar Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The patch contains a test for PLDM read request implementation using PLDM command PLDM_READ_FILE Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-fileio.c | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/core/pldm/test/test-pldm-fileio.c b/core/pldm/test/test-pldm-fileio.c index 924db86e..53a2f811 100644 --- a/core/pldm/test/test-pldm-fileio.c +++ b/core/pldm/test/test-pldm-fileio.c @@ -115,6 +115,7 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, uint8_t table_type; uint8_t *file_attr_table; uint32_t table_size; + struct pldm_read_file_resp *response; /* check command received and reply with appropriate pldm response message */ @@ -195,6 +196,57 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, return OPAL_PARAMETER; break; + case PLDM_READ_FILE: + + payload_len = request_len - sizeof(struct pldm_msg_hdr); + rc = decode_read_file_req(request_msg, payload_len, &file_handle, &offset, + &length); + + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + + /* + * TEST : if file handle received is same as that we send while making + * call to pldm request (i.e. TEST_FILE_IO_HANDLE). + * then PLDM message are transferred without any distortion in path. + */ + if (file_handle != TEST_FILE_IO_HANDLE) { + printf("PLDM_TEST : File Handle not matched"); + return OPAL_PARAMETER; + } + + /* + * check if length + offset < TEST_FILE_IO_LENGTH + * so required data length can be readed + */ + if (file_handle != TEST_FILE_IO_HANDLE || + length + offset > TEST_FILE_IO_LENGTH) { + perror("TEST : length+offset Invalid"); + return OPAL_PARAMETER; + } + + + *response_len = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_read_file_resp) + length - 1; + + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + + rc = encode_read_file_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, length, *response_msg); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + + response = (struct pldm_read_file_resp *) + ((struct pldm_msg *)*response_msg)->payload; + + /* Copy required buffer to end of PLDM response */ + memcpy(response->file_data, pldm_file_io_buff + offset, length); + break; default: @@ -212,6 +264,7 @@ int pldm_test_reply_request_file_io(void *request_msg, size_t request_len, int main(void) { size_t rc; + char buf_read[TEST_FILE_IO_LENGTH]; char buf_write[TEST_FILE_IO_LENGTH] = TEST_FILE_IO_BUF1; uint64_t size = strlen(buf_write); @@ -225,6 +278,13 @@ int main(void) return OPAL_PARAMETER; } + /* Attempt to read using pldm file io before init should return error OPAL_PARAMETER */ + rc = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (rc != OPAL_PARAMETER) { + printf("PLDM_TEST : pldm_file_io_read_file failed expect=OPAL_PARAMETER\n"); + return OPAL_PARAMETER; + } + /* Init PLDM File IO */ rc = pldm_file_io_init(); if (rc != OPAL_SUCCESS) { @@ -241,6 +301,20 @@ int main(void) return rc; } + + /* Attempt to read: using pldm file io should return OPAL SUCCESS after init */ + rc = pldm_file_io_read_file(TEST_FILE_IO_HANDLE, TEST_FILE_IO_LENGTH, buf_read, 0, size); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST : pldm_file_io_read_file failed expect=OPAL_PARAMETER\n"); + return rc; + } + + /* Test if buffer read same as buffer send */ + if (strncmp(buf_read, TEST_FILE_IO_BUF1, size) != 0) { + perror("PLDM_TEST pldm read string mismatch"); + return OPAL_PARAMETER; + } + return OPAL_SUCCESS; } From patchwork Wed May 18 07:43: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: 1632642 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=Wneza18z; 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 4L34kX64f7z9sBB for ; Wed, 18 May 2022 17:44:20 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kX5GRsz3bpT for ; Wed, 18 May 2022 17:44:20 +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=Wneza18z; 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=Wneza18z; 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 4L34jt3P9hz3bw6 for ; Wed, 18 May 2022 17:43:46 +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 24I7hZXD016572 for ; Wed, 18 May 2022 07:43:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ztk6S4u0+1cFeiPcfptQEnNQxb7A6pX9h7EXRswGaks=; b=Wneza18zT94nBzou9TEqMzuQHSbmF5MjvgkhTJefarwr7juBcL4jmf7tTevb9L2nPmaE BVpxumscFkMNVKt5FPA/aZkXO6Sq4/1A2y4EOE7oasjJqAaLx33Ap6TJSEVCGds3Romy zRV/N86ssLtx9p8fP8qX6nNfy3fxQIGBqJI2nAdzLOKysmVhLBE1giv30SVFStg34Jpv 809699STnQhBBAYar590IeXh/eEXax2ecnDkeKWHmJgfBILzEe7PSihtsttBjs0D0ECp asU8oX3qSsXsFIvJVBU2DYA1C3XCGVQBRGc7mIkknwNn0RA8ux0+gKcjnC9xBmpNxg/E FA== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vnf8058-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:43 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7hfwb001359 for ; Wed, 18 May 2022 07:43:41 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3g2429db8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:41 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7hck158720678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:38 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B280111C054; Wed, 18 May 2022 07:43:38 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF97411C052; Wed, 18 May 2022 07:43:37 +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:37 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:13:00 +0530 Message-Id: <20220518074304.42497-6-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: Fu-QHehFGuXy9zXU4l0dtfmsDvH37w1q X-Proofpoint-ORIG-GUID: Fu-QHehFGuXy9zXU4l0dtfmsDvH37w1q 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 impostorscore=0 malwarescore=0 bulkscore=0 suspectscore=0 phishscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 5/9] core/pldm/test : Implement pldm bios specification 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" PLDM BIOS specification defines the data structures and messages for communicating BIOS settings, BIOS attributes, boot configurations, and boot order settings. The patch contains test for PLDM_GET_BIOS_TABLE implementation to get string table, attribute table and value table. It also contains test for implementaion to find lid. Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/Makefile.check | 1 + core/pldm/test/common/test-pldm-common.c | 1 + core/pldm/test/test-pldm-bios.c | 289 +++++++++++++++++++++++ 3 files changed, 291 insertions(+) create mode 100644 core/pldm/test/test-pldm-bios.c diff --git a/core/pldm/test/Makefile.check b/core/pldm/test/Makefile.check index 7af66ccf..c63b3eeb 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 4acbfd35..8b138454 100644 --- a/core/pldm/test/common/test-pldm-common.c +++ b/core/pldm/test/common/test-pldm-common.c @@ -49,6 +49,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..53ee5a32 --- /dev/null +++ b/core/pldm/test/test-pldm-bios.c @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +// Copyright 2022 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 duplicates 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 duplicates BMC functionality for Pldm self test + * It generate bios table for self test based on input parameter tabletype + */ +uint32_t get_test_table_entry(uint8_t tableType, uint8_t **bios_table, + uint32_t *bios_table_length) +{ + int pad_len = 0; + uint32_t checksum = 0; + struct pldm_bios_string_table_entry *string_entry; + struct pldm_bios_table_attr_entry_string_info info; + + 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); + if (*bios_table == NULL) + return OPAL_RESOURCE; + + memset(*bios_table, 0, *bios_table_length); + + 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: + + *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); + if (*bios_table == NULL) + return OPAL_RESOURCE; + + 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)); + if (info.def_string == NULL) + return OPAL_RESOURCE; + + 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); + if (*bios_table == NULL) + return OPAL_RESOURCE; + + 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 Failed: 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 OPAL_SUCCESS; + +} + +/* + * This function duplicates 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 Failed : hdr type %d not expected\n", + ((struct pldm_msg *)request_msg)->hdr.type); + return OPAL_PARAMETER; + } + +} + +/* + * This function duplicates BMC functionality for Pldm self test + * it 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 rc; + uint32_t transfer_handle; + uint8_t transfer_op_flag, table_type; + uint8_t *bios_table; + uint32_t bios_table_length = 0; + 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); + rc = decode_get_bios_table_req(request_msg, payload_length, &transfer_handle, + &transfer_op_flag, &table_type); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* get table entry to reply request on behalf on BMC for PLDM self test */ + rc = get_test_table_entry(table_type, &bios_table, &bios_table_length); + if (rc != OPAL_SUCCESS) + return rc; + + payload_length = bios_table_length + sizeof(struct pldm_get_bios_table_resp) - 1; + + *response_len = sizeof(struct pldm_msg_hdr) + + payload_length - 1; + + *response_msg = malloc(*response_len); + if (*response_msg == NULL) + return OPAL_RESOURCE; + + rc = 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); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + free(bios_table); + return OPAL_SUCCESS; + } else + return OPAL_PARAMETER; + + return OPAL_SUCCESS; +} + + +int main(void) +{ + size_t rc; + 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 + */ + rc = pldm_bios_find_lid_by_attr_name(TEST_VALID_ATTR_NAME, &lid); + if (rc != OPAL_HARDWARE) { + printf("PLDM_TEST Failed: pldm_bios_find_lid_by_attr_name", + " called before pldm_bios_init.", + " expected=%d received=%d\n", OPAL_HARDWARE, rc); + return rc; + } + + /* Init Pldm bios */ + rc = pldm_bios_init(); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : pldm_bios_init failed received=%d\n", rc); + return rc; + } + + /* + * Attempt to call pldm_bios_find_lid_by_attr_name() + * when name argument not present return error OPAL_PARAMETER + */ + rc = pldm_bios_find_lid_by_attr_name(name, &lid); + if (rc != OPAL_PARAMETER) { + + printf("PLDM_TEST Failed : pldm_bios_find_lid_by_attr_name", + " called when name argument that is not present.", + " expected=%d received=%d\n", OPAL_PARAMETER, rc); + return rc; + } + + /* + * Attempt to call pldm_bios_find_lid_by_attr_name() + * when name argument present return OPAL_SUCCESS + */ + rc = pldm_bios_find_lid_by_attr_name(TEST_VALID_ATTR_NAME, &lid); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : pldm_bios_find_lid_by_attr_name", + " called when name argument that is present.", + " expected=%d received=%d\n", OPAL_PARAMETER, rc); + return rc; + } + + + /* Init pldm_lid_files_init */ + rc = pldm_lid_files_init(&bl); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : pldm_lid_files_init received=%d\n", rc); + return rc; + } + return 0; +} + From patchwork Wed May 18 07:43: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: 1632643 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=gF8K30+o; 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 4L34kg6qzyz9sBB for ; Wed, 18 May 2022 17:44:27 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kg6KjPz3bjq for ; Wed, 18 May 2022 17:44:27 +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=gF8K30+o; 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=gF8K30+o; 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 4L34jv4gpYz3bqT for ; Wed, 18 May 2022 17:43:47 +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 24I7hgYq006220 for ; Wed, 18 May 2022 07:43:45 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=hECkJiAlYx75eVjbU5HfaPvpYuyqXzQGx2vay//jW6k=; b=gF8K30+olU2u6wBzQIaoUnbhmRcWWbPuw9nsqENKP7EOptLF6sLUaNDRYQvwoKXuziwb lLY7EbCKd2zCYgv3FGjxIQIQdkZA1l4FNfe6gieNMUAjyk+w/d82gdyx5LsIl0f61Azn S19jNVVs5vUwsvoqt7j9NX1K1ZEqhBj3SqHo32KflI9kbUVC55Nr2BtnmVOAJZDzOsXx sTKKkztMt45azewLqdogZOTAaVRH0VrhrJoGyVWS+9nBS8pDu+WKa86CWMm74YfnbbHG u9uw0XbKy4SHMR5nwk91OMkv+Y7UL1wneTDtwI3hQpf7l5rytKAkizI7TuGTgPOsq4Ez tw== 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 3g4vns803g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:45 +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 24I7gS01002856 for ; Wed, 18 May 2022 07:43:43 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3g2429dayx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:42 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7hevA49217864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:40 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA65811C052; Wed, 18 May 2022 07:43:39 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21C3911C04C; Wed, 18 May 2022 07:43:39 +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:38 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:13:01 +0530 Message-Id: <20220518074304.42497-7-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Jo_C7PCW8RXL5Pgs0usNHMnLXuDySvoY X-Proofpoint-GUID: Jo_C7PCW8RXL5Pgs0usNHMnLXuDySvoY 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 impostorscore=0 bulkscore=0 clxscore=1015 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 6/9] core/pldm/test : Initialize pldm platform specification 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" PLDM Platform specification defines the functions and data structures used for discovering, describing, initializing, and accessing sensors and effecters within the management controllers and management devices of a platform management subsystem. This patch test PLDM platform Init implementation using commands 1. PLDM_PLATFORM_EVENT_MESSAGE 2. PLDM_GET_PDR Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/Makefile.check | 3 +- core/pldm/test/test-pldm-platform.c | 298 ++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+), 1 deletion(-) 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 c63b3eeb..0e5706a2 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-bios \ + core/pldm/test/test-pldm-platform LCOV_EXCLUDE += $(PLDM_TEST:%=%.c) diff --git a/core/pldm/test/test-pldm-platform.c b/core/pldm/test/test-pldm-platform.c new file mode 100644 index 00000000..8c852ad7 --- /dev/null +++ b/core/pldm/test/test-pldm-platform.c @@ -0,0 +1,298 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +// Copyright 2022 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 structure duplicates 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 structure duplicates 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); + +/* + * This function duplicates 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 duplicates BMC functionality for Pldm self test + * This generate pdr entry for self test + */ +int get_test_pdr_entry(uint32_t record_hndl, uint8_t **pdr, size_t *pdr_len) +{ + int size; + int rc; + size_t possible_states_size = 0; + struct pldm_state_effecter_pdr *effecter = NULL; + 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); + if (*pdr == NULL) { + perror("PLDM_TEST malloc"); + return OPAL_RESOURCE; + } + memset(*pdr, 0, size); + effecter = (struct pldm_state_effecter_pdr *)(*pdr); + 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; + + rc = encode_state_effecter_pdr(effecter, size, possible_states_effecter_test, + possible_states_size, pdr_len); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + return OPAL_SUCCESS; + +} + +/* + * This function duplicates BMC functionality for Pldm self test + * it 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 : hdr type %d not expected\n", + ((struct pldm_msg *)request_msg)->hdr.type); + return OPAL_PARAMETER; + } + + +} + + + +/* + * This function duplicates BMC functionality for Pldm self test + * it 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; + size_t pdr_len; + int rc = 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); + rc = decode_get_pdr_req(request_msg, payload_len, &record_hndl, &transfer_handle, + &transfer_opflag, &request_cnt, &record_chg_num); + if (rc != PLDM_SUCCESS) + return rc; + + /* Get pdr entry for self test */ + rc = get_test_pdr_entry(record_hndl, &pdr, &pdr_len); + if (rc != OPAL_SUCCESS) + return rc; + + payload_len = (sizeof(struct pldm_get_pdr_resp) - 1) + + pdr_len; + *response_len = sizeof(struct pldm_msg_hdr) + + payload_len; + + *response_msg = malloc(*response_len); + if (*response_msg == NULL) { + perror("PLDM_TEST malloc"); + return OPAL_RESOURCE; + } + + /* + * if record_handle is equal to first record handle or 0 + * then encode next data transfer handle with 2nd record handle + */ + if (record_hndl == EFFECTER1_RECORD_HANDLE || record_hndl == 0) { + rc = encode_get_pdr_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, EFFECTER2_RECORD_HANDLE, + PLDM_GET_NEXTPART, PLDM_START_AND_END, pdr_len, 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) { + rc = encode_get_pdr_resp(((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, 0, PLDM_GET_NEXTPART, PLDM_START_AND_END, + pdr_len, pdr, 0, *response_msg); + } else + return OPAL_PARAMETER; + + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + free(pdr); + break; + + case PLDM_PLATFORM_EVENT_MESSAGE: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + rc = decode_platform_event_message_req(request_msg, payload_len, &format_version, + &tid, &event_class, &event_data_offset); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* 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); + if (*response_msg == NULL) { + perror("PLDM_TEST malloc"); + return OPAL_RESOURCE; + } + + rc = encode_platform_event_message_resp( + ((struct pldm_msg *)request_msg)->hdr.instance_id, + PLDM_SUCCESS, 0, *response_msg); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + return PLDM_SUCCESS; + + default: + return OPAL_PARAMETER; + + } + + return OPAL_SUCCESS; + +} + + +int main(void) +{ + int rc; + + + /* Inittialize pldm platform */ + rc = pldm_platform_init(); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST failed : pldm_platform_init ends with %d\n", rc); + return rc; + } + + + return PLDM_SUCCESS; +} + + From patchwork Wed May 18 07:43: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: 1632644 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=f/hb/Kk+; 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 4L34kq1mx0z9sBB for ; Wed, 18 May 2022 17:44:35 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34kq0jzTz3c5C for ; Wed, 18 May 2022 17:44:35 +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=f/hb/Kk+; 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=f/hb/Kk+; 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 4L34jw2BvJz3c5C for ; Wed, 18 May 2022 17:43:48 +1000 (AEST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7hISi007099 for ; Wed, 18 May 2022 07:43:46 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=FVSp6gZlU2jPg1NizH8PVrOghRRpDAaTnEpZ/CZ+bz4=; b=f/hb/Kk+AEtdCOjAsuniNxxVZb0gLln7rlLsD79qhkii5BsrBYGZuZmmKwiNwJZq5ovm vugzXfm0zoqnUN/XMO4effe/IShv4K/PS7TryGfgD3vz0KRp2brF9sby5x4uHkYTL4yQ pZ0j7imN8FUqqFRsqiMloB9ya82FhCm8xlzH42KpJafwIoG9Hwz9nxbgMcIPvfMLxOh7 +M/rjhckEJT5/v36C+hCJoBl1+Qvit4VZqj/LjlRZ1uH33Ir+cmBcCzjiak4u+BWUpvz ZfwSyg+u2xPywOPgL5y24e1mHTVQVGt7oKlFGKtEaP1M6HMlCkWgmu1SJ7bEyLnKis0E Ig== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vndg05y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:45 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7fr2e021041 for ; Wed, 18 May 2022 07:43:44 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3g2428v9vb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:44 +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 24I7hfDQ51904800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:41 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F81B11C04C; Wed, 18 May 2022 07:43:41 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72D0311C05B; Wed, 18 May 2022 07:43:40 +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:40 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:13:02 +0530 Message-Id: <20220518074304.42497-8-abhishek@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220518074304.42497-1-abhishek@linux.ibm.com> References: <20220518074304.42497-1-abhishek@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: W2UXRMSYZQP5OukWhGh33QJd_RY-nvpD X-Proofpoint-GUID: W2UXRMSYZQP5OukWhGh33QJd_RY-nvpD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_02,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 7/9] core/pldm/test : Implement pldm platform restart and power off request 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 test for platform restart and platform power off requests using PLDM Platform command PLDM_SET_STATE_EFFECTER_STATES Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-platform.c | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/core/pldm/test/test-pldm-platform.c b/core/pldm/test/test-pldm-platform.c index 8c852ad7..8b2e583a 100644 --- a/core/pldm/test/test-pldm-platform.c +++ b/core/pldm/test/test-pldm-platform.c @@ -189,6 +189,10 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len, uint32_t record_hndl; uint8_t format_version, tid, event_class; size_t event_data_offset; + uint16_t effecter_id; + uint8_t comp_effecter_count; + set_effecter_state_field field; + /* check pldm command received and reply with appropriate pldm response message */ switch (((struct pldm_msg *)request_msg)->hdr.command) { @@ -269,6 +273,45 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len, return PLDM_SUCCESS; + case PLDM_SET_STATE_EFFECTER_STATES: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + rc = decode_set_state_effecter_states_req(request_msg, payload_len, &effecter_id, + &comp_effecter_count, &field); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* + * 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 OPAL_SUCCESS; + } else + return OPAL_PARAMETER; + return OPAL_SUCCESS; + default: return OPAL_PARAMETER; @@ -283,6 +326,32 @@ int main(void) { int rc; + /* + * Attempt to call pldm_platform_restart() + * before pldm_platform_init() return error + * OPAL_HARDWARE + */ + rc = pldm_platform_restart(); + if (rc != OPAL_HARDWARE) { + printf("PLDM_TEST failed : pldm_platform_restart", + " called before pldm_platform_init", + " expected=%d received=%d\n", OPAL_HARDWARE, rc); + return OPAL_PARAMETER; + } + + /* + * Attempt to call pldm_platform_power_off() + * before pldm_platform_init() return error + * OPAL_HARDWARE + */ + rc = pldm_platform_power_off(); + if (rc != OPAL_HARDWARE) { + printf("PLDM_TEST failed : pldm_platform_power_off", + " called before pldm_platform_init", + " expected=%d received=%d\n", OPAL_HARDWARE, rc); + return OPAL_PARAMETER; + } + /* Inittialize pldm platform */ rc = pldm_platform_init(); @@ -291,6 +360,25 @@ int main(void) return rc; } + /* + * Attempt to call pldm_platform_restart() + * after pldm_platform_init() return PLDM_SUCCESS + */ + rc = pldm_platform_restart(); + if (rc != PLDM_SUCCESS) { + printf("PLDM_TEST failed : pldm_platform_restart ends with %d\n", rc); + return rc; + } + + /* + * Attempt to call pldm_platform_power_off() + * after pldm_platform_init() return PLDM_SUCCESS + */ + rc = pldm_platform_power_off(); + if (rc != PLDM_SUCCESS) { + printf("PLDM_TEST failed : pldm_platform_power_off ends with %d\n", rc); + return rc; + } return PLDM_SUCCESS; } From patchwork Wed May 18 07:43:03 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: 1632645 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=CmKkO8uZ; 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 4L34ky3tNrz9sBB for ; Wed, 18 May 2022 17:44:42 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34ky2gHKz3cD6 for ; Wed, 18 May 2022 17:44:42 +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=CmKkO8uZ; 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=CmKkO8uZ; 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 4L34jx45rRz3c8k for ; Wed, 18 May 2022 17:43:49 +1000 (AEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I7fokb012412 for ; Wed, 18 May 2022 07:43: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=R3aHQRSvrOWCL0RiBU+gcVo/HkcucG2FwqYM6MYwBhM=; b=CmKkO8uZGwRXlrUjCBl7sQ9etPdJ1JL+M+AkKxt52twrVJ9DIgFJVr2zuASNpqQFSQiq uu2Ec+Kj8QjWQXTkPG5eVfUfkgnR+h8rvQ7yu7fbEI18K1SDjtteVovOVVLs9SDQIyHR 9jm/EbIHTQQB3WCQLG9J93j5MoNhBW8BHp4163MrAdlndoRvkcTVwkVnaxweizu/RJDC BbS9dblL21prT6ftzjKY019LibubmmNLFIhtq5n4Clt5y0cNQqyxZE26XbpbT/e+jUdv peL61sDNuRK0it2y4lyh5BNaf5xRoHaDb6w8qi1xZ0BYmVmJKpFtIJl54loQHUPBlgVf 5A== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vms80ws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:47 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24I7h64X001999 for ; Wed, 18 May 2022 07:43:45 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 3g2428vafq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:45 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7h7xg25100580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:43:07 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25A7B11C054; Wed, 18 May 2022 07:43:42 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6ACA211C04C; Wed, 18 May 2022 07:43:41 +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:41 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:13:03 +0530 Message-Id: <20220518074304.42497-9-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: QRDyGhwRnNko7QT57bYiVoQXG1NLFhwN X-Proofpoint-ORIG-GUID: QRDyGhwRnNko7QT57bYiVoQXG1NLFhwN 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 mlxscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 8/9] core/pldm/test : Implement PLDM FRU table 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 tests: 1. responder implementation for PLDM FRU command PLDM_GET_FRU_RECORD_TABLE_METADATA when request sends on behalf of BMC. 2. pldm_fru_get_table() failure case when fru table not created and pldm_fru_get_table() success case when fru table already created. Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/Makefile.check | 3 +- core/pldm/test/test-pldm-fru.c | 193 +++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) 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 0e5706a2..ba74fd00 100644 --- a/core/pldm/test/Makefile.check +++ b/core/pldm/test/Makefile.check @@ -1,7 +1,8 @@ # -*-Makefile-*- 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-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..2893248e --- /dev/null +++ b/core/pldm/test/test-pldm-fru.c @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +// Copyright 2022 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); + + +/* + * This function duplicates 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 duplicates 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 rc = 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); + rc = 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 OPAL_SUCCESS + * else return error OPAL_PARAMETER + */ + if (rc == PLDM_SUCCESS && completion_code == PLDM_SUCCESS && + total_record_set_identifiers == 1 + && total_table_records == 1) + return OPAL_SUCCESS; + else + return OPAL_PARAMETER; + break; + + default: + return OPAL_PARAMETER; + + } + + return OPAL_SUCCESS; + + + +} + + +/* + * This function duplicates BMC functionality for Pldm self test + * It will only handle PLDM request + * or now we don't have any request + */ +int pldm_test_reply_request(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + if (request_msg != NULL && response_msg != NULL) { + (void)request_len; + (void)*response_len; + } + return OPAL_PARAMETER; + +} + +/* + * This function duplicates 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, rc; + + 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 */ + rc = encode_get_fru_record_table_metadata_req(0, pldm_req, 0); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + + /* initialize responder */ + rc = pldm_mctp_responder_init(); + if (rc != OPAL_SUCCESS) + return rc; + + /* skip mctp layer directly call handle */ + rc = pldm_handle(BMC_EID, pldm_req, size); + if (rc != OPAL_SUCCESS) + return rc; + + /* + * 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 rc; + +} + + +int main(void) +{ + int rc; + void *fru_record_table; + uint32_t fru_record_table_size; + + /* + * Get fru table when fru table not created + * return error OPAL_PARAMETER + */ + rc = pldm_fru_get_table(&fru_record_table, &fru_record_table_size); + if (rc != OPAL_PARAMETER) { + printf("PLDM_TEST Failed : pldm_fru_get_table", + " expected=%d received=%d\n", OPAL_PARAMETER, rc); + return OPAL_PARAMETER; + } + + /* Sending request in behalf of bmc and checking response */ + rc = test_fru_table_metadata_request(); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : test_fru_table_metadata_request return=%d\n", rc); + return rc; + } + + /* Get fru table when fru table created */ + rc = pldm_fru_get_table(&fru_record_table, &fru_record_table_size); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : test_fru_table_metadata_request return=%d\n", rc); + return rc; + } + + return OPAL_SUCCESS; +} + From patchwork Wed May 18 07:43:04 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: 1632646 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=HWOErj4U; 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 4L34l76JPcz9sBB for ; Wed, 18 May 2022 17:44:51 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L34l73Ln1z3c9V for ; Wed, 18 May 2022 17:44:51 +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=HWOErj4U; 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=HWOErj4U; 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 4L34jy6cxpz3c9M for ; Wed, 18 May 2022 17:43:50 +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 24I7TrsY029435 for ; Wed, 18 May 2022 07:43: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=KlWmCWUmNlvXlXGV2OYgVRfMocBoUglgcEG9/+l2Fqo=; b=HWOErj4U2Ip8kLwki0V6ZA2DQE5SQ9U+9Y+UyAjhaH8urPVW4doBkTggSfIpqjJzKMN4 UeK6l38IF/GSptXIQ4LC3ngxcWTuExb9WgBs+MQ3YcGbEQApVn+0ZYJDhrRTUSyD8x7Q 6Ojj/97Y5S2dZkJ2GRGGlb5v/dat3G1jL+FH2b5t9HtQsq+Bu2FihISQjnbUPSfSYxz0 dDJHj5B9Qpj3oO0JGEbdWsRpw+UsWshkZri2OrIGQbY3RWhNdMEiT5KXCsZ2oLpUySdD diwfRqNd44S+SEhmYaVj+VBpsPmHrnrzYYEKgppolXZCJZ4hRGO87Kq1uVB+xHJSHcsj zw== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3g4vf0rarr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:48 +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 24I7gQpC002845 for ; Wed, 18 May 2022 07:43:46 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 3g2429db03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 07:43:46 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24I7TpEL27197948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 May 2022 07:29:51 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52D7D11C052; Wed, 18 May 2022 07:43:43 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 707CA11C04C; Wed, 18 May 2022 07:43:42 +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:42 +0000 (GMT) From: Abhishek Singh Tomar To: skiboot@lists.ozlabs.org Date: Wed, 18 May 2022 13:13:04 +0530 Message-Id: <20220518074304.42497-10-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: KiCtAy93tfkmRWApp48qsRCH5IwhhG8e X-Proofpoint-ORIG-GUID: KiCtAy93tfkmRWApp48qsRCH5IwhhG8e 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 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180037 Subject: [Skiboot] [PATCH v3 9/9] core/pldm/test : Retrieve the BMC information with the FRU PLDM message X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Abhishek Singh Tomar Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch test PLDM command PLDM_GET_FRU_RECORD_BY_OPTION codeflow by retrieving BMC version information Signed-off-by: Abhishek Singh Tomar --- core/pldm/test/test-pldm-fru.c | 144 +++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 5 deletions(-) diff --git a/core/pldm/test/test-pldm-fru.c b/core/pldm/test/test-pldm-fru.c index 2893248e..56cf59e5 100644 --- a/core/pldm/test/test-pldm-fru.c +++ b/core/pldm/test/test-pldm-fru.c @@ -10,6 +10,10 @@ 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); /* @@ -94,7 +98,69 @@ int pldm_test_verify_response_fru(void *response_msg, size_t response_len) } +int pldm_test_reply_request_fru(void *request_msg, size_t request_len, + void **response_msg, size_t *response_len) +{ + int rc, 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: + payload_len = request_len - sizeof(struct pldm_msg_hdr); + rc = 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 (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + /* + * 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 + */ + rc = pldm_test_generate_reply_field_type_version( + PLDM_FRU_RECORD_TYPE_GENERAL, + PLDM_FRU_FIELD_TYPE_VERSION, &fru_ds, &fru_ds_size); + if (rc != OPAL_SUCCESS) + return rc; + + 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); + + rc = 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 (rc != PLDM_SUCCESS) + return rc; + free(fru_ds); + return OPAL_SUCCESS; + } else + return OPAL_PARAMETER; + break; + default: + return PLDM_ERROR_INVALID_DATA; + + } +} /* * This function duplicates BMC functionality for Pldm self test @@ -104,12 +170,15 @@ int pldm_test_verify_response_fru(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) { - if (request_msg != NULL && response_msg != NULL) { - (void)request_len; - (void)*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 Failed : hdr type %d not expected\n", + ((struct pldm_msg *)request_msg)->hdr.type); + return OPAL_PARAMETER; } - return OPAL_PARAMETER; - } /* @@ -156,12 +225,64 @@ int test_fru_table_metadata_request(void) } +/* + * This function duplicates 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, rc; + 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)); + rc = encode_fru_record(*fru_table, *fru_table_size, &curr_size, 0, + PLDM_FRU_RECORD_TYPE_GENERAL, 1, 1, (uint8_t *)tlv, tlv_size); + if (rc != PLDM_SUCCESS) + return OPAL_PARAMETER; + *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 OPAL_SUCCESS; +} + + + int main(void) { int rc; void *fru_record_table; uint32_t fru_record_table_size; + struct variable_field fru_structure_data; /* * Get fru table when fru table not created @@ -188,6 +309,19 @@ int main(void) return rc; } + + /* retrieve the bmc information with + * "FRU Field Type": Version + * "FRU Record Set Identifier": 1, + * "FRU Record Type": "General(1)" + */ + rc = pldm_fru_get_record_by_option(0, 1, PLDM_FRU_RECORD_TYPE_GENERAL, + PLDM_FRU_FIELD_TYPE_VERSION, &fru_structure_data); + if (rc != OPAL_SUCCESS) { + printf("PLDM_TEST Failed : pldm_fru_get_record_by_option return=%d\n", rc); + return rc; + } + return OPAL_SUCCESS; }