+GetHiIpProtocolType()
+{
+ EFI_STATUS Status;
+ REDFISH_OVER_IP_PROTOCOL_DATA *Data;
+ REDFISH_INTERFACE_DATA *DeviceDescriptor;
+
+ Data = NULL;
+ DeviceDescriptor = NULL;
+ if (mSmbios == NULL) {
+ Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+ if (EFI_ERROR (Status)) {
+ return 0;
In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.
+ }
+ }
+ Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+ if (!EFI_ERROR (Status) && (Data != NULL) &&
+ (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+ return Data->HostIpAddressFormat;
+ }
+ return 0;
Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
+}
+
/**
This function discover Redfish service through SMBIOS host interface.
@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (
Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+ if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+ DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));
Missed argument for %a format
Missed space "DEBUG (("
Igor: Inattentiveness. Thank you.
+ return EFI_UNSUPPORTED;
+ }
+ else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+ DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));
Missed argument for %a format
Missed space "DEBUG (("
Igor: Inattentiveness. Thank you.
+ return EFI_UNSUPPORTED;
+ }
//
// Check if we can reach out Redfish service using this network interface.
// Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE **NetworkIntfInstances
)
{
+ EFI_STATUS Status;
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceIntn;
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface;
EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (
ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
while (TRUE) {
+ // If Get Subnet Info skip this interface
+ Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+ if (EFI_ERROR(Status)) {
+ if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+ break;
+ }
+ ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+ continue;
+ }
+
ThisNetworkInterface->IsIpv6 = FALSE;
if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
// Get subnet information in case subnet information is not set because
// RedfishServiceGetNetworkInterfaces hasn't been called yet.
//
- NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+ Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+ if (EFI_ERROR(Status1)) {
+ DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+ FreePool(Instance);
+ continue;
+ }
NewInstance = TRUE;
}
@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
UINT32 *Id;
UINTN Index;
EFI_STATUS Status;
- UINTN ListCount;
+ UINTN ListCount, SuccessfulCount = 0;
ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
- if (Index == ListCount - 1) {
- DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
- return EFI_SUCCESS;
- }
+ SuccessfulCount++;
}
It may be SuccessfulCount must have one indentation less, i.e in scope
of upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.
Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.