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 3459DD811C3 for ; Tue, 26 Mar 2024 15:15:42 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=vwp86sbi4sh6XbitQkchu3ne/0ljjpUBBAIlC0/apnw=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1711466140; v=1; b=fWtR1ivfzl9bERR20PO6EC59MMLd68GLmBV3l8jO0XDnGUGG813uQ5+O/kcLMejf2HOb8W48 YyyxmXvPPaqIwDdt28rPQ5Mqd5uyZK9Aic+f8pGRs9Jbcxp7FUcAwC4QOdbQSibpUT2MRYHzRZ6 COOOoXDqzpU6QCCCKJ+IqbHCd+TrkexCsYRAuYTNLdHMY6NROYWSU2DNQPACHt8gKVWCghGPkU6 3slTz3ObowF5DfRWbLfXl+3/xRFZSVPfcvfgbREsSsl9sDXAVBFXcr3yApDAtY2FNh0VSMh93n/ x3u3YpLQ/pW84+sfcbk0C1CVjip36BFVUMLqlXxhNOOtQ== X-Received: by 127.0.0.2 with SMTP id ToXXYY7687511xuBLm3R8WMw; Tue, 26 Mar 2024 08:15:40 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.72]) by mx.groups.io with SMTP id smtpd.web10.11961.1711466140252457971 for ; Tue, 26 Mar 2024 08:15:40 -0700 X-Received: from PH7P221CA0021.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:32a::27) by DM4PR12MB8499.namprd12.prod.outlook.com (2603:10b6:8:181::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Tue, 26 Mar 2024 15:15:36 +0000 X-Received: from CY4PEPF0000E9D9.namprd05.prod.outlook.com (2603:10b6:510:32a:cafe::cd) by PH7P221CA0021.outlook.office365.com (2603:10b6:510:32a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Tue, 26 Mar 2024 15:15:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D9.mail.protection.outlook.com (10.167.241.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Tue, 26 Mar 2024 15:15:35 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 26 Mar 2024 10:15:33 -0500 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [PATCH V2 2/6] RedfishPkg/RedfishDebugLib: Introduce Redfish DEBUG macro Date: Tue, 26 Mar 2024 23:14:58 +0800 Message-ID: <20240326151503.106-3-abner.chang@amd.com> In-Reply-To: <20240326151503.106-1-abner.chang@amd.com> References: <20240326151503.106-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D9:EE_|DM4PR12MB8499:EE_ X-MS-Office365-Filtering-Correlation-Id: aab1df56-9d42-439b-354c-08dc4da79670 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: MzQSvXGlYeR3DsrUprksHTSY8posX2KubzO12+tOkCK/6SId1QwCyPuRQZt29A67yE12HnNyzygKv01DIeHGOvlDDpPBqpf/RkvLQbVXGc4WQzRXF4OiebG7U2gHS3luCT/deWJmZ2VfBZN+fuI/+C1UF3ENYFiB9xY6C211qLqF0VbK7VKAlQ7ne6T0sqgXH3G5FSbvU7GYifrndCuZayBlu+4y2PBgU6GqwW/wPF6ksqij/CdmxU7Sy+oNMZkIxKUAB5DBTPQkP9FAVOqYnhUa21e94TxAHoOpNXeundOMM2HhzBD734AWl+TMaqvE0EDsjOTFFtIe/+HHBw4xhstfR0e8pxvpyV6bLov7A1yinyqcBJXtKdvDn4vHaIcLozvGC8qbGKlX5twm5W/AQIphiX8Laqutr1Y3oAJ6oh/CY4pUO7ACoo+mNUICtQfZ0WUWCqbpYnI4r5otf/Xot5FRp5U6OTJo7eSqHl2RvwF+tkvTrW9EHPYcF4oixiRxSI7AB5bBi9hOyDUajzr7pQ0GTSO7dtbsfjgBYt23Ay8HdhbPi8fUCie3xL7jki1u+BBCceKbD85LpNObsOCbMIBVlEbk12kylFJ9fMTyb3kmCsOXS6CRLiyVANCJ5GGz5lETuLax/7bqPtgs7J3eq7Ruz+vTGBiOyI4ldgwt9ms7jcBt/HUuz6NyvCa3ctb+IIfShfIHG1ofO2twYN+oP2ncptL1tFUcdZqGmlfOelukZtfTjKF1s+kG3EoYSDx8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2024 15:15:35.7487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aab1df56-9d42-439b-354c-08dc4da79670 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8499 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 Resent-Date: Tue, 26 Mar 2024 08:15:40 -0700 Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: n4jTF9dFEVLRyY4KwveASiEIx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=fWtR1ivf; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io From: Abner Chang Introduce DEBUG_REDFISH macro for the debug message of edk2 Redfish components. DEBUG_REDFISH can be used in any edk2 Redfish component with Redfish DebugCatagory as the first parameter. Whether the debug message is output or not depends on the platform setting of PcdRedfishDebugCatagory. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- RedfishPkg/RedfishPkg.dec | 9 +++ .../RedfishDebugLib/RedfishDebugLib.inf | 4 ++ RedfishPkg/Include/Library/RedfishDebugLib.h | 43 +++++++++++---- .../Library/RedfishDebugLib/RedfishDebugLib.c | 55 ++++--------------- 4 files changed, 57 insertions(+), 54 deletions(-) diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec index 1a9c9ed7bc5..a9665ff68ef 100644 --- a/RedfishPkg/RedfishPkg.dec +++ b/RedfishPkg/RedfishPkg.dec @@ -5,6 +5,7 @@ # (C) Copyright 2021 Hewlett Packard Enterprise Development LP
# Copyright (c) 2023, American Megatrends International LLC. # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -184,3 +185,11 @@ gEfiRedfishPkgTokenSpaceGuid.PcdHttpRetryWaitInSecond|1|UINT16|0x0000101= 0 ## This is used to disable Redfish HTTP cache function and every request= will be sent to Redfish service. gEfiRedfishPkgTokenSpaceGuid.PcdHttpCacheDisabled|FALSE|BOOLEAN|0x000010= 11 + # + # Redfish debug catagories + # To enable the debug message for the entire edk2 Redfish implementation= , below PCDs must be set. + # DEBUG_MANAGEABILITY must be set PcdDebugPrintErrorLevel. + # + # 0x0000000000000001 RedfishPlatformConfigDxe driver debug enabled. + # + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory|0|UINT64|0x00001012 diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf b/Redfi= shPkg/Library/RedfishDebugLib/RedfishDebugLib.inf index d468bb213b6..42ff321b48e 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf @@ -2,6 +2,7 @@ # INF file for Redfish debug library. # # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights re= served. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -35,5 +36,8 @@ RedfishHttpLib UefiLib =20 +[FixedPcd] + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory + [Depex] TRUE diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Incl= ude/Library/RedfishDebugLib.h index ad7a6975867..19e5a895cc8 100644 --- a/RedfishPkg/Include/Library/RedfishDebugLib.h +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h @@ -2,6 +2,7 @@ This file defines the Redfish debug library interface. =20 Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,28 +12,48 @@ #define REDFISH_DEBUG_LIB_H_ =20 #include +#include #include #include #include =20 #include =20 -#define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug err= or level for Redfish networking function -#define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug err= or level for Redfish networking function +// Used with MdePKg DEBUG macro. +#define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< D= ebug error level for Redfish networking function +#define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< D= ebug error level for Redfish Host INterface +#define DEBUG_REDFISH_PLATFORM_CONFIG DEBUG_MANAGEABILITY ///< D= ebug error level for Redfish Platform Configure Driver + +// +// Definitions of Redfish debug capability in Redfish component scope, use= d with DEBUG_REDFISH macro +// For example, Redfish Platform Config Driver +// DEBUG_REDFISH(DEBUG_REDFISH_PLATFORM_CONFIG_DXE, ...) +// +#define DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE 0x00000001 + +#define DEBUG_REDFISH(DebugCategory, ...) \ + do { \ + if (!DebugPrintEnabled()) { \ + break; \ + } \ + if (!DebugRedfishComponentEnabled (DebugCategory)) { \ + break; \ + } \ + DEBUG ((DEBUG_MANAGEABILITY, ##__VA_ARGS__)); \ + } while (FALSE) =20 /** - Debug print the value of StatementValue. + Determine whether the Redfish debug category is enabled in + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory. =20 - @param[in] ErrorLevel DEBUG macro error level. - @param[in] StatementValue The statement value to print. + @param[in] DebugCategory Redfish debug category. =20 - @retval EFI_SUCCESS StatementValue is printed. - @retval EFI_INVALID_PARAMETER StatementValue is NULL. + @retval TRUE This debug category is enabled. + @retval FALSE This debug category is disabled.. **/ -EFI_STATUS -DumpHiiStatementValue ( - IN UINTN ErrorLevel, - IN HII_STATEMENT_VALUE *StatementValue +BOOLEAN +DebugRedfishComponentEnabled ( + IN UINT64 DebugCategory ); =20 /** diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/Redfish= Pkg/Library/RedfishDebugLib/RedfishDebugLib.c index 8b0425b8c3b..f8bb51ff532 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c @@ -2,6 +2,7 @@ Redfish debug library to debug Redfish application. =20 Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -25,55 +26,23 @@ #define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16 =20 /** - Debug print the value of StatementValue. + Determine whether the Redfish debug category is enabled in + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory. =20 - @param[in] ErrorLevel DEBUG macro error level. - @param[in] StatementValue The statement value to print. + @param[in] RedfishDebugCategory Redfish debug category. =20 - @retval EFI_SUCCESS StatementValue is printed. - @retval EFI_INVALID_PARAMETER StatementValue is NULL. + @retval TRUE This debug category is enabled. + @retval FALSE This debug category is disabled.. **/ -EFI_STATUS -DumpHiiStatementValue ( - IN UINTN ErrorLevel, - IN HII_STATEMENT_VALUE *StatementValue +BOOLEAN +DebugRedfishComponentEnabled ( + IN UINT64 RedfishDebugCategory ) { - if (StatementValue =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } + UINT64 DebugCategory; =20 - DEBUG ((ErrorLevel, "BufferValueType: 0x%x\n", StatementValue->BufferVal= ueType)); - DEBUG ((ErrorLevel, "BufferLen: 0x%x\n", StatementValue->BufferLen)); - DEBUG ((ErrorLevel, "Buffer: 0x%p\n", StatementValue->Buffer)); - DEBUG ((ErrorLevel, "Type: 0x%p\n", StatementValue->Type)); - - switch (StatementValue->Type) { - case EFI_IFR_TYPE_NUM_SIZE_8: - DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u8)); - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u16))= ; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u32))= ; - break; - case EFI_IFR_TYPE_NUM_SIZE_64: - DEBUG ((ErrorLevel, "Value: 0x%lx\n", StatementValue->Value.u64)= ); - break; - case EFI_IFR_TYPE_BOOLEAN: - DEBUG ((ErrorLevel, "Value: %a\n", (StatementValue->Value.b ? "t= rue" : "false"))); - break; - case EFI_IFR_TYPE_STRING: - DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.strin= g)); - break; - case EFI_IFR_TYPE_TIME: - case EFI_IFR_TYPE_DATE: - default: - break; - } - - return EFI_SUCCESS; + DebugCategory =3D FixedPcdGet64 (PcdRedfishDebugCategory); + return ((DebugCategory & RedfishDebugCategory) !=3D 0); } =20 /** --=20 2.37.1.windows.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 (#117124): https://edk2.groups.io/g/devel/message/117124 Mute This Topic: https://groups.io/mt/105159784/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-