From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 0EEE49417DA for ; Tue, 7 Nov 2023 14:00:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=j4cBHWhJ/tHS8Nio8IvPLF6Kt8WBmzyJWh0WucZ1afA=; c=relaxed/simple; d=groups.io; h=Mime-Version:Subject:From:In-Reply-To:Date:Cc:Message-Id:References:To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699365646; v=1; b=Wi6/W5ceovkaGKFn/L6VuypAMJD1buYdWc3GZeZmFPyaaJ0kEpd32IVMsetyDKuO4Y0PBsCa TvKQBIoCMmFb5uGSlgcxi//DzX9BsuDHVRuul8Kbu/JfeP9CB46c6m1sXoglwYQxyxYNpeLhsxZ ajnCrT5q1wRTiIg4KyLic1N4= X-Received: by 127.0.0.2 with SMTP id odpPYY7687511xFCrN68q0Ea; Tue, 07 Nov 2023 06:00:46 -0800 X-Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web11.11308.1699365645739833506 for ; Tue, 07 Nov 2023 06:00:46 -0800 X-Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-50930f126b1so7051852e87.3 for ; Tue, 07 Nov 2023 06:00:45 -0800 (PST) X-Gm-Message-State: WMKPSuZclMKekNfQ9rHlJ6hmx7686176AA= X-Google-Smtp-Source: AGHT+IGmzJipMuudlCCX8zw01ZY1HljrlB5LlpsySjfZl3vs9XFjBDNTxR3Xuy3y1ddXta2l+jwTRQ== X-Received: by 2002:ac2:4423:0:b0:503:2e6:6862 with SMTP id w3-20020ac24423000000b0050302e66862mr21898302lfl.32.1699365643271; Tue, 07 Nov 2023 06:00:43 -0800 (PST) X-Received: from smtpclient.apple ([185.9.78.43]) by smtp.gmail.com with ESMTPSA id o11-20020a056512230b00b00505664242cbsm357919lfu.223.2023.11.07.06.00.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2023 06:00:42 -0800 (PST) Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [edk2-devel] [PATCH v3] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx From: "Mike Maslenkin" In-Reply-To: <20231107120605.2035-1-igork@ami.com> Date: Tue, 7 Nov 2023 17:00:41 +0300 Cc: Abner Chang , Nickle Wang Message-Id: References: <20231107120605.2035-1-igork@ami.com> To: devel@edk2.groups.io, Igor Kulchytskyy Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="Wi6/W5ce"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io > On 7. 11. 2023., at 15:06, Igor Kulchytskyy via groups.io wrote: >=20 > Supported function of the driver changed to wait for all newtwork > interface to be installed. > Filer out the network interfaces which are not supported by > Redfish Host Interface. >=20 > Cc: Abner Chang > Cc: Nickle Wang > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 165 ++++++++++++++--= ---- > 1 file changed, 117 insertions(+), 48 deletions(-) >=20 > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/Redfish= Pkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > index 23da3b968f..85e47843e4 100644 > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > @@ -322,9 +322,16 @@ GetTargetNetworkInterfaceInternal ( > { > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; >=20 > + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { > + return NULL; > + } > + > ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERN= AL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > - if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNe= tworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) =3D=3D 0) = { > + if ((CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetN= etworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) =3D=3D 0)= && > + ((TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface->Netwo= rkProtocolType =3D=3D ProtocolTypeTcp6)) || > + (!TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface->Netw= orkProtocolType =3D=3D ProtocolTypeTcp4)))) > + { > return ThisNetworkInterface; > } >=20 > @@ -354,6 +361,10 @@ GetTargetNetworkInterfaceInternalByController ( > { > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; >=20 > + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { > + return NULL; > + } > + > ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERN= AL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > if (ThisNetworkInterface->OpenDriverControllerHandle =3D=3D Controlle= rHandle) { > @@ -476,6 +487,42 @@ CheckIsIpVersion6 ( > return FALSE; > } >=20 > +/** > + This function returns the IP type supported by the Host Interface. > + > + @retval 00h is Unknown > + 01h is Ipv4 > + 02h is Ipv6 > + > +**/ > +UINT8 > +GetHiIpProtocolType ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + REDFISH_OVER_IP_PROTOCOL_DATA *Data; > + REDFISH_INTERFACE_DATA *DeviceDescriptor; > + > + Data =3D NULL; > + DeviceDescriptor =3D NULL; > + if (mSmbios =3D=3D NULL) { > + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID= **)&mSmbios); > + if (EFI_ERROR (Status)) { > + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; > + } > + } > + > + Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescri= ptor, &Data); // Search for SMBIOS type 42h > + if (!EFI_ERROR (Status) && (Data !=3D NULL) && > + (Data->HostIpAssignmentType =3D=3D RedfishHostIpAssignmentStatic)) > + { > + return Data->HostIpAddressFormat; > + } > + > + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; > +} > + > /** > This function discover Redfish service through SMBIOS host interface. >=20 > @@ -512,6 +559,18 @@ DiscoverRedfishHostInterface ( >=20 > Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescrip= tor, &Data); // Search for SMBIOS type 42h > if (!EFI_ERROR (Status) && (Data !=3D NULL) && (DeviceDescriptor !=3D N= ULL)) { > + if ((Instance->NetworkInterface->NetworkProtocolType =3D=3D Protocol= TypeTcp4) && > + (Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HOST_IP_A= DDRESS_FORMAT_IP4)) // IPv4 case > + { > + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Inte= rface requires Ipv6\n", __func__)); > + return EFI_UNSUPPORTED; > + } else if ((Instance->NetworkInterface->NetworkProtocolType =3D=3D P= rotocolTypeTcp6) && > + (Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HO= ST_IP_ADDRESS_FORMAT_IP6)) // IPv6 case > + { > + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Inte= rface requires IPv4\n", __func__)); > + return EFI_UNSUPPORTED; > + } > + > // > // Check if we can reach out Redfish service using this network inter= face. > // Check with MAC address using Device Descriptor Data Device Type 04= and Type 05. > @@ -1102,6 +1161,7 @@ RedfishServiceGetNetworkInterface ( > OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE **NetworkIntfInstances > ) > { > + EFI_STATUS Status; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceI= ntn; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; > EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; > @@ -1141,13 +1201,23 @@ RedfishServiceGetNetworkInterface ( >=20 > ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_IN= TERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > + // If Get Subnet Info failed then skip this interface > + Status =3D NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, = ImageHandle); // Get subnet info > + if (EFI_ERROR (Status)) { > + if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetwor= kInterfaceIntn->Entry)) { > + break; > + } > + > + ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFA= CE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetwo= rkInterfaceIntn->Entry); > + continue; > + } > + > ThisNetworkInterface->IsIpv6 =3D FALSE; > if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) { > ThisNetworkInterface->IsIpv6 =3D TRUE; > } >=20 > CopyMem ((VOID *)&ThisNetworkInterface->MacAddress, &ThisNetworkInter= faceIntn->MacAddress, ThisNetworkInterfaceIntn->HwAddressSize); > - NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle= ); // Get subnet info. > if (!ThisNetworkInterface->IsIpv6) { > IP4_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v4, &ThisNetworkI= nterfaceIntn->SubnetAddr.v4); // IPv4 subnet information. > } else { > @@ -1230,7 +1300,12 @@ RedfishServiceAcquireService ( >=20 > if (TargetNetworkInterface !=3D NULL) { > TargetNetworkInterfaceInternal =3D GetTargetNetworkInterfaceInternal = (TargetNetworkInterface); > - NumNetworkInterfaces =3D 1; > + if (TargetNetworkInterfaceInternal =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a:No network interface on platform.\n", __f= unc__)); > + return EFI_UNSUPPORTED; > + } > + > + NumNetworkInterfaces =3D 1; > } else { > TargetNetworkInterfaceInternal =3D (EFI_REDFISH_DISCOVER_NETWORK_INTE= RFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > NumNetworkInterfaces =3D NumberOfNetworkInterface (); > @@ -1260,7 +1335,13 @@ RedfishServiceAcquireService ( > // Get subnet information in case subnet information is not set bec= ause > // RedfishServiceGetNetworkInterfaces hasn't been called yet. > // > - NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, Ima= geHandle); > + Status1 =3D NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceI= nternal, ImageHandle); > + if (EFI_ERROR (Status1)) { > + DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __fun= c__)); > + FreePool (Instance); > + continue; > + } > + > NewInstance =3D TRUE; > } >=20 > @@ -1547,25 +1628,26 @@ TestForRequiredProtocols ( > ControllerHandle, > EFI_OPEN_PROTOCOL_TEST_PROTOCOL > ); > + if (EFI_ERROR (Status)) { > + return EFI_UNSUPPORTED; > + } > + > + Status =3D gBS->OpenProtocol ( > + ControllerHandle, > + gRequiredProtocol[Index].DiscoveredProtocolGuid, > + (VOID **)&Id, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_GET_PROTOCOL > + ); > if (!EFI_ERROR (Status)) { > - Status =3D gBS->OpenProtocol ( > - ControllerHandle, > - gRequiredProtocol[Index].DiscoveredProtocolGuid, > - (VOID **)&Id, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > - if (Index =3D=3D ListCount - 1) { > - DEBUG ((DEBUG_INFO, "%a: all required protocols are found on t= his controller handle: %p.\n", __func__, ControllerHandle)); > - return EFI_SUCCESS; > - } > - } > + // Already installed > + return EFI_UNSUPPORTED; > } > } >=20 > - return EFI_UNSUPPORTED; > + DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on = this controller handle: %p.\n", __func__, ControllerHandle)); > + return EFI_SUCCESS; > } >=20 > /** > @@ -1600,10 +1682,24 @@ BuildupNetworkInterface ( > EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; > EFI_TPL OldTpl; > BOOLEAN NewNetworkInterfaceIns= talled; > + UINT8 IpType; > + UINTN ListCount; >=20 > + ListCount =3D (sizeof (gRequiredProtocol) / sizeof = (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); > NewNetworkInterfaceInstalled =3D FALSE; > Index =3D 0; > - do { > + > + // Get IP Type to filter out unnecessary network protocol if possible > + IpType =3D GetHiIpProtocolType (); > + > + for (Index =3D 0; Index < ListCount; Index++) { > + // Check IP Type and skip an unnecessary network protocol if does no= t match > + if (((gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeTcp4)= && (IpType =3D=3D REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6)) || > + ((gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeTcp6)= && (IpType =3D=3D REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4))) > + { > + continue; > + } > + > Status =3D gBS->OpenProtocol ( > // Already in list? > ControllerHandle, > @@ -1614,11 +1710,6 @@ BuildupNetworkInterface ( > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (!EFI_ERROR (Status)) { > - Index++; > - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DIS= COVER_REQUIRED_PROTOCOL))) { > - break; > - } > - > continue; > } >=20 > @@ -1631,11 +1722,6 @@ BuildupNetworkInterface ( > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (EFI_ERROR (Status)) { > - Index++; > - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DIS= COVER_REQUIRED_PROTOCOL))) { > - break; > - } > - > continue; > } >=20 > @@ -1694,11 +1780,6 @@ BuildupNetworkInterface ( > ProtocolDiscoverIdPtr > ); > if (EFI_ERROR (Status)) { > - Index++; > - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DIS= COVER_REQUIRED_PROTOCOL))) { > - break; > - } > - > continue; > } >=20 > @@ -1755,25 +1836,13 @@ BuildupNetworkInterface ( > } > } else { > DEBUG ((DEBUG_MANAGEABILITY, "%a: Not REST EX, continue with ne= xt\n", __func__)); > - Index++; > - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH= _DISCOVER_REQUIRED_PROTOCOL))) { > - break; > - } > - > continue; > } > } >=20 > return Status; > - } else { > - Index++; > - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DIS= COVER_REQUIRED_PROTOCOL))) { > - break; > - } > - > - continue; > } > - } while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVE= R_REQUIRED_PROTOCOL))); > + } >=20 > return EFI_DEVICE_ERROR; > } > -- > 2.37.1.windows.1 > -The information contained in this message may be confidential and propri= etary to American Megatrends (AMI). This communication is intended to be re= ad only by the individual or entity to whom it is addressed or by their des= ignee. If the reader of this message is not the intended recipient, you are= on notice that any distribution of this message, in any form, is strictly = prohibited. Please promptly notify the sender by reply e-mail or by telepho= ne at 770-246-8600, and then delete or destroy all copies of the transmissi= on. Nice! Ack. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110853): https://edk2.groups.io/g/devel/message/110853 Mute This Topic: https://groups.io/mt/102441003/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-