From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 0E8C4740040 for ; Tue, 9 Jan 2024 11:13:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=t3L1SjigHI+IpXxI4pXanv1mhfarmXIsx9s/QbynuTQ=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1704798812; v=1; b=U4D1iTR2U87PRj9Lu+mmr7KzgCG6QIEfRY54IEZ6l8CGIjTzBNpgLqlMlimrQhGHDwS9lnYj FGGlvZQKPH6o2XFv1TBlvNK+OKuWsqalQG8Pqkj3/MwfnjXDw8mmVYaXrtXo/CxK8w9mcbj7DO1 vhz4StmCcSgRORw5QxvLGtNQ= X-Received: by 127.0.0.2 with SMTP id vPmoYY7687511xyo5Qm03Sjv; Tue, 09 Jan 2024 03:13:32 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.52]) by mx.groups.io with SMTP id smtpd.web11.14205.1704798811726088604 for ; Tue, 09 Jan 2024 03:13:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NHU2B4wLrG2YCBaxDGG85GL9rqDGgeDUFgNkTEmVpG31EpwCxSELGoufBLBUWGT2kMSWfIYKSNnBRpDGHgmIQZ+KhbQtFj3fPbqoXQKAJPftnfTkVMTp5Qv6GA9oOInzOBzka8FS87sOJTHOGV9KSnYFMAMxfuq3Mph1Fe2OrC+F42i0zXkMvBsUEa+3C6Foaiay8ciniu+oUmUuImSc+nVSfabnOZ92WvyVw9yFh4P4Ip1z49LfTYfuZoVGFkGH9Ug5DqqUbwnnWTh7QTZOQan9lubsho1TcJC4wU29gY+tq+ShF0NxikpR0iCb4B1HFdRqZPBQZm79xjeeUGjKIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f82sp8BWfBRoHUBShgQo6Q7LlG870nkBmcnY0F23ZFY=; b=DoZKxDoFZDY6jxSe70qMfZHKS542FxN1olzCVybJKc67ygDsojjsVGICldRICmu5Jjdg9A5lKmQO9W//zS/1pRxWndtW9+7yRWlXHasB2wFwMBK5It1nxSU2yWEJc+9CWu/OnxmOcxl41roREmIziivLM02iTm5gT2MoK1jyeWoP1gTrZt4JpK+jCp9cUE+gx7iR6uLF7uIenGVZ9HzSyH+VkIPArJS8nykiJ4UW0HsKJNZFwZVivrmD5nUXACLX4PUbR4aeMiPC1w32LX9BN+jC1VZ+yL5vz2o4CB86BcGTDRAlMmRqHkm5CUhNda0LvFYhoA+eWQKZcF37Ey5WTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from DS7PR03CA0342.namprd03.prod.outlook.com (2603:10b6:8:55::14) by BL0PR12MB5505.namprd12.prod.outlook.com (2603:10b6:208:1ce::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Tue, 9 Jan 2024 11:13:29 +0000 X-Received: from CY4PEPF0000EE36.namprd05.prod.outlook.com (2603:10b6:8:55:cafe::de) by DS7PR03CA0342.outlook.office365.com (2603:10b6:8:55::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23 via Frontend Transport; Tue, 9 Jan 2024 11:13:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE36.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.12 via Frontend Transport; Tue, 9 Jan 2024 11:13:28 +0000 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Jan 2024 03:13:15 -0800 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Jan 2024 03:13:15 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Tue, 9 Jan 2024 03:13:14 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [PATCH v2] RedfishPkg/RedfishDebugLib: add function to print buffer. Date: Tue, 9 Jan 2024 19:13:14 +0800 Message-ID: <20240109111314.536-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE36:EE_|BL0PR12MB5505:EE_ X-MS-Office365-Filtering-Correlation-Id: c27cd4cd-4b36-40d0-8a4b-08dc110401bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: D3pLzPBGXBV302+re1zk17jZEQgbLHxluaIZAylSwv5U4qQ0M9UvD9KfgEu7lkNHp/vDdEG03ZDQpX/ThpinYTwbYlwoWd3MCnchz7QtroQOC9x1YTv1bpm+vLVwPGX5tX+kEanBd0cLiimYaU0atIVa6GAr1CjVs1SPU2tmW5O+mYA7MnpbirOuKtYpIrifZB2dUs6oHmASPpB/z4RfDDiqBlExmrfnNmKlubwVxU9oSdjT/rFDlFiJiyma7MERy0NCKl1QsY+bVZAgP/3w24uROuGK7OqLN73VzYSOl+uchkOv+ab3TjbTnkW4Asq7rgRfhY4VR4FGCoo1WuO/vlay3OVmoMr2IHXQ3V/aISsq3uPi5qhhSK/6mUy5YsKZpwTwf2IpjfajyQ3HZTd6C41mnoUldoNJEbe2oWrSSeTiJM3rlk7cAulAd9qcB7ZiGJqIK9JwFQkUT0a2SGND88APu4E30phkLoZyF/aOovUoCi6hE3p0Dcento98UZ/MG/UR2a16Tq6RPUgvqAu9n7ikHLKC+M4AZMH3i4Wg3iYEhYyUn7pDeVWqpHfElVABwi+yp2d3UPdKD7Eh+siBddsnZuZW+lteRIh6PyGvdqhCe2Ga5Zb2nfStiuEsaGzp2oTvrGG0HRQ3ZAmiqcwmiqZMOF2dLS9j9HLK7SgbYEjfzZVnXfy+JJkih+X6VtUshjU3O6B2oUlv56uuoK0Y1QVF/QOaA9SccvMHrx6TU3l4PB9xjFo6UJntyg3DOgov X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2024 11:13:28.5101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c27cd4cd-4b36-40d0-8a4b-08dc110401bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE36.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5505 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: bWbXHu6CptOEn7zl8np6y3mdx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=U4D1iTR2; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Introduce DumpBuffer function to print the buffer content. This helps developer to debug Redfish issue. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- RedfishPkg/Include/Library/RedfishDebugLib.h | 20 ++++++++- .../Library/RedfishDebugLib/RedfishDebugLib.c | 45 +++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Incl= ude/Library/RedfishDebugLib.h index 5f75bad12a..3430cf1d14 100644 --- a/RedfishPkg/Include/Library/RedfishDebugLib.h +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h @@ -1,7 +1,7 @@ /** @file This file defines the Redfish debug library interface. =20 - Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -138,4 +138,22 @@ DumpIpv4Address ( IN EFI_IPv4_ADDRESS *Ipv4Address ); =20 +/** + Debug output raw data buffer. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Buffer Debug output data buffer. + @param[in] BufferSize The size of Buffer in byte. + + @retval EFI_SUCCESS Debug dump finished. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + +**/ +EFI_STATUS +DumpBuffer ( + IN UINTN ErrorLevel, + IN UINT8 *Buffer, + IN UINTN BufferSize + ); + #endif diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/Redfish= Pkg/Library/RedfishDebugLib/RedfishDebugLib.c index efa9a5ca13..3728f51213 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c @@ -1,7 +1,7 @@ /** @file Redfish debug library to debug Redfish application. =20 - Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -19,8 +19,9 @@ #define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') #endif =20 -#define REDFISH_JSON_STRING_LENGTH 200 -#define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDEN= T(2)) +#define REDFISH_JSON_STRING_LENGTH 200 +#define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JS= ON_INDENT(2)) +#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16 =20 /** Debug print the value of StatementValue. @@ -366,3 +367,41 @@ DumpIpv4Address ( =20 return EFI_SUCCESS; } + +/** + Debug output raw data buffer. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Buffer Debug output data buffer. + @param[in] BufferSize The size of Buffer in byte. + + @retval EFI_SUCCESS Debug dump finished. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + +**/ +EFI_STATUS +DumpBuffer ( + IN UINTN ErrorLevel, + IN UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + UINTN Index; + + if (Buffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize)); + for (Index =3D 0; Index < BufferSize; Index++) { + if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW =3D=3D 0) { + DEBUG ((ErrorLevel, "\n%04X: ", Index)); + } + + DEBUG ((ErrorLevel, "%02X ", Buffer[Index])); + } + + DEBUG ((ErrorLevel, "\n")); + + return EFI_SUCCESS; +} --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113439): https://edk2.groups.io/g/devel/message/113439 Mute This Topic: https://groups.io/mt/103617651/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-