]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix a bug. iSCSI driver doesn’t follow driver model Start()/Stop() in case no configu...
authorhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Jul 2010 08:54:45 +0000 (08:54 +0000)
committerhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Jul 2010 08:54:45 +0000 (08:54 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10740 6f19259b-4bc3-4df7-8a09-765794883524

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

index e673705c45815896aa020709a415942ea853d272..920cc945569c8233fac4361706ddffef1738a259 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The entry point of IScsi driver.\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -137,16 +137,61 @@ IScsiDriverBindingStart (
 {\r
   EFI_STATUS        Status;\r
   ISCSI_DRIVER_DATA *Private;\r
+  VOID              *Interface;\r
+\r
+  Private = IScsiCreateDriverData (This->DriverBindingHandle, ControllerHandle);\r
+  if (Private == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Create a underlayer child instance, but not need to configure it. Just open ChildHandle\r
+  // via BY_DRIVER. That is, establishing the relationship between ControllerHandle and ChildHandle.\r
+  // Therefore, when DisconnectController(), especially VLAN virtual controller handle,\r
+  // IScsiDriverBindingStop() will be called.\r
+  //\r
+  Status = NetLibCreateServiceChild (\r
+             ControllerHandle,\r
+             This->DriverBindingHandle,\r
+             &gEfiTcp4ServiceBindingProtocolGuid,\r
+             &Private->ChildHandle\r
+             );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Private->ChildHandle,\r
+                  &gEfiTcp4ProtocolGuid,\r
+                  &Interface,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\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
+  Status = gBS->InstallProtocolInterface (\r
+                  &ControllerHandle,\r
+                  &gIScsiPrivateGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &Private->IScsiIdentifier\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
 \r
   //\r
   // Try to add a port configuration page for this controller.\r
   //\r
   IScsiConfigUpdateForm (This->DriverBindingHandle, ControllerHandle, TRUE);\r
 \r
-  Private = IScsiCreateDriverData (This->DriverBindingHandle, ControllerHandle);\r
-  if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
   //\r
   // Get the iSCSI configuration data of this controller.\r
   //\r
@@ -190,19 +235,7 @@ IScsiDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
-  //\r
-  // Install the iSCSI private stuff as a flag to indicate this controller\r
-  // is already controlled by iSCSI driver.\r
-  //\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &ControllerHandle,\r
-                  &gIScsiPrivateGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &Private->IScsiIdentifier\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
+\r
   //\r
   // Update/Publish the iSCSI Boot Firmware Table.\r
   //\r
@@ -213,7 +246,6 @@ IScsiDriverBindingStart (
 ON_ERROR:\r
 \r
   IScsiSessionAbort (&Private->Session);\r
-  IScsiCleanDriverData (Private);\r
 \r
   return Status;\r
 }\r
@@ -312,6 +344,27 @@ IScsiDriverBindingStop (
 \r
   Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);\r
 \r
+  if (Private->ChildHandle != NULL) {\r
+    Status = gBS->CloseProtocol (\r
+                    Private->ChildHandle,\r
+                    &gEfiTcp4ProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    IScsiController\r
+                    );\r
+\r
+    ASSERT (!EFI_ERROR (Status));\r
+\r
+    Status = NetLibDestroyServiceChild (\r
+               IScsiController,\r
+               This->DriverBindingHandle,\r
+               &gEfiTcp4ServiceBindingProtocolGuid,\r
+               Private->ChildHandle\r
+               );\r
+    ASSERT (!EFI_ERROR (Status));\r
+  }\r
+\r
+  IScsiConfigUpdateForm (This->DriverBindingHandle, IScsiController, FALSE);\r
+\r
   //\r
   // Uninstall the private protocol.\r
   //\r
index b1e804fcdb8fae6df8d2c97690ad78c988b23986..8c761f882c65f511b1a587ad12c85a431541ee9f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header file of IScsiImpl.c.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -153,7 +153,7 @@ struct _ISCSI_DRIVER_DATA {
   EFI_HANDLE                      Image;\r
   EFI_HANDLE                      Controller;\r
   ISCSI_PRIVATE_PROTOCOL          IScsiIdentifier;\r
-\r
+  EFI_HANDLE                      ChildHandle;\r
   EFI_EVENT                       ExitBootServiceEvent;\r
 \r
   EFI_EXT_SCSI_PASS_THRU_PROTOCOL IScsiExtScsiPassThru;\r