]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Update iSCSI driver to check existing AIP instances
authorYe Ting <ting.ye@intel.com>
Fri, 18 Dec 2015 06:31:31 +0000 (06:31 +0000)
committertye1 <tye1@Edk2>
Fri, 18 Dec 2015 06:31:31 +0000 (06:31 +0000)
According to UEFI spec, iSCSI HBA must install an AIP instance
with network boot information block. This patch updates UEFI
iSCSI driver to check whether there are AIP instances installed
by iSCSI HBA adapter and if yes, the UEFI iSCSI driver will return
EFI_ABORTED in its driver binding Start(). Also the patch
introduces a PCD PcdIScsiAIPNetworkBootPolicy for
platform owner to define particular policy when the iSCSI HBA
will survive and UEFI iSCSI will fail. The default policy is
STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD which means that when ISCSI HBA
adapter installs an AIP and claims it supports an offload engine
for iSCSI boot, the UEFI iSCSI driver will return EFI_ABORTED.

The patch V2 adds a new value ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_AIP
to PCD PcdIScsiAIPNetworkBootPolicy. This allows the platform to
avoid running into buggy IHV drivers that have issue with AIP.
It is suggested by El-Haj-Mahmoud,Samer <samer.el-haj-mahmoud@hpe.com>.

Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19367 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/IScsiDxe/IScsiDriver.c
NetworkPkg/IScsiDxe/IScsiDriver.h
NetworkPkg/IScsiDxe/IScsiDxe.inf
NetworkPkg/IScsiDxe/IScsiImpl.h
NetworkPkg/NetworkPkg.dec
NetworkPkg/NetworkPkg.uni

index 363daadc8f70db50da558924ad0268342a595f61..a7031dfc4ed8d47c77c6b0672b269840ad257dca 100644 (file)
@@ -74,6 +74,142 @@ IScsiIsDevicePathSupported (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Check whether an iSCSI HBA adapter already installs an AIP instance with\r
+  network boot policy matching the value specified in PcdIScsiAIPNetworkBootPolicy.\r
+  If yes, return EFI_SUCCESS.\r
+\r
+  @retval EFI_SUCCESS              Found an AIP with matching network boot policy.\r
+  @retval EFI_NOT_FOUND            AIP is unavailable or the network boot policy\r
+                                   not matched.\r
+**/\r
+EFI_STATUS\r
+IScsiCheckAip (\r
+  )\r
+{\r
+  UINTN                            AipHandleCount;\r
+  EFI_HANDLE                       *AipHandleBuffer;\r
+  UINTN                            AipIndex;\r
+  EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
+  EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *ExtScsiPassThru;\r
+  EFI_GUID                         *InfoTypesBuffer;\r
+  UINTN                            InfoTypeBufferCount;\r
+  UINTN                            TypeIndex;\r
+  VOID                             *InfoBlock;\r
+  UINTN                            InfoBlockSize;\r
+  BOOLEAN                          Supported;\r
+  EFI_ADAPTER_INFO_NETWORK_BOOT    *NetworkBoot;\r
+  EFI_STATUS                       Status;\r
+  UINT8                            NetworkBootPolicy;\r
+\r
+  //\r
+  // Check any AIP instances exist in system.\r
+  //\r
+  AipHandleCount = 0;\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiAdapterInformationProtocolGuid,\r
+                  NULL,\r
+                  &AipHandleCount,\r
+                  &AipHandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status) || AipHandleCount == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  InfoBlock = NULL;\r
+\r
+  for (AipIndex = 0; AipIndex < AipHandleCount; AipIndex++) {\r
+    Status = gBS->HandleProtocol (\r
+                    AipHandleBuffer[AipIndex],\r
+                    &gEfiAdapterInformationProtocolGuid,\r
+                    (VOID *) &Aip\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+    ASSERT (Aip != NULL);\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    AipHandleBuffer[AipIndex],\r
+                    &gEfiExtScsiPassThruProtocolGuid,\r
+                    (VOID *) &ExtScsiPassThru\r
+                    );\r
+    if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) {\r
+      continue;\r
+    }\r
+\r
+    InfoTypesBuffer     = NULL;\r
+    InfoTypeBufferCount = 0;\r
+    Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);\r
+    if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {\r
+      continue;\r
+    }\r
+    //\r
+    // Check whether the AIP instance has Network boot information block.\r
+    //\r
+    Supported = FALSE;\r
+    for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) {\r
+      if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
+        Supported = TRUE;\r
+        break;\r
+      }\r
+    }\r
+\r
+    FreePool (InfoTypesBuffer);\r
+    if (!Supported) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // We now have network boot information block.\r
+    //\r
+    InfoBlock     = NULL;\r
+    InfoBlockSize = 0;\r
+    Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);\r
+    if (EFI_ERROR (Status) || InfoBlock == NULL) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Check whether the network boot policy matches.\r
+    //\r
+    NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock;\r
+    NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);\r
+\r
+    if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) {\r
+      Status = EFI_SUCCESS;\r
+      goto Exit;\r
+    }\r
+    if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 &&\r
+         !NetworkBoot->iScsiIpv4BootCapablity) ||\r
+         ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 &&\r
+         !NetworkBoot->iScsiIpv6BootCapablity) ||\r
+         ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 &&\r
+         !NetworkBoot->OffloadCapability) ||\r
+         ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 &&\r
+         !NetworkBoot->iScsiMpioCapability) ||\r
+         ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 &&\r
+         !NetworkBoot->iScsiIpv4Boot) ||\r
+         ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 &&\r
+         !NetworkBoot->iScsiIpv6Boot)) {\r
+      FreePool (InfoBlock);\r
+      continue;\r
+    }\r
+\r
+    Status = EFI_SUCCESS;\r
+    goto Exit;\r
+  }\r
+\r
+  Status = EFI_NOT_FOUND;\r
+\r
+Exit:\r
+  if (InfoBlock != NULL) {\r
+    FreePool (InfoBlock);\r
+  }\r
+  if (AipHandleBuffer != NULL) {\r
+    FreePool (AipHandleBuffer);\r
+  }\r
+  return Status;\r
+}\r
 \r
 /**\r
   Tests to see if this driver supports a given controller. This is the worker function for\r
@@ -215,6 +351,7 @@ IScsiStart (
   BOOLEAN                         NeedUpdate;\r
   VOID                            *Interface;\r
   EFI_GUID                        *ProtocolGuid;\r
+  UINT8                           NetworkBootPolicy;\r
 \r
   //\r
   // Test to see if iSCSI driver supports the given controller.\r
@@ -256,6 +393,20 @@ IScsiStart (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);\r
+  if (NetworkBootPolicy != ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_AIP) {\r
+    //\r
+    // Check existing iSCSI AIP.\r
+    //\r
+    Status = IScsiCheckAip ();\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Find iSCSI AIP with specified network boot policy. return EFI_ABORTED.\r
+      //\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  \r
   //\r
   // Record the incoming NIC info.\r
   //\r
index 338e3dcf188b30b99a0a802e87e3888b324bb0bd..9e59b3857ed38d903cc18c2743d6a23d1f970347 100644 (file)
@@ -29,6 +29,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define IP_MODE_AUTOCONFIG_IP4     3\r
 #define IP_MODE_AUTOCONFIG_IP6     4\r
+#define ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_AIP    0x00\r
+#define STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP      0x01\r
+#define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4      0x02\r
+#define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6      0x04\r
+#define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD  0x08\r
+#define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO     0x10\r
+#define STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4   0x20\r
+#define STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6   0x40\r
 \r
 extern EFI_COMPONENT_NAME2_PROTOCOL       gIScsiComponentName2;\r
 extern EFI_COMPONENT_NAME_PROTOCOL        gIScsiComponentName;\r
index 3e20828c51808659ffa48030c648d5d6d6852eaa..89521209b7cff3a2f6067637365a685a338711eb 100644 (file)
@@ -4,7 +4,7 @@
 #  The iSCSI driver provides iSCSI service in the preboot environment and supports\r
 #  booting over iSCSI.\r
 #                                                    \r
-# Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
   ## UNDEFINED # Variable\r
   gEfiIScsiInitiatorNameProtocolGuid\r
   ## PRODUCES       \r
-  gEfiAuthenticationInfoProtocolGuid            \r
+  gEfiAuthenticationInfoProtocolGuid\r
+  ## CONSUMES\r
+  gEfiAdapterInformationProtocolGuid\r
 \r
 [Guids]\r
   gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event\r
   gEfiAcpiTableGuid                             ## SOMETIMES_CONSUMES ## SystemTable\r
   gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES ## SystemTable\r
   gEfiAcpi20TableGuid                           ## SOMETIMES_CONSUMES ## SystemTable\r
+  gEfiAdapterInfoNetworkBootGuid                ## SOMETIMES_CONSUMES ## UNDEFINED\r
   \r
   ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"\r
   ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"\r
   ## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData     mVendorStorageName\r
   ## SOMETIMES_CONSUMES ## HII\r
   gIScsiConfigGuid\r
+\r
+[Pcd]\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy ## CONSUMES\r
   \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   IScsiDxeExtra.uni\r
index 7c8eb3784208cb3fd76bc66a712de7afd0ab3c2e..9941b8c3ea11eeb88f014f9e259d5f6d02098582 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The shared head file for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/AuthenticationInfo.h>\r
 #include <Protocol/IScsiInitiatorName.h>\r
 #include <Protocol/ScsiPassThruExt.h>\r
+#include <Protocol/AdapterInformation.h>\r
 \r
 #include <Library/HiiLib.h>\r
 #include <Library/UefiHiiServicesLib.h>\r
index de5dabea36180e3e03bb138729a90fc7ce4004ce..288d1aad2ba102acaf4ca9fb138be7d83190cbb4 100644 (file)
   # @Prompt Type Value of Dhcp6 Unique Identifier (DUID).\r
   gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType|4|UINT8|0x10000001\r
 \r
+  ## Network boot policy to stop UEFI iSCSI if applicable.\r
+  # 0x00 = Always use UEFI iSCSI and ignore AIP.\r
+  # 0x01 = Stop UEFI iSCSI if iSCSI HBA adapter produces AIP protocol with Network Boot.\r
+  # 0x02 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv4 targets.\r
+  # 0x04 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv6 targets.\r
+  # 0x08 = Stop UEFI iSCSI if iSCSI HBA adapter supports an offload engine for iSCSI boot.\r
+  # 0x10 = Stop UEFI iSCSI if iSCSI HBA adapter supports multipath I/O for iSCSI boot.\r
+  # 0x20 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv4 targets.\r
+  # 0x40 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv6 targets.\r
+  # @Prompt Type Value of network boot policy used in iSCSI.\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy|0x08|UINT8|0x10000007\r
+\r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   NetworkPkgExtra.uni\r
index a1b0185257eb026da2038b9102ddb1abd561d3cb..7e6dec7f3237b5309b63564b0ee49983e089898c 100644 (file)
Binary files a/NetworkPkg/NetworkPkg.uni and b/NetworkPkg/NetworkPkg.uni differ