RedfishPkg/RedfishDiscoverDxe: EFI Redfish Discover Protocol

BZ#:2906
EDK2 EFI Redfish Discover Protocol implementation. Refer to UEFI
spec 2.9 section 31.1.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Fan Wang <fan.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
This commit is contained in:
Abner Chang 2021-03-24 15:35:54 +08:00 committed by mergify[bot]
parent 5eb2de2d98
commit 7e7b729f6c
7 changed files with 2539 additions and 2 deletions

View File

@ -5,7 +5,7 @@
# 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>
# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@ -15,4 +15,5 @@
INF RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
INF RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf
INF RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.inf
INF RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
!endif

View File

@ -6,7 +6,7 @@
# of EDKII Redfish drivers according to the value of flags described in
# "RedfishDefines.dsc.inc".
#
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@ -17,4 +17,5 @@
RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf
RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.inf
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
!endif

View File

@ -0,0 +1,218 @@
/** @file
Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
for EFI Refish Discover Protocol
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "RedfishDiscoverInternal.h"
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] Language A pointer to a three-character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
@param[out] DriverName A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
RedfishDiscoverComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an EFI Driver.
@param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] ControllerHandle The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
@param[in] ChildHandle The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
@param[in] Language A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
@param[out] ControllerName A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
by Language, from the point of view of the driver specified
by This.
@retval EFI_SUCCESS The Unicode string for the user-readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently managing
the controller specified by ControllerHandle and
ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
RedfishDiscoverComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
///
/// Component Name Protocol instance
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName = {
RedfishDiscoverComponentNameGetDriverName,
RedfishDiscoverComponentNameGetControllerName,
"eng"
};
///
/// Component Name 2 Protocol instance
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) RedfishDiscoverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishDiscoverComponentNameGetControllerName,
"en"
};
///
/// Table of driver names
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mRedfishDiscoverDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" },
{ NULL, NULL }
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable = NULL;
/**
Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] Language A pointer to a three-character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
@param[out] DriverName A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
RedfishDiscoverComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mRedfishDiscoverDriverNameTable,
DriverName,
(BOOLEAN)(This == &gRedfishDiscoverComponentName)
);
}
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an EFI Driver.
@param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] ControllerHandle The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
@param[in] ChildHandle The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
@param[in] Language A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
@param[out] ControllerName A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
by Language, from the point of view of the driver specified
by This.
@retval EFI_SUCCESS The Unicode string for the user-readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently managing
the controller specified by ControllerHandle and
ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
RedfishDiscoverComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
## @file
# Implementation of EFI_REDFISH_DISCOVER_PROTOCOL interfaces.
#
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x0001001b
BASE_NAME = RedfishDiscoverDxe
FILE_GUID = 28A76FE5-43D7-48A3-9714-C1B7BDD6DFB6
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = RedfishDiscoverEntryPoint
UNLOAD_IMAGE = RedfishDiscoverUnload
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
NetworkPkg/NetworkPkg.dec
RedfishPkg/RedfishPkg.dec
[Sources]
ComponentName.c
RedfishDiscoverDxe.c
RedfishSmbiosHostInterface.c
RedfishDiscoverInternal.h
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
PrintLib
RestExLib
UefiLib
UefiBootServicesTableLib
UefiDriverEntryPoint
[Protocols]
gEfiRestExServiceBindingProtocolGuid ## Consuming
gEfiRestExProtocolGuid ## Consuming
gEfiTcp4ServiceBindingProtocolGuid ## Consuming
gEfiTcp4ProtocolGuid ## Consuming
gEfiTcp6ServiceBindingProtocolGuid ## Consuming
gEfiTcp6ProtocolGuid ## Consuming
gEfiRedfishDiscoverProtocolGuid ## Prodcuing
gEfiSmbiosProtocolGuid ## Consuming
gEfiDriverBindingProtocolGuid ## Consuming
[Pcd]
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand ## CONSUMES

View File

@ -0,0 +1,234 @@
/** @file
This file defines the EFI Redfish Discover Protocol interface.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef EFI_REDFISH_DISCOVER_INTERNAL_H_
#define EFI_REDFISH_DISCOVER_INTERNAL_H_
#include <Uefi.h>
#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/RedfishDiscover.h>
#include <Protocol/Smbios.h>
#include <Protocol/Tcp4.h>
#include <Protocol/Tcp6.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
#include <Library/PrintLib.h>
#include <Library/RestExLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <IndustryStandard/RedfishHostInterface.h>
#define REDFISH_DISCOVER_VERSION 0x00010000
#define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
//
//GUID definitions
//
#define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
{ \
0xfbab97a4, 0x4c6a, 0xf8e8, { 0xf2, 0x25, 0x42, 0x8a, 0x80, 0x3f, 0xb6, 0xaa } \
}
#define EFI_REDFISH_DISCOVER_TCP6_INSTANCE_GUID \
{ \
0xbe513b6d, 0x41c1, 0x96Ed, { 0x8d, 0xaf, 0x3e, 0x89, 0xc5, 0xf5, 0x02, 0x25 } \
}
#define EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_GUID \
{ \
0xc44a6076, 0xd42a, 0x4d54, { 0x85, 0x6d, 0x98, 0x8a, 0x85, 0x8f, 0xa1, 0x11 } \
}
extern EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2;
extern EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable;
//
// Enumeration of network protocols
// required for the Redfish service discovery.
//
typedef enum {
ProtocolTypeTcp4 = 0, ///< Network protocol TCPv4.
ProtocolTypeTcp6, ///< Network protocol TCCv6.
ProtocolTypeRestEx, ///< REST EX over network protocol.
MaxProtocolType
} NETWORK_INTERFACE_PROTOCOL_TYPE;
//
// Network protocol information installed on
// the network interface.
//
typedef struct {
EFI_GUID ProtocolGuid; ///< Network protocol GUID.
EFI_GUID ProtocolServiceGuid; ///< Network protocol service GUID.
UINT32 ProtocolDiscoverId; ///< The identifier installed on network protocol handle.
EFI_HANDLE ProtocolControllerHandle; ///< The controller handle on network protocol.
VOID *NetworkProtocolInterface; ///< The protocol interface of network protocol.
} REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL;
//
// Internal structure used to maintain network
// interface properties.
//
typedef struct {
LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
UINTN HwAddressSize; ///< The size of network interface hardware address.
EFI_MAC_ADDRESS MacAddress; ///< MAC address of network interface.
CHAR16 *StrMacAddr; ///< String to MAC address of network interface.
BOOLEAN GotSubnetInfo; ///< Indicates sub net information is retrieved.
EFI_IP_ADDRESS SubnetAddr; ///< Subnet ID.
EFI_IP_ADDRESS SubnetMask; ///< Subnet mask (IPv4 only)
UINT8 SubnetPrefixLength; ///< Subnet prefix.
UINT16 VlanId; ///< VLAN ID
UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number.
EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info.
//
// Network interface protocol and REST EX infor.
//
UINT32 NetworkProtocolType; ///< Network protocol type. Refer to
///< NETWORK_INTERFACE_PROTOCOL_TYPE.
REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo; ///< Network interface protocol information.
EFI_HANDLE RestExHandle; ///< REST EX handle associated with this network interface.
} EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
//
// Internal structure used to maintain REST EX properties.
//
typedef struct {
LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
EFI_HANDLE RestExChildHandle; ///< The child handle created throught REST EX Service Protocol.
EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol.
EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL.
UINT32 RestExId; ///< The identifier installed on REST EX controller handle.
} EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL;
/**
This function to get subnet information.
@param[in] ImageHandle EFI handle with this image.
@param[in] Instance Instance of Network interface.
@retval EFI_STATUS Get subnet information successfully.
@retval Otherwise Fail to get subnet information.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
IN EFI_HANDLE ImageHandle,
IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
);
//
// The require network protocol matrix.
//
typedef struct {
UINT32 ProtocolType; ///< Network protocol type,
///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
CHAR16 *ProtocolName; ///< Protocol name.
EFI_GUID *RequiredProtocolGuid; ///< Network protocol interface GUID.
EFI_GUID *RequiredServiceBindingProtocolGuid; ///< Network protocol service GUID.
EFI_GUID *DiscoveredProtocolGuid; ///< Protocol interface GUID use to install identifier.
EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo; ///< Function of getting subnet information.
} REDFISH_DISCOVER_REQUIRED_PROTOCOL;
//
// Link list of Redfish discover instance.
//
typedef struct {
LIST_ENTRY NextInstance; ///< Next list.
EFI_REDFISH_DISCOVERED_INSTANCE *Instance; ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
} EFI_REDFISH_DISCOVERED_INTERNAL_LIST;
//
// Internal structure of Redfish discover instance.
//
typedef struct {
LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE Owner; ///< The owner owns this Redfish service discovery.
///< It's the EFI image handle of driver uses
///< EFI Redfish Discover Protocol.
EFI_REDFISH_DISCOVER_FLAG DiscoverFlags; ///< EFI_REDFISH_DISCOVER_FLAG
EFI_REDFISH_DISCOVERED_TOKEN *DiscoverToken; ///< Token used to signal when Redfish service is discovered.
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
///< instance used to discover Redfish service.
//
// Below for Host insterface discovery.
//
BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface.
EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface.
} EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
/**
The function adds a new foudn Redfish service to internal list and
notify clinet.
It simply frees the packet.
@param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE.
@param[in] RedfishVersion Redfish version.
@param[in] RedfishLocation Redfish location.
@param[in] Uuid Service UUID string.
@param[in] Os OS string.
@param[in] OsVer OS version string.
@param[in] Product Product string.
@param[in] ProductVer Product verison string.
@param[in] UseHttps Redfish service requires secured connection.
@retval EFI_SUCCESS Redfish service is added to list successfully.
**/
EFI_STATUS
AddAndSignalNewRedfishService (
IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance,
IN UINTN *RedfishVersion OPTIONAL,
IN CHAR8 *RedfishLocation OPTIONAL,
IN CHAR8 *Uuid OPTIONAL,
IN CHAR8 *Os OPTIONAL,
IN CHAR8 *OsVer OPTIONAL,
IN CHAR8 *Product OPTIONAL,
IN CHAR8 *ProductVer OPTIONAL,
IN BOOLEAN UseHttps
);
/**
The function gets information reported in Redfish Host Interface.
It simply frees the packet.
@param[in] Smbios SMBIOS protocol.
@param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
@param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
@retval EFI_SUCCESS Get host interface succesfully.
@retval Otherwise Fail to tet host interface.
**/
EFI_STATUS
RedfishGetHostInterfaceProtocolData (
IN EFI_SMBIOS_PROTOCOL *Smbios,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
);
extern EFI_GUID gRedfishDiscoverTcp4Instance;
extern EFI_GUID gRedfishDiscoverTcp6Instance;
extern EFI_GUID gRedfishDiscoverRestEXInstance;
#endif

