RedfishPkg: Redfish discover driver improvement

Bug fix:
- function stack fault
- properly handle "SubnetAddrInfoIPv6" when there is no IPv6 support
- copy-n-paste error in RedfishGetHostInterfaceProtocolData()
- fix typo
Enhancement:
- Redfish discover driver now can configure host IP address based on
  the information from SMBIOS type 42 record. This saves the effort of
  configuring host IP address in setup menu.
- Performance improvement to driver binding process. Redfish discover
  driver will wait until all required drivers are ready and do driver
  binding start().
- Use CopyGuid() to copy GUID instead of intrinsic function.
- Error handling when SMBIOS data is corrupted.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
This commit is contained in:
Nickle Wang 2023-03-27 22:28:58 +08:00 committed by mergify[bot]
parent c2abf77116
commit 0cd7542a69
3 changed files with 120 additions and 57 deletions

View File

@ -1,9 +1,10 @@
/** @file /** @file
The implementation of EFI Redfidh Discover Protocol. The implementation of EFI Redfish Discover Protocol.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2022, AMD Incorporated. All rights reserved. Copyright (c) 2022, AMD Incorporated. All rights reserved.
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -270,10 +271,13 @@ Tcp6GetSubnetInfo (
if (IpModedata.AddressCount == 0) { if (IpModedata.AddressCount == 0) {
DEBUG ((DEBUG_INFO, "%a: No IPv6 address configured.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: No IPv6 address configured.\n", __FUNCTION__));
Instance->SubnetAddrInfoIPv6Number = 0;
return EFI_SUCCESS;
} }
if (Instance->SubnetAddrInfoIPv6 != NULL) { if (Instance->SubnetAddrInfoIPv6 != NULL) {
FreePool (Instance->SubnetAddrInfoIPv6); FreePool (Instance->SubnetAddrInfoIPv6);
Instance->SubnetAddrInfoIPv6 = NULL;
} }
Instance->SubnetAddrInfoIPv6 = AllocateZeroPool (IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO)); Instance->SubnetAddrInfoIPv6 = AllocateZeroPool (IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO));
@ -447,7 +451,7 @@ NumberOfNetworkInterface (
/** /**
This function checks the IP version supported on this This function checks the IP version supported on this
netwoek interface. network interface.
@param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL @param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
@ -472,7 +476,7 @@ CheckIsIpVersion6 (
@param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE @param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE
@retval EFI_SUCCESS Redfish service is discovered through SMBIOS Host interface. @retval EFI_SUCCESS Redfish service is discovered through SMBIOS Host interface.
@retval Others Fail to discover Redfish service throught SMBIOS host interface @retval Others Fail to discover Redfish service through SMBIOS host interface
**/ **/
EFI_STATUS EFI_STATUS
@ -487,7 +491,7 @@ DiscoverRedfishHostInterface (
CHAR16 Ipv6Str[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" + 1]; CHAR16 Ipv6Str[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" + 1];
CHAR8 RedfishServiceLocateStr[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" + 1]; CHAR8 RedfishServiceLocateStr[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" + 1];
UINTN StrSize; UINTN StrSize;
UINTN MacCompareStstus; UINTN MacCompareStatus;
BOOLEAN IsHttps; BOOLEAN IsHttps;
Data = NULL; Data = NULL;
@ -503,24 +507,52 @@ DiscoverRedfishHostInterface (
Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) { if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
// //
// Chceck if we can reach out Redfish service using this network interface. // Check if we can reach out Redfish service using this network interface.
// Check with MAC address using Device Descroptor Data Device Type 04 and Type 05. // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
// Those two types of Redfish host interface device has MAC information. // Those two types of Redfish host interface device has MAC information.
// //
if (DeviceDescriptor->DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { if (DeviceDescriptor->DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
MacCompareStstus = CompareMem (&Instance->NetworkInterface->MacAddress, &DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.MacAddress, 6); MacCompareStatus = CompareMem (&Instance->NetworkInterface->MacAddress, &DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.MacAddress, 6);
} else if (DeviceDescriptor->DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) { } else if (DeviceDescriptor->DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) {
MacCompareStstus = CompareMem (&Instance->NetworkInterface->MacAddress, &DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress, 6); MacCompareStatus = CompareMem (&Instance->NetworkInterface->MacAddress, &DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress, 6);
} else { } else {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (MacCompareStstus != 0) { if (MacCompareStatus != 0) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (Data->RedfishServiceIpAddressFormat == 1) { Instance->HostAddrFormat = Data->HostIpAddressFormat;
if (Data->HostIpAddressFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) {
IP4_COPY_ADDRESS ((VOID *)&Instance->HostIpAddress.v4, (VOID *)Data->HostIpAddress);
IP4_COPY_ADDRESS ((VOID *)&Instance->HostSubnetMask.v4, (VOID *)Data->HostIpMask);
if (EFI_IP4_EQUAL (&Instance->HostIpAddress.v4, &mZeroIp4Addr)) {
DEBUG ((DEBUG_ERROR, "%a: invalid host IP address: zero address\n", __FUNCTION__));
//
// Invalid IP address detected. Change address format to Unknown and use system default address.
//
Instance->HostAddrFormat = REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
}
if (!IP4_IS_VALID_NETMASK (EFI_IP4 (Instance->HostSubnetMask.v4))) {
DEBUG ((DEBUG_ERROR, "%a: invalid subnet mask address\n", __FUNCTION__));
//
// Invalid subnet mast address detected. Change address format to Unknown and use system default address.
//
Instance->HostAddrFormat = REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
}
} else if (Data->HostIpAddressFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) {
IP6_COPY_ADDRESS ((VOID *)&Instance->HostIpAddress.v6, (VOID *)Data->HostIpAddress);
}
if (Data->RedfishServiceIpAddressFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) {
IP4_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v4, (VOID *)Data->RedfishServiceIpAddress); IP4_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v4, (VOID *)Data->RedfishServiceIpAddress);
if (EFI_IP4_EQUAL (&Instance->TargetIpAddress.v4, &mZeroIp4Addr)) {
DEBUG ((DEBUG_ERROR, "%a: invalid service IP address: zero address\n", __FUNCTION__));
}
} else { } else {
IP6_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v6, (VOID *)Data->RedfishServiceIpAddress); IP6_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v6, (VOID *)Data->RedfishServiceIpAddress);
} }
@ -530,7 +562,7 @@ DiscoverRedfishHostInterface (
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} else { } else {
// //
// Add this istance to list without detial information of Redfish // Add this instance to list without detail information of Redfish
// service. // service.
// //
IsHttps = FALSE; IsHttps = FALSE;
@ -614,7 +646,7 @@ DiscoverRedfishHostInterface (
@param[in] Os OS string. @param[in] Os OS string.
@param[in] OsVer OS version string. @param[in] OsVer OS version string.
@param[in] Product Product string. @param[in] Product Product string.
@param[in] ProductVer Product verison string. @param[in] ProductVer Product version string.
@param[in] UseHttps Redfish service requires secured connection. @param[in] UseHttps Redfish service requires secured connection.
@retval EFI_SUCCESS Redfish service is added to list successfully. @retval EFI_SUCCESS Redfish service is added to list successfully.
@ -671,7 +703,7 @@ AddAndSignalNewRedfishService (
do { do {
if ((Char16Uuid == NULL) || (DiscoveredList->Instance->Information.Uuid == NULL)) { if ((Char16Uuid == NULL) || (DiscoveredList->Instance->Information.Uuid == NULL)) {
// //
// Check if this Redfish instance already found using IP addrress. // Check if this Redfish instance already found using IP address.
// //
if (!CheckIsIpVersion6 (NetworkInterface)) { if (!CheckIsIpVersion6 (NetworkInterface)) {
if (CompareMem ( if (CompareMem (
@ -849,6 +881,10 @@ AddAndSignalNewRedfishService (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto EXIT_FREE_CONFIG_DATA; goto EXIT_FREE_CONFIG_DATA;
} }
if (Instance->HostAddrFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) {
IP6_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPoint.IPv6Node->LocalAddress, &Instance->HostIpAddress.v6);
}
} else { } else {
RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node = AllocateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT)); RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node = AllocateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT));
if (RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node == NULL) { if (RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node == NULL) {
@ -856,7 +892,13 @@ AddAndSignalNewRedfishService (
goto EXIT_FREE_CONFIG_DATA; goto EXIT_FREE_CONFIG_DATA;
} }
RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDefaultAddress = TRUE; if (Instance->HostAddrFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) {
RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDefaultAddress = FALSE;
IP4_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->LocalAddress, &Instance->HostIpAddress.v4);
IP4_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->LocalSubnet, &Instance->HostSubnetMask.v4);
} else {
RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDefaultAddress = TRUE;
}
} }
Status = RestEx->Configure ( Status = RestEx->Configure (
@ -955,7 +997,7 @@ NetworkInterfaceGetSubnetInfo (
Instance Instance
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a:Faile to get Subnet infomation.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a:Failed to get Subnet infomation.\n", __FUNCTION__));
return Status; return Status;
} else { } else {
DEBUG ((DEBUG_INFO, "%a:MAC address: %s\n", __FUNCTION__, Instance->StrMacAddr)); DEBUG ((DEBUG_INFO, "%a:MAC address: %s\n", __FUNCTION__, Instance->StrMacAddr));
@ -982,7 +1024,7 @@ NetworkInterfaceGetSubnetInfo (
ThisSubnetAddrInfoIPv6++; ThisSubnetAddrInfoIPv6++;
for (IPv6InfoIndex = 0; IPv6InfoIndex < Instance->SubnetAddrInfoIPv6Number - 1; IPv6InfoIndex++) { for (IPv6InfoIndex = 0; IPv6InfoIndex < Instance->SubnetAddrInfoIPv6Number - 1; IPv6InfoIndex++) {
// //
// Build up addtional EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL instances. // Build up additional EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL instances.
// //
NewNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL)); NewNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL));
if (NewNetworkInterface != NULL) { if (NewNetworkInterface != NULL) {
@ -1103,9 +1145,9 @@ RedfishServiceGetNetworkInterface (
/** /**
This function acquires Redfish services by discovering static Redfish setting This function acquires Redfish services by discovering static Redfish setting
according to Redfish Host Interface or through SSDP. Returns a list of EFI according to Redfish Host Interface or through SSDP. Returns a list of EFI
handles in EFI_REDFISH_DISCOVERED_LIST. Each of EFI handle has cooresponding handles in EFI_REDFISH_DISCOVERED_LIST. Each of EFI handle has corresponding
EFI REST EX instance installed on it. Each REST EX isntance is a child instance which EFI REST EX instance installed on it. Each REST EX instance is a child instance which
created through EFI REST EX serivce protoocl for communicating with specific created through EFI REST EX service protocol for communicating with specific
Redfish service. Redfish service.
@param[in] This EFI_REDFISH_DISCOVER_PROTOCOL instance. @param[in] This EFI_REDFISH_DISCOVER_PROTOCOL instance.
@ -1255,7 +1297,7 @@ RedfishServiceAbortAcquire (
) )
{ {
// This function is used to abort Redfish service discovery through SSDP // This function is used to abort Redfish service discovery through SSDP
// on the network interface. SSDP is optionally supprted by EFI_REDFISH_DISCOVER_PROTOCOL, // on the network interface. SSDP is optionally suppoted by EFI_REDFISH_DISCOVER_PROTOCOL,
// we dont have implementation for SSDP now. // we dont have implementation for SSDP now.
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -1425,7 +1467,7 @@ CreateRedfishDiscoverNetworkInterface (
} }
/** /**
This function destory network interface This function destroy network interface
@param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL instance. @param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL instance.
@ -1433,7 +1475,7 @@ CreateRedfishDiscoverNetworkInterface (
@retval EFI_STATUS @retval EFI_STATUS
**/ **/
EFI_STATUS EFI_STATUS
DestroyRedfishNetwrokInterface ( DestroyRedfishNetworkInterface (
IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface
) )
{ {
@ -1467,11 +1509,13 @@ TestForRequiredProtocols (
IN EFI_HANDLE ControllerHandle IN EFI_HANDLE ControllerHandle
) )
{ {
UINT32 Id; UINT32 *Id;
UINTN Index; UINTN Index;
EFI_STATUS Status; EFI_STATUS Status;
UINTN ListCount;
for (Index = 0; Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); Index++) { ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
for (Index = 0; Index < ListCount; Index++) {
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid, gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,
@ -1490,8 +1534,10 @@ TestForRequiredProtocols (
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: %s is found on this controller handle.\n", __FUNCTION__, gRequiredProtocol[Index].ProtocolName)); if (Index == ListCount - 1) {
return EFI_SUCCESS; DEBUG ((DEBUG_ERROR, "%a: all required protocols are found on this controller handle: %p.\n", __FUNCTION__, ControllerHandle));
return EFI_SUCCESS;
}
} }
} }
} }
@ -1517,7 +1563,7 @@ BuildupNetworkInterface (
IN EFI_HANDLE ControllerHandle IN EFI_HANDLE ControllerHandle
) )
{ {
UINT32 Id; UINT32 *Id;
UINT32 Index; UINT32 Index;
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface;
BOOLEAN IsNew; BOOLEAN IsNew;
@ -1578,13 +1624,11 @@ BuildupNetworkInterface (
return Status; return Status;
} }
NetworkInterface->NetworkProtocolType = gRequiredProtocol[Index].ProtocolType; NetworkInterface->NetworkProtocolType = gRequiredProtocol[Index].ProtocolType;
NetworkInterface->OpenDriverAgentHandle = This->DriverBindingHandle; NetworkInterface->OpenDriverAgentHandle = This->DriverBindingHandle;
NetworkInterface->OpenDriverControllerHandle = ControllerHandle; NetworkInterface->OpenDriverControllerHandle = ControllerHandle;
NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGuid = \ CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGuid, gRequiredProtocol[Index].RequiredProtocolGuid);
*gRequiredProtocol[Index].RequiredProtocolGuid; CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolServiceGuid, gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid);
NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolServiceGuid = \
*gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid;
ProtocolDiscoverIdPtr = &NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolDiscoverId; ProtocolDiscoverIdPtr = &NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolDiscoverId;
OpenDriverAgentHandle = NetworkInterface->OpenDriverAgentHandle; OpenDriverAgentHandle = NetworkInterface->OpenDriverAgentHandle;
OpenDriverControllerHandle = NetworkInterface->OpenDriverControllerHandle; OpenDriverControllerHandle = NetworkInterface->OpenDriverControllerHandle;
@ -1598,7 +1642,7 @@ BuildupNetworkInterface (
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
} else { } else {
// Record REST_EX instance. REST_EX is created when clinet asks for Redfish service discovery. // Record REST_EX instance. REST_EX is created when client asks for Redfish service discovery.
// Redfish Service Discover protocol will match REST EX to the corresponding EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL // Redfish Service Discover protocol will match REST EX to the corresponding EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
// when discovery. // when discovery.
@ -1655,9 +1699,9 @@ BuildupNetworkInterface (
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeRestEx)) { if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeRestEx)) {
// Install Redfish Discover Protocol when EFI REST EX protcol is discovered. // Install Redfish Discover Protocol when EFI REST EX protocol is discovered.
// This ensures EFI REST EX is ready while the consumer of EFI_REDFISH_DISCOVER_PROTOCOL // This ensures EFI REST EX is ready while the consumer of EFI_REDFISH_DISCOVER_PROTOCOL
// acquires Redfish serivce over network interface. // acquires Redfish service over network interface.
if (!NewNetworkInterfaceInstalled) { if (!NewNetworkInterfaceInstalled) {
NetworkInterface = GetTargetNetworkInterfaceInternalByController (ControllerHandle); NetworkInterface = GetTargetNetworkInterfaceInternalByController (ControllerHandle);
@ -1678,6 +1722,14 @@ BuildupNetworkInterface (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI_REDFISH_DISCOVER_PROTOCOL\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI_REDFISH_DISCOVER_PROTOCOL\n", __FUNCTION__));
} }
} else {
DEBUG ((DEBUG_INFO, "%a: Not REST EX, continue with next\n", __FUNCTION__));
Index++;
if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
break;
}
continue;
} }
} }
@ -1692,11 +1744,11 @@ BuildupNetworkInterface (
} }
} while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))); } while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)));
return EFI_UNSUPPORTED; return EFI_DEVICE_ERROR;
} }
/** /**
Close the protocol opened for Redfish discovery. This function also destories Close the protocol opened for Redfish discovery. This function also destroy
the network services. the network services.
@param[in] ThisBindingProtocol A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ThisBindingProtocol A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@ -1707,8 +1759,8 @@ BuildupNetworkInterface (
@param[in] DriverAgentHandle Driver agent handle which used to open protocol earlier. @param[in] DriverAgentHandle Driver agent handle which used to open protocol earlier.
@param[in] DriverControllerHandle Driver controller handle which used to open protocol earlier. @param[in] DriverControllerHandle Driver controller handle which used to open protocol earlier.
@retval EFI_SUCCESS Prorocol is closed successfully. @retval EFI_SUCCESS Protocol is closed successfully.
@retval Others Prorocol is closed unsuccessfully. @retval Others Protocol is closed unsuccessfully.
**/ **/
EFI_STATUS EFI_STATUS
@ -1748,7 +1800,7 @@ CloseProtocolService (
must support a protocol interface that supplies must support a protocol interface that supplies
an I/O abstraction to the driver. an I/O abstraction to the driver.
@retval EFI_SUCCESS One of required protocol is found. @retval EFI_SUCCESS One of required protocol is found.
@retval Others Faile to stop the services on network interface. @retval Others Failed to stop the services on network interface.
**/ **/
EFI_STATUS EFI_STATUS
StopServiceOnNetworkInterface ( StopServiceOnNetworkInterface (
@ -1792,14 +1844,14 @@ StopServiceOnNetworkInterface (
ThisNetworkInterface->OpenDriverControllerHandle ThisNetworkInterface->OpenDriverControllerHandle
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = DestroyRedfishNetwrokInterface (ThisNetworkInterface); Status = DestroyRedfishNetworkInterface (ThisNetworkInterface);
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
// //
// Disconnect EFI Redfish discover driver controller to notify the // Disconnect EFI Redfish discover driver controller to notify the
// clinet which uses .EFI Redfish discover protocol. // client which uses .EFI Redfish discover protocol.
// //
if (DiscoverProtocolHandle != NULL) { if (DiscoverProtocolHandle != NULL) {
gBS->DisconnectController (DiscoverProtocolHandle, NULL, NULL); gBS->DisconnectController (DiscoverProtocolHandle, NULL, NULL);
@ -1945,7 +1997,7 @@ RedfishDiscoverDriverBindingSupported (
@retval EFI_SUCCESS The device was started. @retval EFI_SUCCESS The device was started.
@retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
@retval Others The driver failded to start the device. @retval Others The driver failed to start the device.
**/ **/
EFI_STATUS EFI_STATUS
@ -2030,7 +2082,7 @@ RedfishDiscoverEntryPoint (
InitializeListHead (&mEfiRedfishDiscoverNetworkInterface); InitializeListHead (&mEfiRedfishDiscoverNetworkInterface);
InitializeListHead (&mEfiRedfishDiscoverRestExInstance); InitializeListHead (&mEfiRedfishDiscoverRestExInstance);
// //
// Install binding protoocl to obtain UDP and REST EX protocol. // Install binding protocol to obtain UDP and REST EX protocol.
// //
Status = EfiLibInstallDriverBindingComponentName2 ( Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle, ImageHandle,

View File

@ -3,6 +3,7 @@
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2022, AMD Incorporated. All rights reserved. Copyright (c) 2022, AMD Incorporated. All rights reserved.
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -102,7 +103,7 @@ typedef struct {
UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number. UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number.
EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info. EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info.
// //
// Network interface protocol and REST EX infor. // Network interface protocol and REST EX info.
// //
UINT32 NetworkProtocolType; ///< Network protocol type. Refer to UINT32 NetworkProtocolType; ///< Network protocol type. Refer to
///< NETWORK_INTERFACE_PROTOCOL_TYPE. ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
@ -112,7 +113,7 @@ typedef struct {
// EFI_REDFISH_DISCOVER_PROTOCOL instance installed // EFI_REDFISH_DISCOVER_PROTOCOL instance installed
// on this network interface. // on this network interface.
// //
EFI_HANDLE EfiRedfishDiscoverProtocolHandle; ///< EFI_REDFISH_DISCOVER_PROTOTOCOL instance installed EFI_HANDLE EfiRedfishDiscoverProtocolHandle; ///< EFI_REDFISH_DISCOVER_PROTOCOL instance installed
///< on this network interface. ///< on this network interface.
} EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
@ -123,7 +124,7 @@ typedef struct {
LIST_ENTRY Entry; ///< Link list entry. LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol. EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle 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 RestExChildHandle; ///< The child handle created through REST EX Service Protocol.
EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol. EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol.
EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL. EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL.
UINT32 RestExId; ///< The identifier installed on REST EX controller handle. UINT32 RestExId; ///< The identifier installed on REST EX controller handle.
@ -178,15 +179,18 @@ typedef struct {
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
///< instance used to discover Redfish service. ///< instance used to discover Redfish service.
// //
// Below for Host insterface discovery. // Below for Host interface discovery.
// //
BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface. BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface.
EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface. EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface.
UINT8 HostAddrFormat; ///< Unknown=00h, Ipv4=01h, Ipv6=02h.
EFI_IP_ADDRESS HostIpAddress; ///< Host IP address reported in Redfish Host interface.
EFI_IP_ADDRESS HostSubnetMask; ///< Host subnet mask address reported in Redfish Host interface.
} EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE; } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
/** /**
The function adds a new foudn Redfish service to internal list and The function adds a new found Redfish service to internal list and
notify clinet. notify client.
It simply frees the packet. It simply frees the packet.
@ -197,7 +201,7 @@ typedef struct {
@param[in] Os OS string. @param[in] Os OS string.
@param[in] OsVer OS version string. @param[in] OsVer OS version string.
@param[in] Product Product string. @param[in] Product Product string.
@param[in] ProductVer Product verison string. @param[in] ProductVer Product version string.
@param[in] UseHttps Redfish service requires secured connection. @param[in] UseHttps Redfish service requires secured connection.
@retval EFI_SUCCESS Redfish service is added to list successfully. @retval EFI_SUCCESS Redfish service is added to list successfully.
@ -224,7 +228,7 @@ AddAndSignalNewRedfishService (
@param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA. @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
@param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA. @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
@retval EFI_SUCCESS Get host interface succesfully. @retval EFI_SUCCESS Get host interface successfully.
@retval Otherwise Fail to tet host interface. @retval Otherwise Fail to tet host interface.
**/ **/

View File

@ -4,6 +4,7 @@
Discover Redfish SMBIOS Host Interface. Discover Redfish SMBIOS Host Interface.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -22,7 +23,7 @@ SMBIOS_TABLE_TYPE42 *mType42Record;
@param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA. @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
@param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA. @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
@retval EFI_SUCCESS Get host interface succesfully. @retval EFI_SUCCESS Get host interface successfully.
@retval Otherwise Fail to tet host interface. @retval Otherwise Fail to tet host interface.
**/ **/
@ -69,9 +70,15 @@ RedfishGetHostInterfaceProtocolData (
// //
if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) { if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) {
if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1); if (SpecificDataLen != sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
}
} else { } else {
ASSERT (SpecificDataLen > sizeof (REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) + 1); if (SpecificDataLen != sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
}
} }
*DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp; *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;