]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Fix PXE performance issue : enhance EfiPxeBcSetIpFilter() to eliminate unnecessary...
authorhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 9 Jun 2011 09:25:02 +0000 (09:25 +0000)
committerhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 9 Jun 2011 09:25:02 +0000 (09:25 +0000)
Reviewed-by: xdu2
Signed-off-by: hhuan13
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11779 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c

index 03bde34116d68b245c0d02badf99e0b862d6f779..0efcda58e56ea3ebfdaf69b22fa3a52ec5084693 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding for UEFI PXEBC protocol.\r
 \r
-Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2011, 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
@@ -341,7 +341,7 @@ PxeBcDriverBindingStart (
     goto ON_ERROR;\r
   }\r
   ZeroMem (&Private->Udp4CfgData, sizeof (EFI_UDP4_CONFIG_DATA));\r
-  Private->Udp4CfgData.AcceptBroadcast    = TRUE;\r
+  Private->Udp4CfgData.AcceptBroadcast    = FALSE;\r
   Private->Udp4CfgData.AcceptPromiscuous  = FALSE;\r
   Private->Udp4CfgData.AcceptAnyPort      = TRUE;\r
   Private->Udp4CfgData.AllowDuplicatePort = TRUE;\r
index c3cb765837833d9130fd8248882dc3e9b21ec505..4ea15a6314f508222b6b33a0ef18e14af78e3c41 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Interface routines for PxeBc.\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2011, 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
@@ -727,6 +727,8 @@ ON_EXIT:
     }\r
   }\r
 \r
+  Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r
+\r
   //\r
   // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r
   // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r
@@ -1040,6 +1042,8 @@ EfiPxeBcDiscover (
 \r
 ON_EXIT:\r
 \r
+  Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r
+  \r
   //\r
   // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r
   // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r
@@ -1274,6 +1278,7 @@ EfiPxeBcMtftp (
     Mode->IcmpErrorReceived = TRUE;\r
   }\r
 \r
+  Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r
   //\r
   // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r
   // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r
@@ -1866,7 +1871,11 @@ EfiPxeBcSetIpFilter (
   PXEBC_PRIVATE_DATA        *Private;\r
   EFI_PXE_BASE_CODE_MODE    *Mode;\r
   UINTN                     Index;\r
+  EFI_UDP4_CONFIG_DATA      *Udp4Cfg;\r
   BOOLEAN                   PromiscuousNeed;\r
+  BOOLEAN                   AcceptPromiscuous;\r
+  BOOLEAN                   AcceptBroadcast;\r
+  BOOLEAN                   MultiCastUpdate;\r
 \r
   if (This == NULL) {\r
     DEBUG ((EFI_D_ERROR, "This == NULL.\n"));\r
@@ -1891,6 +1900,11 @@ EfiPxeBcSetIpFilter (
     return EFI_NOT_STARTED;\r
   }\r
 \r
+  if (Mode->UsingIpv6) {\r
+    DEBUG ((EFI_D_ERROR, "This driver is PXE for IPv4 Only.\n"));\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   PromiscuousNeed = FALSE;\r
 \r
   for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r
@@ -1912,54 +1926,71 @@ EfiPxeBcSetIpFilter (
     }\r
   }\r
 \r
-  //\r
-  // Clear the UDP instance configuration, all joined groups will be left\r
-  // during the operation.\r
-  //\r
-  Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r
-  Private->Udp4CfgData.AcceptPromiscuous  = FALSE;\r
-  Private->Udp4CfgData.AcceptBroadcast    = FALSE;\r
+  AcceptPromiscuous = FALSE;\r
+  AcceptBroadcast   = FALSE;\r
+  MultiCastUpdate   = FALSE;\r
 \r
   if (PromiscuousNeed ||\r
       ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) ||\r
       ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0)\r
      ) {\r
     //\r
-    // Configure the udp4 filter to receive all packages\r
+    // Configure the udp4 filter to receive all packages.\r
     //\r
-    Private->Udp4CfgData.AcceptPromiscuous  = TRUE;\r
-\r
+    AcceptPromiscuous  = TRUE;\r
+  } else if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) {\r
     //\r
-    // Configure the UDP instance with the new configuration.\r
+    // Configure the udp4 filter to receive all broadcast packages.\r
     //\r
-    Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-  } else {\r
+    AcceptBroadcast   = TRUE;\r
+  }\r
 \r
-    if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) {\r
-      //\r
-      // Configure the udp4 filter to receive all broadcast packages\r
-      //\r
-      Private->Udp4CfgData.AcceptBroadcast    = TRUE;\r
+  //\r
+  // In multicast condition when Promiscuous FALSE and IpCnt no-zero.\r
+  // Here check if there is any update of the multicast ip address. If yes,\r
+  // we need leave the old multicast group (by Config UDP instance to NULL),\r
+  // and join the new multicast group.\r
+  //\r
+  if (!AcceptPromiscuous) {\r
+    if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) {\r
+      if (Mode->IpFilter.IpCnt != NewFilter->IpCnt) {\r
+        MultiCastUpdate = TRUE;\r
+      } else if (CompareMem (Mode->IpFilter.IpList, NewFilter->IpList, NewFilter->IpCnt * sizeof (EFI_IP_ADDRESS)) != 0 ) {\r
+        MultiCastUpdate = TRUE;\r
+      }\r
     }\r
+  }\r
+  \r
+  //\r
+  // Check whether we need reconfigure the UDP instance.\r
+  //\r
+  Udp4Cfg = &Private->Udp4CfgData;\r
+  if ((AcceptPromiscuous != Udp4Cfg->AcceptPromiscuous) ||\r
+         (AcceptBroadcast != Udp4Cfg->AcceptBroadcast)     || MultiCastUpdate) {\r
+    //\r
+    // Clear the UDP instance configuration, all joined groups will be left\r
+    // during the operation.\r
+    //\r
+    Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r
 \r
     //\r
     // Configure the UDP instance with the new configuration.\r
     //\r
-    Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r
+    Udp4Cfg->AcceptPromiscuous = AcceptPromiscuous;\r
+    Udp4Cfg->AcceptBroadcast   = AcceptBroadcast;\r
+    Status = Private->Udp4Read->Configure (Private->Udp4Read, Udp4Cfg);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
 \r
-    if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) {\r
-\r
+    //\r
+    // In not Promiscuous mode, need to join the new multicast group.\r
+    //\r
+    if (!AcceptPromiscuous) {\r
       for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r
         if (IP4_IS_MULTICAST (EFI_NTOHL (NewFilter->IpList[Index].v4))) {\r
           //\r
-          // Join the mutilcast group\r
+          // Join the mutilcast group.\r
           //\r
           Status = Private->Udp4Read->Groups (Private->Udp4Read, TRUE, &NewFilter->IpList[Index].v4);\r
           if (EFI_ERROR (Status)) {\r