]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
1. Add DPC protocol and DpcLib library in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ArpImpl.c
index 52b6e21652c630fa654153a80674649a92ffa654..404e6cc9d68ef30582f4d8470ee9a4ad3cf4b6cf 100644 (file)
@@ -66,7 +66,6 @@ ArpInitInstance (
 /**\r
   Process the Arp packets received from Mnp, the procedure conforms to RFC826.\r
 \r
-  @param  Event                  The Event this notify function registered to.\r
   @param  Context                Pointer to the context data registerd to the\r
                                  Event.\r
 \r
@@ -75,8 +74,7 @@ ArpInitInstance (
 **/\r
 VOID\r
 EFIAPI\r
-ArpOnFrameRcvd (\r
-  IN EFI_EVENT  Event,\r
+ArpOnFrameRcvdDpc (\r
   IN VOID       *Context\r
   )\r
 {\r
@@ -146,11 +144,6 @@ ArpOnFrameRcvd (
   ArpAddress.TargetHwAddr    = ArpAddress.SenderProtoAddr + Head->ProtoAddrLen;\r
   ArpAddress.TargetProtoAddr = ArpAddress.TargetHwAddr + Head->HwAddrLen;\r
 \r
-  if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {\r
-    ARP_DEBUG_ERROR (("ArpOnFrameRcvd: Faild to acquire the CacheTableLock.\n"));\r
-    goto RECYCLE_RXDATA;\r
-  }\r
-\r
   SenderAddress[Hardware].Type       = Head->HwType;\r
   SenderAddress[Hardware].Length     = Head->HwAddrLen;\r
   SenderAddress[Hardware].AddressPtr = ArpAddress.SenderHwAddr;\r
@@ -172,7 +165,7 @@ ArpOnFrameRcvd (
     // This address (either hardware or protocol address, or both) is configured to\r
     // be a deny entry, silently skip the normal process.\r
     //\r
-    goto UNLOCK_EXIT;\r
+    goto RECYCLE_RXDATA;\r
   }\r
 \r
   ProtoMatched = FALSE;\r
@@ -211,7 +204,7 @@ ArpOnFrameRcvd (
     //\r
     // Protocol type unmatchable, skip.\r
     //\r
-    goto UNLOCK_EXIT;\r
+    goto RECYCLE_RXDATA;\r
   }\r
 \r
   //\r
@@ -238,7 +231,7 @@ ArpOnFrameRcvd (
     //\r
     // This arp packet isn't targeted to us, skip now.\r
     //\r
-    goto UNLOCK_EXIT;\r
+    goto RECYCLE_RXDATA;\r
   }\r
 \r
   if (!MergeFlag) {\r
@@ -259,7 +252,7 @@ ArpOnFrameRcvd (
       //\r
       CacheEntry = ArpAllocCacheEntry (NULL);\r
       if (CacheEntry == NULL) {\r
-        goto UNLOCK_EXIT;\r
+        goto RECYCLE_RXDATA;\r
       }\r
     }\r
 \r
@@ -295,10 +288,6 @@ ArpOnFrameRcvd (
     ArpSendFrame (Instance, CacheEntry, ARP_OPCODE_REPLY);\r
   }\r
 \r
-UNLOCK_EXIT:\r
-\r
-  NET_UNLOCK (&ArpService->Lock);\r
-\r
 RECYCLE_RXDATA:\r
 \r
   //\r
@@ -321,9 +310,8 @@ RESTART_RECEIVE:
   );\r
 }\r
 \r
-\r
 /**\r
-  Process the already sent arp packets.\r
+  Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.\r
 \r
   @param  Event                  The Event this notify function registered to.\r
   @param  Context                Pointer to the context data registerd to the\r
@@ -334,10 +322,31 @@ RESTART_RECEIVE:
 **/\r
 VOID\r
 EFIAPI\r
-ArpOnFrameSent (\r
+ArpOnFrameRcvd (\r
   IN EFI_EVENT  Event,\r
   IN VOID       *Context\r
   )\r
+{\r
+  //\r
+  // Request ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK\r
+  //\r
+  NetLibQueueDpc (TPL_CALLBACK, ArpOnFrameRcvdDpc, Context);\r
+}\r
+\r
+/**\r
+  Process the already sent arp packets.\r
+\r
+  @param  Context                Pointer to the context data registerd to the\r
+                                 Event.\r
+\r
+  @return None.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ArpOnFrameSentDpc (\r
+  IN VOID       *Context\r
+  )\r
 {\r
   EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *TxToken;\r
   EFI_MANAGED_NETWORK_TRANSMIT_DATA     *TxData;\r
@@ -362,6 +371,29 @@ ArpOnFrameSent (
   NetFreePool (TxToken);\r
 }\r
 \r
+/**\r
+  Request ArpOnFrameSentDpc as a DPC at TPL_CALLBACK.\r
+\r
+  @param  Event                  The Event this notify function registered to.\r
+  @param  Context                Pointer to the context data registerd to the\r
+                                 Event.\r
+\r
+  @return None.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ArpOnFrameSent (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  //\r
+  // Request ArpOnFrameSentDpc as a DPC at TPL_CALLBACK\r
+  //\r
+  NetLibQueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context);\r
+}\r
+\r
 \r
 /**\r
   Process the arp cache olding and drive the retrying arp requests.\r
@@ -390,10 +422,6 @@ ArpTimerHandler (
   ASSERT (Context != NULL);\r
   ArpService = (ARP_SERVICE_DATA *)Context;\r
 \r
-  if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {\r
-    return;\r
-  }\r
-\r
   //\r
   // Iterate all the pending requests to see whether a retry is needed to send out\r
   // or the request finally fails because the retry time reaches the limitation.\r
@@ -492,8 +520,6 @@ ArpTimerHandler (
       CacheEntry->DecayTime -= ARP_PERIODIC_TIMER_INTERVAL;\r
     }\r
   }\r
-\r
-  NET_UNLOCK (&ArpService->Lock);\r
 }\r
 \r
 \r
@@ -789,6 +815,11 @@ ArpAddressResolved (
     }\r
   }\r
 \r
+  //\r
+  // Dispatch the DPCs queued by the NotifyFunction of the Context->UserRequestEvent.\r
+  //\r
+  NetLibDispatchDpc ();\r
+\r
   return Count;\r
 }\r
 \r
@@ -958,7 +989,7 @@ ArpConfigureInstance (
       //\r
       // Cancel the arp requests issued by this instance.\r
       //\r
-      ArpCancelRequest (Instance, NULL, NULL);\r
+      Instance->ArpProto.Cancel (&Instance->ArpProto, NULL, NULL);\r
 \r
       //\r
       // Free the buffer previously allocated to hold the station address.\r