This patch also contains a bug fix in HTTP driver that the RxToken is not 
closed, this is one of the main reasons which lower the download speed.

   Wrap = (HTTP_TOKEN_WRAP *) Context;
+  gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
   if (EFI_ERROR (Wrap->TcpWrap.RxToken.CompletionToken.Status)) {
     return ;
   }

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Fu Siyuan
Sent: Monday, September 14, 2015 4:24 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting...@intel.com>; Wu, Jiaxin <jiaxin...@intel.com>
Subject: [edk2] [Patch 3/4] NetworkPkg: Update Http driver to use DPC mechanism.

This patch updates the HttpDxe driver to use the DPC mechanism to avoid long 
time delay when single event.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan...@intel.com>
---
 NetworkPkg/HttpDxe/HttpDriver.h |  2 +-  NetworkPkg/HttpDxe/HttpDxe.inf  |  1 +
 NetworkPkg/HttpDxe/HttpImpl.c   |  9 ++++++-
 NetworkPkg/HttpDxe/HttpProto.c  | 55 +++++++++++++++++++++++++++++++++++------
 4 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDriver.h 
index d95b05b..eea8d51 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.h
+++ b/NetworkPkg/HttpDxe/HttpDriver.h
@@ -28,7 +28,7 @@
 #include <Library/DebugLib.h>
 #include <Library/NetLib.h>
 #include <Library/HttpLib.h>
-#include <Library/TcpIoLib.h>
+#include <Library/DpcLib.h>
 
 //
 // UEFI Driver Model Protocols
diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf 
index e811700..0d3bd00 100644
--- a/NetworkPkg/HttpDxe/HttpDxe.inf
+++ b/NetworkPkg/HttpDxe/HttpDxe.inf
@@ -48,6 +48,7 @@
   DebugLib
   NetLib
   HttpLib
+  DpcLib
 
 [Protocols]
   gEfiHttpServiceBindingProtocolGuid               ## BY_START
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c 
index dc06b98..c176a65 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -498,6 +498,8 @@ EfiHttpRequest (
     goto Error5;    
   }
 
+  DispatchDpc ();
+
   return EFI_SUCCESS;
 
 Error5:
@@ -1329,6 +1331,7 @@ EfiHttpPoll (
   )
 {
   HTTP_PROTOCOL                 *HttpInstance;
+  EFI_STATUS                    Status;
 
   if (This == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -1345,5 +1348,9 @@ EfiHttpPoll (
     return EFI_NOT_STARTED;
   }
 
-  return HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
+  Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
+
+  DispatchDpc ();
+
+  return Status;
 }
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c 
index e8ce987..06a41b7 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -38,20 +38,18 @@ HttpCommonNotify (
 /**
   The notify function associated with TxToken for Tcp4->Transmit().
 
-  @param[in]  Event   The event signaled.
   @param[in]  Context The context.
 
 **/
 VOID
 EFIAPI
-HttpTcpTransmitNotify (
-  IN EFI_EVENT  Event,
+HttpTcpTransmitNotifyDpc (
   IN VOID       *Context
   )
 {
   HTTP_TOKEN_WRAP          *Wrap;
 
-  if ((Event == NULL) || (Context == NULL)) {
+  if (Context == NULL) {
     return ;
   }
 
@@ -80,16 +78,35 @@ HttpTcpTransmitNotify (  }
 
 /**
+  Request HttpTcpTransmitNotifyDpc as a DPC at TPL_CALLBACK.
+
+  @param  Event                 The receive event delivered to TCP for 
transmit.
+  @param  Context               Context for the callback.
+
+**/
+VOID
+EFIAPI
+HttpTcpTransmitNotify (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  //
+  // Request HttpTcpTransmitNotifyDpc as a DPC at TPL_CALLBACK
+  //
+  QueueDpc (TPL_CALLBACK, HttpTcpTransmitNotifyDpc, Context); }
+
+
+/**
   The notify function associated with RxToken for Tcp4->Receive ().
 
-  @param[in]  Event   The event signaled.
   @param[in]  Context The context.
 
 **/
 VOID
 EFIAPI
-HttpTcpReceiveNotify (
-  IN EFI_EVENT  Event,
+HttpTcpReceiveNotifyDpc (
   IN VOID       *Context
   )
 {
@@ -99,11 +116,12 @@ HttpTcpReceiveNotify (
   EFI_STATUS               Status;
   HTTP_PROTOCOL            *HttpInstance;
 
-  if ((Event == NULL) || (Context == NULL)) {
+  if (Context == NULL) {
     return ;
   }
 
   Wrap = (HTTP_TOKEN_WRAP *) Context;
+  gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
   if (EFI_ERROR (Wrap->TcpWrap.RxToken.CompletionToken.Status)) {
     return ;
   }
@@ -173,6 +191,27 @@ HttpTcpReceiveNotify (  }
 
 /**
+  Request HttpTcpReceiveNotifyDpc as a DPC at TPL_CALLBACK.
+
+  @param  Event                 The receive event delivered to TCP for receive.
+  @param  Context               Context for the callback.
+
+**/
+VOID
+EFIAPI
+HttpTcpReceiveNotify (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  //
+  // Request HttpTcpTransmitNotifyDpc as a DPC at TPL_CALLBACK
+  //
+  QueueDpc (TPL_CALLBACK, HttpTcpReceiveNotifyDpc, Context); }
+
+
+/**
   Create events for the TCP4 connection token and TCP4 close token.
 
   @param[in]  HttpInstance       Pointer to HTTP_PROTOCOL structure.
--
2.5.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to