Revision: 14803
          http://sourceforge.net/p/edk2/code/14803
Author:   jiaxinwu
Date:     2013-10-25 08:07:26 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
Fix a bug about the iSCSI DHCP dependency issue.
Create rules to determine whether iSCSI need DHCP protocol in current 
configuration by examining user?\226?\128?\153s configuration data in 
DriverBindingSupported().

Signed-off-by: Wu Jiaxin <[email protected] >
Reviewed-by: Ye Ting <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>

Modified Paths:
--------------
    trunk/edk2/NetworkPkg/IScsiDxe/IScsiDriver.c
    trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.c
    trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h

Modified: trunk/edk2/NetworkPkg/IScsiDxe/IScsiDriver.c
===================================================================
--- trunk/edk2/NetworkPkg/IScsiDxe/IScsiDriver.c        2013-10-25 08:05:47 UTC 
(rev 14802)
+++ trunk/edk2/NetworkPkg/IScsiDxe/IScsiDriver.c        2013-10-25 08:07:26 UTC 
(rev 14803)
@@ -112,13 +112,16 @@
   EFI_STATUS                Status;
   EFI_GUID                  *IScsiServiceBindingGuid;
   EFI_GUID                  *TcpServiceBindingGuid;
+  EFI_GUID                  *DhcpServiceBindingGuid;
 
   if (IpVersion == IP_VERSION_4) {
     IScsiServiceBindingGuid  = &gIScsiV4PrivateGuid;
     TcpServiceBindingGuid    = &gEfiTcp4ServiceBindingProtocolGuid;
+    DhcpServiceBindingGuid   = &gEfiDhcp4ServiceBindingProtocolGuid;
   } else {
     IScsiServiceBindingGuid  = &gIScsiV6PrivateGuid;
     TcpServiceBindingGuid    = &gEfiTcp6ServiceBindingProtocolGuid;
+    DhcpServiceBindingGuid   = &gEfiDhcp6ServiceBindingProtocolGuid;
   }
 
   Status = gBS->OpenProtocol (
@@ -131,24 +134,40 @@
                   );
   if (!EFI_ERROR (Status)) {
     return EFI_ALREADY_STARTED;
-  } else {
+  }
+
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
+                  TcpServiceBindingGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+  if (EFI_ERROR (Status)) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = IScsiIsDevicePathSupported (RemainingDevicePath);
+  if (EFI_ERROR (Status)) {
+    return EFI_UNSUPPORTED;
+  }
+
+  if (IScsiDhcpIsConfigured (ControllerHandle, IpVersion)) {
     Status = gBS->OpenProtocol (
                     ControllerHandle,
-                    TcpServiceBindingGuid,
+                    DhcpServiceBindingGuid,
                     NULL,
                     This->DriverBindingHandle,
                     ControllerHandle,
                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                     );
-    if (!EFI_ERROR (Status)) {
-      Status = IScsiIsDevicePathSupported (RemainingDevicePath);
-      if (!EFI_ERROR (Status)) {
-        return EFI_SUCCESS;
-      }
+    if (EFI_ERROR (Status)) {
+      return EFI_UNSUPPORTED;
     }
   }
-
-  return EFI_UNSUPPORTED;
+  
+  return EFI_SUCCESS;
 }
 
 

Modified: trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.c
===================================================================
--- trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.c  2013-10-25 08:05:47 UTC (rev 
14802)
+++ trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.c  2013-10-25 08:07:26 UTC (rev 
14803)
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous routines for iSCSI driver.
 
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -890,7 +890,100 @@
   FreePool (Private);
 }
 
+/**
+  Check wheather the Controller handle is configured to use DHCP protocol.
 
+  @param[in]  Controller           The handle of the controller.
+  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
+  
+  @retval TRUE                     The handle of the controller need the Dhcp 
protocol.
+  @retval FALSE                    The handle of the controller does not need 
the Dhcp protocol.
+  
+**/
+BOOLEAN
+IScsiDhcpIsConfigured (
+  IN EFI_HANDLE  Controller,
+  IN UINT8       IpVersion
+  )
+{
+  ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+  UINT8                       *AttemptConfigOrder;
+  UINTN                       AttemptConfigOrderSize;
+  UINTN                       Index;
+  EFI_STATUS                  Status;
+  EFI_MAC_ADDRESS             MacAddr;
+  UINTN                       HwAddressSize;
+  UINT16                      VlanId;
+  CHAR16                      MacString[ISCSI_MAX_MAC_STRING_LEN];
+  CHAR16                      AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
+  
+  AttemptConfigOrder = IScsiGetVariableAndSize (
+                         L"AttemptOrder",
+                         &gIScsiConfigGuid,
+                         &AttemptConfigOrderSize
+                         );
+  if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+    return FALSE;
+  }
+  
+  //
+  // Get MAC address of this network device.
+  //
+  Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
+  if(EFI_ERROR (Status)) {
+    return FALSE;
+  }
+  //
+  // Get VLAN ID of this network device.
+  //
+  VlanId = NetLibGetVlanId (Controller);
+  IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
+  
+  for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
+    UnicodeSPrint (
+      AttemptName,
+      (UINTN) 128,
+      L"%s%d",
+      MacString,
+      (UINTN) AttemptConfigOrder[Index]
+      );
+    Status = GetVariable2 (
+               AttemptName,
+               &gEfiIScsiInitiatorNameProtocolGuid,
+               (VOID**)&AttemptTmp,
+               NULL
+               );
+    if(EFI_ERROR (Status)) {
+      continue;
+    }
+    ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);
+
+    if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {
+      FreePool (AttemptTmp);
+      continue;
+    }
+
+    if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG && 
+        AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? 
IP_MODE_IP4 : IP_MODE_IP6)) {
+      FreePool (AttemptTmp);
+      continue;
+    }
+    
+    if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG ||
+       AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE ||
+       AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) { 
+      FreePool (AttemptTmp);
+      FreePool (AttemptConfigOrder);
+      return TRUE;
+    }
+
+    FreePool (AttemptTmp);
+  }
+  
+  FreePool (AttemptConfigOrder);
+  return FALSE;
+}
+
 /**
   Get the various configuration data.
 

Modified: trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h
===================================================================
--- trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h  2013-10-25 08:05:47 UTC (rev 
14802)
+++ trunk/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h  2013-10-25 08:07:26 UTC (rev 
14803)
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous definitions for iSCSI driver.
 
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -299,6 +299,22 @@
   );
 
 /**
+  Check wheather the Controller handle is configured to use DHCP protocol.
+
+  @param[in]  Controller           The handle of the controller.
+  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
+  
+  @retval TRUE                     The handle of the controller need the Dhcp 
protocol.
+  @retval FALSE                    The handle of the controller does not need 
the Dhcp protocol.
+  
+**/
+BOOLEAN
+IScsiDhcpIsConfigured (
+  IN EFI_HANDLE  Controller,
+  IN UINT8       IpVersion
+  );
+
+/**
   Get the various configuration data of this iSCSI instance.
 
   @param[in]  Private   The iSCSI driver data.

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to