[PATCH 1/1] RedfishClientPkg: Facilities of EDK2 Redfish Feature driver Env.


Nickle Wang
 

Initial common header file and meta files for feature drivers.

Signed-off-by: Nickle Wang <nickle.wang@...>
Cc: Abner Chang <abner.chang@...>
Cc: Liming Gao <gaoliming@...>
---
.../Include/Guid/RedfishClientPkgTokenSpace.h | 20 +++
.../EdkIIRedfishResourceConfigProtocol.h | 129 ++++++++++++++++++
.../Include/RedfishCollectionCommon.h | 53 +++++++
.../Include/RedfishResourceCommon.h | 123 +++++++++++++++++
RedfishClientPkg/RedfishClientPkg.dec | 8 +-
5 files changed, 332 insertions(+), 1 deletion(-)
create mode 100644 RedfishClientPkg/Include/Guid/RedfishClientPkgTokenSpac=
e.h
create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceC=
onfigProtocol.h
create mode 100644 RedfishClientPkg/Include/RedfishCollectionCommon.h
create mode 100644 RedfishClientPkg/Include/RedfishResourceCommon.h

diff --git a/RedfishClientPkg/Include/Guid/RedfishClientPkgTokenSpace.h b/R=
edfishClientPkg/Include/Guid/RedfishClientPkgTokenSpace.h
new file mode 100644
index 0000000000..1cdf429da4
--- /dev/null
+++ b/RedfishClientPkg/Include/Guid/RedfishClientPkgTokenSpace.h
@@ -0,0 +1,20 @@
+/** @file=0D
+ GUID for RedfishClientPkg PCD Token Space=0D
+=0D
+ (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>=0D
+=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#ifndef _REDFISHCLIENTPKG_TOKEN_SPACE_GUID_H_=0D
+#define _REDFISHCLIENTPKG_TOKEN_SPACE_GUID_H_=0D
+=0D
+#define REDFISHCLIENTPKG_TOKEN_SPACE_GUID \=0D
+ { \=0D
+ 0x8c444dae, 0x728b, 0x48ee, { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c=
, 0xc8 } \=0D
+ }=0D
+=0D
+extern EFI_GUID gEfiRedfishClientPkgTokenSpaceGuid;=0D
+=0D
+#endif=0D
diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigPr=
otocol.h b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigProt=
ocol.h
new file mode 100644
index 0000000000..d6c41dda52
--- /dev/null
+++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigProtocol.h
@@ -0,0 +1,129 @@
+/** @file=0D
+ This file defines the EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL interface.=
=0D
+=0D
+ (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>=0D
+=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#ifndef EDKII_REDFISH_RESOURCE_CONFIG_H_=0D
+#define EDKII_REDFISH_RESOURCE_CONFIG_H_=0D
+=0D
+typedef struct _EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL EDKII_REDFISH_RESOU=
RCE_CONFIG_PROTOCOL;=0D
+=0D
+/**=0D
+ Provising redfish resource by given URI.=0D
+=0D
+ @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI=
G_PROTOCOL instance.=0D
+ @param[in] Uri Target URI to create resource.=0D
+ @param[in] HttpPostMode TRUE if resource does not exist, HTTP P=
OST method is used.=0D
+ FALSE if the resource exist but some of=
properties are missing,=0D
+ HTTP PUT method is used.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+typedef=0D
+EFI_STATUS=0D
+(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_PROVISIONING) (=0D
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,=0D
+ IN CHAR8 *Uri,=0D
+ IN BOOLEAN HttpPostMode=0D
+ );=0D
+=0D
+/**=0D
+ Consume resource from given URI.=0D
+=0D
+ @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI=
G_PROTOCOL instance.=0D
+ @param[in] Uri The target URI to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+typedef=0D
+EFI_STATUS=0D
+(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CONSUME) (=0D
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,=0D
+ IN CHAR8 *Uri=0D
+ );=0D
+=0D
+=0D
+/**=0D
+ Update resource to given URI.=0D
+=0D
+ @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI=
G_PROTOCOL instance.=0D
+ @param[in] Uri The target URI to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+typedef=0D
+EFI_STATUS=0D
+(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_UPDATE) (=0D
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,=0D
+ IN CHAR8 *Uri=0D
+ );=0D
+=0D
+=0D
+/**=0D
+ Check resource on given URI.=0D
+=0D
+ @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI=
G_PROTOCOL instance.=0D
+ @param[in] Uri The target URI to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+typedef=0D
+EFI_STATUS=0D
+(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CHECK) (=0D
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,=0D
+ IN CHAR8 *Uri=0D
+ );=0D
+=0D
+//=0D
+// definition of REDFISH_SCHEMA_INFO=0D
+//=0D
+#define REDFISH_SCHEMA_STRING_SIZE (FixedPcdGet32 (PcdMaxRedfishSchemaStr=
ingSize))=0D
+#define REDFISH_SCHEMA_VERSION_SIZE (FixedPcdGet32 (PcdMaxRedfishSchemaVer=
sionSize))=0D
+=0D
+typedef struct _SCHEMA_INFO {=0D
+ CHAR8 Schema[REDFISH_SCHEMA_STRING_SIZE];=0D
+ CHAR8 Major[REDFISH_SCHEMA_VERSION_SIZE];=0D
+ CHAR8 Minor[REDFISH_SCHEMA_VERSION_SIZE];=0D
+ CHAR8 Errata[REDFISH_SCHEMA_VERSION_SIZE];=0D
+} REDFISH_SCHEMA_INFO;=0D
+=0D
+/**=0D
+ Get information about this protocol.=0D
+=0D
+ @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI=
G_PROTOCOL instance.=0D
+ @param[out] Info The schema information.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+typedef=0D
+EFI_STATUS=0D
+(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_GET_INFO) (=0D
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,=0D
+ OUT REDFISH_SCHEMA_INFO *Info=0D
+ );=0D
+=0D
+struct _EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL {=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_PROVISIONING Provisioning;=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CONSUME Consume;=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_UPDATE Update;=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CHECK Check;=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_GET_INFO GetInfo;=0D
+};=0D
+=0D
+extern EFI_GUID gEdkIIRedfishResourceConfigProtocolGuid;=0D
+=0D
+#endif=0D
diff --git a/RedfishClientPkg/Include/RedfishCollectionCommon.h b/RedfishCl=
ientPkg/Include/RedfishCollectionCommon.h
new file mode 100644
index 0000000000..3962b361ed
--- /dev/null
+++ b/RedfishClientPkg/Include/RedfishCollectionCommon.h
@@ -0,0 +1,53 @@
+/** @file=0D
+ Redfish feature driver collection common header file.=0D
+=0D
+ (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>=0D
+=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#ifndef EFI_REDFISH_COLLECTION_COMMON_H_=0D
+#define EFI_REDFISH_COLLECTION_COMMON_H_=0D
+=0D
+//=0D
+// Libraries=0D
+//=0D
+#include <Library/BaseMemoryLib.h>=0D
+#include <Library/DebugLib.h>=0D
+#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/PrintLib.h>=0D
+#include <Library/PcdLib.h>=0D
+#include <Library/RedfishLib.h>=0D
+#include <Library/RedfishFeatureUtilityLib.h>=0D
+#include <Library/UefiLib.h>=0D
+#include <Library/UefiBootServicesTableLib.h>=0D
+=0D
+//=0D
+// Protocols=0D
+//=0D
+#include <Protocol/EdkIIRedfishConfigHandler.h>=0D
+#include <Protocol/EdkIIRedfishResourceConfigProtocol.h>=0D
+#include <Protocol/EdkIIRedfishFeature.h>=0D
+#include <Protocol/RestJsonStructure.h>=0D
+#include <Protocol/RestEx.h>=0D
+=0D
+#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D =
'\0')=0D
+#define REDFISH_DEBUG_TRACE DEBUG_INFO=0D
+=0D
+typedef struct _REDFISH_COLLECTION_PRIVATE {=0D
+ EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol;=0D
+ EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol;=0D
+ REDFISH_SERVICE RedfishService;=0D
+ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler;=0D
+ EFI_EVENT Event;=0D
+ CHAR8 *CollectionPath;=0D
+ CHAR8 *CollectionJson;=0D
+ REDFISH_PAYLOAD CollectionPayload;=0D
+ REDFISH_RESPONSE RedResponse;=0D
+} REDFISH_COLLECTION_PRIVATE;=0D
+=0D
+#define REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL(This) \=0D
+ BASE_CR ((This), REDFISH_COLLECTION_PRIVATE, ConfigHandler)=0D
+=0D
+#endif=0D
diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h b/RedfishClie=
ntPkg/Include/RedfishResourceCommon.h
new file mode 100644
index 0000000000..1ba992bb69
--- /dev/null
+++ b/RedfishClientPkg/Include/RedfishResourceCommon.h
@@ -0,0 +1,123 @@
+/** @file=0D
+ Redfish feature driver common header file.=0D
+=0D
+ (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>=0D
+=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#ifndef EFI_REDFISH_RESOURCE_COMMON_H_=0D
+#define EFI_REDFISH_RESOURCE_COMMON_H_=0D
+=0D
+#define MAX_RED_PATH_LEN 128=0D
+#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0')=0D
+#define REDFISH_DEBUG_TRACE DEBUG_INFO=0D
+=0D
+//=0D
+// Libraries=0D
+//=0D
+#include <Library/DebugLib.h>=0D
+#include <Library/BaseMemoryLib.h>=0D
+#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/PrintLib.h>=0D
+#include <Library/PcdLib.h>=0D
+#include <Library/RedfishLib.h>=0D
+#include <Library/RedfishFeatureUtilityLib.h>=0D
+#include <Library/RedfishPlatformConfigLib.h>=0D
+#include <Library/UefiLib.h>=0D
+#include <Library/UefiBootServicesTableLib.h>=0D
+=0D
+//=0D
+// Protocols=0D
+//=0D
+#include <Protocol/EdkIIRedfishConfigHandler.h>=0D
+#include <Protocol/EdkIIRedfishResourceConfigProtocol.h>=0D
+#include <Protocol/RestJsonStructure.h>=0D
+#include <Protocol/RestEx.h>=0D
+=0D
+=0D
+typedef struct _REDFISH_RESOURCE_COMMON_PRIVATE {=0D
+ REDFISH_SERVICE RedfishService;=0D
+ EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol;=0D
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL RedfishResourceConfig;=0D
+ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler;=0D
+ EFI_EVENT Event;=0D
+ CHAR8 *Uri;=0D
+ CHAR8 *Json;=0D
+ REDFISH_PAYLOAD Payload;=0D
+} REDFISH_RESOURCE_COMMON_PRIVATE;=0D
+=0D
+#define REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL(This) \=
=0D
+ BASE_CR ((This), REDFISH_RESOURCE_COMMON_PRIVATE, ConfigHandler)=
=0D
+=0D
+#define REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL(This) =
\=0D
+ BASE_CR ((This), REDFISH_RESOURCE_COMMON_PRIVATE, RedfishResourc=
eConfig)=0D
+=0D
+=0D
+/**=0D
+ Consume resource from given URI.=0D
+=0D
+ @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV=
ATE instance.=0D
+ @param[in] Json The JSON to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+RedfishConsumeResourceCommon (=0D
+ IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,=0D
+ IN CHAR8 *Json=0D
+ );=0D
+=0D
+/**=0D
+ Provisioning redfish resource by given URI.=0D
+=0D
+ @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL =
instance.=0D
+ @param[in] ResourceExist TRUE if resource exists, PUT method wil=
l be used.=0D
+ FALSE if resource does not exist POST m=
ethod is used.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+RedfishProvisioningResourceCommon (=0D
+ IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,=0D
+ IN BOOLEAN ResourceExist=0D
+ );=0D
+=0D
+/**=0D
+ Check resource from given URI.=0D
+=0D
+ @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV=
ATE instance.=0D
+ @param[in] Json The JSON to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+RedfishCheckResourceCommon (=0D
+ IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,=0D
+ IN CHAR8 *Json=0D
+ );=0D
+=0D
+/**=0D
+ Update resource to given URI.=0D
+=0D
+ @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV=
ATE instance.=0D
+ @param[in] Json The JSON to consume.=0D
+=0D
+ @retval EFI_SUCCESS Value is returned successfully.=0D
+ @retval Others Some error happened.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+RedfishUpdateResourceCommon (=0D
+ IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,=0D
+ IN CHAR8 *Json=0D
+ );=0D
+=0D
+#endif=0D
diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi=
shClientPkg.dec
index 8fa92d5b1e..f01509d78f 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -21,9 +21,12 @@
=0D
[Protocols]=0D
## Include/Protocol/EdkIIRedfishFeature.h=0D
- gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEFBF, { 0x2=
A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } }=0D
+ gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEFBF=
, { 0x2A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } }=0D
+ ## Include/Protocol/EdkIIRedfishResourceConfigProtocol.h=0D
+ gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646=
, { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } }=0D
=0D
[Guids]=0D
+ ## Include/Guid/RedfishClientPkgTokenSpace.h=0D
gEfiRedfishClientPkgTokenSpaceGuid =3D { 0x8c444dae, 0x728b, 0x48ee, =
{ 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } }=0D
=0D
[PcdsFixedAtBuild]=0D
@@ -35,3 +38,6 @@
#=0D
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv=
entGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, =
0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003=0D
=0D
+[PcdsFixedAtBuild]=0D
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT=
32|0x10000001=0D
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT=
32|0x10000002=0D
--=20
2.31.1.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.