View File

@ -0,0 +1,118 @@
/** @file
RedfishSmbiosHostInterface.c
Discover Redfish SMBIOS Host Interface.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "RedfishDiscoverInternal.h"
SMBIOS_TABLE_TYPE42 *mType42Record;
/**
The function gets information reported in Redfish Host Interface.
It simply frees the packet.
@param[in] Smbios SMBIOS protocol.
@param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
@param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
@retval EFI_SUCCESS Get host interface succesfully.
@retval Otherwise Fail to tet host interface.
**/
EFI_STATUS
RedfishGetHostInterfaceProtocolData (
IN EFI_SMBIOS_PROTOCOL *Smbios,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
)
{
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_SMBIOS_TABLE_HEADER *Record;
UINT16 Offset;
UINT8 *RecordTmp;
UINT8 ProtocolLength;
UINT8 SpecificDataLen;
if ((Smbios == NULL) || (ProtocolData == NULL)) {
return EFI_INVALID_PARAMETER;
}
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) {
if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) {
//
// Check Interface Type, should be Network Host Interface = 40h
//
mType42Record = (SMBIOS_TABLE_TYPE42 *) Record;
if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
ASSERT (Record->Length >= 9);
Offset = 5;
RecordTmp = (UINT8 *) Record + Offset;
//
// Get interface specific data length.
//
SpecificDataLen = *RecordTmp;
Offset += 1;
RecordTmp = (UINT8 *) Record + Offset;
//
// Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
//
if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
*DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
Offset = Offset + SpecificDataLen;
RecordTmp = (UINT8 *) Record + Offset;
//
// Check Protocol count. if > 1, only use the first protocol.
//
ASSERT (*RecordTmp == 1);
Offset += 1;
RecordTmp = (UINT8 *) Record + Offset;
//
// Check protocol identifier.
//
if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
Offset += 1;
RecordTmp = (UINT8 *) Record + Offset;
ProtocolLength = *RecordTmp;
Offset += 1;
RecordTmp = (UINT8 *) Record + Offset;
//
// This SMBIOS record is invalid, if the length of protocol specific data for
// Redfish Over IP protocol is wrong.
//
if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
return EFI_SECURITY_VIOLATION;
}
Offset += ProtocolLength;
//
// This SMBIOS record is invalid, if the length is smaller than the offset.
//
if (Offset > mType42Record->Hdr.Length) {
return EFI_SECURITY_VIOLATION;
}
*ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
return EFI_SUCCESS;
}
}
}
}
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
}
*ProtocolData = NULL;
return EFI_NOT_FOUND;
}