Revision: 14802
http://sourceforge.net/p/edk2/code/14802
Author: jiaxinwu
Date: 2013-10-25 08:05:47 +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/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
2013-10-24 23:14:10 UTC (rev 14801)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
2013-10-25 08:05:47 UTC (rev 14802)
@@ -1,7 +1,7 @@
/** @file
The entry point of IScsi driver.
-Copyright (c) 2004 - 2011, 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
@@ -24,6 +24,44 @@
};
/**
+ Tests to see if this driver supports the RemainingDevicePath.
+
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a
device path. This
+ parameter is ignored by device drivers, and
is optional for bus
+ drivers. For bus drivers, if this parameter
is not NULL, then
+ the bus driver must determine if the bus
controller specified
+ by ControllerHandle and the child
controller specified
+ by RemainingDevicePath are both supported
by this
+ bus driver.
+
+ @retval EFI_SUCCESS The RemainingDevicePath is supported or
NULL.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the
driver specified by This.
+**/
+EFI_STATUS
+IScsiIsDevicePathSupported (
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
+
+ CurrentDevicePath = RemainingDevicePath;
+ if (CurrentDevicePath != NULL) {
+ while (!IsDevicePathEnd (CurrentDevicePath)) {
+ if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) &&
(CurrentDevicePath->SubType == MSG_ISCSI_DP)) {
+ return EFI_SUCCESS;
+ }
+
+ CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
+ }
+
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
Tests to see if this driver supports a given controller. If a child device
is provided,
it further tests to see if this driver supports creating a handle for the
specified child device.
@@ -56,7 +94,6 @@
)
{
EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -82,17 +119,23 @@
return EFI_UNSUPPORTED;
}
- CurrentDevicePath = RemainingDevicePath;
- if (CurrentDevicePath != NULL) {
- while (!IsDevicePathEnd (CurrentDevicePath)) {
- if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) &&
(CurrentDevicePath->SubType == MSG_ISCSI_DP)) {
- return EFI_SUCCESS;
- }
+ Status = IScsiIsDevicePathSupported (RemainingDevicePath);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
- CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
+ if (IScsiDhcpIsConfigured (ControllerHandle)) {
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
}
-
- return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
@@ -170,7 +213,7 @@
goto ON_ERROR;
}
- //
+ //
// Always install private protocol no matter what happens later. We need to
// keep the relationship between ControllerHandle and ChildHandle.
//
Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
2013-10-24 23:14:10 UTC (rev 14801)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
2013-10-25 08:05:47 UTC (rev 14802)
@@ -1,7 +1,7 @@
/** @file
Miscellaneous routines for iSCSI driver.
-Copyright (c) 2004 - 2011, 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
@@ -617,6 +617,60 @@
}
/**
+ Check wheather the Controller is configured to use DHCP protocol.
+
+ @param[in] Controller The handle of the controller.
+
+ @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
+ )
+{
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddress;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
+ CHAR16 MacString[70];
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigDataTmp;
+
+ //
+ // Get the mac string, it's the name of various variable
+ //
+ Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ VlanId = NetLibGetVlanId (Controller);
+ IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString);
+
+ //
+ // Get the normal configuration.
+ //
+ Status = GetVariable2 (
+ MacString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&ConfigDataTmp,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+
+ if (ConfigDataTmp->Enabled && ConfigDataTmp->InitiatorInfoFromDhcp) {
+ FreePool (ConfigDataTmp);
+ return TRUE;
+ }
+
+ FreePool (ConfigDataTmp);
+ return FALSE;
+}
+
+/**
Get the various configuration data of this iSCSI instance.
@param[in] Private The iSCSI driver data.
Modified: trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
2013-10-24 23:14:10 UTC (rev 14801)
+++ trunk/edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
2013-10-25 08:05:47 UTC (rev 14802)
@@ -1,7 +1,7 @@
/** @file
Miscellaneous definitions for iSCSI driver.
-Copyright (c) 2004 - 2011, 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
@@ -222,6 +222,20 @@
);
/**
+ Check wheather the Controller is configured to use DHCP protocol.
+
+ @param[in] Controller The handle of the controller.
+
+ @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
+ );
+
+/**
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