]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. update timeout interval time from 10ms to 50ms
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Aug 2009 06:37:36 +0000 (06:37 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Aug 2009 06:37:36 +0000 (06:37 +0000)
2. refine MnpDxe code.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9063 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c
MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h

index cc027a56dd5f4165ffc36beb9e5c023de0ac395a..838765de7403103218804aef70158dbbbeebe89f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of Managed Network Protocol private services.\r
 \r
-Copyright (c) 2005 - 2008, Intel Corporation. <BR> \r
+Copyright (c) 2005 - 2009, Intel Corporation. <BR> \r
 All rights reserved. This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
@@ -44,162 +44,6 @@ EFI_MANAGED_NETWORK_CONFIG_DATA mMnpDefaultConfigData = {
   FALSE\r
 };\r
 \r
-/**\r
-  Configure the Snp receive filters according to the instances' receive filter\r
-  settings.\r
-\r
-  @param[in]  MnpServiceData        Pointer to the mnp service context data.\r
-\r
-  @retval     EFI_SUCCESS           The receive filters is configured.\r
-  @retval     EFI_OUT_OF_RESOURCES  The receive filters can't be configured due \r
-                                    to lack of memory resource.\r
-\r
-**/\r
-EFI_STATUS\r
-MnpConfigReceiveFilters (\r
-  IN MNP_SERVICE_DATA  *MnpServiceData\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-  EFI_MAC_ADDRESS             *MCastFilter;\r
-  UINT32                      MCastFilterCnt;\r
-  UINT32                      EnableFilterBits;\r
-  UINT32                      DisableFilterBits;\r
-  BOOLEAN                     ResetMCastFilters;\r
-  LIST_ENTRY                  *Entry;\r
-  UINT32                      Index;\r
-  MNP_GROUP_ADDRESS           *GroupAddress;\r
-\r
-  NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r
-\r
-  Snp = MnpServiceData->Snp;\r
-\r
-  //\r
-  // Initialize the enable filter and disable filter.\r
-  //\r
-  EnableFilterBits  = 0;\r
-  DisableFilterBits = Snp->Mode->ReceiveFilterMask;\r
-\r
-  if (MnpServiceData->UnicastCount != 0) {\r
-    //\r
-    // Enable unicast if any instance wants to receive unicast.\r
-    //\r
-    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
-  }\r
-\r
-  if (MnpServiceData->BroadcastCount != 0) {\r
-    //\r
-    // Enable broadcast if any instance wants to receive broadcast.\r
-    //\r
-    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
-  }\r
-\r
-  MCastFilter       = NULL;\r
-  MCastFilterCnt    = 0;\r
-  ResetMCastFilters = TRUE;\r
-\r
-  if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) {\r
-    //\r
-    // There are instances configured to receive multicast and already some group\r
-    // addresses are joined.\r
-    //\r
-\r
-    ResetMCastFilters = FALSE;\r
-\r
-    if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) {\r
-      //\r
-      // The joind group address is less than simple network's maximum count.\r
-      // Just configure the snp to do the multicast filtering.\r
-      //\r
-\r
-      EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
-\r
-      //\r
-      // Allocate pool for the mulicast addresses.\r
-      //\r
-      MCastFilterCnt  = MnpServiceData->GroupAddressCount;\r
-      MCastFilter     = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);\r
-      if (MCastFilter == NULL) {\r
-\r
-        DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n"));\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      //\r
-      // Fill the multicast HW address buffer.\r
-      //\r
-      Index = 0;\r
-      NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {\r
-\r
-        GroupAddress            = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);\r
-        CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index)));\r
-        Index++;\r
-\r
-        ASSERT (Index <= MCastFilterCnt);\r
-      }\r
-    } else {\r
-      //\r
-      // The maximum multicast is reached, set the filter to be promiscuous\r
-      // multicast.\r
-      //\r
-\r
-      if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r
-        EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
-      } else {\r
-        //\r
-        // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp,\r
-        // set the NIC to be promiscuous although this will tremendously degrade\r
-        // the performance.\r
-        //\r
-        EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
-      }\r
-    }\r
-  }\r
-\r
-  if (MnpServiceData->PromiscuousCount != 0) {\r
-    //\r
-    // Enable promiscuous if any instance wants to receive promiscuous.\r
-    //\r
-    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
-  }\r
-\r
-  //\r
-  // Set the disable filter.\r
-  //\r
-  DisableFilterBits ^= EnableFilterBits;\r
-\r
-  //\r
-  // Configure the receive filters of SNP.\r
-  //\r
-  Status = Snp->ReceiveFilters (\r
-                  Snp,\r
-                  EnableFilterBits,\r
-                  DisableFilterBits,\r
-                  ResetMCastFilters,\r
-                  MCastFilterCnt,\r
-                  MCastFilter\r
-                  );\r
-  DEBUG_CODE (\r
-    if (EFI_ERROR (Status)) {\r
-\r
-    DEBUG (\r
-      (EFI_D_ERROR,\r
-      "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",\r
-      Status)\r
-      );\r
-  }\r
-  );\r
-\r
-  if (MCastFilter != NULL) {\r
-    //\r
-    // Free the buffer used to hold the group addresses.\r
-    //\r
-    gBS->FreePool (MCastFilter);\r
-  }\r
-\r
-  return Status;\r
-}\r
 \r
 /**\r
   Add Count of net buffers to MnpServiceData->FreeNbufQue. The length of the net\r
@@ -1157,6 +1001,162 @@ MnpConfigureInstance (
   return Status;\r
 }\r
 \r
+/**\r
+  Configure the Snp receive filters according to the instances' receive filter\r
+  settings.\r
+\r
+  @param[in]  MnpServiceData        Pointer to the mnp service context data.\r
+\r
+  @retval     EFI_SUCCESS           The receive filters is configured.\r
+  @retval     EFI_OUT_OF_RESOURCES  The receive filters can't be configured due \r
+                                    to lack of memory resource.\r
+\r
+**/\r
+EFI_STATUS\r
+MnpConfigReceiveFilters (\r
+  IN MNP_SERVICE_DATA  *MnpServiceData\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+  EFI_MAC_ADDRESS             *MCastFilter;\r
+  UINT32                      MCastFilterCnt;\r
+  UINT32                      EnableFilterBits;\r
+  UINT32                      DisableFilterBits;\r
+  BOOLEAN                     ResetMCastFilters;\r
+  LIST_ENTRY                  *Entry;\r
+  UINT32                      Index;\r
+  MNP_GROUP_ADDRESS           *GroupAddress;\r
+\r
+  NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r
+\r
+  Snp = MnpServiceData->Snp;\r
+\r
+  //\r
+  // Initialize the enable filter and disable filter.\r
+  //\r
+  EnableFilterBits  = 0;\r
+  DisableFilterBits = Snp->Mode->ReceiveFilterMask;\r
+\r
+  if (MnpServiceData->UnicastCount != 0) {\r
+    //\r
+    // Enable unicast if any instance wants to receive unicast.\r
+    //\r
+    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
+  }\r
+\r
+  if (MnpServiceData->BroadcastCount != 0) {\r
+    //\r
+    // Enable broadcast if any instance wants to receive broadcast.\r
+    //\r
+    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
+  }\r
+\r
+  MCastFilter       = NULL;\r
+  MCastFilterCnt    = 0;\r
+  ResetMCastFilters = TRUE;\r
+\r
+  if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) {\r
+    //\r
+    // There are instances configured to receive multicast and already some group\r
+    // addresses are joined.\r
+    //\r
+\r
+    ResetMCastFilters = FALSE;\r
+\r
+    if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) {\r
+      //\r
+      // The joind group address is less than simple network's maximum count.\r
+      // Just configure the snp to do the multicast filtering.\r
+      //\r
+\r
+      EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
+\r
+      //\r
+      // Allocate pool for the mulicast addresses.\r
+      //\r
+      MCastFilterCnt  = MnpServiceData->GroupAddressCount;\r
+      MCastFilter     = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);\r
+      if (MCastFilter == NULL) {\r
+\r
+        DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n"));\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // Fill the multicast HW address buffer.\r
+      //\r
+      Index = 0;\r
+      NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {\r
+\r
+        GroupAddress            = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);\r
+        CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index)));\r
+        Index++;\r
+\r
+        ASSERT (Index <= MCastFilterCnt);\r
+      }\r
+    } else {\r
+      //\r
+      // The maximum multicast is reached, set the filter to be promiscuous\r
+      // multicast.\r
+      //\r
+\r
+      if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r
+        EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
+      } else {\r
+        //\r
+        // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp,\r
+        // set the NIC to be promiscuous although this will tremendously degrade\r
+        // the performance.\r
+        //\r
+        EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (MnpServiceData->PromiscuousCount != 0) {\r
+    //\r
+    // Enable promiscuous if any instance wants to receive promiscuous.\r
+    //\r
+    EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
+  }\r
+\r
+  //\r
+  // Set the disable filter.\r
+  //\r
+  DisableFilterBits ^= EnableFilterBits;\r
+\r
+  //\r
+  // Configure the receive filters of SNP.\r
+  //\r
+  Status = Snp->ReceiveFilters (\r
+                  Snp,\r
+                  EnableFilterBits,\r
+                  DisableFilterBits,\r
+                  ResetMCastFilters,\r
+                  MCastFilterCnt,\r
+                  MCastFilter\r
+                  );\r
+  DEBUG_CODE (\r
+    if (EFI_ERROR (Status)) {\r
+\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",\r
+      Status)\r
+      );\r
+  }\r
+  );\r
+\r
+  if (MCastFilter != NULL) {\r
+    //\r
+    // Free the buffer used to hold the group addresses.\r
+    //\r
+    gBS->FreePool (MCastFilter);\r
+  }\r
+\r
+  return Status;\r
+}\r
 \r
 \r
 /**\r
index 9c6facd599b513900a0adcd09f9d2a11e9135e81..b9fa4ab34326011299f5c9632ec1f09d022ed2ec 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Declaration of structures and functions of MnpDxe driver.\r
     \r
-Copyright (c) 2005 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2005 - 2009, Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define NET_ETHER_FCS_SIZE            4\r
 \r
 #define MNP_SYS_POLL_INTERVAL         (10 * TICKS_PER_MS)   // 10 milliseconds\r
-#define MNP_TIMEOUT_CHECK_INTERVAL    (10 * TICKS_PER_MS)   // 10 milliseconds\r
+#define MNP_TIMEOUT_CHECK_INTERVAL    (50 * TICKS_PER_MS)   // 50 milliseconds\r
 #define MNP_TX_TIMEOUT_TIME           (500 * TICKS_PER_MS)  // 500 milliseconds\r
 #define MNP_INIT_NET_BUFFER_NUM       512\r
 #define MNP_NET_BUFFER_INCREASEMENT   64\r
@@ -740,4 +740,20 @@ MnpPoll (
   IN EFI_MANAGED_NETWORK_PROTOCOL  *This\r
   );\r
 \r
+/**\r
+  Configure the Snp receive filters according to the instances' receive filter\r
+  settings.\r
+\r
+  @param[in]  MnpServiceData        Pointer to the mnp service context data.\r
+\r
+  @retval     EFI_SUCCESS           The receive filters is configured.\r
+  @retval     EFI_OUT_OF_RESOURCES  The receive filters can't be configured due \r
+                                    to lack of memory resource.\r
+\r
+**/\r
+EFI_STATUS\r
+MnpConfigReceiveFilters (\r
+  IN MNP_SERVICE_DATA  *MnpServiceData\r
+  );\r
+\r
 #endif\r
