* [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish
@ 2020-11-05 14:38 Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg Abner Chang
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Andrew Fish, Ray Ni, Jiaxin Wu, Ting Ye, Siyuan Fu,
Fan Wang, Nickle Wang, Peter O'Hanley
This patch set enables the Redfish support on Emulator platform.
The main change on this patch set is,
1. Provide the EFI application to configure the network information of
Redfish service. The configurations are stored in EFI variables.
2. The Platform Redfish Host Interface library consumes the EFI variables
created in step #1 and then creates the SMBIOS type 42 record.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Fan Wang <fan.wang@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
Abner Chang (6):
RedfishPkg: Add PCD definition to RedfishPkg
RedfishPkg: DSC and FDF include files for enabling EFI Redfish support
EmulatorPkg/RedfishPlatformHostInterfaceLib library
EmulatorPkg/Application: Publish Redfish Host Interface Record
EmulatorPkg: Add allowable dependency
EmulatorPkg: Redfish related changes on EmulatorPkg
.../RedfishPlatformConfig.c | 298 ++++++++++
.../RedfishPlatformConfig.inf | 42 ++
EmulatorPkg/EmulatorPkg.ci.yaml | 1 +
EmulatorPkg/EmulatorPkg.dec | 1 +
EmulatorPkg/EmulatorPkg.dsc | 26 +-
EmulatorPkg/EmulatorPkg.fdf | 5 +
.../RedfishPlatformHostInterfaceLib.c | 528 ++++++++++++++++++
.../RedfishPlatformHostInterfaceLib.inf | 47 ++
RedfishPkg/Redfish.dsc.inc | 21 +
RedfishPkg/Redfish.fdf.inc | 16 +
RedfishPkg/RedfishComponents.dsc.inc | 18 +
RedfishPkg/RedfishDefines.dsc.inc | 27 +
RedfishPkg/RedfishLibs.dsc.inc | 15 +
RedfishPkg/RedfishPkg.dec | 22 +
14 files changed, 1066 insertions(+), 1 deletion(-)
create mode 100644 EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
create mode 100644 EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
create mode 100644 RedfishPkg/Redfish.dsc.inc
create mode 100644 RedfishPkg/Redfish.fdf.inc
create mode 100644 RedfishPkg/RedfishComponents.dsc.inc
create mode 100644 RedfishPkg/RedfishDefines.dsc.inc
create mode 100644 RedfishPkg/RedfishLibs.dsc.inc
--
2.17.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
2020-11-09 4:24 ` [edk2-devel] " Nickle Wang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support Abner Chang
` (8 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Nickle Wang, Peter O'Hanley
This PCD is the UEFI device path which is used as the Redfish
host interface.
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Ting Ye <ting.ye@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
RedfishPkg/RedfishPkg.dec | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec
index f12f83526c..b38e9b4789 100644
--- a/RedfishPkg/RedfishPkg.dec
+++ b/RedfishPkg/RedfishPkg.dec
@@ -28,3 +28,25 @@
[Guids]
gEfiRedfishPkgTokenSpaceGuid = { 0x4fdbccb7, 0xe829, 0x4b4c, { 0x88, 0x87, 0xb2, 0x3f, 0xd7, 0x25, 0x4b, 0x85 }}
+[PcdsFixedAtBuild, PcdsPatchableInModule]
+ #
+ # This PCD is the UEFI device path which is used as the Redfish host interface.
+ #
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath|{0x0}|REST_EX_SERVICE_DEVICE_PATH_DATA|0x00001000 {
+ <HeaderFiles>
+ Pcd/RestExServiceDevicePath.h
+ <Packages>
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ RedfishPkg/RedfishPkg.dec
+ }
+ #
+ # This PCD indicates the EFI REST EX access mode to Redfish service.
+ # Default is set to out of band access.
+ #
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceAccessModeInBand|FALSE|BOOLEAN|0x00001001
+ #
+ # This PCD indicates the access mode EFI Discover protocol uses to look for the proper EFI REST EX
+ # protocol instance.
+ #
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand|FALSE|BOOLEAN|0x00001002
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
2020-11-09 4:26 ` [edk2-devel] " Nickle Wang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Abner Chang
` (7 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Jiaxin Wu, Siyuan Fu, Fan Wang, Nickle Wang, Peter O'Hanley
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Fan Wang <fan.wang@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
RedfishPkg/Redfish.dsc.inc | 21 +++++++++++++++++++++
RedfishPkg/Redfish.fdf.inc | 16 ++++++++++++++++
RedfishPkg/RedfishComponents.dsc.inc | 18 ++++++++++++++++++
RedfishPkg/RedfishDefines.dsc.inc | 27 +++++++++++++++++++++++++++
RedfishPkg/RedfishLibs.dsc.inc | 15 +++++++++++++++
5 files changed, 97 insertions(+)
create mode 100644 RedfishPkg/Redfish.dsc.inc
create mode 100644 RedfishPkg/Redfish.fdf.inc
create mode 100644 RedfishPkg/RedfishComponents.dsc.inc
create mode 100644 RedfishPkg/RedfishDefines.dsc.inc
create mode 100644 RedfishPkg/RedfishLibs.dsc.inc
diff --git a/RedfishPkg/Redfish.dsc.inc b/RedfishPkg/Redfish.dsc.inc
new file mode 100644
index 0000000000..ac72909ca2
--- /dev/null
+++ b/RedfishPkg/Redfish.dsc.inc
@@ -0,0 +1,21 @@
+## @file
+# Redfish DSC include file for Platform DSC
+#
+# This file includes all required information to enable Redfish features.
+# It can be included to a platform DSC file by using "!include RedfishPkg/Redfish.dsc.inc".
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ !include RedfishPkg/RedfishDefines.dsc.inc
+
+[LibraryClasses]
+ !include RedfishPkg/RedfishLibs.dsc.inc
+
+[Components]
+ !include RedfishPkg/RedfishComponents.dsc.inc
+
diff --git a/RedfishPkg/Redfish.fdf.inc b/RedfishPkg/Redfish.fdf.inc
new file mode 100644
index 0000000000..19de479a80
--- /dev/null
+++ b/RedfishPkg/Redfish.fdf.inc
@@ -0,0 +1,16 @@
+## @file
+# Redfish FDF include file for [FV*] section of all Architectures.
+#
+# This file can be included to the [FV*] section(s) of a platform FDF file
+# by using "!include RedfishPkg/RedfisLibs.fdf.inc" to specify the module instances
+# to be built in the firmware volume.
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+!if $(REDFISH_ENABLE) == TRUE
+ INF RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf
+ INF RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
+!endif
diff --git a/RedfishPkg/RedfishComponents.dsc.inc b/RedfishPkg/RedfishComponents.dsc.inc
new file mode 100644
index 0000000000..ac1b57ed8f
--- /dev/null
+++ b/RedfishPkg/RedfishComponents.dsc.inc
@@ -0,0 +1,18 @@
+## @file
+# Redfish DSC include file for [Components*] section of all Architectures.
+#
+# This file can be included to the [Components*] section(s) of a platform DSC file
+# by using "!include RedfishPkg/RedfishComponents.dsc.inc" to specify the INF files
+# of EDKII Redfish drivers according to the value of flags described in
+# "RedfishDefines.dsc.inc".
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+!if $(REDFISH_ENABLE) == TRUE
+ RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf
+ RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
+!endif
diff --git a/RedfishPkg/RedfishDefines.dsc.inc b/RedfishPkg/RedfishDefines.dsc.inc
new file mode 100644
index 0000000000..0049f92378
--- /dev/null
+++ b/RedfishPkg/RedfishDefines.dsc.inc
@@ -0,0 +1,27 @@
+## @file
+# RedfishPkg DSC include file for [Defines] section of all Architectures.
+#
+# This file can be included to the [Defines] section of a platform DSC file by
+# using "!include RedfishPkg/RedfishDefines.dsc.inc" to set value of
+# flags.
+#
+# These flags can be defined before the !include line, or changed on the command
+# line to enable or disable related feature support.
+# -D FLAG=VALUE
+#
+# The default value of these flags are:
+# DEFINE REDFISH_ENABLE = TRUE
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+!ifndef REDFISH_ENABLE
+ #
+ # This flag is to enable or disable the whole Redfish support.
+ #
+ DEFINE REDFISH_ENABLE = TRUE
+!endif
+
diff --git a/RedfishPkg/RedfishLibs.dsc.inc b/RedfishPkg/RedfishLibs.dsc.inc
new file mode 100644
index 0000000000..e780b5c270
--- /dev/null
+++ b/RedfishPkg/RedfishLibs.dsc.inc
@@ -0,0 +1,15 @@
+## @file
+# Redfish DSC include file for [LibraryClasses*] section of all Architectures.
+#
+# This file can be included to the [LibraryClasses*] section(s) of a platform DSC file
+# by using "!include RedfishPkg/RedfisLibs.dsc.inc" to specify the library instances
+# of EDKII network library classes.
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+!if $(REDFISH_ENABLE) == TRUE
+!endif
+
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record Abner Chang
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni, Nickle Wang,
Peter O'Hanley
Platform specific implementation of providing
Redfish host interface information.
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Ting Ye <ting.ye@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
EmulatorPkg/EmulatorPkg.dec | 1 +
.../RedfishPlatformHostInterfaceLib.c | 528 ++++++++++++++++++
.../RedfishPlatformHostInterfaceLib.inf | 47 ++
3 files changed, 576 insertions(+)
create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
diff --git a/EmulatorPkg/EmulatorPkg.dec b/EmulatorPkg/EmulatorPkg.dec
index 064f963c72..5d7fe6473e 100644
--- a/EmulatorPkg/EmulatorPkg.dec
+++ b/EmulatorPkg/EmulatorPkg.dec
@@ -46,6 +46,7 @@
gEmuSystemConfigGuid = { 0xF8626165, 0x6CEB, 0x924A, { 0xBA, 0xFC, 0xF1, 0x3A, 0xB9, 0xD6, 0x57, 0x28 } }
gEmuVirtualDisksGuid = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
gEmuPhysicalDisksGuid = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
+ gEmuRedfishServiceGuid = { 0x3fb208ac, 0x2185, 0x498c, { 0xbf, 0x46, 0xdc, 0x23, 0xda, 0x58, 0x7b, 0x55 } }
[PcdsFeatureFlag]
## If TRUE, if symbols only load on breakpoints and gdb entry
diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
new file mode 100644
index 0000000000..4e7bb65c06
--- /dev/null
+++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -0,0 +1,528 @@
+/** @file
+ PCI/PCIe network interface instace of RedfishPlatformHostInterfaceLib
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
+#include <Library/RedfishHostInterfaceLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+
+#include <Pcd/RestExServiceDevicePath.h>
+#include <Guid/GlobalVariable.h>
+
+#define VERBOSE_COLUME_SIZE (16)
+
+REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData;
+UINT8 mRedfishProtocolDataSize;
+
+/**
+ Get the MAC address of NIC.
+
+ @param[out] MacAddress Pointer to retrieve MAC address
+
+ @retval EFI_SUCCESS MAC address is returned in MacAddress
+
+**/
+EFI_STATUS
+GetMacAddressInformation (
+ OUT EFI_MAC_ADDRESS *MacAddress
+ )
+{
+ MAC_ADDR_DEVICE_PATH *Mac;
+ REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
+ EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
+ MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
+
+ Mac = NULL;
+ RestExServiceDevicePathData = NULL;
+ RestExServiceDevicePath = NULL;
+
+ RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr(PcdRedfishRestExServiceDevicePath);
+ if (RestExServiceDevicePathData == NULL ||
+ RestExServiceDevicePathData->DevicePathNum == 0 ||
+ !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) {
+ return EFI_NOT_FOUND;
+ }
+
+ RestExServiceDevicePath = RestExServiceDevicePathData->DevicePath;
+ if (RestExServiceDevicePathData->DevicePathMatchMode != DEVICE_PATH_MATCH_MAC_NODE) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Find Mac DevicePath Node.
+ //
+ while (!IsDevicePathEnd (RestExServiceDevicePath) &&
+ ((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
+ (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP))) {
+ RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
+ }
+
+ if (!IsDevicePathEnd (RestExServiceDevicePath)) {
+ MacAddressDevicePath = (MAC_ADDR_DEVICE_PATH *)RestExServiceDevicePath;
+ CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
+ return EFI_SUCCESS;
+ }
+ return EFI_NOT_FOUND;
+}
+
+/**
+ Get platform Redfish host interface device descriptor.
+
+ @param[out] DeviceType Pointer to retrieve device type.
+ @param[out] DeviceDescriptor Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
+ this memory using FreePool().
+ @retval EFI_SUCCESS Device descriptor is returned successfully in DeviceDescriptor.
+ @retval EFI_NOT_FOUND No Redfish host interface descriptor provided on this platform.
+ @retval Others Fail to get device descriptor.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceDeviceDescriptor (
+ OUT UINT8 *DeviceType,
+ OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
+)
+{
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddress;
+ REDFISH_INTERFACE_DATA *RedfishInterfaceData;
+ PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
+
+ RedfishInterfaceData = AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
+ if (RedfishInterfaceData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
+ //
+ // Fill up device type information.
+ //
+ ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
+ ThisDeviceDescriptor->Length = sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1;
+ Status = GetMacAddressInformation (&MacAddress);
+ if (EFI_ERROR (Status)) {
+ FreePool (RedfishInterfaceData);
+ return EFI_NOT_FOUND;
+ }
+ CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor->MacAddress));
+ *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
+ *DeviceDescriptor = RedfishInterfaceData;
+ return EFI_SUCCESS;
+}
+/**
+ Get platform Redfish host interface protocol data.
+ Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
+ Then continuously pass previous ProtocolRecord for retrieving the next ProtocolRecord.
+
+ @param[out] ProtocolRecord Pointer to retrieve the protocol record.
+ caller has to free the new protocol record returned from
+ this function using FreePool().
+ @param[in] IndexOfProtocolData The index of protocol data.
+
+ @retval EFI_SUCCESS Protocol records are all returned.
+ @retval EFI_NOT_FOUND No more protocol records.
+ @retval Others Fail to get protocol records.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceProtocolData (
+ OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
+ IN UINT8 IndexOfProtocolData
+)
+{
+ MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
+
+ if (mRedfishOverIpProtocolData == 0) {
+ return EFI_NOT_FOUND;
+ }
+ if (IndexOfProtocolData == 0) {
+ //
+ // Return the first Redfish protocol data to caller. We only have
+ // one protocol data in this case.
+ //
+ ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *) AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
+ ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
+ ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
+ CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
+ *ProtocolRecord = ThisProtocolRecord;
+ return EFI_SUCCESS;
+ }
+ return EFI_NOT_FOUND;
+}
+/**
+ Dump IPv4 address.
+
+ @param[in] Ip IPv4 address
+**/
+VOID
+InternalDumpIp4Addr (
+ IN EFI_IPv4_ADDRESS *Ip
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < 4; Index++) {
+ DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index]));
+ if (Index < 3) {
+ DEBUG ((DEBUG_VERBOSE, "."));
+ }
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+}
+/**
+ Dump IPv6 address.
+
+ @param[in] Ip IPv6 address
+**/
+VOID
+InternalDumpIp6Addr (
+ IN EFI_IPv6_ADDRESS *Ip
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < 16; Index++) {
+ if (Ip->Addr[Index] != 0) {
+ DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
+ }
+ Index++;
+
+ if (Index > 15) {
+ return;
+ }
+
+ if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
+ DEBUG ((DEBUG_VERBOSE, "0"));
+ }
+ DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
+
+ if (Index < 15) {
+ DEBUG ((DEBUG_VERBOSE, ":"));
+ }
+ }
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+}
+/**
+ Dump data
+
+ @param[in] Data Pointer to data.
+ @param[in] Size size of data to dump.
+**/
+VOID
+InternalDumpData (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < Size; Index++) {
+ DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
+ }
+}
+/**
+ Dump hex data
+
+ @param[in] Data Pointer to hex data.
+ @param[in] Size size of hex data to dump.
+**/
+VOID
+InternalDumpHex (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ UINTN Left;
+
+ Count = Size / VERBOSE_COLUME_SIZE;
+ Left = Size % VERBOSE_COLUME_SIZE;
+ for (Index = 0; Index < Count; Index++) {
+ InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, VERBOSE_COLUME_SIZE);
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+ }
+
+ if (Left != 0) {
+ InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, Left);
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+}
+/**
+ Dump Redfish over IP protocol data
+
+ @param[in] RedfishProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA
+ @param[in] RedfishProtocolDataSize size of data to dump.
+**/
+VOID
+DumpRedfishIpProtocolData (
+ IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
+ IN UINT8 RedfishProtocolDataSize
+ )
+{
+ CHAR16 Hostname[16];
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
+ InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSize);
+
+ DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->ServiceUuid - %g\n", &(RedfishProtocolData->ServiceUuid)));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAssignmentType - %d\n", RedfishProtocolData->HostIpAssignmentType));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddressFormat - %d\n", RedfishProtocolData->HostIpAddressFormat));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
+ if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpAddress));
+ } else {
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpAddress));
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
+ if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpMask));
+ } else {
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpMask));
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddressFormat - %d\n", RedfishProtocolData->RedfishServiceIpAddressFormat));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
+ if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
+ } else {
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
+ if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
+ InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
+ } else {
+ InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceVlanId - %d\n", RedfishProtocolData->RedfishServiceVlanId));
+
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength));
+
+ AsciiStrToUnicodeStrS((CHAR8 *) RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
+ DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
+}
+
+/**
+ Get Redfish host interface protocol data from variale.
+
+ @param[out] RedfishProtocolData Pointer to retrieve REDFISH_OVER_IP_PROTOCOL_DATA.
+ @param[out] RedfishProtocolDataSize Size of REDFISH_OVER_IP_PROTOCOL_DATA.
+
+ @retval EFI_SUCESS REDFISH_OVER_IP_PROTOCOL_DATA is returned successfully.
+**/
+EFI_STATUS
+GetRedfishRecordFromVariable (
+ OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
+ OUT UINT8 *RedfishProtocolDataSize
+ )
+{
+ EFI_STATUS Status;
+ UINT8 HostIpAssignmentType;
+ UINTN HostIpAssignmentTypeSize;
+ EFI_IPv4_ADDRESS HostIpAddress;
+ UINTN IPv4DataSize;
+ EFI_IPv4_ADDRESS HostIpMask;
+ EFI_IPv4_ADDRESS RedfishServiceIpAddress;
+ EFI_IPv4_ADDRESS RedfishServiceIpMask;
+ UINT16 RedfishServiceIpPort;
+ UINTN IpPortDataSize;
+ UINT8 HostNameSize;
+ CHAR8 RedfishHostName[20];
+
+ if (RedfishProtocolData == NULL || RedfishProtocolDataSize == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // 1. Retrieve Address Information from variable.
+ //
+ Status = gRT->GetVariable (
+ L"HostIpAssignmentType",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &HostIpAssignmentTypeSize,
+ &HostIpAssignmentType
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAssignmentType - %r\n", Status));
+ return Status;
+ }
+
+ IPv4DataSize = sizeof (EFI_IPv4_ADDRESS);
+ if (HostIpAssignmentType == 1 ) {
+ Status = gRT->GetVariable (
+ L"HostIpAddress",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &IPv4DataSize,
+ &HostIpAddress
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAddress - %r\n", Status));
+ return Status;
+ }
+
+ Status = gRT->GetVariable (
+ L"HostIpMask",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &IPv4DataSize,
+ &HostIpMask
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpMask - %r\n", Status));
+ return Status;
+ }
+ }
+
+ Status = gRT->GetVariable (
+ L"RedfishServiceIpAddress",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &IPv4DataSize,
+ &RedfishServiceIpAddress
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpAddress - %r\n", Status));
+ return Status;
+ }
+
+ Status = gRT->GetVariable (
+ L"RedfishServiceIpMask",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &IPv4DataSize,
+ &RedfishServiceIpMask
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpMask - %r\n", Status));
+ return Status;
+ }
+
+ Status = gRT->GetVariable (
+ L"RedfishServiceIpPort",
+ &gEmuRedfishServiceGuid,
+ NULL,
+ &IpPortDataSize,
+ &RedfishServiceIpPort
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpPort - %r\n", Status));
+ return Status;
+ }
+
+ AsciiSPrint (
+ RedfishHostName,
+ sizeof (RedfishHostName),
+ "%d.%d.%d.%d",
+ RedfishServiceIpAddress.Addr[0],
+ RedfishServiceIpAddress.Addr[1],
+ RedfishServiceIpAddress.Addr[2],
+ RedfishServiceIpAddress.Addr[3]
+ );
+
+ HostNameSize = (UINT8) AsciiStrLen (RedfishHostName) + 1;
+
+ //
+ // 2. Protocol Data Size.
+ //
+ *RedfishProtocolDataSize = sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 + HostNameSize;
+
+ //
+ // 3. Protocol Data.
+ //
+ *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZeroPool (*RedfishProtocolDataSize);
+ if (*RedfishProtocolData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
+
+ (*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
+ (*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
+
+ if (HostIpAssignmentType == 1 ) {
+ (*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
+ (*RedfishProtocolData)->HostIpAddress[1] = HostIpAddress.Addr[1];
+ (*RedfishProtocolData)->HostIpAddress[2] = HostIpAddress.Addr[2];
+ (*RedfishProtocolData)->HostIpAddress[3] = HostIpAddress.Addr[3];
+
+ (*RedfishProtocolData)->HostIpMask[0] = HostIpMask.Addr[0];
+ (*RedfishProtocolData)->HostIpMask[1] = HostIpMask.Addr[1];
+ (*RedfishProtocolData)->HostIpMask[2] = HostIpMask.Addr[2];
+ (*RedfishProtocolData)->HostIpMask[3] = HostIpMask.Addr[3];
+ }
+
+ (*RedfishProtocolData)->RedfishServiceIpDiscoveryType = 1; // Use static IP address
+ (*RedfishProtocolData)->RedfishServiceIpAddressFormat = 1; // Only support IPv4
+
+ (*RedfishProtocolData)->RedfishServiceIpAddress[0] = RedfishServiceIpAddress.Addr[0];
+ (*RedfishProtocolData)->RedfishServiceIpAddress[1] = RedfishServiceIpAddress.Addr[1];
+ (*RedfishProtocolData)->RedfishServiceIpAddress[2] = RedfishServiceIpAddress.Addr[2];
+ (*RedfishProtocolData)->RedfishServiceIpAddress[3] = RedfishServiceIpAddress.Addr[3];
+
+ (*RedfishProtocolData)->RedfishServiceIpMask[0] = RedfishServiceIpMask.Addr[0];
+ (*RedfishProtocolData)->RedfishServiceIpMask[1] = RedfishServiceIpMask.Addr[1];
+ (*RedfishProtocolData)->RedfishServiceIpMask[2] = RedfishServiceIpMask.Addr[2];
+ (*RedfishProtocolData)->RedfishServiceIpMask[3] = RedfishServiceIpMask.Addr[3];
+
+ (*RedfishProtocolData)->RedfishServiceIpPort = RedfishServiceIpPort;
+ (*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
+
+ (*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
+ AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
+
+ return Status;
+}
+
+/**
+ Construct Redfish host interface protocol data.
+
+ @param ImageHandle The image handle.
+ @param SystemTable The system table.
+
+ @retval EFI_SUCEESS Install Boot manager menu success.
+ @retval Other Return error status.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishPlatformHostInterfaceConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+{
+ EFI_STATUS Status;
+
+ Status = GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData, &mRedfishProtocolDataSize);
+ DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FUNCTION__, Status));
+ if (!EFI_ERROR (Status)) {
+ DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
+ }
+ return EFI_SUCCESS;
+}
diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
new file mode 100644
index 0000000000..6fe5d9b32b
--- /dev/null
+++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
@@ -0,0 +1,47 @@
+## @file
+# NULL instance of RedfishPlatformHostInterfaceLib
+#
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001000b
+ BASE_NAME = RedfishPlatformHostInterfaceLib
+ FILE_GUID = D5ECB7F2-4906-94E2-45B1-31BF4FD90122
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = RedfishPlatformHostInterfaceLib
+ CONSTRUCTOR = RedfishPlatformHostInterfaceConstructor
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ RedfishPlatformHostInterfaceLib.c
+
+[Packages]
+ EmulatorPkg/EmulatorPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ RedfishPkg/RedfishPkg.dec
+
+[LibraryClasses]
+ UefiLib
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+ MemoryAllocationLib
+
+[Pcd]
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath ## CONSUMES
+
+[Guids]
+ gEmuRedfishServiceGuid
+
+[Depex]
+ gEfiVariableArchProtocolGuid AND
+ gEfiVariableWriteArchProtocolGuid
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
` (2 preceding siblings ...)
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency Abner Chang
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni, Nickle Wang,
Peter O'Hanley
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Ting Ye <ting.ye@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
.../RedfishPlatformConfig.c | 298 ++++++++++++++++++
.../RedfishPlatformConfig.inf | 42 +++
2 files changed, 340 insertions(+)
create mode 100644 EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
create mode 100644 EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
diff --git a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
new file mode 100644
index 0000000000..89d4c760a7
--- /dev/null
+++ b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
@@ -0,0 +1,298 @@
+/** @file
+ The implementation for Redfish Platform Configuration application.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/NetLib.h>
+#include <Library/UefiApplicationEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/ShellParameters.h>
+
+UINTN Argc;
+CHAR16 **Argv;
+
+/**
+
+ This function parse application ARG.
+
+ @return Status
+**/
+EFI_STATUS
+GetArg (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
+
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID**)&ShellParameters
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Argc = ShellParameters->Argc;
+ Argv = ShellParameters->Argv;
+ return EFI_SUCCESS;
+}
+
+/**
+
+ This function print the help message.
+
+**/
+VOID
+PrintHelp (
+ VOID
+ )
+{
+ Print (L"\n");
+ Print (L"Format (Only Ipv4 Address is supported):\n");
+ Print (L"RedfishPlatformConfig.efi -s HostIpAddress HostIpMask RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort\n");
+ Print (L"OR:\n");
+ Print (L"RedfishPlatformConfig.efi -a RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort\n");
+ Print (L"\n");
+}
+
+/**
+ The user Entry Point for Application. The user code starts with this function
+ as the real entry point for the application.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+UefiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ RETURN_STATUS ReturnStatus;
+
+ UINT8 HostIpAssignmentType;
+ EFI_IPv4_ADDRESS HostIpAddress;
+ EFI_IPv4_ADDRESS HostIpMask;
+ EFI_IPv4_ADDRESS RedfishServiceIpAddress;
+ EFI_IPv4_ADDRESS RedfishServiceIpMask;
+ UINTN RedfishServiceIpPort;
+
+ Status = GetArg();
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Format is like :
+ // RedfishPlatformConfig.efi -s HostIpAddress HostIpMask RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
+ // RedfishPlatformConfig.efi -a RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
+ //
+ if (Argc != 7 && Argc != 5) {
+
+ PrintHelp();
+ return EFI_UNSUPPORTED;
+ }
+
+ if (StrCmp(Argv[1], L"-s") == 0) {
+
+ HostIpAssignmentType = 1;
+
+ Status = NetLibStrToIp4 (Argv[2], &HostIpAddress);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ Status = NetLibStrToIp4 (Argv[3], &HostIpMask);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ ReturnStatus = StrDecimalToUintnS (Argv[6], NULL, &RedfishServiceIpPort);
+ if (RETURN_ERROR (ReturnStatus)) {
+ PrintHelp();
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"HostIpAssignmentType",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (UINT8),
+ &HostIpAssignmentType
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"HostIpAddress",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &HostIpAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"HostIpMask",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &HostIpMask
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpAddress",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &RedfishServiceIpAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpMask",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &RedfishServiceIpMask
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpPort",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (UINT16),
+ &RedfishServiceIpPort
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Print (L"\n");
+ Print (L"HostIpAssignmentType is Static!\n");
+ Print (L"HostIpAddress: %s has been set Successfully!\n", Argv[2]);
+ Print (L"HostIpMask: %s has been set Successfully!\n", Argv[3]);
+ Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n", Argv[4]);
+ Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[5]);
+ Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[6]);
+ Print (L"Please Restart!\n");
+
+ } else if (StrCmp(Argv[1], L"-a") == 0) {
+
+ HostIpAssignmentType = 3;
+
+ Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask);
+ if (EFI_ERROR (Status)) {
+ PrintHelp();
+ return Status;
+ }
+ ReturnStatus = StrDecimalToUintnS (Argv[4], NULL, &RedfishServiceIpPort);
+ if (RETURN_ERROR (ReturnStatus)) {
+ PrintHelp();
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"HostIpAssignmentType",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (UINT8),
+ &HostIpAssignmentType
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpAddress",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &RedfishServiceIpAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpMask",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (EFI_IPv4_ADDRESS),
+ &RedfishServiceIpMask
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gRT->SetVariable (
+ L"RedfishServiceIpPort",
+ &gEmuRedfishServiceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (UINT16),
+ &RedfishServiceIpPort
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Print (L"\n");
+ Print (L"HostIpAssignmentType is Auto!\n");
+ Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n", Argv[2]);
+ Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[3]);
+ Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[4]);
+ Print (L"Please Restart!\n");
+ } else if (StrCmp(Argv[1], L"-h") == 0 || StrCmp(Argv[1], L"-help") == 0) {
+
+ PrintHelp();
+ } else {
+
+ PrintHelp();
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
new file mode 100644
index 0000000000..386c9bdd8c
--- /dev/null
+++ b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
@@ -0,0 +1,42 @@
+## @file
+# Sample UEFI Application Reference EDKII Module.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001000b
+ BASE_NAME = RedfishPlatformConfig
+ FILE_GUID = C02B67BB-3D19-4ACC-A080-1BDB575F8F36
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = UefiMain
+
+[Sources]
+ RedfishPlatformConfig.c
+
+[Packages]
+ EmulatorPkg/EmulatorPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ NetworkPkg/NetworkPkg.dec
+ RedfishPkg/RedfishPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ NetLib
+ UefiApplicationEntryPoint
+ UefiLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+[Protocols]
+ gEfiShellParametersProtocolGuid ## CONSUMES
+ gEfiShellProtocolGuid ## CONSUMES
+
+[Guids]
+ gEmuRedfishServiceGuid
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
` (3 preceding siblings ...)
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg Abner Chang
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni, Nickle Wang,
Peter O'Hanley
Add RedfishPkg to DependencyCheck section in
yaml file.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
EmulatorPkg/EmulatorPkg.ci.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/EmulatorPkg/EmulatorPkg.ci.yaml b/EmulatorPkg/EmulatorPkg.ci.yaml
index 980844c1fd..97fdef17ab 100644
--- a/EmulatorPkg/EmulatorPkg.ci.yaml
+++ b/EmulatorPkg/EmulatorPkg.ci.yaml
@@ -47,6 +47,7 @@
"MdeModulePkg/MdeModulePkg.dec",
"EmulatorPkg/EmulatorPkg.dec",
"NetworkPkg/NetworkPkg.dec",
+ "RedfishPkg/RedfishPkg.dec",
"EmbeddedPkg/EmbeddedPkg.dec", ## is this one OK??
],
# For host based unit tests
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
` (4 preceding siblings ...)
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency Abner Chang
@ 2020-11-05 14:38 ` Abner Chang
[not found] ` <1644A5FDFD825A04.31306@groups.io>
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Abner Chang @ 2020-11-05 14:38 UTC (permalink / raw)
To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni, Nickle Wang,
Peter O'Hanley
- REDFISH_ENABLE definition to control EFI Redfish support
- Add Redfish platform host interface library to
EmulatorPkg build.
- Set RestExServiceDevicePath PCD value.
- Add Redfish host interface config EFI application
to EmulatorPkg build.
- Use Redfish DSC/FDF include file.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Peter O'Hanley <peter.ohanley@hpe.com>
---
EmulatorPkg/EmulatorPkg.dsc | 26 +++++++++++++++++++++++++-
EmulatorPkg/EmulatorPkg.fdf | 5 +++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index a27cb1beb0..aa5504c137 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -34,6 +34,11 @@
DEFINE NETWORK_ISCSI_ENABLE = FALSE
DEFINE SECURE_BOOT_ENABLE = FALSE
+ #
+ # Redfish definition
+ #
+ DEFINE REDFISH_ENABLE = FALSE
+
[SkuIds]
0|DEFAULT
@@ -95,7 +100,9 @@
#
PlatformBootManagerLib|EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
KeyMapLib|EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
-
+ !if $(REDFISH_ENABLE) == TRUE
+ RedfishPlatformHostInterfaceLib|EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
+ !endif
#
# Misc
#
@@ -249,6 +256,18 @@
# 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
+!if $(REDFISH_ENABLE) == TRUE
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePathMatchMode|DEVICE_PATH_MATCH_MAC_NODE
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePathNum|1
+ #
+ # Below is the MAC address of network adapter on EDK2 Emulator platform.
+ # You can use ifconfig under EFI shell to get the MAC address of network adapter on EDK2 Emulator platform.
+ #
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePath|{DEVICE_PATH("MAC(000000000000,0x1)")}
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceAccessModeInBand|False
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand|False
+!endif
+
[PcdsDynamicDefault.common.DEFAULT]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
@@ -447,6 +466,11 @@
!include NetworkPkg/Network.dsc.inc
+!if $(REDFISH_ENABLE) == TRUE
+ EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
+!endif
+!include RedfishPkg/Redfish.dsc.inc
+
[BuildOptions]
#
# Disable deprecated APIs.
diff --git a/EmulatorPkg/EmulatorPkg.fdf b/EmulatorPkg/EmulatorPkg.fdf
index b256aa9397..5420756eaa 100644
--- a/EmulatorPkg/EmulatorPkg.fdf
+++ b/EmulatorPkg/EmulatorPkg.fdf
@@ -208,6 +208,11 @@ INF EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf
!endif
!include NetworkPkg/Network.fdf.inc
+#
+# EFI Redfish drivers
+#
+!include RedfishPkg/Redfish.fdf.inc
+
INF FatPkg/EnhancedFatDxe/Fat.inf
!if "XCODE5" not in $(TOOL_CHAIN_TAG)
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg Abner Chang
@ 2020-11-09 4:24 ` Nickle Wang
0 siblings, 0 replies; 14+ messages in thread
From: Nickle Wang @ 2020-11-09 4:24 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: O'Hanley, Peter (EXL)
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Abner
> Chang
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Wang, Nickle (HPS SW) <nickle.wang@hpe.com>; O'Hanley, Peter (EXL)
> <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 1/6]
> RedfishPkg: Add PCD definition to RedfishPkg
>
> This PCD is the UEFI device path which is used as the Redfish host interface.
>
> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> Signed-off-by: Ting Ye <ting.ye@intel.com>
> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> RedfishPkg/RedfishPkg.dec | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec index
> f12f83526c..b38e9b4789 100644
> --- a/RedfishPkg/RedfishPkg.dec
> +++ b/RedfishPkg/RedfishPkg.dec
> @@ -28,3 +28,25 @@
> [Guids]
> gEfiRedfishPkgTokenSpaceGuid = { 0x4fdbccb7, 0xe829, 0x4b4c, { 0x88,
> 0x87, 0xb2, 0x3f, 0xd7, 0x25, 0x4b, 0x85 }}
>
> +[PcdsFixedAtBuild, PcdsPatchableInModule]
> + #
> + # This PCD is the UEFI device path which is used as the Redfish host
> interface.
> + #
> +
> +gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath|{0x0}
> |RE
> +ST_EX_SERVICE_DEVICE_PATH_DATA|0x00001000 {
> + <HeaderFiles>
> + Pcd/RestExServiceDevicePath.h
> + <Packages>
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + RedfishPkg/RedfishPkg.dec
> + }
> + #
> + # This PCD indicates the EFI REST EX access mode to Redfish service.
> + # Default is set to out of band access.
> + #
> +
> +gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceAccessModeInBa
> nd|FA
> +LSE|BOOLEAN|0x00001001
> + #
> + # This PCD indicates the access mode EFI Discover protocol uses to
> +look for the proper EFI REST EX
> + # protocol instance.
> + #
> +
> +gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand|FA
> LSE|B
> +OOLEAN|0x00001002
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support Abner Chang
@ 2020-11-09 4:26 ` Nickle Wang
0 siblings, 0 replies; 14+ messages in thread
From: Nickle Wang @ 2020-11-09 4:26 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: Jiaxin Wu, Siyuan Fu, Fan Wang, O'Hanley, Peter (EXL)
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Abner
> Chang
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>; Siyuan Fu <siyuan.fu@intel.com>; Fan
> Wang <fan.wang@intel.com>; Wang, Nickle (HPS SW)
> <nickle.wang@hpe.com>; O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 2/6]
> RedfishPkg: DSC and FDF include files for enabling EFI Redfish support
>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Fan Wang <fan.wang@intel.com>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> RedfishPkg/Redfish.dsc.inc | 21 +++++++++++++++++++++
> RedfishPkg/Redfish.fdf.inc | 16 ++++++++++++++++
> RedfishPkg/RedfishComponents.dsc.inc | 18 ++++++++++++++++++
> RedfishPkg/RedfishDefines.dsc.inc | 27 +++++++++++++++++++++++++++
> RedfishPkg/RedfishLibs.dsc.inc | 15 +++++++++++++++
> 5 files changed, 97 insertions(+)
> create mode 100644 RedfishPkg/Redfish.dsc.inc create mode 100644
> RedfishPkg/Redfish.fdf.inc create mode 100644
> RedfishPkg/RedfishComponents.dsc.inc
> create mode 100644 RedfishPkg/RedfishDefines.dsc.inc create mode 100644
> RedfishPkg/RedfishLibs.dsc.inc
>
> diff --git a/RedfishPkg/Redfish.dsc.inc b/RedfishPkg/Redfish.dsc.inc new file
> mode 100644 index 0000000000..ac72909ca2
> --- /dev/null
> +++ b/RedfishPkg/Redfish.dsc.inc
> @@ -0,0 +1,21 @@
> +## @file
> +# Redfish DSC include file for Platform DSC # # This file includes all
> +required information to enable Redfish features.
> +# It can be included to a platform DSC file by using "!include
> RedfishPkg/Redfish.dsc.inc".
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> #
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + !include RedfishPkg/RedfishDefines.dsc.inc
> +
> +[LibraryClasses]
> + !include RedfishPkg/RedfishLibs.dsc.inc
> +
> +[Components]
> + !include RedfishPkg/RedfishComponents.dsc.inc
> +
> diff --git a/RedfishPkg/Redfish.fdf.inc b/RedfishPkg/Redfish.fdf.inc new file
> mode 100644 index 0000000000..19de479a80
> --- /dev/null
> +++ b/RedfishPkg/Redfish.fdf.inc
> @@ -0,0 +1,16 @@
> +## @file
> +# Redfish FDF include file for [FV*] section of all Architectures.
> +#
> +# This file can be included to the [FV*] section(s) of a platform FDF
> +file # by using "!include RedfishPkg/RedfisLibs.fdf.inc" to specify the
> +module instances # to be built in the firmware volume.
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> #
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +!if $(REDFISH_ENABLE) == TRUE
> + INF RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf
> + INF RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> +!endif
> diff --git a/RedfishPkg/RedfishComponents.dsc.inc
> b/RedfishPkg/RedfishComponents.dsc.inc
> new file mode 100644
> index 0000000000..ac1b57ed8f
> --- /dev/null
> +++ b/RedfishPkg/RedfishComponents.dsc.inc
> @@ -0,0 +1,18 @@
> +## @file
> +# Redfish DSC include file for [Components*] section of all Architectures.
> +#
> +# This file can be included to the [Components*] section(s) of a
> +platform DSC file # by using "!include
> +RedfishPkg/RedfishComponents.dsc.inc" to specify the INF files # of
> +EDKII Redfish drivers according to the value of flags described in #
> "RedfishDefines.dsc.inc".
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> #
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +!if $(REDFISH_ENABLE) == TRUE
> + RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf
> + RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> +!endif
> diff --git a/RedfishPkg/RedfishDefines.dsc.inc
> b/RedfishPkg/RedfishDefines.dsc.inc
> new file mode 100644
> index 0000000000..0049f92378
> --- /dev/null
> +++ b/RedfishPkg/RedfishDefines.dsc.inc
> @@ -0,0 +1,27 @@
> +## @file
> +# RedfishPkg DSC include file for [Defines] section of all Architectures.
> +#
> +# This file can be included to the [Defines] section of a platform DSC
> +file by # using "!include RedfishPkg/RedfishDefines.dsc.inc" to set
> +value of # flags.
> +#
> +# These flags can be defined before the !include line, or changed on
> +the command # line to enable or disable related feature support.
> +# -D FLAG=VALUE
> +#
> +# The default value of these flags are:
> +# DEFINE REDFISH_ENABLE = TRUE
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> #
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +!ifndef REDFISH_ENABLE
> + #
> + # This flag is to enable or disable the whole Redfish support.
> + #
> + DEFINE REDFISH_ENABLE = TRUE
> +!endif
> +
> diff --git a/RedfishPkg/RedfishLibs.dsc.inc b/RedfishPkg/RedfishLibs.dsc.inc
> new file mode 100644 index 0000000000..e780b5c270
> --- /dev/null
> +++ b/RedfishPkg/RedfishLibs.dsc.inc
> @@ -0,0 +1,15 @@
> +## @file
> +# Redfish DSC include file for [LibraryClasses*] section of all Architectures.
> +#
> +# This file can be included to the [LibraryClasses*] section(s) of a
> +platform DSC file # by using "!include RedfishPkg/RedfisLibs.dsc.inc"
> +to specify the library instances # of EDKII network library classes.
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> #
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +!if $(REDFISH_ENABLE) == TRUE
> +!endif
> +
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library
[not found] ` <1644A5FDFD825A04.31306@groups.io>
@ 2020-11-24 9:24 ` Ni, Ray
0 siblings, 0 replies; 14+ messages in thread
From: Ni, Ray @ 2020-11-24 9:24 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: Justen, Jordan L, Andrew Fish, Wang, Nickle (HPS SW),
O'Hanley, Peter (EXL)
Acked-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner (HPS SW/FW Technologist)
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com>; Wang, Nickle
> (HPS SW) <nickle.wang@hpe.com>; O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library
>
> Platform specific implementation of providing
> Redfish host interface information.
>
> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> Signed-off-by: Ting Ye <ting.ye@intel.com>
> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> EmulatorPkg/EmulatorPkg.dec | 1 +
> .../RedfishPlatformHostInterfaceLib.c | 528 ++++++++++++++++++
> .../RedfishPlatformHostInterfaceLib.inf | 47 ++
> 3 files changed, 576 insertions(+)
> create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
> create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
>
> diff --git a/EmulatorPkg/EmulatorPkg.dec b/EmulatorPkg/EmulatorPkg.dec
> index 064f963c72..5d7fe6473e 100644
> --- a/EmulatorPkg/EmulatorPkg.dec
> +++ b/EmulatorPkg/EmulatorPkg.dec
> @@ -46,6 +46,7 @@
> gEmuSystemConfigGuid = { 0xF8626165, 0x6CEB, 0x924A, { 0xBA, 0xFC, 0xF1, 0x3A, 0xB9, 0xD6, 0x57, 0x28 } }
> gEmuVirtualDisksGuid = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
> gEmuPhysicalDisksGuid = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
> + gEmuRedfishServiceGuid = { 0x3fb208ac, 0x2185, 0x498c, { 0xbf, 0x46, 0xdc, 0x23, 0xda, 0x58, 0x7b, 0x55 } }
>
> [PcdsFeatureFlag]
> ## If TRUE, if symbols only load on breakpoints and gdb entry
> diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
> b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
> new file mode 100644
> index 0000000000..4e7bb65c06
> --- /dev/null
> +++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
> @@ -0,0 +1,528 @@
> +/** @file
> + PCI/PCIe network interface instace of RedfishPlatformHostInterfaceLib
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/RedfishHostInterfaceLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +
> +#include <Pcd/RestExServiceDevicePath.h>
> +#include <Guid/GlobalVariable.h>
> +
> +#define VERBOSE_COLUME_SIZE (16)
> +
> +REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData;
> +UINT8 mRedfishProtocolDataSize;
> +
> +/**
> + Get the MAC address of NIC.
> +
> + @param[out] MacAddress Pointer to retrieve MAC address
> +
> + @retval EFI_SUCCESS MAC address is returned in MacAddress
> +
> +**/
> +EFI_STATUS
> +GetMacAddressInformation (
> + OUT EFI_MAC_ADDRESS *MacAddress
> + )
> +{
> + MAC_ADDR_DEVICE_PATH *Mac;
> + REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
> + EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
> + MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
> +
> + Mac = NULL;
> + RestExServiceDevicePathData = NULL;
> + RestExServiceDevicePath = NULL;
> +
> + RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr(PcdRedfishRestExServiceDevicePath);
> + if (RestExServiceDevicePathData == NULL ||
> + RestExServiceDevicePathData->DevicePathNum == 0 ||
> + !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + RestExServiceDevicePath = RestExServiceDevicePathData->DevicePath;
> + if (RestExServiceDevicePathData->DevicePathMatchMode != DEVICE_PATH_MATCH_MAC_NODE) {
> + return EFI_NOT_FOUND;
> + }
> +
> + //
> + // Find Mac DevicePath Node.
> + //
> + while (!IsDevicePathEnd (RestExServiceDevicePath) &&
> + ((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
> + (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP))) {
> + RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
> + }
> +
> + if (!IsDevicePathEnd (RestExServiceDevicePath)) {
> + MacAddressDevicePath = (MAC_ADDR_DEVICE_PATH *)RestExServiceDevicePath;
> + CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
> + return EFI_SUCCESS;
> + }
> + return EFI_NOT_FOUND;
> +}
> +
> +/**
> + Get platform Redfish host interface device descriptor.
> +
> + @param[out] DeviceType Pointer to retrieve device type.
> + @param[out] DeviceDescriptor Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
> + this memory using FreePool().
> + @retval EFI_SUCCESS Device descriptor is returned successfully in DeviceDescriptor.
> + @retval EFI_NOT_FOUND No Redfish host interface descriptor provided on this platform.
> + @retval Others Fail to get device descriptor.
> +**/
> +EFI_STATUS
> +RedfishPlatformHostInterfaceDeviceDescriptor (
> + OUT UINT8 *DeviceType,
> + OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
> +)
> +{
> + EFI_STATUS Status;
> + EFI_MAC_ADDRESS MacAddress;
> + REDFISH_INTERFACE_DATA *RedfishInterfaceData;
> + PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
> +
> + RedfishInterfaceData = AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
> + if (RedfishInterfaceData == NULL) {
> + return EFI_OUT_OF_RESOURCES;
> + }
> + RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
> + //
> + // Fill up device type information.
> + //
> + ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
> + ThisDeviceDescriptor->Length = sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1;
> + Status = GetMacAddressInformation (&MacAddress);
> + if (EFI_ERROR (Status)) {
> + FreePool (RedfishInterfaceData);
> + return EFI_NOT_FOUND;
> + }
> + CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor-
> >MacAddress));
> + *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
> + *DeviceDescriptor = RedfishInterfaceData;
> + return EFI_SUCCESS;
> +}
> +/**
> + Get platform Redfish host interface protocol data.
> + Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
> + Then continuously pass previous ProtocolRecord for retrieving the next ProtocolRecord.
> +
> + @param[out] ProtocolRecord Pointer to retrieve the protocol record.
> + caller has to free the new protocol record returned from
> + this function using FreePool().
> + @param[in] IndexOfProtocolData The index of protocol data.
> +
> + @retval EFI_SUCCESS Protocol records are all returned.
> + @retval EFI_NOT_FOUND No more protocol records.
> + @retval Others Fail to get protocol records.
> +**/
> +EFI_STATUS
> +RedfishPlatformHostInterfaceProtocolData (
> + OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
> + IN UINT8 IndexOfProtocolData
> +)
> +{
> + MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
> +
> + if (mRedfishOverIpProtocolData == 0) {
> + return EFI_NOT_FOUND;
> + }
> + if (IndexOfProtocolData == 0) {
> + //
> + // Return the first Redfish protocol data to caller. We only have
> + // one protocol data in this case.
> + //
> + ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *) AllocatePool (mRedfishProtocolDataSize + sizeof
> (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
> + ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
> + ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
> + CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData,
> mRedfishProtocolDataSize);
> + *ProtocolRecord = ThisProtocolRecord;
> + return EFI_SUCCESS;
> + }
> + return EFI_NOT_FOUND;
> +}
> +/**
> + Dump IPv4 address.
> +
> + @param[in] Ip IPv4 address
> +**/
> +VOID
> +InternalDumpIp4Addr (
> + IN EFI_IPv4_ADDRESS *Ip
> + )
> +{
> + UINTN Index;
> +
> + for (Index = 0; Index < 4; Index++) {
> + DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index]));
> + if (Index < 3) {
> + DEBUG ((DEBUG_VERBOSE, "."));
> + }
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "\n"));
> +}
> +/**
> + Dump IPv6 address.
> +
> + @param[in] Ip IPv6 address
> +**/
> +VOID
> +InternalDumpIp6Addr (
> + IN EFI_IPv6_ADDRESS *Ip
> + )
> +{
> + UINTN Index;
> +
> + for (Index = 0; Index < 16; Index++) {
> + if (Ip->Addr[Index] != 0) {
> + DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
> + }
> + Index++;
> +
> + if (Index > 15) {
> + return;
> + }
> +
> + if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
> + DEBUG ((DEBUG_VERBOSE, "0"));
> + }
> + DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
> +
> + if (Index < 15) {
> + DEBUG ((DEBUG_VERBOSE, ":"));
> + }
> + }
> + DEBUG ((DEBUG_VERBOSE, "\n"));
> +}
> +/**
> + Dump data
> +
> + @param[in] Data Pointer to data.
> + @param[in] Size size of data to dump.
> +**/
> +VOID
> +InternalDumpData (
> + IN UINT8 *Data,
> + IN UINTN Size
> + )
> +{
> + UINTN Index;
> + for (Index = 0; Index < Size; Index++) {
> + DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
> + }
> +}
> +/**
> + Dump hex data
> +
> + @param[in] Data Pointer to hex data.
> + @param[in] Size size of hex data to dump.
> +**/
> +VOID
> +InternalDumpHex (
> + IN UINT8 *Data,
> + IN UINTN Size
> + )
> +{
> + UINTN Index;
> + UINTN Count;
> + UINTN Left;
> +
> + Count = Size / VERBOSE_COLUME_SIZE;
> + Left = Size % VERBOSE_COLUME_SIZE;
> + for (Index = 0; Index < Count; Index++) {
> + InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, VERBOSE_COLUME_SIZE);
> + DEBUG ((DEBUG_VERBOSE, "\n"));
> + }
> +
> + if (Left != 0) {
> + InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, Left);
> + DEBUG ((DEBUG_VERBOSE, "\n"));
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "\n"));
> +}
> +/**
> + Dump Redfish over IP protocol data
> +
> + @param[in] RedfishProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA
> + @param[in] RedfishProtocolDataSize size of data to dump.
> +**/
> +VOID
> +DumpRedfishIpProtocolData (
> + IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
> + IN UINT8 RedfishProtocolDataSize
> + )
> +{
> + CHAR16 Hostname[16];
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
> + InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSize);
> +
> + DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->ServiceUuid - %g\n", &(RedfishProtocolData->ServiceUuid)));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAssignmentType - %d\n", RedfishProtocolData-
> >HostIpAssignmentType));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddressFormat - %d\n", RedfishProtocolData-
> >HostIpAddressFormat));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
> + if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
> + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpAddress));
> + } else {
> + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpAddress));
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
> + if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
> + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpMask));
> + } else {
> + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpMask));
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData-
> >RedfishServiceIpDiscoveryType));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddressFormat - %d\n", RedfishProtocolData-
> >RedfishServiceIpAddressFormat));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
> + if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
> + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
> + } else {
> + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
> + if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
> + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
> + } else {
> + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
> + }
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData-
> >RedfishServiceIpPort));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceVlanId - %d\n", RedfishProtocolData-
> >RedfishServiceVlanId));
> +
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData-
> >RedfishServiceHostnameLength));
> +
> + AsciiStrToUnicodeStrS((CHAR8 *) RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof
> (Hostname[0]));
> + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
> +}
> +
> +/**
> + Get Redfish host interface protocol data from variale.
> +
> + @param[out] RedfishProtocolData Pointer to retrieve REDFISH_OVER_IP_PROTOCOL_DATA.
> + @param[out] RedfishProtocolDataSize Size of REDFISH_OVER_IP_PROTOCOL_DATA.
> +
> + @retval EFI_SUCESS REDFISH_OVER_IP_PROTOCOL_DATA is returned successfully.
> +**/
> +EFI_STATUS
> +GetRedfishRecordFromVariable (
> + OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
> + OUT UINT8 *RedfishProtocolDataSize
> + )
> +{
> + EFI_STATUS Status;
> + UINT8 HostIpAssignmentType;
> + UINTN HostIpAssignmentTypeSize;
> + EFI_IPv4_ADDRESS HostIpAddress;
> + UINTN IPv4DataSize;
> + EFI_IPv4_ADDRESS HostIpMask;
> + EFI_IPv4_ADDRESS RedfishServiceIpAddress;
> + EFI_IPv4_ADDRESS RedfishServiceIpMask;
> + UINT16 RedfishServiceIpPort;
> + UINTN IpPortDataSize;
> + UINT8 HostNameSize;
> + CHAR8 RedfishHostName[20];
> +
> + if (RedfishProtocolData == NULL || RedfishProtocolDataSize == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // 1. Retrieve Address Information from variable.
> + //
> + Status = gRT->GetVariable (
> + L"HostIpAssignmentType",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &HostIpAssignmentTypeSize,
> + &HostIpAssignmentType
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAssignmentType - %r\n", Status));
> + return Status;
> + }
> +
> + IPv4DataSize = sizeof (EFI_IPv4_ADDRESS);
> + if (HostIpAssignmentType == 1 ) {
> + Status = gRT->GetVariable (
> + L"HostIpAddress",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &IPv4DataSize,
> + &HostIpAddress
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAddress - %r\n", Status));
> + return Status;
> + }
> +
> + Status = gRT->GetVariable (
> + L"HostIpMask",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &IPv4DataSize,
> + &HostIpMask
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpMask - %r\n", Status));
> + return Status;
> + }
> + }
> +
> + Status = gRT->GetVariable (
> + L"RedfishServiceIpAddress",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &IPv4DataSize,
> + &RedfishServiceIpAddress
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpAddress - %r\n", Status));
> + return Status;
> + }
> +
> + Status = gRT->GetVariable (
> + L"RedfishServiceIpMask",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &IPv4DataSize,
> + &RedfishServiceIpMask
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpMask - %r\n", Status));
> + return Status;
> + }
> +
> + Status = gRT->GetVariable (
> + L"RedfishServiceIpPort",
> + &gEmuRedfishServiceGuid,
> + NULL,
> + &IpPortDataSize,
> + &RedfishServiceIpPort
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpPort - %r\n", Status));
> + return Status;
> + }
> +
> + AsciiSPrint (
> + RedfishHostName,
> + sizeof (RedfishHostName),
> + "%d.%d.%d.%d",
> + RedfishServiceIpAddress.Addr[0],
> + RedfishServiceIpAddress.Addr[1],
> + RedfishServiceIpAddress.Addr[2],
> + RedfishServiceIpAddress.Addr[3]
> + );
> +
> + HostNameSize = (UINT8) AsciiStrLen (RedfishHostName) + 1;
> +
> + //
> + // 2. Protocol Data Size.
> + //
> + *RedfishProtocolDataSize = sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 + HostNameSize;
> +
> + //
> + // 3. Protocol Data.
> + //
> + *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZeroPool (*RedfishProtocolDataSize);
> + if (*RedfishProtocolData == NULL) {
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> + CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
> +
> + (*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
> + (*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
> +
> + if (HostIpAssignmentType == 1 ) {
> + (*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
> + (*RedfishProtocolData)->HostIpAddress[1] = HostIpAddress.Addr[1];
> + (*RedfishProtocolData)->HostIpAddress[2] = HostIpAddress.Addr[2];
> + (*RedfishProtocolData)->HostIpAddress[3] = HostIpAddress.Addr[3];
> +
> + (*RedfishProtocolData)->HostIpMask[0] = HostIpMask.Addr[0];
> + (*RedfishProtocolData)->HostIpMask[1] = HostIpMask.Addr[1];
> + (*RedfishProtocolData)->HostIpMask[2] = HostIpMask.Addr[2];
> + (*RedfishProtocolData)->HostIpMask[3] = HostIpMask.Addr[3];
> + }
> +
> + (*RedfishProtocolData)->RedfishServiceIpDiscoveryType = 1; // Use static IP address
> + (*RedfishProtocolData)->RedfishServiceIpAddressFormat = 1; // Only support IPv4
> +
> + (*RedfishProtocolData)->RedfishServiceIpAddress[0] = RedfishServiceIpAddress.Addr[0];
> + (*RedfishProtocolData)->RedfishServiceIpAddress[1] = RedfishServiceIpAddress.Addr[1];
> + (*RedfishProtocolData)->RedfishServiceIpAddress[2] = RedfishServiceIpAddress.Addr[2];
> + (*RedfishProtocolData)->RedfishServiceIpAddress[3] = RedfishServiceIpAddress.Addr[3];
> +
> + (*RedfishProtocolData)->RedfishServiceIpMask[0] = RedfishServiceIpMask.Addr[0];
> + (*RedfishProtocolData)->RedfishServiceIpMask[1] = RedfishServiceIpMask.Addr[1];
> + (*RedfishProtocolData)->RedfishServiceIpMask[2] = RedfishServiceIpMask.Addr[2];
> + (*RedfishProtocolData)->RedfishServiceIpMask[3] = RedfishServiceIpMask.Addr[3];
> +
> + (*RedfishProtocolData)->RedfishServiceIpPort = RedfishServiceIpPort;
> + (*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
> +
> + (*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
> + AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
> +
> + return Status;
> +}
> +
> +/**
> + Construct Redfish host interface protocol data.
> +
> + @param ImageHandle The image handle.
> + @param SystemTable The system table.
> +
> + @retval EFI_SUCEESS Install Boot manager menu success.
> + @retval Other Return error status.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishPlatformHostInterfaceConstructor (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> +)
> +{
> + EFI_STATUS Status;
> +
> + Status = GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData, &mRedfishProtocolDataSize);
> + DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FUNCTION__, Status));
> + if (!EFI_ERROR (Status)) {
> + DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
> + }
> + return EFI_SUCCESS;
> +}
> diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
> b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
> new file mode 100644
> index 0000000000..6fe5d9b32b
> --- /dev/null
> +++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
> @@ -0,0 +1,47 @@
> +## @file
> +# NULL instance of RedfishPlatformHostInterfaceLib
> +#
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x0001000b
> + BASE_NAME = RedfishPlatformHostInterfaceLib
> + FILE_GUID = D5ECB7F2-4906-94E2-45B1-31BF4FD90122
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = RedfishPlatformHostInterfaceLib
> + CONSTRUCTOR = RedfishPlatformHostInterfaceConstructor
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources]
> + RedfishPlatformHostInterfaceLib.c
> +
> +[Packages]
> + EmulatorPkg/EmulatorPkg.dec
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + RedfishPkg/RedfishPkg.dec
> +
> +[LibraryClasses]
> + UefiLib
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + PcdLib
> + MemoryAllocationLib
> +
> +[Pcd]
> + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath ## CONSUMES
> +
> +[Guids]
> + gEmuRedfishServiceGuid
> +
> +[Depex]
> + gEfiVariableArchProtocolGuid AND
> + gEfiVariableWriteArchProtocolGuid
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency
[not found] ` <1644A5FE6C306DA9.32447@groups.io>
@ 2020-11-24 9:24 ` Ni, Ray
0 siblings, 0 replies; 14+ messages in thread
From: Ni, Ray @ 2020-11-24 9:24 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: Justen, Jordan L, Andrew Fish, Wang, Nickle (HPS SW),
O'Hanley, Peter (EXL)
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner (HPS SW/FW Technologist)
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com>; Wang, Nickle
> (HPS SW) <nickle.wang@hpe.com>; O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency
>
> Add RedfishPkg to DependencyCheck section in
> yaml file.
>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> EmulatorPkg/EmulatorPkg.ci.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/EmulatorPkg/EmulatorPkg.ci.yaml b/EmulatorPkg/EmulatorPkg.ci.yaml
> index 980844c1fd..97fdef17ab 100644
> --- a/EmulatorPkg/EmulatorPkg.ci.yaml
> +++ b/EmulatorPkg/EmulatorPkg.ci.yaml
> @@ -47,6 +47,7 @@
> "MdeModulePkg/MdeModulePkg.dec",
> "EmulatorPkg/EmulatorPkg.dec",
> "NetworkPkg/NetworkPkg.dec",
> + "RedfishPkg/RedfishPkg.dec",
> "EmbeddedPkg/EmbeddedPkg.dec", ## is this one OK??
> ],
> # For host based unit tests
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg
[not found] ` <1644A5FF1778E4F7.31306@groups.io>
@ 2020-11-24 9:24 ` Ni, Ray
0 siblings, 0 replies; 14+ messages in thread
From: Ni, Ray @ 2020-11-24 9:24 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: Justen, Jordan L, Andrew Fish, Wang, Nickle (HPS SW),
O'Hanley, Peter (EXL)
Acked-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner (HPS SW/FW Technologist)
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com>; Wang, Nickle
> (HPS SW) <nickle.wang@hpe.com>; O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg
>
> - REDFISH_ENABLE definition to control EFI Redfish support
> - Add Redfish platform host interface library to
> EmulatorPkg build.
> - Set RestExServiceDevicePath PCD value.
> - Add Redfish host interface config EFI application
> to EmulatorPkg build.
> - Use Redfish DSC/FDF include file.
>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> EmulatorPkg/EmulatorPkg.dsc | 26 +++++++++++++++++++++++++-
> EmulatorPkg/EmulatorPkg.fdf | 5 +++++
> 2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
> index a27cb1beb0..aa5504c137 100644
> --- a/EmulatorPkg/EmulatorPkg.dsc
> +++ b/EmulatorPkg/EmulatorPkg.dsc
> @@ -34,6 +34,11 @@
> DEFINE NETWORK_ISCSI_ENABLE = FALSE
> DEFINE SECURE_BOOT_ENABLE = FALSE
>
> + #
> + # Redfish definition
> + #
> + DEFINE REDFISH_ENABLE = FALSE
> +
> [SkuIds]
> 0|DEFAULT
>
> @@ -95,7 +100,9 @@
> #
> PlatformBootManagerLib|EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
> KeyMapLib|EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
> -
> + !if $(REDFISH_ENABLE) == TRUE
> +
> RedfishPlatformHostInterfaceLib|EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.inf
> + !endif
> #
> # Misc
> #
> @@ -249,6 +256,18 @@
> # 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
> gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
>
> +!if $(REDFISH_ENABLE) == TRUE
> +
> gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePathMatchMode|DEVICE_PATH_MATCH_MAC_NO
> DE
> + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePathNum|1
> + #
> + # Below is the MAC address of network adapter on EDK2 Emulator platform.
> + # You can use ifconfig under EFI shell to get the MAC address of network adapter on EDK2 Emulator platform.
> + #
> + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath.DevicePath|{DEVICE_PATH("MAC(000000000000,0x1)")}
> + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceAccessModeInBand|False
> + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand|False
> +!endif
> +
> [PcdsDynamicDefault.common.DEFAULT]
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
> @@ -447,6 +466,11 @@
>
> !include NetworkPkg/Network.dsc.inc
>
> +!if $(REDFISH_ENABLE) == TRUE
> + EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
> +!endif
> +!include RedfishPkg/Redfish.dsc.inc
> +
> [BuildOptions]
> #
> # Disable deprecated APIs.
> diff --git a/EmulatorPkg/EmulatorPkg.fdf b/EmulatorPkg/EmulatorPkg.fdf
> index b256aa9397..5420756eaa 100644
> --- a/EmulatorPkg/EmulatorPkg.fdf
> +++ b/EmulatorPkg/EmulatorPkg.fdf
> @@ -208,6 +208,11 @@ INF EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf
> !endif
> !include NetworkPkg/Network.fdf.inc
>
> +#
> +# EFI Redfish drivers
> +#
> +!include RedfishPkg/Redfish.fdf.inc
> +
> INF FatPkg/EnhancedFatDxe/Fat.inf
>
> !if "XCODE5" not in $(TOOL_CHAIN_TAG)
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record
[not found] ` <1644A5FE1ACD3DCB.8528@groups.io>
@ 2020-12-03 5:25 ` Ni, Ray
2020-12-03 5:41 ` Abner Chang
0 siblings, 1 reply; 14+ messages in thread
From: Ni, Ray @ 2020-12-03 5:25 UTC (permalink / raw)
To: devel@edk2.groups.io, Chang, Abner (HPS SW/FW Technologist)
Cc: Justen, Jordan L, Andrew Fish, Wang, Nickle (HPS SW),
O'Hanley, Peter (EXL)
Acked-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> Abner (HPS SW/FW Technologist)
> Sent: Thursday, November 5, 2020 10:39 PM
> To: devel@edk2.groups.io
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish
> <afish@apple.com>; Ni, Ray <ray.ni@intel.com>; Wang, Nickle (HPS SW)
> <nickle.wang@hpe.com>; O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 4/6]
> EmulatorPkg/Application: Publish Redfish Host Interface Record
>
> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> Signed-off-by: Ting Ye <ting.ye@intel.com>
> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Nickle Wang <nickle.wang@hpe.com>
> Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> ---
> .../RedfishPlatformConfig.c | 298 ++++++++++++++++++
> .../RedfishPlatformConfig.inf | 42 +++
> 2 files changed, 340 insertions(+)
> create mode 100644
> EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
> create mode 100644
> EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
>
> diff --git
> a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
> b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
> new file mode 100644
> index 0000000000..89d4c760a7
> --- /dev/null
> +++
> b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
> @@ -0,0 +1,298 @@
> +/** @file
> + The implementation for Redfish Platform Configuration application.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/DebugLib.h>
> +#include <Library/NetLib.h>
> +#include <Library/UefiApplicationEntryPoint.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +#include <Protocol/ShellParameters.h>
> +
> +UINTN Argc;
> +CHAR16 **Argv;
> +
> +/**
> +
> + This function parse application ARG.
> +
> + @return Status
> +**/
> +EFI_STATUS
> +GetArg (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
> +
> + Status = gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiShellParametersProtocolGuid,
> + (VOID**)&ShellParameters
> + );
> + if (EFI_ERROR(Status)) {
> + return Status;
> + }
> +
> + Argc = ShellParameters->Argc;
> + Argv = ShellParameters->Argv;
> + return EFI_SUCCESS;
> +}
> +
> +/**
> +
> + This function print the help message.
> +
> +**/
> +VOID
> +PrintHelp (
> + VOID
> + )
> +{
> + Print (L"\n");
> + Print (L"Format (Only Ipv4 Address is supported):\n");
> + Print (L"RedfishPlatformConfig.efi -s HostIpAddress HostIpMask
> RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort\n");
> + Print (L"OR:\n");
> + Print (L"RedfishPlatformConfig.efi -a RedfishServiceIpAddress
> RedfishServiceIpMask RedfishServiceIpPort\n");
> + Print (L"\n");
> +}
> +
> +/**
> + The user Entry Point for Application. The user code starts with this function
> + as the real entry point for the application.
> +
> + @param[in] ImageHandle The firmware allocated handle for the EFI image.
> + @param[in] SystemTable A pointer to the EFI System Table.
> +
> + @retval EFI_SUCCESS The entry point is executed successfully.
> + @retval other Some error occurs when executing this entry point.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +UefiMain (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> + RETURN_STATUS ReturnStatus;
> +
> + UINT8 HostIpAssignmentType;
> + EFI_IPv4_ADDRESS HostIpAddress;
> + EFI_IPv4_ADDRESS HostIpMask;
> + EFI_IPv4_ADDRESS RedfishServiceIpAddress;
> + EFI_IPv4_ADDRESS RedfishServiceIpMask;
> + UINTN RedfishServiceIpPort;
> +
> + Status = GetArg();
> + if (EFI_ERROR(Status)) {
> + return Status;
> + }
> +
> + //
> + // Format is like :
> + // RedfishPlatformConfig.efi -s HostIpAddress HostIpMask
> RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
> + // RedfishPlatformConfig.efi -a RedfishServiceIpAddress
> RedfishServiceIpMask RedfishServiceIpPort
> + //
> + if (Argc != 7 && Argc != 5) {
> +
> + PrintHelp();
> + return EFI_UNSUPPORTED;
> + }
> +
> + if (StrCmp(Argv[1], L"-s") == 0) {
> +
> + HostIpAssignmentType = 1;
> +
> + Status = NetLibStrToIp4 (Argv[2], &HostIpAddress);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + Status = NetLibStrToIp4 (Argv[3], &HostIpMask);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + ReturnStatus = StrDecimalToUintnS (Argv[6], NULL, &RedfishServiceIpPort);
> + if (RETURN_ERROR (ReturnStatus)) {
> + PrintHelp();
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"HostIpAssignmentType",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (UINT8),
> + &HostIpAssignmentType
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"HostIpAddress",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &HostIpAddress
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"HostIpMask",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &HostIpMask
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpAddress",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &RedfishServiceIpAddress
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpMask",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &RedfishServiceIpMask
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpPort",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (UINT16),
> + &RedfishServiceIpPort
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Print (L"\n");
> + Print (L"HostIpAssignmentType is Static!\n");
> + Print (L"HostIpAddress: %s has been set Successfully!\n", Argv[2]);
> + Print (L"HostIpMask: %s has been set Successfully!\n", Argv[3]);
> + Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n", Argv[4]);
> + Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[5]);
> + Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[6]);
> + Print (L"Please Restart!\n");
> +
> + } else if (StrCmp(Argv[1], L"-a") == 0) {
> +
> + HostIpAssignmentType = 3;
> +
> + Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask);
> + if (EFI_ERROR (Status)) {
> + PrintHelp();
> + return Status;
> + }
> + ReturnStatus = StrDecimalToUintnS (Argv[4], NULL, &RedfishServiceIpPort);
> + if (RETURN_ERROR (ReturnStatus)) {
> + PrintHelp();
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"HostIpAssignmentType",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (UINT8),
> + &HostIpAssignmentType
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpAddress",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &RedfishServiceIpAddress
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpMask",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (EFI_IPv4_ADDRESS),
> + &RedfishServiceIpMask
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gRT->SetVariable (
> + L"RedfishServiceIpPort",
> + &gEmuRedfishServiceGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (UINT16),
> + &RedfishServiceIpPort
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Print (L"\n");
> + Print (L"HostIpAssignmentType is Auto!\n");
> + Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n", Argv[2]);
> + Print (L"RedfishServiceIpMask: %s has been set Successfully!\n", Argv[3]);
> + Print (L"RedfishServiceIpPort: %s has been set Successfully!\n", Argv[4]);
> + Print (L"Please Restart!\n");
> + } else if (StrCmp(Argv[1], L"-h") == 0 || StrCmp(Argv[1], L"-help") == 0) {
> +
> + PrintHelp();
> + } else {
> +
> + PrintHelp();
> + return EFI_UNSUPPORTED;
> + }
> +
> + return EFI_SUCCESS;
> +}
> diff --git
> a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
> b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
> new file mode 100644
> index 0000000000..386c9bdd8c
> --- /dev/null
> +++
> b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.inf
> @@ -0,0 +1,42 @@
> +## @file
> +# Sample UEFI Application Reference EDKII Module.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x0001000b
> + BASE_NAME = RedfishPlatformConfig
> + FILE_GUID = C02B67BB-3D19-4ACC-A080-1BDB575F8F36
> + MODULE_TYPE = UEFI_APPLICATION
> + VERSION_STRING = 1.0
> + ENTRY_POINT = UefiMain
> +
> +[Sources]
> + RedfishPlatformConfig.c
> +
> +[Packages]
> + EmulatorPkg/EmulatorPkg.dec
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + NetworkPkg/NetworkPkg.dec
> + RedfishPkg/RedfishPkg.dec
> +
> +[LibraryClasses]
> + DebugLib
> + NetLib
> + UefiApplicationEntryPoint
> + UefiLib
> + UefiBootServicesTableLib
> + UefiRuntimeServicesTableLib
> +[Protocols]
> + gEfiShellParametersProtocolGuid ## CONSUMES
> + gEfiShellProtocolGuid ## CONSUMES
> +
> +[Guids]
> + gEmuRedfishServiceGuid
> --
> 2.17.1
>
>
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-devel] [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record
2020-12-03 5:25 ` [edk2-devel] [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record Ni, Ray
@ 2020-12-03 5:41 ` Abner Chang
0 siblings, 0 replies; 14+ messages in thread
From: Abner Chang @ 2020-12-03 5:41 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io
Cc: Justen, Jordan L, Andrew Fish, Wang, Nickle (HPS SW),
O'Hanley, Peter (EXL)
Thanks Ray, all of the patches are reviewed. I will help to merge it to edk2 for the follow up contributions.
Abner
> -----Original Message-----
> From: Ni, Ray [mailto:ray.ni@intel.com]
> Sent: Thursday, December 3, 2020 1:25 PM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> <abner.chang@hpe.com>
> Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish
> <afish@apple.com>; Wang, Nickle (HPS SW) <nickle.wang@hpe.com>;
> O'Hanley, Peter (EXL) <peter.ohanley@hpe.com>
> Subject: RE: [edk2-devel] [Platform Redfish Host Interface PATCH 4/6]
> EmulatorPkg/Application: Publish Redfish Host Interface Record
>
> Acked-by: Ray Ni <ray.ni@intel.com>
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> > Abner (HPS SW/FW Technologist)
> > Sent: Thursday, November 5, 2020 10:39 PM
> > To: devel@edk2.groups.io
> > Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish
> > <afish@apple.com>; Ni, Ray <ray.ni@intel.com>; Wang, Nickle (HPS SW)
> > <nickle.wang@hpe.com>; O'Hanley, Peter (EXL)
> <peter.ohanley@hpe.com>
> > Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 4/6]
> > EmulatorPkg/Application: Publish Redfish Host Interface Record
> >
> > Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> > Signed-off-by: Ting Ye <ting.ye@intel.com>
> > Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> > Signed-off-by: Fan Wang <fan.wang@intel.com>
> > Signed-off-by: Abner Chang <abner.chang@hpe.com>
> >
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Andrew Fish <afish@apple.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Nickle Wang <nickle.wang@hpe.com>
> > Cc: Peter O'Hanley <peter.ohanley@hpe.com>
> > ---
> > .../RedfishPlatformConfig.c | 298 ++++++++++++++++++
> > .../RedfishPlatformConfig.inf | 42 +++
> > 2 files changed, 340 insertions(+)
> > create mode 100644
> > EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.c
> > create mode 100644
> > EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.in
> > f
> >
> > diff --git
> > a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > c
> > b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > c
> > new file mode 100644
> > index 0000000000..89d4c760a7
> > --- /dev/null
> > +++
> > b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > c
> > @@ -0,0 +1,298 @@
> > +/** @file
> > + The implementation for Redfish Platform Configuration application.
> > +
> > + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > + (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Uefi.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/NetLib.h>
> > +#include <Library/UefiApplicationEntryPoint.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +#include <Library/UefiRuntimeServicesTableLib.h>
> > +#include <Library/UefiLib.h>
> > +#include <Protocol/ShellParameters.h>
> > +
> > +UINTN Argc;
> > +CHAR16 **Argv;
> > +
> > +/**
> > +
> > + This function parse application ARG.
> > +
> > + @return Status
> > +**/
> > +EFI_STATUS
> > +GetArg (
> > + VOID
> > + )
> > +{
> > + EFI_STATUS Status;
> > + EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
> > +
> > + Status = gBS->HandleProtocol (
> > + gImageHandle,
> > + &gEfiShellParametersProtocolGuid,
> > + (VOID**)&ShellParameters
> > + );
> > + if (EFI_ERROR(Status)) {
> > + return Status;
> > + }
> > +
> > + Argc = ShellParameters->Argc;
> > + Argv = ShellParameters->Argv;
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +
> > + This function print the help message.
> > +
> > +**/
> > +VOID
> > +PrintHelp (
> > + VOID
> > + )
> > +{
> > + Print (L"\n");
> > + Print (L"Format (Only Ipv4 Address is supported):\n");
> > + Print (L"RedfishPlatformConfig.efi -s HostIpAddress HostIpMask
> > RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort\n");
> > + Print (L"OR:\n");
> > + Print (L"RedfishPlatformConfig.efi -a RedfishServiceIpAddress
> > RedfishServiceIpMask RedfishServiceIpPort\n");
> > + Print (L"\n");
> > +}
> > +
> > +/**
> > + The user Entry Point for Application. The user code starts with
> > +this function
> > + as the real entry point for the application.
> > +
> > + @param[in] ImageHandle The firmware allocated handle for the EFI
> image.
> > + @param[in] SystemTable A pointer to the EFI System Table.
> > +
> > + @retval EFI_SUCCESS The entry point is executed successfully.
> > + @retval other Some error occurs when executing this entry point.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +UefiMain (
> > + IN EFI_HANDLE ImageHandle,
> > + IN EFI_SYSTEM_TABLE *SystemTable
> > + )
> > +{
> > + EFI_STATUS Status;
> > + RETURN_STATUS ReturnStatus;
> > +
> > + UINT8 HostIpAssignmentType;
> > + EFI_IPv4_ADDRESS HostIpAddress;
> > + EFI_IPv4_ADDRESS HostIpMask;
> > + EFI_IPv4_ADDRESS RedfishServiceIpAddress; EFI_IPv4_ADDRESS
> > + RedfishServiceIpMask;
> > + UINTN RedfishServiceIpPort;
> > +
> > + Status = GetArg();
> > + if (EFI_ERROR(Status)) {
> > + return Status;
> > + }
> > +
> > + //
> > + // Format is like :
> > + // RedfishPlatformConfig.efi -s HostIpAddress HostIpMask
> > RedfishServiceIpAddress RedfishServiceIpMask RedfishServiceIpPort
> > + // RedfishPlatformConfig.efi -a RedfishServiceIpAddress
> > RedfishServiceIpMask RedfishServiceIpPort
> > + //
> > + if (Argc != 7 && Argc != 5) {
> > +
> > + PrintHelp();
> > + return EFI_UNSUPPORTED;
> > + }
> > +
> > + if (StrCmp(Argv[1], L"-s") == 0) {
> > +
> > + HostIpAssignmentType = 1;
> > +
> > + Status = NetLibStrToIp4 (Argv[2], &HostIpAddress);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + Status = NetLibStrToIp4 (Argv[3], &HostIpMask);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + Status = NetLibStrToIp4 (Argv[4], &RedfishServiceIpAddress);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + Status = NetLibStrToIp4 (Argv[5], &RedfishServiceIpMask);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + ReturnStatus = StrDecimalToUintnS (Argv[6], NULL,
> &RedfishServiceIpPort);
> > + if (RETURN_ERROR (ReturnStatus)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"HostIpAssignmentType",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (UINT8),
> > + &HostIpAssignmentType
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"HostIpAddress",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &HostIpAddress
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"HostIpMask",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &HostIpMask
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpAddress",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &RedfishServiceIpAddress
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpMask",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &RedfishServiceIpMask
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpPort",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (UINT16),
> > + &RedfishServiceIpPort
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Print (L"\n");
> > + Print (L"HostIpAssignmentType is Static!\n");
> > + Print (L"HostIpAddress: %s has been set Successfully!\n", Argv[2]);
> > + Print (L"HostIpMask: %s has been set Successfully!\n", Argv[3]);
> > + Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n",
> Argv[4]);
> > + Print (L"RedfishServiceIpMask: %s has been set Successfully!\n",
> Argv[5]);
> > + Print (L"RedfishServiceIpPort: %s has been set Successfully!\n",
> Argv[6]);
> > + Print (L"Please Restart!\n");
> > +
> > + } else if (StrCmp(Argv[1], L"-a") == 0) {
> > +
> > + HostIpAssignmentType = 3;
> > +
> > + Status = NetLibStrToIp4 (Argv[2], &RedfishServiceIpAddress);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + Status = NetLibStrToIp4 (Argv[3], &RedfishServiceIpMask);
> > + if (EFI_ERROR (Status)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > + ReturnStatus = StrDecimalToUintnS (Argv[4], NULL,
> &RedfishServiceIpPort);
> > + if (RETURN_ERROR (ReturnStatus)) {
> > + PrintHelp();
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"HostIpAssignmentType",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (UINT8),
> > + &HostIpAssignmentType
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpAddress",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &RedfishServiceIpAddress
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpMask",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (EFI_IPv4_ADDRESS),
> > + &RedfishServiceIpMask
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = gRT->SetVariable (
> > + L"RedfishServiceIpPort",
> > + &gEmuRedfishServiceGuid,
> > + EFI_VARIABLE_NON_VOLATILE |
> > EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (UINT16),
> > + &RedfishServiceIpPort
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Print (L"\n");
> > + Print (L"HostIpAssignmentType is Auto!\n");
> > + Print (L"RedfishServiceIpAddress: %s has been set Successfully!\n",
> Argv[2]);
> > + Print (L"RedfishServiceIpMask: %s has been set Successfully!\n",
> Argv[3]);
> > + Print (L"RedfishServiceIpPort: %s has been set Successfully!\n",
> Argv[4]);
> > + Print (L"Please Restart!\n");
> > + } else if (StrCmp(Argv[1], L"-h") == 0 || StrCmp(Argv[1], L"-help")
> > + == 0) {
> > +
> > + PrintHelp();
> > + } else {
> > +
> > + PrintHelp();
> > + return EFI_UNSUPPORTED;
> > + }
> > +
> > + return EFI_SUCCESS;
> > +}
> > diff --git
> > a/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > inf
> > b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > inf
> > new file mode 100644
> > index 0000000000..386c9bdd8c
> > --- /dev/null
> > +++
> > b/EmulatorPkg/Application/RedfishPlatformConfig/RedfishPlatformConfig.
> > inf
> > @@ -0,0 +1,42 @@
> > +## @file
> > +# Sample UEFI Application Reference EDKII Module.
> > +#
> > +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> #
> > +(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> # #
> > +SPDX-License-Identifier: BSD-2-Clause-Patent # # ##
> > +
> > +[Defines]
> > + INF_VERSION = 0x0001000b
> > + BASE_NAME = RedfishPlatformConfig
> > + FILE_GUID = C02B67BB-3D19-4ACC-A080-1BDB575F8F36
> > + MODULE_TYPE = UEFI_APPLICATION
> > + VERSION_STRING = 1.0
> > + ENTRY_POINT = UefiMain
> > +
> > +[Sources]
> > + RedfishPlatformConfig.c
> > +
> > +[Packages]
> > + EmulatorPkg/EmulatorPkg.dec
> > + MdePkg/MdePkg.dec
> > + MdeModulePkg/MdeModulePkg.dec
> > + NetworkPkg/NetworkPkg.dec
> > + RedfishPkg/RedfishPkg.dec
> > +
> > +[LibraryClasses]
> > + DebugLib
> > + NetLib
> > + UefiApplicationEntryPoint
> > + UefiLib
> > + UefiBootServicesTableLib
> > + UefiRuntimeServicesTableLib
> > +[Protocols]
> > + gEfiShellParametersProtocolGuid ## CONSUMES
> > + gEfiShellProtocolGuid ## CONSUMES
> > +
> > +[Guids]
> > + gEmuRedfishServiceGuid
> > --
> > 2.17.1
> >
> >
> >
> >
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-12-03 5:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 14:38 [Platform Redfish Host Interface PATCH 0/6] Enable Platform Redfish Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 1/6] RedfishPkg: Add PCD definition to RedfishPkg Abner Chang
2020-11-09 4:24 ` [edk2-devel] " Nickle Wang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 2/6] RedfishPkg: DSC and FDF include files for enabling EFI Redfish support Abner Chang
2020-11-09 4:26 ` [edk2-devel] " Nickle Wang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency Abner Chang
2020-11-05 14:38 ` [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg Abner Chang
[not found] ` <1644A5FDFD825A04.31306@groups.io>
2020-11-24 9:24 ` [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Ni, Ray
[not found] ` <1644A5FE6C306DA9.32447@groups.io>
2020-11-24 9:24 ` [edk2-devel] [Platform Redfish Host Interface PATCH 5/6] EmulatorPkg: Add allowable dependency Ni, Ray
[not found] ` <1644A5FF1778E4F7.31306@groups.io>
2020-11-24 9:24 ` [edk2-devel] [Platform Redfish Host Interface PATCH 6/6] EmulatorPkg: Redfish related changes on EmulatorPkg Ni, Ray
[not found] ` <1644A5FE1ACD3DCB.8528@groups.io>
2020-12-03 5:25 ` [edk2-devel] [Platform Redfish Host Interface PATCH 4/6] EmulatorPkg/Application: Publish Redfish Host Interface Record Ni, Ray
2020-12-03 5:41 ` Abner Chang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox