summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/DxeUdpIoLib
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-20 05:42:23 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-20 05:42:23 +0000
commit36ee91ca3661d3d020a7841aacbf858d885c4728 (patch)
tree418e7a4d4a84d86a78d4b260acab20877be5bd45 /MdeModulePkg/Library/DxeUdpIoLib
parent04e12c21476db29e8f92030ed00122fa4e1e56cc (diff)
downloadedk2-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/Library/DxeUdpIoLib')
-rw-r--r--MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c117
1 files changed, 90 insertions, 27 deletions
diff --git a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
index d56456afb2..b1329f8604 100644
--- a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
+++ b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
@@ -35,6 +35,13 @@ Abstract:
STATIC
VOID
EFIAPI
+UdpIoOnDgramSentDpc (
+ IN VOID *Context
+ );
+
+STATIC
+VOID
+EFIAPI
UdpIoOnDgramSent (
IN EFI_EVENT Event,
IN VOID *Context
@@ -100,7 +107,7 @@ UdpIoWrapTx (
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
+ NET_TPL_EVENT,
UdpIoOnDgramSent,
Token,
&UdpToken->Event
@@ -202,7 +209,7 @@ UdpIoCreateRxToken (
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
+ NET_TPL_EVENT,
UdpIoOnDgramRcvd,
Token,
&Token->UdpToken.Event
@@ -364,10 +371,7 @@ UdpIoCancelDgrams (
Token = NET_LIST_USER_STRUCT (Entry, UDP_TX_TOKEN, Link);
if ((ToCancel == NULL) || (ToCancel (Token, Context))) {
- NetListRemoveEntry (Entry);
UdpIo->Udp->Cancel (UdpIo->Udp, &Token->UdpToken);
- Token->CallBack (Token->Packet, NULL, IoStatus, Token->Context);
- UdpIoFreeTxToken (Token);
}
}
}
@@ -400,9 +404,7 @@ UdpIoFreePort (
UdpIoCancelDgrams (UdpIo, EFI_ABORTED, NULL, NULL);
if ((RxToken = UdpIo->RecvRequest) != NULL) {
- UdpIo->RecvRequest = NULL;
UdpIo->Udp->Cancel (UdpIo->Udp, &RxToken->UdpToken);
- UdpIoFreeRxToken (RxToken);
}
//
@@ -454,9 +456,7 @@ UdpIoCleanPort (
UdpIoCancelDgrams (UdpIo, EFI_ABORTED, NULL, NULL);
if ((RxToken = UdpIo->RecvRequest) != NULL) {
- UdpIo->RecvRequest = NULL;
UdpIo->Udp->Cancel (UdpIo->Udp, &RxToken->UdpToken);
- UdpIoFreeRxToken (RxToken);
}
UdpIo->Udp->Configure (UdpIo->Udp, NULL);
@@ -468,7 +468,6 @@ UdpIoCleanPort (
It will remove the packet from the local list then call
the packet owner's callback function.
- @param Event The event signalled.
@param Context The UDP TX Token.
@return None
@@ -477,8 +476,7 @@ UdpIoCleanPort (
STATIC
VOID
EFIAPI
-UdpIoOnDgramSent (
- IN EFI_EVENT Event,
+UdpIoOnDgramSentDpc (
IN VOID *Context
)
{
@@ -493,6 +491,29 @@ UdpIoOnDgramSent (
UdpIoFreeTxToken (Token);
}
+/**
+ Request UdpIoOnDgramSentDpc as a DPC at TPL_CALLBACK.
+
+ @param Event The event signalled.
+ @param Context The UDP TX Token.
+
+ @return None
+
+**/
+STATIC
+VOID
+EFIAPI
+UdpIoOnDgramSent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // Request UdpIoOnDgramSentDpc as a DPC at TPL_CALLBACK
+ //
+ NetLibQueueDpc (TPL_CALLBACK, UdpIoOnDgramSentDpc, Context);
+}
+
/**
Send a packet through the UDP IO port.
@@ -529,14 +550,18 @@ UdpIoSendDatagram (
return EFI_OUT_OF_RESOURCES;
}
+ //
+ // Insert the tx token into SendDatagram list before transmitting it. Remove
+ // it from the list if the returned status is not EFI_SUCCESS.
+ //
+ NetListInsertHead (&UdpIo->SentDatagram, &Token->Link);
Status = UdpIo->Udp->Transmit (UdpIo->Udp, &Token->UdpToken);
-
if (EFI_ERROR (Status)) {
+ NetListRemoveEntry (&Token->Link);
UdpIoFreeTxToken (Token);
return Status;
}
- NetListInsertHead (&UdpIo->SentDatagram, &Token->Link);
return EFI_SUCCESS;
}
@@ -609,13 +634,11 @@ UdpIoRecycleDgram (
UdpIoFreeRxToken (Token);
}
-
/**
The event handle for UDP receive request. It will build
a NET_BUF from the recieved UDP data, then deliver it
to the receiver.
- @param Event The UDP receive request event
@param Context The UDP RX token.
@return None
@@ -624,8 +647,7 @@ UdpIoRecycleDgram (
STATIC
VOID
EFIAPI
-UdpIoOnDgramRcvd (
- IN EFI_EVENT Event,
+UdpIoOnDgramRcvdDpc (
IN VOID *Context
)
{
@@ -651,10 +673,15 @@ UdpIoOnDgramRcvd (
UdpRxData = UdpToken->Packet.RxData;
if (EFI_ERROR (UdpToken->Status) || (UdpRxData == NULL)) {
- Token->CallBack (NULL, NULL, UdpToken->Status, Token->Context);
- UdpIoFreeRxToken (Token);
+ if (UdpToken->Status != EFI_ABORTED) {
+ //
+ // Invoke the CallBack only if the reception is not actively aborted.
+ //
+ Token->CallBack (NULL, NULL, UdpToken->Status, Token->Context);
+ }
- goto ON_EXIT;
+ UdpIoFreeRxToken (Token);
+ return;
}
//
@@ -674,7 +701,7 @@ UdpIoOnDgramRcvd (
Token->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, Token->Context);
UdpIoFreeRxToken (Token);
- goto ON_EXIT;
+ return;
}
UdpSession = &UdpRxData->UdpSession;
@@ -687,9 +714,45 @@ UdpIoOnDgramRcvd (
Points.RemoteAddr = NTOHL (Points.RemoteAddr);
Token->CallBack (Netbuf, &Points, EFI_SUCCESS, Token->Context);
+}
+
+/**
+ Request UdpIoOnDgramRcvdDpc as a DPC at TPL_CALLBACK.
+
+ @param Event The UDP receive request event.
+ @param Context The UDP RX token.
+
+ @return None
+
+**/
+STATIC
+VOID
+EFIAPI
+UdpIoOnDgramRcvd (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Request UdpIoOnDgramRcvdDpc as a DPC at TPL_CALLBACK
+
+Arguments:
+
+ Event - The UDP receive request event
+ Context - The UDP RX token.
+
+Returns:
-ON_EXIT:
- return;
+ None
+
+--*/
+{
+ //
+ // Request UdpIoOnDgramRcvdDpc as a DPC at TPL_CALLBACK
+ //
+ NetLibQueueDpc (TPL_CALLBACK, UdpIoOnDgramRcvdDpc, Context);
}
@@ -729,13 +792,13 @@ UdpIoRecvDatagram (
return EFI_OUT_OF_RESOURCES;
}
+ UdpIo->RecvRequest = Token;
Status = UdpIo->Udp->Receive (UdpIo->Udp, &Token->UdpToken);
if (EFI_ERROR (Status)) {
+ UdpIo->RecvRequest = NULL;
UdpIoFreeRxToken (Token);
- return Status;
}
- UdpIo->RecvRequest = Token;
- return EFI_SUCCESS;
+ return Status;
}