]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
Add VLAN support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiConfig.c
index 25d89f54e31e1f517ae32fc4006c53934b83154a..35214f2ce95b19c09d7f7b0ee286b22584c51516 100644 (file)
@@ -67,7 +67,7 @@ IScsiIpToStr (
 \r
 /**\r
   Update the list of iSCSI devices the iSCSI driver is controlling.\r
-  \r
+\r
   @retval EFI_SUCCESS            The callback successfully handled the action.\r
   @retval Others                 Other errors as indicated.   \r
 **/\r
@@ -84,19 +84,20 @@ IScsiUpdateDeviceList (
   UINTN                       HandleIndex;\r
   UINTN                       Index;\r
   UINTN                       LastDeviceIndex;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
+  EFI_MAC_ADDRESS             MacAddress;\r
+  UINTN                       HwAddressSize;\r
+  UINT16                      VlanId;\r
   ISCSI_MAC_INFO              *CurMacInfo;\r
   ISCSI_MAC_INFO              TempMacInfo;\r
-  CHAR16                      MacString[65];\r
+  CHAR16                      MacString[70];\r
   UINTN                       DeviceListSize;\r
 \r
   //\r
-  // Dump all the handles the Simple Network Protocol is installed on.\r
+  // Dump all the handles the Managed Network Service Binding Protocol is installed on.\r
   //\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gEfiSimpleNetworkProtocolGuid,\r
+                  &gEfiManagedNetworkServiceBindingProtocolGuid,\r
                   NULL,\r
                   &NumHandles,\r
                   &Handles\r
@@ -127,14 +128,15 @@ IScsiUpdateDeviceList (
     LastDeviceIndex = 0;\r
 \r
     for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++) {\r
-      gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-\r
-      Mode = Snp->Mode;\r
+      Status = NetLibGetMacAddress (Handles[HandleIndex], &MacAddress, &HwAddressSize);\r
+      ASSERT (Status == EFI_SUCCESS);\r
+      VlanId = NetLibGetVlanId (Handles[HandleIndex]);\r
 \r
       for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {\r
         CurMacInfo = &DeviceList->MacInfo[Index];\r
-        if ((CurMacInfo->Len == Mode->HwAddressSize) &&\r
-            (NET_MAC_EQUAL (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize))\r
+        if ((CurMacInfo->Len == HwAddressSize) &&\r
+            (CurMacInfo->VlanId == VlanId) &&\r
+            (NET_MAC_EQUAL (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize))\r
             ) {\r
           //\r
           // The previous configured NIC is still here.\r
@@ -163,7 +165,7 @@ IScsiUpdateDeviceList (
       // delete the variables\r
       //\r
       CurMacInfo = &DeviceList->MacInfo[Index];\r
-      IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, MacString);\r
+      IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, CurMacInfo->VlanId, MacString);\r
       gRT->SetVariable (MacString, &gEfiIScsiInitiatorNameProtocolGuid, 0, 0, NULL);\r
       gRT->SetVariable (MacString, &mIScsiCHAPAuthInfoGuid, 0, 0, NULL);\r
     }\r
@@ -181,12 +183,12 @@ IScsiUpdateDeviceList (
   DeviceList->NumDevice = (UINT8) NumHandles;\r
 \r
   for (Index = 0; Index < NumHandles; Index++) {\r
-    gBS->HandleProtocol (Handles[Index], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-    Mode        = Snp->Mode;\r
+    NetLibGetMacAddress (Handles[Index], &MacAddress, &HwAddressSize);\r
 \r
     CurMacInfo  = &DeviceList->MacInfo[Index];\r
-    CopyMem (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize);\r
-    CurMacInfo->Len = (UINT8) Mode->HwAddressSize;\r
+    CopyMem (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize);\r
+    CurMacInfo->Len = (UINT8) HwAddressSize;\r
+    CurMacInfo->VlanId = NetLibGetVlanId (Handles[Index]);\r
   }\r
 \r
   gRT->SetVariable (\r
@@ -776,7 +778,9 @@ IScsiConfigUpdateForm (
   ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
   BOOLEAN                     EntryExisted;\r
   EFI_STATUS                  Status;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+  EFI_MAC_ADDRESS             MacAddress;\r
+  UINTN                       HwAddressSize;\r
+  UINT16                      VlanId;\r
   CHAR16                      PortString[128];\r
   UINT16                      FormIndex;\r
   UINTN                       BufferSize;\r
@@ -813,17 +817,13 @@ IScsiConfigUpdateForm (
       ConfigFormEntry->Controller = Controller;\r
 \r
       //\r
-      // Get the simple network protocol and convert the MAC address into\r
-      // the formatted string.\r
+      // Get the MAC address and convert it into the formatted string.\r
       //\r
-      Status = gBS->HandleProtocol (\r
-                      Controller,\r
-                      &gEfiSimpleNetworkProtocolGuid,\r
-                      (VOID **)&Snp\r
-                      );\r
+      Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);\r
       ASSERT (Status == EFI_SUCCESS);\r
+      VlanId = NetLibGetVlanId (Controller);\r
 \r
-      IScsiMacAddrToStr (&Snp->Mode->PermanentAddress, Snp->Mode->HwAddressSize, ConfigFormEntry->MacString);\r
+      IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, ConfigFormEntry->MacString);\r
 \r
       //\r
       // Get the normal session configuration data.\r