mirror of https://github.com/acidanthera/audk.git
RedfishPkg: Create RestEx child on selected interface
When a MAC address matching interface is found, a RestEx child will be created to provide the Redfish communication on that interface. Currently, It will try to locate all RestEx binding services and choose the first satisfied instance without taking care about current selected interface. This might raise an issue on the system with multiple network devices that the RestEx child was installed on wrong interface. Signed-off-by: Minh Nguyen <minhnguyen1@os.amperecomputing.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:
parent
05762bd2e0
commit
a1f6485a9b
|
@ -2,6 +2,7 @@
|
|||
This library provides help functions for REST EX Protocol.
|
||||
|
||||
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
|
||||
Copyright (c) 2023, Ampere Computing LLC. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
|
@ -20,6 +21,7 @@
|
|||
This function allows the caller to create child handle for specific
|
||||
REST server.
|
||||
|
||||
@param[in] Controller The controller handle used of selected interface.
|
||||
@param[in] Image The image handle used to open service.
|
||||
@param[in] AccessMode Access mode of REST server.
|
||||
@param[in] ConfigType Underlying configuration to communicate with REST server.
|
||||
|
@ -32,6 +34,7 @@
|
|||
**/
|
||||
EFI_STATUS
|
||||
RestExLibCreateChild (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
|
||||
IN EFI_REST_EX_CONFIG_TYPE ConfigType,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
This library provides help functions for REST EX Protocol.
|
||||
|
||||
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
|
||||
Copyright (c) 2023, Ampere Computing LLC. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
|
@ -9,6 +10,7 @@
|
|||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
@ -21,6 +23,7 @@
|
|||
This function allows the caller to create child handle for specific
|
||||
REST server.
|
||||
|
||||
@param[in] Controller The controller handle used of selected interface.
|
||||
@param[in] Image The image handle used to open service.
|
||||
@param[in] AccessMode Access mode of REST server.
|
||||
@param[in] ConfigType Underlying configuration to communicate with REST server.
|
||||
|
@ -33,6 +36,7 @@
|
|||
**/
|
||||
EFI_STATUS
|
||||
RestExLibCreateChild (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
|
||||
IN EFI_REST_EX_CONFIG_TYPE ConfigType,
|
||||
|
@ -41,8 +45,6 @@ RestExLibCreateChild (
|
|||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN NoBuffer;
|
||||
EFI_HANDLE *Handle;
|
||||
EFI_HANDLE ChildHandle;
|
||||
EFI_REST_EX_PROTOCOL *RestEx;
|
||||
EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
|
||||
|
@ -59,116 +61,83 @@ RestExLibCreateChild (
|
|||
}
|
||||
|
||||
*ChildInstanceHandle = NULL;
|
||||
//
|
||||
// Locate all REST EX binding service.
|
||||
//
|
||||
Handle = NULL;
|
||||
NoBuffer = 0;
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
&NoBuffer,
|
||||
&Handle
|
||||
);
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
|
||||
if (Handle == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
ChildHandle = NULL;
|
||||
Status = NetLibCreateServiceChild (
|
||||
Controller,
|
||||
Image,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
&NoBuffer,
|
||||
&Handle
|
||||
&ChildHandle
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Handle);
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Failed to create service child - %r \n",
|
||||
__func__,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Search for the proper REST EX instance.
|
||||
//
|
||||
while (NoBuffer != 0) {
|
||||
ChildHandle = NULL;
|
||||
Status = NetLibCreateServiceChild (
|
||||
*(Handle + (NoBuffer - 1)),
|
||||
Image,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
&ChildHandle
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiRestExProtocolGuid,
|
||||
(VOID **)&RestEx,
|
||||
Image,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the information of REST service provided by this EFI REST EX driver
|
||||
//
|
||||
Status = RestEx->GetService (
|
||||
RestEx,
|
||||
&RestExServiceInfo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Check REST EX property.
|
||||
//
|
||||
switch (ConfigType) {
|
||||
case EfiRestExConfigHttp:
|
||||
LenOfConfig = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
|
||||
break;
|
||||
|
||||
case EfiRestExConfigUnspecific:
|
||||
LenOfConfig = REST_EX_CONFIG_DATA_LEN_UNKNOWN;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
|
||||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
|
||||
{
|
||||
goto ON_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This is proper REST EX instance.
|
||||
//
|
||||
*ChildInstanceHandle = ChildHandle;
|
||||
FreePool (Handle);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ON_ERROR:;
|
||||
NetLibDestroyServiceChild (
|
||||
*(Handle + (NoBuffer - 1)),
|
||||
Image,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
ChildHandle
|
||||
);
|
||||
NoBuffer--;
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiRestExProtocolGuid,
|
||||
(VOID **)&RestEx,
|
||||
Image,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
FreePool (Handle);
|
||||
//
|
||||
// Get the information of REST service provided by this EFI REST EX driver
|
||||
//
|
||||
Status = RestEx->GetService (
|
||||
RestEx,
|
||||
&RestExServiceInfo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Check REST EX property.
|
||||
//
|
||||
switch (ConfigType) {
|
||||
case EfiRestExConfigHttp:
|
||||
LenOfConfig = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
|
||||
break;
|
||||
|
||||
case EfiRestExConfigUnspecific:
|
||||
LenOfConfig = REST_EX_CONFIG_DATA_LEN_UNKNOWN;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
|
||||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
|
||||
{
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// This is proper REST EX instance.
|
||||
//
|
||||
*ChildInstanceHandle = ChildHandle;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ON_ERROR:;
|
||||
NetLibDestroyServiceChild (
|
||||
Controller,
|
||||
Image,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
ChildHandle
|
||||
);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ CreateRestExInstance (
|
|||
EFI_STATUS Status;
|
||||
|
||||
Status = RestExLibCreateChild (
|
||||
Instance->NetworkInterface->OpenDriverControllerHandle,
|
||||
Instance->Owner,
|
||||
FixedPcdGetBool (PcdRedfishDiscoverAccessModeInBand) ? EfiRestExServiceInBandAccess : EfiRestExServiceOutOfBandAccess,
|
||||
EfiRestExConfigHttp,
|
||||
|
|
Loading…
Reference in New Issue