index 0c8196a7689efefd13a9f8b3f8a1c835020185f2..a7b703f8a8828837d8c833c6c84c14164563e19f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of Managed Network Protocol I/O functions.\r
     \r
-Copyright (c) 2005 - 2007, Intel Corporation. <BR>\r
+Copyright (c) 2005 - 2009, Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -1016,7 +1016,7 @@ MnpCheckPacketTimeout (
       RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);\r
 \r
       //\r
-      // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
+      // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
       //\r
       if (RxDataWrap->TimeoutTick >= (MNP_TIMEOUT_CHECK_INTERVAL / 10)) {\r
 \r
index 292673d88bf5990f5535112a4e007f1c69577948..8d392eee1c4f16f869c9158b6c63c84fdd6d6126 100644 (file)
@@ -424,7 +424,7 @@ Udp4CheckTimeout (
       Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link);\r
 \r
       //\r
-      // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
+      // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
       //\r
       if (Wrap->TimeoutTick <= (UDP4_TIMEOUT_INTERVAL / 10)) {\r
         //\r
index 82b21de971cdfeb25556071c42466b817ab294eb..0823b6995c67a5ca888000f044d7a774537cc919 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI UDPv4 protocol implementation.\r
    \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
 All rights reserved. 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
@@ -43,7 +43,7 @@ extern UINT16                          mUdp4RandomPort;
 \r
 #define ICMP_ERROR_PACKET_LENGTH  8\r
 \r
-#define UDP4_TIMEOUT_INTERVAL (10 * TICKS_PER_MS)  // 10 milliseconds\r
+#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS)  // 50 milliseconds\r
 \r
 #define UDP4_HEADER_SIZE      sizeof (EFI_UDP4_HEADER)\r
 #define UDP4_MAX_DATA_SIZE    65507\r