public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Mike Maslenkin" <mike.maslenkin@gmail.com>
To: Igor Kulchytskyy <igork@ami.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Abner Chang <abner.chang@amd.com>,
	 Nickle Wang <nicklew@nvidia.com>
Subject: Re: [edk2-devel] [PATCH v2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
Date: Fri, 3 Nov 2023 18:54:10 +0300	[thread overview]
Message-ID: <CAL77WPC+D=9y6FgMW8yAtLN6WW_HRJDixNEK-Wh9VyU7TmDBYw@mail.gmail.com> (raw)
In-Reply-To: <20231101201704.1504-1-igork@ami.com>

On Wed, Nov 1, 2023 at 11:17 PM Igor Kulchytskyy <igork@ami.com> wrote:
>
> 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.
>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
> Signed-off-by: Igor Kulchytskyy <igork@ami.com>
> ---
>  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 131 ++++++++++++++------
>  1 file changed, 95 insertions(+), 36 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 23da3b968f..c67b8acf12 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +
>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> -    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
> +    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
> +        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
> +            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
>        return ThisNetworkInterface;
>      }
>
> @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +
>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
>      if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
> @@ -476,6 +486,39 @@ CheckIsIpVersion6 (
>    return FALSE;
>  }
>
> +/**
> +  This function returns the  IP type supported by the Host Interface
> +
> +  @retval IP Type
> +  //  Unknown=00h,
> +  //  Ipv4=01h,
> +  //  Ipv6=02h,
> +
> +**/
> +STATIC
> +UINT8
> +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 REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> +    }
> +  }
> +  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
> +  if (!EFI_ERROR (Status) && (Data != NULL) &&
> +      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
> +      return Data->HostIpAddressFormat;
> +  }
> +  return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> +}
> +
>  /**
>    This function discover Redfish service through SMBIOS host interface.
>
> @@ -512,6 +555,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", __func__));
> +      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", __func__));
> +      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 +1154,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 +1194,16 @@ RedfishServiceGetNetworkInterface (
>
>    ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> +    // If Get Subnet Info failed then 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;

Now this loop looks like:

while (TRUE) {
    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn,
ImageHandle); // Get subnet info
    if (EFI_ERROR (Status)) {
      if (Cond) {
        break;
      }
      continue;
    }

    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
    }
    CopyMem ((VOID *)&ThisNetworkInterface->MacAddress,
&ThisNetworkInterfaceIntn->MacAddress,
ThisNetworkInterfaceIntn->HwAddressSize);
    NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn,
ImageHandle); // Get subnet info.
....

It seems the second call NetworkInterfaceGetSubnetInfo()  is not required.


Regards,
Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110644): https://edk2.groups.io/g/devel/message/110644
Mute This Topic: https://groups.io/mt/102328322/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2023-11-03 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 20:17 [edk2-devel] [PATCH v2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx Igor Kulchytskyy via groups.io
2023-11-02  2:56 ` Nickle Wang via groups.io
2023-11-02 20:58   ` Igor Kulchytskyy via groups.io
2023-11-02  8:03 ` Chang, Abner via groups.io
2023-11-03 15:54 ` Mike Maslenkin [this message]
2023-11-03 18:01   ` Igor Kulchytskyy via groups.io
     [not found]   ` <17942EE0F919609E.3650@groups.io>
2023-11-06  3:16     ` Igor Kulchytskyy via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL77WPC+D=9y6FgMW8yAtLN6WW_HRJDixNEK-Wh9VyU7TmDBYw@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox