]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix a bug about the iSCSI DHCP dependency issue.
authorWu Jiaxin <jiaxin.wu@intel.com>
Fri, 25 Oct 2013 08:05:47 +0000 (08:05 +0000)
committerjiaxinwu <jiaxinwu@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Oct 2013 08:05:47 +0000 (08:05 +0000)
Create rules to determine whether iSCSI need DHCP protocol in current configuration by examining user’s configuration data in DriverBindingSupported().

Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com >
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14802 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h

index f668fe3d9c8579ed590fb779344a58c8e4c34907..f4663d9f59c1837328ad45864f35a634cead7f23 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The entry point of IScsi driver.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -23,6 +23,44 @@ EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
   NULL\r
 };\r
 \r
+/**\r
+  Tests to see if this driver supports the RemainingDevicePath. \r
+\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For bus drivers, if this parameter is not NULL, then \r
+                                   the bus driver must determine if the bus controller specified \r
+                                   by ControllerHandle and the child controller specified \r
+                                   by RemainingDevicePath are both supported by this \r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The RemainingDevicePath is supported or NULL.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+IScsiIsDevicePathSupported (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;\r
+\r
+  CurrentDevicePath = RemainingDevicePath;\r
+  if (CurrentDevicePath != NULL) {\r
+    while (!IsDevicePathEnd (CurrentDevicePath)) {\r
+      if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) {\r
+        return EFI_SUCCESS;\r
+      }\r
+\r
+      CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);\r
+    }\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Tests to see if this driver supports a given controller. If a child device is provided, \r
   it further tests to see if this driver supports creating a handle for the specified child device.\r
@@ -56,7 +94,6 @@ IScsiDriverBindingSupported (
   )\r
 {\r
   EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;\r
 \r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -82,17 +119,23 @@ IScsiDriverBindingSupported (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  CurrentDevicePath = RemainingDevicePath;\r
-  if (CurrentDevicePath != NULL) {\r
-    while (!IsDevicePathEnd (CurrentDevicePath)) {\r
-      if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) {\r
-        return EFI_SUCCESS;\r
-      }\r
+  Status = IScsiIsDevicePathSupported (RemainingDevicePath);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
-      CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);\r
+  if (IScsiDhcpIsConfigured (ControllerHandle)) {\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDhcp4ServiceBindingProtocolGuid,\r
+                    NULL,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
     }\r
-\r
-    return EFI_UNSUPPORTED;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -170,7 +213,7 @@ IScsiDriverBindingStart (
     goto ON_ERROR;\r
   }\r
 \r
-  //
+  //\r
   // Always install private protocol no matter what happens later. We need to \r
   // keep the relationship between ControllerHandle and ChildHandle.\r
   //\r
index 5341e5a01ef8bf1187b0272b88714ab040d08d14..16ffec09bdbbe6c4bec40457872622dc6af4317d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous routines for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -616,6 +616,60 @@ IScsiCleanDriverData (
   FreePool (Private);\r
 }\r
 \r
+/**\r
+  Check wheather the Controller is configured to use DHCP protocol.\r
+\r
+  @param[in]  Controller           The handle of the controller.\r
+  \r
+  @retval TRUE                     The handle of the controller need the Dhcp protocol.\r
+  @retval FALSE                    The handle of the controller does not need the Dhcp protocol.\r
+  \r
+**/\r
+BOOLEAN\r
+IScsiDhcpIsConfigured (\r
+  IN EFI_HANDLE  Controller\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_MAC_ADDRESS             MacAddress;\r
+  UINTN                       HwAddressSize;\r
+  UINT16                      VlanId;\r
+  CHAR16                      MacString[70];\r
+  ISCSI_SESSION_CONFIG_NVDATA *ConfigDataTmp;\r
+\r
+  //\r
+  // Get the mac string, it's the name of various variable\r
+  //\r
+  Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+  VlanId = NetLibGetVlanId (Controller);\r
+  IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString);\r
+\r
+  //\r
+  // Get the normal configuration.\r
+  //\r
+  Status = GetVariable2 (\r
+             MacString,\r
+             &gEfiIScsiInitiatorNameProtocolGuid,\r
+             (VOID**)&ConfigDataTmp,\r
+             NULL\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+  \r
+\r
+  if (ConfigDataTmp->Enabled && ConfigDataTmp->InitiatorInfoFromDhcp) {\r
+    FreePool (ConfigDataTmp);\r
+    return TRUE;\r
+  }\r
+\r
+  FreePool (ConfigDataTmp);\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Get the various configuration data of this iSCSI instance.\r
 \r
index 512c67c38c74855f635e16de9463962e2c59af67..b310c9c579aabcd39276be6a01780690709965ef 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous definitions for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -221,6 +221,20 @@ IScsiCleanDriverData (
   IN ISCSI_DRIVER_DATA  *Private\r
   );\r
 \r
+/**\r
+  Check wheather the Controller is configured to use DHCP protocol.\r
+\r
+  @param[in]  Controller           The handle of the controller.\r
+  \r
+  @retval TRUE                     The handle of the controller need the Dhcp protocol.\r
+  @retval FALSE                    The handle of the controller does not need the Dhcp protocol.\r
+  \r
+**/\r
+BOOLEAN\r
+IScsiDhcpIsConfigured (\r
+  IN EFI_HANDLE  Controller\r
+  );\r
+\r
 /**\r
   Get the various configuration data of this iSCSI instance.\r
 \r