]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Verified ChildHandle, and correct the name for a child.
authorWu Jiaxin <jiaxin.wu@intel.com>
Wed, 4 Feb 2015 05:47:07 +0000 (05:47 +0000)
committerjiaxinwu <jiaxinwu@Edk2>
Wed, 4 Feb 2015 05:47:07 +0000 (05:47 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
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@16740 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/IScsiDxe/ComponentName.c

index 1ee21f5d5d33b807f3c1e023d680abcf8e33c08f..46d89d855ca38bb5b53017a2e682bf3fa78d10d2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Component Name(2) protocol implementation for iSCSI.\r
 \r
 /** @file\r
   UEFI Component Name(2) protocol implementation for iSCSI.\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
 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
@@ -102,9 +102,9 @@ IScsiComponentNameGetDriverName (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Update the component name for the iSCSI NIC handle.\r
+  Update the component name for the iSCSI instance.\r
 \r
 \r
-  @param[in]  Controller            The handle of the NIC controller.\r
+  @param[in]  IScsiExtScsiPassThru  A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param[in]  Ipv6Flag              TRUE if IP6 network stack is used.\r
   \r
   @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.\r
   @param[in]  Ipv6Flag              TRUE if IP6 network stack is used.\r
   \r
   @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.\r
@@ -114,58 +114,28 @@ IScsiComponentNameGetDriverName (
 **/\r
 EFI_STATUS\r
 UpdateName (\r
 **/\r
 EFI_STATUS\r
 UpdateName (\r
-  IN   EFI_HANDLE  Controller,\r
+  IN   EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru,\r
   IN   BOOLEAN     Ipv6Flag\r
   )\r
 {\r
   IN   BOOLEAN     Ipv6Flag\r
   )\r
 {\r
-  EFI_STATUS                  Status;\r
-  EFI_MAC_ADDRESS             MacAddr;\r
-  UINTN                       HwAddressSize;\r
-  UINT16                      VlanId;\r
-  ISCSI_NIC_INFO              *ThisNic;\r
-  ISCSI_NIC_INFO              *NicInfo;\r
-  LIST_ENTRY                  *Entry;\r
-  CHAR16                      HandleName[80];\r
+  EFI_STATUS                       Status;\r
+  CHAR16                           HandleName[80];\r
+  ISCSI_DRIVER_DATA                *Private;\r
+  UINT8                            NicIndex;\r
 \r
 \r
-  //\r
-  // Get MAC address of this network device.\r
-  //\r
-  Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get VLAN ID of this network device.\r
-  //\r
-  VlanId = NetLibGetVlanId (Controller);\r
-\r
-  //\r
-  // Check whether the NIC information exists.\r
-  //\r
-  ThisNic = NULL;\r
-\r
-  NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {\r
-    NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);\r
-    if (NicInfo->HwAddressSize == HwAddressSize &&\r
-        CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&\r
-        NicInfo->VlanId == VlanId) {\r
-\r
-      ThisNic = NicInfo;\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (ThisNic == NULL) {\r
-    return EFI_UNSUPPORTED;\r
+  if (IScsiExtScsiPassThru == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
   }\r
-\r
+  \r
+  Private  = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru);\r
+  NicIndex = Private->Session->ConfigData->NicIndex;\r
+    \r
   UnicodeSPrint (\r
     HandleName,\r
     sizeof (HandleName),\r
     L"iSCSI (%s, NicIndex=%d)",\r
     Ipv6Flag ? L"IPv6" : L"IPv4",\r
   UnicodeSPrint (\r
     HandleName,\r
     sizeof (HandleName),\r
     L"iSCSI (%s, NicIndex=%d)",\r
     Ipv6Flag ? L"IPv6" : L"IPv4",\r
-    ThisNic->NicIndex\r
+    NicIndex\r
   );\r
 \r
   if (gIScsiControllerNameTable != NULL) {\r
   );\r
 \r
   if (gIScsiControllerNameTable != NULL) {\r
@@ -193,7 +163,6 @@ UpdateName (
            );\r
 }\r
 \r
            );\r
 }\r
 \r
-\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
   that is being managed by a driver.\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
   that is being managed by a driver.\r
@@ -272,11 +241,18 @@ IScsiComponentNameGetControllerName (
   OUT CHAR16                        **ControllerName\r
   )\r
 {\r
   OUT CHAR16                        **ControllerName\r
   )\r
 {\r
+  EFI_STATUS                      Status;\r
+  \r
   EFI_HANDLE                      IScsiController;\r
   BOOLEAN                         Ipv6Flag;\r
   EFI_HANDLE                      IScsiController;\r
   BOOLEAN                         Ipv6Flag;\r
-  EFI_STATUS                      Status;\r
   EFI_GUID                        *IScsiPrivateGuid;\r
   ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;\r
   EFI_GUID                        *IScsiPrivateGuid;\r
   ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;\r
+  \r
+  EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru;\r
+  \r
+  if (ControllerHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
   //\r
   // Get the handle of the controller we are controling.\r
 \r
   //\r
   // Get the handle of the controller we are controling.\r
@@ -295,9 +271,6 @@ IScsiComponentNameGetControllerName (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
-  // \r
-  // Retrieve an instance of a produced protocol from IScsiController  \r
-  // \r
   Status = gBS->OpenProtocol (\r
                   IScsiController,\r
                   IScsiPrivateGuid,\r
   Status = gBS->OpenProtocol (\r
                   IScsiController,\r
                   IScsiPrivateGuid,\r
@@ -310,9 +283,55 @@ IScsiComponentNameGetControllerName (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-  Status = UpdateName(IScsiController, Ipv6Flag);\r
-  if (EFI_ERROR(Status)) {\r
-    return Status;\r
+  if(ChildHandle != NULL) {\r
+    if(!Ipv6Flag) {\r
+      //\r
+      // Make sure this driver produced ChildHandle\r
+      //\r
+      Status = EfiTestChildHandle (\r
+                 ControllerHandle,\r
+                 ChildHandle,\r
+                 &gEfiTcp4ProtocolGuid\r
+                 );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+    } else {\r
+      //\r
+      // Make sure this driver produced ChildHandle\r
+      //\r
+      Status = EfiTestChildHandle (\r
+                 ControllerHandle,\r
+                 ChildHandle,\r
+                 &gEfiTcp6ProtocolGuid\r
+                 );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+    }\r
+    \r
+    //\r
+    // Retrieve an instance of a produced protocol from ChildHandle\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    ChildHandle,\r
+                    &gEfiExtScsiPassThruProtocolGuid,\r
+                   (VOID **)&IScsiExtScsiPassThru,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    \r
+    //\r
+    // Update the component name for this child handle.\r
+    //\r
+    Status = UpdateName (IScsiExtScsiPassThru, Ipv6Flag);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
   }\r
 \r
   return LookupUnicodeString2 (\r
   }\r
 \r
   return LookupUnicodeString2 (\r