diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-11-20 05:42:23 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-11-20 05:42:23 +0000 |
commit | 36ee91ca3661d3d020a7841aacbf858d885c4728 (patch) | |
tree | 418e7a4d4a84d86a78d4b260acab20877be5bd45 /MdeModulePkg/Universal/Network/ArpDxe | |
parent | 04e12c21476db29e8f92030ed00122fa4e1e56cc (diff) | |
download | edk2-platforms-36ee91ca3661d3d020a7841aacbf858d885c4728.tar.xz |
1. Add DPC protocol and DpcLib library in MdeModulePkg.
2. Add DpcDxe module and DxeDpcLib module in MdeModulePkg
3. Port network stack module to use DPC.
4. Use MIN, and MAX defined in MdePkg to replace NET_MIN and NET_MAX.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4307 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/ArpDxe')
-rw-r--r-- | MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c | 24 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c | 83 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h | 14 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c | 71 |
4 files changed, 108 insertions, 84 deletions
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c index 58bc72219c..af2e082576 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -178,11 +178,6 @@ ArpCreateService ( }
//
- // Init the lock.
- //
- NET_LOCK_INIT (&ArpService->Lock);
-
- //
// Init the lists.
//
NetListInit (&ArpService->ChildrenList);
@@ -506,6 +501,7 @@ ArpServiceBindingCreateChild ( ARP_SERVICE_DATA *ArpService;
ARP_INSTANCE_DATA *Instance;
VOID *Mnp;
+ EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -564,11 +560,7 @@ ArpServiceBindingCreateChild ( goto ERROR;
}
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
-
- Status = EFI_ACCESS_DENIED;
- goto ERROR;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Insert the instance into children list managed by the arp service context data.
@@ -576,7 +568,7 @@ ArpServiceBindingCreateChild ( NetListInsertTail (&ArpService->ChildrenList, &Instance->List);
ArpService->ChildrenNumber++;
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
ERROR:
@@ -633,6 +625,7 @@ ArpServiceBindingDestroyChild ( ARP_SERVICE_DATA *ArpService;
ARP_INSTANCE_DATA *Instance;
EFI_ARP_PROTOCOL *Arp;
+ EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -693,10 +686,7 @@ ArpServiceBindingDestroyChild ( return Status;
}
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- Instance->Destroyed = FALSE;
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
if (Instance->Configured) {
//
@@ -716,7 +706,7 @@ ArpServiceBindingDestroyChild ( NetListRemoveEntry (&Instance->List);
ArpService->ChildrenNumber--;
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
NetFreePool (Instance);
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c index 52b6e21652..404e6cc9d6 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c @@ -66,7 +66,6 @@ ArpInitInstance ( /**
Process the Arp packets received from Mnp, the procedure conforms to RFC826.
- @param Event The Event this notify function registered to.
@param Context Pointer to the context data registerd to the
Event.
@@ -75,8 +74,7 @@ ArpInitInstance ( **/
VOID
EFIAPI
-ArpOnFrameRcvd (
- IN EFI_EVENT Event,
+ArpOnFrameRcvdDpc (
IN VOID *Context
)
{
@@ -146,11 +144,6 @@ ArpOnFrameRcvd ( ArpAddress.TargetHwAddr = ArpAddress.SenderProtoAddr + Head->ProtoAddrLen;
ArpAddress.TargetProtoAddr = ArpAddress.TargetHwAddr + Head->HwAddrLen;
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- ARP_DEBUG_ERROR (("ArpOnFrameRcvd: Faild to acquire the CacheTableLock.\n"));
- goto RECYCLE_RXDATA;
- }
-
SenderAddress[Hardware].Type = Head->HwType;
SenderAddress[Hardware].Length = Head->HwAddrLen;
SenderAddress[Hardware].AddressPtr = ArpAddress.SenderHwAddr;
@@ -172,7 +165,7 @@ ArpOnFrameRcvd ( // This address (either hardware or protocol address, or both) is configured to
// be a deny entry, silently skip the normal process.
//
- goto UNLOCK_EXIT;
+ goto RECYCLE_RXDATA;
}
ProtoMatched = FALSE;
@@ -211,7 +204,7 @@ ArpOnFrameRcvd ( //
// Protocol type unmatchable, skip.
//
- goto UNLOCK_EXIT;
+ goto RECYCLE_RXDATA;
}
//
@@ -238,7 +231,7 @@ ArpOnFrameRcvd ( //
// This arp packet isn't targeted to us, skip now.
//
- goto UNLOCK_EXIT;
+ goto RECYCLE_RXDATA;
}
if (!MergeFlag) {
@@ -259,7 +252,7 @@ ArpOnFrameRcvd ( //
CacheEntry = ArpAllocCacheEntry (NULL);
if (CacheEntry == NULL) {
- goto UNLOCK_EXIT;
+ goto RECYCLE_RXDATA;
}
}
@@ -295,10 +288,6 @@ ArpOnFrameRcvd ( ArpSendFrame (Instance, CacheEntry, ARP_OPCODE_REPLY);
}
-UNLOCK_EXIT:
-
- NET_UNLOCK (&ArpService->Lock);
-
RECYCLE_RXDATA:
//
@@ -321,9 +310,8 @@ RESTART_RECEIVE: );
}
-
/**
- Process the already sent arp packets.
+ Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.
@param Event The Event this notify function registered to.
@param Context Pointer to the context data registerd to the
@@ -334,11 +322,32 @@ RESTART_RECEIVE: **/
VOID
EFIAPI
-ArpOnFrameSent (
+ArpOnFrameRcvd (
IN EFI_EVENT Event,
IN VOID *Context
)
{
+ //
+ // Request ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK
+ //
+ NetLibQueueDpc (TPL_CALLBACK, ArpOnFrameRcvdDpc, Context);
+}
+
+/**
+ Process the already sent arp packets.
+
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
+VOID
+EFIAPI
+ArpOnFrameSentDpc (
+ IN VOID *Context
+ )
+{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *TxToken;
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
@@ -362,6 +371,29 @@ ArpOnFrameSent ( NetFreePool (TxToken);
}
+/**
+ Request ArpOnFrameSentDpc as a DPC at TPL_CALLBACK.
+
+ @param Event The Event this notify function registered to.
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
+VOID
+EFIAPI
+ArpOnFrameSent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // Request ArpOnFrameSentDpc as a DPC at TPL_CALLBACK
+ //
+ NetLibQueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context);
+}
+
/**
Process the arp cache olding and drive the retrying arp requests.
@@ -390,10 +422,6 @@ ArpTimerHandler ( ASSERT (Context != NULL);
ArpService = (ARP_SERVICE_DATA *)Context;
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return;
- }
-
//
// Iterate all the pending requests to see whether a retry is needed to send out
// or the request finally fails because the retry time reaches the limitation.
@@ -492,8 +520,6 @@ ArpTimerHandler ( CacheEntry->DecayTime -= ARP_PERIODIC_TIMER_INTERVAL;
}
}
-
- NET_UNLOCK (&ArpService->Lock);
}
@@ -789,6 +815,11 @@ ArpAddressResolved ( }
}
+ //
+ // Dispatch the DPCs queued by the NotifyFunction of the Context->UserRequestEvent.
+ //
+ NetLibDispatchDpc ();
+
return Count;
}
@@ -958,7 +989,7 @@ ArpConfigureInstance ( //
// Cancel the arp requests issued by this instance.
//
- ArpCancelRequest (Instance, NULL, NULL);
+ Instance->ArpProto.Cancel (&Instance->ArpProto, NULL, NULL);
//
// Free the buffer previously allocated to hold the station address.
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h index 729cb5d68e..1c5e421a04 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h @@ -125,8 +125,6 @@ struct _ARP_SERVICE_DATA { EFI_SIMPLE_NETWORK_MODE SnpMode;
- NET_LOCK Lock;
-
UINTN ChildrenNumber;
NET_LIST_ENTRY ChildrenList;
@@ -300,6 +298,12 @@ ArpInitInstance ( VOID
EFIAPI
+ArpOnFrameRcvdDpc (
+ IN VOID *Context
+ );
+
+VOID
+EFIAPI
ArpOnFrameRcvd (
IN EFI_EVENT Event,
IN VOID *Context
@@ -307,6 +311,12 @@ ArpOnFrameRcvd ( VOID
EFIAPI
+ArpOnFrameSentDpc (
+ IN VOID *Context
+ );
+
+VOID
+EFIAPI
ArpOnFrameSent (
IN EFI_EVENT Event,
IN VOID *Context
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c index eb1b082a21..d760f7c018 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c @@ -51,6 +51,7 @@ ArpConfigure ( {
EFI_STATUS Status;
ARP_INSTANCE_DATA *Instance;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -65,16 +66,14 @@ ArpConfigure ( Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
- if (EFI_ERROR (NET_TRYLOCK (&Instance->ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Configure this instance, the ConfigData has already passed the basic checks.
//
Status = ArpConfigureInstance (Instance, ConfigData);
- NET_UNLOCK (&Instance->ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
return Status;
}
@@ -131,6 +130,7 @@ ArpAdd ( ARP_CACHE_ENTRY *CacheEntry;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
NET_ARP_ADDRESS MatchAddress[2];
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -166,9 +166,7 @@ ArpAdd ( MatchAddress[Protocol].Length = Instance->ConfigData.SwAddressLength;
MatchAddress[Protocol].AddressPtr = TargetSwAddress;
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// See whether the entry to add exists. Check the DeinedCacheTable first.
@@ -262,7 +260,7 @@ ArpAdd ( UNLOCK_EXIT:
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
return Status;
}
@@ -309,7 +307,7 @@ ArpFind ( {
EFI_STATUS Status;
ARP_INSTANCE_DATA *Instance;
- ARP_SERVICE_DATA *ArpService;
+ EFI_TPL OldTpl;
if ((This == NULL) ||
(!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) ||
@@ -318,15 +316,12 @@ ArpFind ( }
Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
- ArpService = Instance->ArpService;
if (!Instance->Configured) {
return EFI_NOT_STARTED;
}
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// All the check passed, find the cache entries now.
@@ -341,7 +336,7 @@ ArpFind ( Refresh
);
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
return Status;
}
@@ -373,8 +368,8 @@ ArpDelete ( )
{
ARP_INSTANCE_DATA *Instance;
- ARP_SERVICE_DATA *ArpService;
UINTN Count;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -386,18 +381,14 @@ ArpDelete ( return EFI_NOT_STARTED;
}
- ArpService = Instance->ArpService;
-
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Delete the specified cache entries.
//
Count = ArpDeleteCacheEntry (Instance, BySwAddress, AddressBuffer, TRUE);
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}
@@ -422,8 +413,8 @@ ArpFlush ( )
{
ARP_INSTANCE_DATA *Instance;
- ARP_SERVICE_DATA *ArpService;
UINTN Count;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -435,18 +426,14 @@ ArpFlush ( return EFI_NOT_STARTED;
}
- ArpService = Instance->ArpService;
-
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Delete the dynamic entries from the cache table.
//
Count = ArpDeleteCacheEntry (Instance, FALSE, NULL, FALSE);
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}
@@ -491,6 +478,7 @@ ArpRequest ( NET_ARP_ADDRESS HardwareAddress;
NET_ARP_ADDRESS ProtocolAddress;
USER_REQUEST_CONTEXT *RequestContext;
+ EFI_TPL OldTpl;
if ((This == NULL) || (TargetHwAddress == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -545,9 +533,7 @@ ArpRequest ( //
NetZeroMem (TargetHwAddress, SnpMode->HwAddressSize);
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Check whether the software address is in the denied table.
@@ -653,12 +639,17 @@ ArpRequest ( UNLOCK_EXIT:
- NET_UNLOCK (&ArpService->Lock);
+ NET_RESTORE_TPL (OldTpl);
SIGNAL_USER:
if ((ResolvedEvent != NULL) && (Status == EFI_SUCCESS)) {
gBS->SignalEvent (ResolvedEvent);
+
+ //
+ // Dispatch the DPC queued by the NotifyFunction of ResolvedEvent.
+ //
+ NetLibDispatchDpc ();
}
return Status;
@@ -695,8 +686,8 @@ ArpCancel ( )
{
ARP_INSTANCE_DATA *Instance;
- ARP_SERVICE_DATA *ArpService;
UINTN Count;
+ EFI_TPL OldTpl;
if ((This == NULL) ||
((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) ||
@@ -710,18 +701,20 @@ ArpCancel ( return EFI_NOT_STARTED;
}
- ArpService = Instance->ArpService;
-
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {
- return EFI_ACCESS_DENIED;
- }
+ OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
//
// Cancel the specified request.
//
Count = ArpCancelRequest (Instance, TargetSwAddress, ResolvedEvent);
- NET_UNLOCK (&ArpService->Lock);
+ //
+ // Dispatch the DPCs queued by the NotifyFunction of the events signaled
+ // by ArpCancleRequest.
+ //
+ NetLibDispatchDpc ();
+
+ NET_RESTORE_TPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}
|