From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.812.1675486194147572334 for ; Fri, 03 Feb 2023 20:49:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=Zvl+wvh/; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.40, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2oEWJQycICxKX37XPumHRq5F1U/X5paz5yHzrBAPUDSffTtY1LnFMg7XpNz5bMOC8cg40x96IVZzFUgnrDSR97Z/2Flp51+hMl5iLJ/meLo9CfGF6l/ETJK4gskn2VJP/m2ECBccLIE+7jEdkVbjhRDzd1r6QzPyjCHq5INDoxkXbm24jne+T4zfSjjyIdCCnI/QWzwm52W2qnJaGkTmPLJnv/qaTvbKGEwHii8siQlWUt3QqGsNmtgSibCIvz1SzWJHyVyQG6tDjjmIbo9aYjCA6S0ZVYltSOy4LdoZSlSs32s8fjHQX5nYku2fDu0gkdrlMfdvDPQJRL3TxLuvA== 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=w5QrhXWmonLdbUTYvLLC2IRbLbEE3/nIgNceyLF8gqg=; b=e4AivBZ2TZDnTiHVRnLRA0k9JF/B4VvIRw/Ksiz29YRQJDhVOKIY7R9g0EzNJ2otp8w3f7HRdimT4X4x1Oyw18/en6JotPhgs8nTfuw3hELhRWhu+CoR5oihzmccYOPJYMZnOkIDucNwKs/kfIYlMBC6YVuLL/fNYz1FUNrXz6v0MKSupRYRI5/GxRLvv1r5tjKqGkljDC1AlMjm6ZWRImit8hu4kvEj2pOql/fekkyX7DIcB6lB/jYH43RqsnCBbvOvBDaaKSQiBOlW0eDfHXJcQXaniFU1+0XzLGbYFnrUP1ITTPakCsqjeY7BCWMe3oVojd1U45CBoPx6NSRgdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w5QrhXWmonLdbUTYvLLC2IRbLbEE3/nIgNceyLF8gqg=; b=Zvl+wvh/xPImODiVeMc36LPUvNdKLCoqMqPjgu3ddxo/36yoQAC/pVBKjSim8+DgaWYJxK+ARluNT0SCdmznRPsbXxM/9FSEzfhIfDRBWN30uwuzPPn53xIC0jVfexxFjffRxrFdWDaAEOVFr5IBogPbN/saSjuILgwlouM2dJk= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by CH0PR12MB5124.namprd12.prod.outlook.com (2603:10b6:610:bf::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Sat, 4 Feb 2023 04:49:51 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::d606:ab63:cf3:5d36]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::d606:ab63:cf3:5d36%5]) with mapi id 15.20.6064.031; Sat, 4 Feb 2023 04:49:51 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [PATCH 1/1] RedfishPkg/RedfishDebugLib: provide Redfish debug functions Thread-Topic: [PATCH 1/1] RedfishPkg/RedfishDebugLib: provide Redfish debug functions Thread-Index: AQHZNhzkU+btxpln4EqSCVlIvL7H3q6+Os8Q Date: Sat, 4 Feb 2023 04:49:51 +0000 Message-ID: References: <20230201090911.849-1-nicklew@nvidia.com> In-Reply-To: <20230201090911.849-1-nicklew@nvidia.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-02-04T04:49:50Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=5922920d-3195-418c-b496-6669791be1cd; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|CH0PR12MB5124:EE_ x-ms-office365-filtering-correlation-id: b438144b-aae9-491a-d8c3-08db066b4075 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OoqTfHZl8Y8dJ2mgdGpntZgauPPruvynYqPUayWavX2rLnDQwmFxbPQQKrIBwD3v58og5KbRBvzPuoZ0l8Q/QFx/3RkfKtRiM6LRHVAJpHhM9gKnYXPiKiW3lOvzUb4grG+BkbZvjnUPiC2jQx3XC8+81Be7gvSeh5Wg1s4hQmQbKUbTKkOfhxKCvsFq9cPU3nhxdpM/1Ut/oAT1/A3PPv7AiE3D9E3RYwzvWxp+3nwgijhduOUK9va0IqT3xNG3Asthj+iaP6rqi4noWgNuN7Rq6e5Vha0Ifj/OcbbE6PdhowbSVGgJsgvvFIZNTF1/oKlVTpb2uV9OMI19JWuj7WnAQsSarcuIGlA+e8W8FLCm8KwTUHo3JtJULij4tA7IXEGNNKFggfS+1nFUStySwWSOp8WeFdz0YYudc0otJQZkMxnA76q8Pr1abUEVYUHFXg0zLG9+JTeShSHsdxeCv8HmDrfdzPen+Rko4OdpsGtcivKd3sWwcu++D2A4Ig9k5C0Hcuie1rsMOaN/YJ8j+yIX5IHIOyBj3vkHsAT2FA3GFIyMaeTehfTerBVvtFOGHiWW+EMFBsksNtKPzVZpMyb1YdEQ6DNAP3HOxqcM2YWY3yu3Pk8V0C9Y0b0ovjjAH0OZ9C1gU6PhNMOPvBkYI4zVGnDr/2d8T2oenI06NJObo4dHcr1BkzDeUYbeK9kvufH9dhYwqTJMqQtM0r+eow== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(376002)(346002)(366004)(39860400002)(451199018)(26005)(6506007)(38070700005)(316002)(9686003)(30864003)(53546011)(7696005)(54906003)(71200400001)(33656002)(110136005)(86362001)(5660300002)(52536014)(55016003)(2906002)(478600001)(4326008)(83380400001)(66476007)(66946007)(66446008)(64756008)(66556008)(76116006)(8936002)(8676002)(186003)(122000001)(41300700001)(38100700002)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?b6hUnrxdxIxsHBdD0GYR6tjcqqu4kerzsBvSpYKcMzSZ/vU0MBTKi/kzpuZZ?= =?us-ascii?Q?mhy7QMbXss+TitB0RJAzCtiXKcIUbAwChQietgkKowtAvckDK9dwuDGJami5?= =?us-ascii?Q?8UuvvdiRYzsghJdwjwkggLLFh0aVa5SANH5ovNzTHhpcUhFKG21qWD0QI2X5?= =?us-ascii?Q?4VF6TCntPyERbgUD0hn94IaK71b9mX+iey2Tl3lnt1Xvv6hEJFMgYe0o97uY?= =?us-ascii?Q?QbcU78aIbBaf9f29yU58RPwTEE/tjFEAMN3LGFfvqHHg0TmJniEu8IByNYuu?= =?us-ascii?Q?jpb3/oAjh7+IPVgHLF6/Csqp8ccyymnv2fTaiUUsAEeB/ATo6B2VB5Qnswul?= =?us-ascii?Q?D8f6xaPKRx2KGWJykDIPuZtblZ94upXK8y03L+6+VVN+jw6fRy1Mgp5po/2J?= =?us-ascii?Q?lrg2twgyLCMltsQL8sqd/yLKZVft3yKLtO42HxvAtuxLZuC6fa2HBqFP+qZz?= =?us-ascii?Q?9LwZ3Zzyml+m9eVFIgT0ByY+ubStZw+00W4WAQphbiWhMJKKX4zLH+dw0dof?= =?us-ascii?Q?mRSJF0cfw7V1SLWDFJ3Qat17OAvkaVxhamvWfumd0kzE1RpJaT2aaJnGk0z0?= =?us-ascii?Q?X15a1lmm/lMLID/YuFY3cU7aKPdWXPVCvCvOxSQSDNhQK9uS0MXB9o0Yv0Jm?= =?us-ascii?Q?vWQ5q3O536Iirx2emy6tBvBz7FJC31a2Qk86KiXRNlD+6mG+tuIH7I9KA4To?= =?us-ascii?Q?LfBArM8rGRC3jEHvex/UyQKJODggBylc90kJxpHIcQPR/+EcJV7zNkYZM/sI?= =?us-ascii?Q?gUWU0UhJO64lmfiEWOFYXpsdcLwisPQWADN16CaxMsYD71E7YVT4m50hR0Yz?= =?us-ascii?Q?5ue0mIK1ktBtS7OShblM9FWDZqU10BcesM4i5NpUt7hXNPf1uNZE+D/jSVx+?= =?us-ascii?Q?8pZ5P7HPGU+W6d49t2kwMAExRwigiqR97ykdImrsfXV2d6jFcmLDGvZeY5NL?= =?us-ascii?Q?1UmeBrElNiJj6JHzWQ+Mz24slcNwzc1MusANyesvKtYQ1ZCZdK3O3fgFcanE?= =?us-ascii?Q?rc/Gv+Lk9CMDKqaJ4FtXZE1e6mmUPTxdfFVggJRm8QeFYsNpO3t7KR9ZTC/5?= =?us-ascii?Q?bsHiq9urlo5FhnKs2eGRFoqNo/w/e98mVd5igf0NdWPw1DwvMXSJ7KIBusZC?= =?us-ascii?Q?HnOidGLB+eMASBxzyr8q4tR/YUlijyRqWIc+CViqePabK7bYnOcF2948KyA+?= =?us-ascii?Q?oq7sVr5eOUOmRh7x5EKwf6n9eL877rhLnU+nAEbTaMXVxLW1JT4ARHJt34rt?= =?us-ascii?Q?a4oJGEHraZ4B59f+Q1RG5SMsA27WEqSuBUZ7MnnpeA/JkyLnmhMqF1Di4pCj?= =?us-ascii?Q?dcSHX8w2ngA3LQfIq5y2ClXxzxVpFvMc5/y5X62qTbBBl1GvMwtXTp0m9Oam?= =?us-ascii?Q?ZQ6HnjH/rTce+qzzQG7kaZh21HBNhV7uMLqPBK4zGkhpxh1zQvXnevE/yM8A?= =?us-ascii?Q?CnampsTVGzO4VL4cF+Xi2m5NrOn13GIzi5uPTRiD7FAbi932qtkx17drJgXb?= =?us-ascii?Q?/M88lkmdx9a6ju/1bsMfa+CoUnHO730UcW6Q5Y1AEkOjRIAbjdrmjc40HaQV?= =?us-ascii?Q?YQyNBlm4rWg9H9igbrQ=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b438144b-aae9-491a-d8c3-08db066b4075 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2023 04:49:51.5477 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8DEdSdOK0VfzQRo105Pb8QouU1xxF2L0llgkzNcWrhiGsu4xyV6r4yQT8+bPrrF85YAXp3tVuq7ypwqcLl5DSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5124 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Thanks for introducing the debug lib for Redfish as Redfish has bunch of in= formation to output. We can create a new debug print level for Redfish in MdePkg.dec later. Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Wednesday, February 1, 2023 5:09 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > ; Nick Ramirez > Subject: [PATCH 1/1] RedfishPkg/RedfishDebugLib: provide Redfish debug > functions >=20 > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. >=20 >=20 > Introduce RedfishDebugLib to RedfishPkg. This library provides several > debugging functions for Redfish application. Redfish drivers rely on Rest= Ex > protocol to communicate with BMC and the communication data may be big > and complicated. Use RedfishDebugLib in RedfishRestExDxe to simplify > debugging process. >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > RedfishPkg/RedfishPkg.dec | 5 + > RedfishPkg/RedfishLibs.dsc.inc | 2 + > .../RedfishDebugLib/RedfishDebugLib.inf | 38 +++ > .../RedfishRestExDxe/RedfishRestExDxe.inf | 2 + > RedfishPkg/Include/Library/RedfishDebugLib.h | 90 +++++++ > .../RedfishRestExDxe/RedfishRestExInternal.h | 2 + > .../Library/RedfishDebugLib/RedfishDebugLib.c | 229 > ++++++++++++++++++ .../RedfishRestExDxe/RedfishRestExProtocol.c | 32 += -- > 8 files changed, 385 insertions(+), 15 deletions(-) create mode 100644 > RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > create mode 100644 RedfishPkg/Include/Library/RedfishDebugLib.h > create mode 100644 RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c >=20 > diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec index > d2b189b13d..e1158b7050 100644 > --- a/RedfishPkg/RedfishPkg.dec > +++ b/RedfishPkg/RedfishPkg.dec > @@ -3,6 +3,7 @@ > # > # Copyright (c) 2019, Intel Corporation. All rights reserved.
# (C)= Copyright > 2021 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -54,6 +55,10 @@ > # > RedfishContentCodingLib|Include/Library/RedfishContentCodingLib.h >=20 > + ## @libraryclass Redfish Debug Library > + # Library provides Redfish debug functions. > + RedfishDebugLib|Include/Library/RedfishDebugLib.h > + > [LibraryClasses.Common.Private] > ## @libraryclass Provides the private C runtime library functions. > # CRT library is currently used by edk2 JsonLib (open source > diff --git a/RedfishPkg/RedfishLibs.dsc.inc b/RedfishPkg/RedfishLibs.dsc.= inc > index 56950b711f..84f52d4b27 100644 > --- a/RedfishPkg/RedfishLibs.dsc.inc > +++ b/RedfishPkg/RedfishLibs.dsc.inc > @@ -6,6 +6,7 @@ > # of EDKII network library classes. > # > # (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -17,5 +18,6 @@ > RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.in= f > JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf > RedfishLib|RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > + > + RedfishDebugLib|RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > !endif >=20 > diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > new file mode 100644 > index 0000000000..b9d88cc70c > --- /dev/null > +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > @@ -0,0 +1,38 @@ > +## @file > +# > +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reser= ved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## > + > +[Defines] > + INF_VERSION =3D 0x00010006 > + BASE_NAME =3D RedfishDebugLib > + FILE_GUID =3D 7F64C79F-ABD0-4446-86B5-2C1AE36168A= D > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishDebugLib| DXE_DRIVER UEFI_DR= IVER > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 EBC > +# > + > +[Sources] > + RedfishDebugLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + JsonLib > + MemoryAllocationLib > + RedfishLib > + UefiLib > + > +[Depex] > + TRUE > diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf > b/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf > index 75437b086a..3f10fd733e 100644 > --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf > +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf > @@ -3,6 +3,7 @@ > # > # Copyright (c) 2019, Intel Corporation. All rights reserved.
# (= C) > Copyright 2020 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reser= ved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -43,6 +44,7 @@ > PrintLib > MemoryAllocationLib > NetLib > + RedfishDebugLib > UefiLib > UefiBootServicesTableLib > UefiDriverEntryPoint > diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h > b/RedfishPkg/Include/Library/RedfishDebugLib.h > new file mode 100644 > index 0000000000..387b06c734 > --- /dev/null > +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h > @@ -0,0 +1,90 @@ > +/** @file > + This file defines the Redfish debug library interface. > + > + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REDFISH_DEBUG_LIB_H_ > +#define REDFISH_DEBUG_LIB_H_ > + > +#include > +#include > +#include > + > +#define DEBUG_REDFISH_NETWORK DEBUG_INFO ///< Debug error level for > Redfish networking function > + > +/** > + > + This function dump the Json string in given error level. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] JsonValue Json value to dump. > + > + @retval EFI_SUCCESS Json string is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpJsonValue ( > + IN UINTN ErrorLevel, > + IN EDKII_JSON_VALUE JsonValue > + ); > + > +/** > + > + This function dump the status code, header and body in given Redfish > + payload. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] Payload Redfish payload to dump > + > + @retval EFI_SUCCESS Redfish payload is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpRedfishPayload ( > + IN UINTN ErrorLevel, > + IN REDFISH_PAYLOAD Payload > + ); > + > +/** > + > + This function dump the status code, header and body in given Redfish > + response. > + > + @param[in] Message Message string > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] Response Redfish response to dump > + > + @retval EFI_SUCCESS Redfish response is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpRedfishResponse ( > + IN CONST CHAR8 *Message, > + IN UINTN ErrorLevel, > + IN REDFISH_RESPONSE *Response > + ); > + > +/** > + > + This function dump the HTTP status code. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] HttpStatusCode HTTP status code > + > + @retval EFI_SUCCESS HTTP status code is printed > + > +**/ > +EFI_STATUS > +DumpHttpStatusCode ( > + IN UINTN ErrorLevel, > + IN EFI_HTTP_STATUS_CODE HttpStatusCode > + ); > + > +#endif > diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h > b/RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h > index a687c4ddb1..bca679e2cc 100644 > --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h > +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h > @@ -3,6 +3,7 @@ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. >=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -21,6 +22,7 @@ > #include > #include #include > +#include > #include > #include > #include diff --git > a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c > b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c > new file mode 100644 > index 0000000000..de242d581b > --- /dev/null > +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c > @@ -0,0 +1,229 @@ > +/** @file > + Redfish debug library to debug Redfish application. > + > + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include > +#include #include > + #include > + > +#ifndef IS_EMPTY_STRING > +#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') > +#endif > + > +#define REDFISH_JSON_STRING_LENGTH 200 #define > +REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | > EDKII_JSON_INDENT(2)) > + > +/** > + > + This function dump the Json string in given error level. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] JsonValue Json value to dump. > + > + @retval EFI_SUCCESS Json string is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpJsonValue ( > + IN UINTN ErrorLevel, > + IN EDKII_JSON_VALUE JsonValue > + ) > +{ > + CHAR8 *String; > + CHAR8 *Runner; > + CHAR8 Buffer[REDFISH_JSON_STRING_LENGTH + 1]; > + UINTN StrLen; > + UINTN Count; > + UINTN Index; > + > + if (JsonValue =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + String =3D JsonDumpString (JsonValue, REDFISH_JSON_OUTPUT_FORMAT); if > + (String =3D=3D NULL) { > + return EFI_UNSUPPORTED; > + } > + > + StrLen =3D AsciiStrLen (String); > + if (StrLen =3D=3D 0) { > + return EFI_UNSUPPORTED; > + } > + > + Count =3D StrLen / REDFISH_JSON_STRING_LENGTH; Runner =3D String; f= or > + (Index =3D 0; Index < Count; Index++) { > + AsciiStrnCpyS (Buffer, (REDFISH_JSON_STRING_LENGTH + 1), Runner, > REDFISH_JSON_STRING_LENGTH); > + Buffer[REDFISH_JSON_STRING_LENGTH] =3D '\0'; > + DEBUG ((ErrorLevel, "%a", Buffer)); > + Runner +=3D REDFISH_JSON_STRING_LENGTH; } > + > + Count =3D StrLen % REDFISH_JSON_STRING_LENGTH; if (Count > 0) { > + DEBUG ((ErrorLevel, "%a", Runner)); } > + > + DEBUG ((ErrorLevel, "\n")); > + > + FreePool (String); > + return EFI_SUCCESS; > +} > + > +/** > + > + This function dump the status code, header and body in given Redfish > + payload. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] Payload Redfish payload to dump > + > + @retval EFI_SUCCESS Redfish payload is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpRedfishPayload ( > + IN UINTN ErrorLevel, > + IN REDFISH_PAYLOAD Payload > + ) > +{ > + EDKII_JSON_VALUE JsonValue; > + > + if (Payload =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + JsonValue =3D RedfishJsonInPayload (Payload); if (JsonValue !=3D NULL= ) { > + DEBUG ((ErrorLevel, "Payload:\n")); > + DumpJsonValue (ErrorLevel, JsonValue); } > + > + return EFI_SUCCESS; > +} > + > +/** > + > + This function dump the HTTP status code. > + > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] HttpStatusCode HTTP status code > + > + @retval EFI_SUCCESS HTTP status code is printed > + > +**/ > +EFI_STATUS > +DumpHttpStatusCode ( > + IN UINTN ErrorLevel, > + IN EFI_HTTP_STATUS_CODE HttpStatusCode > + ) > +{ > + switch (HttpStatusCode) { > + case HTTP_STATUS_100_CONTINUE: > + DEBUG ((ErrorLevel, "Status code: 100 CONTINUE\n")); > + break; > + case HTTP_STATUS_200_OK: > + DEBUG ((ErrorLevel, "Status code: 200 OK\n")); > + break; > + case HTTP_STATUS_201_CREATED: > + DEBUG ((ErrorLevel, "Status code: 201 CREATED\n")); > + break; > + case HTTP_STATUS_202_ACCEPTED: > + DEBUG ((ErrorLevel, "Status code: 202 ACCEPTED\n")); > + break; > + case HTTP_STATUS_304_NOT_MODIFIED: > + DEBUG ((ErrorLevel, "Status code: 304 NOT MODIFIED\n")); > + break; > + case HTTP_STATUS_400_BAD_REQUEST: > + DEBUG ((ErrorLevel, "Status code: 400 BAD REQUEST\n")); > + break; > + case HTTP_STATUS_401_UNAUTHORIZED: > + DEBUG ((ErrorLevel, "Status code: 401 UNAUTHORIZED\n")); > + break; > + case HTTP_STATUS_403_FORBIDDEN: > + DEBUG ((ErrorLevel, "Status code: 403 FORBIDDEN\n")); > + break; > + case HTTP_STATUS_404_NOT_FOUND: > + DEBUG ((ErrorLevel, "Status code: 404 NOT FOUND\n")); > + break; > + case HTTP_STATUS_405_METHOD_NOT_ALLOWED: > + DEBUG ((ErrorLevel, "Status code: 405 METHOD NOT ALLOWED\n")); > + break; > + case HTTP_STATUS_500_INTERNAL_SERVER_ERROR: > + DEBUG ((ErrorLevel, "Status code: 500 INTERNAL SERVER ERROR\n")); > + break; > + default: > + DEBUG ((ErrorLevel, "Status code: 0x%x\n", HttpStatusCode)); > + break; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + > + This function dump the status code, header and body in given Redfish > + response. > + > + @param[in] Message Message string > + @param[in] ErrorLevel DEBUG macro error level > + @param[in] Response Redfish response to dump > + > + @retval EFI_SUCCESS Redfish response is printed. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +DumpRedfishResponse ( > + IN CONST CHAR8 *Message, > + IN UINTN ErrorLevel, > + IN REDFISH_RESPONSE *Response > + ) > +{ > + UINTN Index; > + > + if (Response =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (!IS_EMPTY_STRING (Message)) { > + DEBUG ((ErrorLevel, "%a\n", Message)); } > + > + // > + // status code > + // > + if (Response->StatusCode !=3D NULL) { > + DumpHttpStatusCode (ErrorLevel, *(Response->StatusCode)); } > + > + // > + // header > + // > + if (Response->HeaderCount > 0) { > + DEBUG ((ErrorLevel, "Header: %d\n", Response->HeaderCount)); > + for (Index =3D 0; Index < Response->HeaderCount; Index++) { > + DEBUG ((ErrorLevel, " %a: %a\n", Response->Headers[Index].FieldNa= me, > Response->Headers[Index].FieldValue)); > + } > + } > + > + // > + // Body > + // > + if (Response->Payload !=3D NULL) { > + DumpRedfishPayload (ErrorLevel, Response->Payload); } > + > + return EFI_SUCCESS; > +} > diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c > b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c > index 4b61fc01ad..662b69512c 100644 > --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c > +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c > @@ -3,6 +3,7 @@ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. >=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -87,12 +88,12 @@ RedfishRestExSendReceive ( > MediaPresent =3D TRUE; > NetLibDetectMedia (Instance->Service->ControllerHandle, &MediaPresent)= ; > if (!MediaPresent) { > - DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive(): No MediaPresent.\n"= )); > + DEBUG ((DEBUG_REDFISH_NETWORK, "RedfishRestExSendReceive(): No > + MediaPresent.\n")); > return EFI_NO_MEDIA; > } >=20 > - DEBUG ((DEBUG_INFO, "\nRedfishRestExSendReceive():\n")); > - DEBUG ((DEBUG_INFO, "*** Perform HTTP Request Method - %d, URL: %s\n", > RequestMessage->Data.Request->Method, RequestMessage->Data.Request- > >Url)); > + DEBUG ((DEBUG_REDFISH_NETWORK, "\nRedfishRestExSendReceive():\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "*** Perform HTTP Request Method - > %d, > + URL: %s\n", RequestMessage->Data.Request->Method, > + RequestMessage->Data.Request->Url)); >=20 > // > // Add header "Expect" to server, only for URL write. > @@ -195,7 +196,7 @@ ReSendRequest:; > goto ON_EXIT; > } >=20 > - DEBUG ((DEBUG_INFO, "Receiving HTTP response and headers...\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "Receiving HTTP response and > + headers...\n")); > Status =3D RedfishCheckHttpReceiveStatus ( > Instance, > HttpIoRecvResponse ( > @@ -219,17 +220,17 @@ ReSendRequest:; > RequestMessage->HeaderCount--; // Minus one head= er count for > "Expect". > } >=20 > - DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData- > >Response.StatusCode)); > + DEBUG ((DEBUG_REDFISH_NETWORK, "HTTP Response StatusCode - %d:", > + ResponseData->Response.StatusCode)); > if (ResponseData->Response.StatusCode =3D=3D HTTP_STATUS_200_OK) { > - DEBUG ((DEBUG_INFO, "HTTP_STATUS_200_OK\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "HTTP_STATUS_200_OK\n")); >=20 > if (SendChunkProcess =3D=3D HttpIoSendChunkHeaderZeroContent) { > - DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chu= nks.")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "This is chunk transfer, start to > + send all chunks.")); > SendChunkProcess++; > goto ReSendRequest; > } > } else if (ResponseData->Response.StatusCode =3D=3D > HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) { > - DEBUG ((DEBUG_INFO, > "HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, > + "HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE\n")); >=20 > Status =3D EFI_BAD_BUFFER_SIZE; > goto ON_EXIT; > @@ -239,25 +240,25 @@ ReSendRequest:; > Status =3D EFI_ACCESS_DENIED; > goto ON_EXIT; > } else if (ResponseData->Response.StatusCode =3D=3D > HTTP_STATUS_400_BAD_REQUEST) { > - DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, > "HTTP_STATUS_400_BAD_REQUEST\n")); > if (SendChunkProcess =3D=3D HttpIoSendChunkHeaderZeroContent) { > - DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. = Try > to send all chunks...\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "Bad request may caused by zero > + length chunk. Try to send all chunks...\n")); > SendChunkProcess++; > goto ReSendRequest; > } > } else if (ResponseData->Response.StatusCode =3D=3D > HTTP_STATUS_100_CONTINUE) { > - DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "HTTP_STATUS_100_CONTINUE\n")); > if (SendChunkProcess =3D=3D HttpIoSendChunkHeaderZeroContent) { > // > // We get HTTP_STATUS_100_CONTINUE to send the body using chunk > transfer. > // > - DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk > transfer...\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "HTTP_STATUS_100_CONTINUE for > + chunk transfer...\n")); > SendChunkProcess++; > goto ReSendRequest; > } >=20 > if (SendNonChunkProcess =3D=3D HttpIoSendNonChunkHeaderZeroContent) = { > - DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk > transfer...\n")); > + DEBUG ((DEBUG_REDFISH_NETWORK, "HTTP_STATUS_100_CONTINUE for > non > + chunk transfer...\n")); > SendNonChunkProcess++; > goto ReSendRequest; > } > @@ -281,6 +282,7 @@ ReSendRequest:; > } > } else { > DEBUG ((DEBUG_ERROR, "This HTTP Status is not handled!\n")); > + DumpHttpStatusCode (DEBUG_REDFISH_NETWORK, > + ResponseData->Response.StatusCode); > Status =3D EFI_UNSUPPORTED; > goto ON_EXIT; > } > @@ -394,10 +396,10 @@ ReSendRequest:; > TotalReceivedSize +=3D ResponseData->BodyLength; > } >=20 > - DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", > TotalReceivedSize)); > + DEBUG ((DEBUG_REDFISH_NETWORK, "Total of lengh of Response :%d\n", > + TotalReceivedSize)); > } >=20 > - DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", > Status)); > + DEBUG ((DEBUG_REDFISH_NETWORK, "RedfishRestExSendReceive()- > + EFI_STATUS: %r\n", Status)); >=20 > ON_EXIT: >=20 > -- > 2.39.1.windows.1