From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.54]) by mx.groups.io with SMTP id smtpd.web11.80280.1684120778686043388 for ; Sun, 14 May 2023 20:19:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=Ne9h7bKe; 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.102.54, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLoLxhjeqrqLm/Yd/LC+n95R5QehuihdD1EA8QB/II/WpQTMtpEeVlWZ82SL4UBVhoZGaJq7b1A/uSFC7NiIQnloXleYsKXImTB/5yqU/60bfJMPrMb5k/pZQgloC+NSjpoLGr4TW1Dx8U3W/9L0rgDGMm76IvNUz/Mv0b5BLv/Jk2RACEBaGo/9KAs0v0sZi/qPB+Gh22fokZrm90XdGZFf3YrpM+/MGrJ40uxZUqsd2TxZrUDLvSKZjlxHR7HFBqV38849ho+7EmsbWVaOXIRQ5DPW++TMA07gSpRTZvNWmo7taAf/3UrVFfDK3kysm8Uj/ZwL/di0ZOZob5Useg== 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=RisAq6sEPQyABSYrfiOm7oBGqI6VsvEZfFB6BJ4lDk8=; b=j/5OjZfWtgIZe8d4kPQozzxc+b1HGaGZ0809r75VARx6qGvFaeQIMe74yazpGbRSW7C3xChRtIQWefLfbhh/kA3xL2OtvSzbbV9fxHQa2+8LIO4E96Ce0wFntK4NencCG7EeOK7fBNPq2LeiJ7ExXsjVl6UUSQUbcvrvV1VdKZ+4ICoK78lruBCQPuOiRvYdX26shmWpE0hz6XLGzo0n5ph5JYNk7yXlTfnWNBk+3zud9/ZfpzxEdNJY+Pxm8uBPcNhdsnvE0MNs+SMi6dfVLPcTk/nq6YQRiBdTM8mWWkqK2gMwSrwUr6MsuWPPQY7o5XUumWWxFO9P/4uX2g3+Gg== 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=RisAq6sEPQyABSYrfiOm7oBGqI6VsvEZfFB6BJ4lDk8=; b=Ne9h7bKe9MTmunGJxypecBVNl5rIZKvtpwzAZC8ggk3Ta0DzO6RrHdGVNym6aY2SFNfIj90w1WBWFhRmGh0nfA5wZCWfEt57XBqMoT2FrZ8/r9EFi8XvOUlNuT+5zCjlngHuITiYMxHDIm99CvCZHqwhjHMoUDoD/qwOBRj9DSM= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by SJ0PR12MB6854.namprd12.prod.outlook.com (2603:10b6:a03:47c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Mon, 15 May 2023 03:19:34 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040%5]) with mapi id 15.20.6387.029; Mon, 15 May 2023 03:19:33 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-redfish-client][PATCH 2/3] RedfishClientPkg: Add Redfish Resource Addendum Library Thread-Topic: [edk2-redfish-client][PATCH 2/3] RedfishClientPkg: Add Redfish Resource Addendum Library Thread-Index: AQHZhKKhrTsTbnAaQESZr8yKWHd0s69aqDcw Date: Mon, 15 May 2023 03:19:33 +0000 Message-ID: References: <20230512072301.17881-1-nicklew@nvidia.com> In-Reply-To: <20230512072301.17881-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-05-15T03:19:30Z; 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=79db31a1-69dd-478b-b7ba-096a2ba4bfc5; 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_|SJ0PR12MB6854:EE_ x-ms-office365-filtering-correlation-id: c4ece878-c547-4980-ac35-08db54f33465 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qKzbe1xoq8YpKw0WgdlNL+vvJ6DC2NfnnZ4O41GntjUvxhv1Tjg3rVjR2ZYWSeGmj3AsvzlK8dz4N+Qg1SqvrVLV4OkZdh8IXubaOBhiV2db5kFObgH75MOacUscN/mh2r4vIaE7YhwgtIPqYx3m/3DDifD7wRMjFRfHD7Jtvrnb2KVPMROuMy5OwGmTyKr0DlSKhJV0yWkL7cK4v7bwMoNG26BDIhSvtONsfk6qlS2nJN5ffNfwmS42UK83eK5EYbd//es7iJ5K3cvdWKS4n4lHpUBhaWg2RcMz4VgyWDouLZogumPjsmyPDUgxvbSdIbn0152o5liH3Kem6Dzb5yJlps/qpoOobxdwgFoJ6E70WOQJwz9TbA6Q+f5GklGtHJxiRkyWY5SiZKLt+cdMG7ZxDd+TDHleeM46fhFMrUL+r4BnoRWJq+YGXXGlhS81vfe9UH7Dc/Z8y2RBDUh7vx5Fh5cB/nfC5GDXulPkj4edDoVHHFzwaNRxj/qIFyLUtTZ3Sqa9LAmzI7nS0vheFuARNuOME14UHPbifj6XX1Fg4JkJv/c7tnMjT9TmHn30UVx1Su0K8cfW6uFxOR84E0DmzOgar4g2s2rTtbb1bPTDdQa+aKrPoIKj7z1XdbUW 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:(13230028)(4636009)(136003)(366004)(376002)(396003)(346002)(39860400002)(451199021)(83380400001)(30864003)(6506007)(26005)(2906002)(33656002)(186003)(110136005)(38100700002)(53546011)(9686003)(38070700005)(52536014)(86362001)(5660300002)(7696005)(8936002)(8676002)(71200400001)(66556008)(66476007)(66446008)(64756008)(4326008)(66946007)(478600001)(41300700001)(76116006)(55016003)(122000001)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?PbtyOswTmShQpaF6uVEpO30vYs7EQ+aKbEK68eVZ5wPktALQ1h80zm3MIZiQ?= =?us-ascii?Q?NllSMIYskEjoAO2CFCEH6V7P9yjqmPonx1kLUzEaitHSoR1Cgf3nbctLT9Ed?= =?us-ascii?Q?QGBXkhw7hzKdzdEKP3OAvQndCwLBajywJmh+daf1JZuRyh+F1/O0GfgbWndg?= =?us-ascii?Q?DwYVVB0bZZ4rNZMXeBd4gCQ4UcpOn/NbUup+E11kTcvkEkqR8d/4ye1UZCm1?= =?us-ascii?Q?Sd6bEghd2bwJH7oyaYrzCC7TUg07MsD3CtzOfrNkC5vXD8JEy4LPSjIqq+cI?= =?us-ascii?Q?NpCQUPmRH4XSElrZNATKhJcedtGHa0DfrizVc7a4/nRn5sLzvQ7LjK9q7bAg?= =?us-ascii?Q?eE4U97cZgaCRZyIyjGil68zo4YI3jqtaUAgFLKVnk+8l4VYYdQGgxz3iHdfu?= =?us-ascii?Q?NTa+iT8a9JmVCto0OZGK+REffJ0kWkHm4i0KbtsaVOEkFf3I+dLEEX+xbEy8?= =?us-ascii?Q?/XwNXgidTN8N65Ibb+nTIV8RTv87fSXbxpFOepgmjLGo9z0GQCa3fDwco7Kh?= =?us-ascii?Q?kZSaW2bZL3nJhk96tElGICRlCZJy6gMeeeDvMAhS5BFcsed9jxfeH/qS/ao3?= =?us-ascii?Q?mxFM1hku216NlCs8ft41INTUk95f9E70XJug42jPFlE25evsUIL+6KmfSMgK?= =?us-ascii?Q?TQfmZteyi8RGSB2wB9MiCqJbelaA+xju76yi5vzvXac8QEnBdx811vVNizab?= =?us-ascii?Q?2ddK56dZiwDXmTrN63yVWTULDiNSLDjYA9DS2RmJHZNxwPS+TrCgWaWq0yO0?= =?us-ascii?Q?FbJ5xfAWrkHfJe3huAWhwF0Xd5x2xYIo455S6uyknMr50kDQUDt2TXeinH8t?= =?us-ascii?Q?Dfpop63LbSw8M6CpPnyf41lUvRq8Ms8bw8ZV0AC972I92HvqyMem414XLIVX?= =?us-ascii?Q?gJV2p5afxoC4UOx4EnhjfccQ8zGvKMeGRJoXiSpXKf+38aOgIsBwNPUhtI+g?= =?us-ascii?Q?j848cvk76uniXWMYHWqoC6mKgLBxTLuTOT6FI4owz9fZzdQgZKgnSYu5MD/k?= =?us-ascii?Q?p25LVtwxji96vJhH37jkUx5Cf5Wq49ZqSF11KPJc3Wv0U1Mi8zo9xUzHreSY?= =?us-ascii?Q?umn8wussV+5zoUDPLsKOniUt5IKKBxnDx+qG0nsBz9g5F7ho73OfvRAqhtfj?= =?us-ascii?Q?Knv0YqXamOwHRiV69rvNRwbramNsw0jfBDAsD5qpjbUZ2ey7RC99+cC1R+8d?= =?us-ascii?Q?sWQHw3ijaVslM+U78S91MR4P9/gGGjEZ9EyEntUJbFgJJqbJiXueRuADTgNH?= =?us-ascii?Q?d7ISDJecqtGk5vUlfT32hUyPqcpgOHJXbhjs8Vnly3MY97+hYkgqQsUOddyi?= =?us-ascii?Q?A8uBzwzlh3O1Fq0BPTH1LHhPtOyIgVm4drGi6F9dqR45gYz1XGiprsn7gU8s?= =?us-ascii?Q?VCpzT5MqaP37HNltt4NytNgHboyej1/jLfYtyp5QpjRiKzYbL8Y7bzDsCRRP?= =?us-ascii?Q?u+8rNFzPAW7SIS+DInPyqVEz5s+OZvaQZONK7Qq67k/JJVqM9sWv6FzjwSrY?= =?us-ascii?Q?yIMoy58lOQNqT3b4T796bFrwQd73vcSoNQfYt0xHihXRgONYQ0CQ2b3wAoyU?= =?us-ascii?Q?TTAC/d5v55zFw6fcHqM=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: c4ece878-c547-4980-ac35-08db54f33465 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 May 2023 03:19:33.5703 (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: CR2YNkpMvDZi1QXgBbZGLgk+v9hcqbpaqY20YqC3Fh4D7sPW8lM7TRzC7OPgqhfkIHW1J9l6zACz4n7inlbJ/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6854 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Nickle,=20 I read though this patch and was confused by function naming and the functi= on description in the function header. I think we have to revise it and ma= ke the description of functionality clear for user to follow. I apologize if we ever discussed this before however I don't have the synch= ronous mind now. 1. Protocol definitions=20 This protocol is provided by platform that would like to add an addition= al Redfish resource in "Oem" property or to add other platform specific pro= perty in the name other than "Oem". Both of two protocol interfaces give platform an chance to add "OEM" or = other Redfish property, however the naming of function prototypes are not c= onsistent. The naming of "OemCallback" and "ProvisioningCallback" are also = not consistent. How do you think the naming below, struct _EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL { UINT64 Revision; EDKII_REDFISH_RESOURCE_ADDENDUM_OEM AddAddendumOemRedfishReso= urce; ///< EDKII_REDFISH_RESOURCE_ADDENDUM_OTHER AddAddendumOtherRedfishReso= urce; ///< }; Would above look simple and clear? Also, please add some comments to these = two functions if you are agree with this change. 2. Function naming in the library, RedfishGetOemData -> RedfishGetAddendumOemData RedfishGetAddendumData-> RedfishGetAddendumOtherData 3. The current description in function header looks to me not quite clear. = Please elaborates some more functionality in the function header and parame= ters 4. Shall we have to update readme.md? Thanks Abner > -----Original Message----- > From: Nickle Wang > Sent: Friday, May 12, 2023 3:23 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > > Subject: [edk2-redfish-client][PATCH 2/3] RedfishClientPkg: Add Redfish > Resource Addendum Library >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > Implement RedfishAddendumLib to support Redfish Resource Addendum > Protocol. > Feature driver calls this library to get addendum data before providing > data to Redfish service >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > --- > RedfishClientPkg/RedfishClientLibs.dsc.inc | 4 +- > RedfishClientPkg/RedfishClientPkg.dsc | 2 + > .../RedfishAddendumLib/RedfishAddendumLib.inf | 40 +++ > .../Include/Library/RedfishAddendumLib.h | 65 +++++ > .../RedfishAddendumLib/RedfishAddendumLib.c | 262 > ++++++++++++++++++ > 5 files changed, 372 insertions(+), 1 deletion(-) > create mode 100644 > RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf > create mode 100644 > RedfishClientPkg/Include/Library/RedfishAddendumLib.h > create mode 100644 > RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c >=20 > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index fe0c4b08..5ea38015 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -2,10 +2,11 @@ > # Redfish DSC include file for [LibraryClasses*] section of all Architec= tures. > # > # This file can be included to the [LibraryClasses*] section(s) of a pla= tform > DSC file > -# by using "!include RedfishPkg/RedfisLibs.dsc.inc" to specify the libra= ry > instances > +# by using "!include RedfishPkg/RedfishLibs.dsc.inc" to specify the libr= ary > instances > # of EDKII network library classes. > # > # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -37,3 +38,4 @@ >=20 > EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResou > rceConfigLib/EdkIIRedfishResourceConfigLib.inf >=20 > RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.= i > nf >=20 > RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVersi > onLib.inf > + > RedfishAddendumLib|RedfishClientPkg/Library/RedfishAddendumLib/Redfi > shAddendumLib.inf > diff --git a/RedfishClientPkg/RedfishClientPkg.dsc > b/RedfishClientPkg/RedfishClientPkg.dsc > index 2b2149cc..d3b645b6 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dsc > +++ b/RedfishClientPkg/RedfishClientPkg.dsc > @@ -2,6 +2,7 @@ > # Redfish Client Package > # > # (C) Copyright 2021 Hewlett-Packard Enterprise Development LP. > +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -49,5 +50,6 @@ >=20 >=20 > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLi= b.i > nf > RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > + RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf >=20 > !include RedfishClientPkg/RedfishClient.dsc.inc > diff --git > a/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf > b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf > new file mode 100644 > index 00000000..1ecfaa69 > --- /dev/null > +++ > b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf > @@ -0,0 +1,40 @@ > +## @file > +# > +# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010006 > + BASE_NAME =3D RedfishAddendumLib > + FILE_GUID =3D 7B227D39-746D-4247-8291-27B0FA79A7A= F > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishAddendumLib| DXE_DRIVER > UEFI_DRIVER > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 EBC > +# > + > +[Sources] > + RedfishAddendumLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + RedfishClientPkg/RedfishClientPkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + UefiBootServicesTableLib > + MemoryAllocationLib > + UefiLib > + JsonLib > + > +[Protocols] > + gEdkIIRedfishResourceAddendumProtocolGuid ## CONSUMED ## > + > diff --git a/RedfishClientPkg/Include/Library/RedfishAddendumLib.h > b/RedfishClientPkg/Include/Library/RedfishAddendumLib.h > new file mode 100644 > index 00000000..d77347fd > --- /dev/null > +++ b/RedfishClientPkg/Include/Library/RedfishAddendumLib.h > @@ -0,0 +1,65 @@ > +/** @file > + This file defines the Redfish addendum library interface. > + > + Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REDFISH_ADDENDUM_LIB_H_ > +#define REDFISH_ADDENDUM_LIB_H_ > + > +#include > +#include > +#include > + > +/** > + Provide redfish resource with addendum data in given schema. > + > + @param[in] Uri Uri of input resource. > + @param[in] Schema Redfish schema string. > + @param[in] Version Schema version string. > + @param[in] JsonText Input resource in JSON format string. > + @param[out] JsonWithAddendum The input resource with addendum > value attached. > + > + @retval EFI_SUCCESS Addendum data is attached. > + @retval EFI_NOT_FOUND No addendum protocol is found in syst= em. > + @retval EFI_UNSUPPORTED No addendum data is required in given > schema. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishGetAddendumData ( > + IN EFI_STRING Uri, > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *JsonText, > + OUT CHAR8 **JsonWithAddendum > + ); > + > +/** > + Provide redfish OEM resource with given schema information. > + > + @param[in] Uri Uri of input resource. > + @param[in] Schema Redfish schema string. > + @param[in] Version Schema version string. > + @param[in] JsonText Input resource in JSON format string. > + @param[out] JsonWithOem The input resource with OEM value > attached. > + > + @retval EFI_SUCCESS OEM data is attached. > + @retval EFI_NOT_FOUND No addendum protocol is found in syst= em. > + @retval EFI_UNSUPPORTED No OEM data is required in given sche= ma. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishGetOemData ( > + IN EFI_STRING Uri, > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *JsonText, > + OUT CHAR8 **JsonWithOem > + ); > + > +#endif > diff --git > a/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c > b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c > new file mode 100644 > index 00000000..6aa6e3cc > --- /dev/null > +++ > b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c > @@ -0,0 +1,262 @@ > +/** @file > + Redfish addendum library helps Redfish application to get addendum dat= a > and OEM > + data from platform driver. > + > + Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + > + Convert Unicode string to ASCII string. It's call responsibility to re= lease > returned buffer. > + > + @param[in] UnicodeStr Unicode string to convert. > + > + @retval CHAR8 * ASCII string returned. > + @retval NULL Errors occur. > + > +**/ > +CHAR8 * > +UnicodeToAscii ( > + IN EFI_STRING UnicodeStr > + ) > +{ > + CHAR8 *AsciiStr; > + UINTN AsciiStrSize; > + EFI_STATUS Status; > + > + if (IS_EMPTY_STRING (UnicodeStr)) { > + return NULL; > + } > + > + AsciiStrSize =3D StrLen (UnicodeStr) + 1; > + AsciiStr =3D AllocatePool (AsciiStrSize); > + if (AsciiStr =3D=3D NULL) { > + return NULL; > + } > + > + Status =3D UnicodeStrToAsciiStrS (UnicodeStr, AsciiStr, AsciiStrSize); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "UnicodeStrToAsciiStrS failed: %r\n", Status)); > + FreePool (AsciiStr); > + return NULL; > + } > + > + return AsciiStr; > +} > + > +/** > + Provide redfish resource with addendum data in given schema. > + > + @param[in] Uri Uri of input resource. > + @param[in] Schema Redfish schema string. > + @param[in] Version Schema version string. > + @param[in] JsonText Input resource in JSON format string. > + @param[out] JsonWithAddendum The input resource with addendum > value attached. > + It is the caller's responsibility to fre= e this buffer. > + > + @retval EFI_SUCCESS Addendum data is attached. > + @retval EFI_NOT_FOUND No addendum protocol is found in syst= em. > + @retval EFI_UNSUPPORTED No addendum data is required in given > schema. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishGetAddendumData ( > + IN EFI_STRING Uri, > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *JsonText, > + OUT CHAR8 **JsonWithAddendum > + ) > +{ > + REDFISH_RESOURCE_SCHEMA_INFO SchemaInfo; > + EDKII_JSON_VALUE JsonValue; > + EFI_STATUS Status; > + EFI_HANDLE *HandleBuffer; > + UINTN NumberOfHandles; > + UINTN Index; > + EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL *Protocol; > + > + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Schema) || > IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (JsonText) || > (JsonWithAddendum =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *JsonWithAddendum =3D NULL; > + SchemaInfo.Uri =3D UnicodeToAscii (Uri); > + SchemaInfo.Schema =3D Schema; > + SchemaInfo.Version =3D Version; > + NumberOfHandles =3D 0; > + HandleBuffer =3D NULL; > + > + JsonValue =3D JsonLoadString (JsonText, 0, NULL); > + if ((JsonValue =3D=3D NULL) || !JsonValueIsObject (JsonValue)) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D gBS->LocateHandleBuffer ( > + ByProtocol, > + &gEdkIIRedfishResourceAddendumProtocolGuid, > + NULL, > + &NumberOfHandles, > + &HandleBuffer > + ); > + if (EFI_ERROR (Status)) { > + goto ON_RELEASE; > + } > + > + for (Index =3D 0; Index < NumberOfHandles; Index++) { > + Status =3D gBS->HandleProtocol ( > + HandleBuffer[Index], > + &gEdkIIRedfishResourceAddendumProtocolGuid, > + (VOID **)&Protocol > + ); > + if (EFI_ERROR (Status)) { > + continue; > + } > + > + Status =3D Protocol->ProvisioningCallback (Protocol, &SchemaInfo, > JsonValue); > + if (!EFI_ERROR (Status)) { > + *JsonWithAddendum =3D JsonDumpString (JsonValue, > EDKII_JSON_COMPACT); > + break; > + } > + } > + > +ON_RELEASE: > + > + if (HandleBuffer !=3D NULL) { > + FreePool (HandleBuffer); > + } > + > + if (JsonValue !=3D NULL) { > + JsonValueFree (JsonValue); > + } > + > + if (SchemaInfo.Uri !=3D NULL) { > + FreePool (SchemaInfo.Uri); > + } > + > + return Status; > +} > + > +/** > + Provide redfish OEM resource with given schema information. > + > + @param[in] Uri Uri of input resource. > + @param[in] Schema Redfish schema string. > + @param[in] Version Schema version string. > + @param[in] JsonText Input resource in JSON format string. > + @param[out] JsonWithOem The input resource with OEM value > attached. > + > + @retval EFI_SUCCESS OEM data is attached. > + @retval EFI_NOT_FOUND No addendum protocol is found in syst= em. > + @retval EFI_UNSUPPORTED No OEM data is required in given sche= ma. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishGetOemData ( > + IN EFI_STRING Uri, > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *JsonText, > + OUT CHAR8 **JsonWithOem > + ) > +{ > + REDFISH_RESOURCE_SCHEMA_INFO SchemaInfo; > + EDKII_JSON_VALUE JsonValue; > + EDKII_JSON_VALUE JsonValueOem; > + EFI_STATUS Status; > + EFI_HANDLE *HandleBuffer; > + UINTN NumberOfHandles; > + UINTN Index; > + EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL *Protocol; > + > + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Schema) || > IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (JsonText) || > (JsonWithOem =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *JsonWithOem =3D NULL; > + SchemaInfo.Uri =3D UnicodeToAscii (Uri); > + SchemaInfo.Schema =3D Schema; > + SchemaInfo.Version =3D Version; > + JsonValue =3D NULL; > + JsonValueOem =3D NULL; > + NumberOfHandles =3D 0; > + HandleBuffer =3D NULL; > + > + JsonValue =3D JsonLoadString (JsonText, 0, NULL); > + if ((JsonValue =3D=3D NULL) || !JsonValueIsObject (JsonValue)) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + JsonValueOem =3D JsonValueInitObject (); > + if ((JsonValueOem =3D=3D NULL) || !JsonValueIsObject (JsonValueOem)) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto ON_RELEASE; > + } > + > + Status =3D gBS->LocateHandleBuffer ( > + ByProtocol, > + &gEdkIIRedfishResourceAddendumProtocolGuid, > + NULL, > + &NumberOfHandles, > + &HandleBuffer > + ); > + if (EFI_ERROR (Status)) { > + goto ON_RELEASE; > + } > + > + for (Index =3D 0; Index < NumberOfHandles; Index++) { > + Status =3D gBS->HandleProtocol ( > + HandleBuffer[Index], > + &gEdkIIRedfishResourceAddendumProtocolGuid, > + (VOID **)&Protocol > + ); > + if (EFI_ERROR (Status)) { > + continue; > + } > + > + Status =3D Protocol->OemCallback (Protocol, &SchemaInfo, JsonValueOe= m); > + if (!EFI_ERROR (Status)) { > + Status =3D JsonObjectSetValue (JsonValue, "Oem", JsonValueOem); > + if (!EFI_ERROR (Status)) { > + *JsonWithOem =3D JsonDumpString (JsonValue, EDKII_JSON_COMPACT); > + } > + > + break; > + } > + } > + > +ON_RELEASE: > + > + if (HandleBuffer !=3D NULL) { > + FreePool (HandleBuffer); > + } > + > + if (JsonValue !=3D NULL) { > + JsonValueFree (JsonValue); > + } > + > + if (JsonValueOem !=3D NULL) { > + JsonValueFree (JsonValueOem); > + } > + > + if (SchemaInfo.Uri !=3D NULL) { > + FreePool (SchemaInfo.Uri); > + } > + > + return Status; > +} > -- > 2.17.1