X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FUniversal%2FNetwork%2FTcp4Dxe%2FTcp4Timer.c;h=a8e4a933cfd62452c5a1865bde03ca7ab872c7cd;hb=ac8cca2a4dd777970811fb727c396e2585c2bba1;hp=3c02c53912d19a56b404981d5a049064a2e812b2;hpb=85511ddf725b72cd46d301e4baa7d437521bafb1;p=mirror_edk2.git
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
index 3c02c53912..a8e4a933cf 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
@@ -1,57 +1,85 @@
/** @file
-
-Copyright (c) 2005 - 2007, Intel Corporation
-All rights reserved. This program and the accompanying materials
+ TCP timer related functions.
+
+Copyright (c) 2005 - 2010, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Timer.c
-
-Abstract:
-
- TCP timer related functions.
-
-
**/
#include "Tcp4Main.h"
UINT32 mTcpTick = 1000;
+/**
+ Connect timeout handler.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpConnectTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
+/**
+ Timeout handler for TCP retransmission timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpRexmitTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
+
+/**
+ Timeout handler for window probe timer.
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpProbeTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
+/**
+ Timeout handler for keepalive timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpKeepaliveTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
+/**
+ Timeout handler for FIN_WAIT_2 timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpFinwait2Timeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
+/**
+ Timeout handler for 2MSL timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
Tcp2MSLTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
);
TCP_TIMER_HANDLER mTcpTimerHandler[TCP_TIMER_NUMBER] = {
@@ -63,18 +91,15 @@ TCP_TIMER_HANDLER mTcpTimerHandler[TCP_TIMER_NUMBER] = {
Tcp2MSLTimeout,
};
-
/**
Close the TCP connection.
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpClose (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
NetbufFreeList (&Tcb->SndQue);
@@ -89,12 +114,10 @@ TcpClose (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpConnectTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
if (!TCP_CONNECTED (Tcb->State)) {
@@ -123,12 +146,10 @@ TcpConnectTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpRexmitTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
UINT32 FlightSize;
@@ -148,7 +169,7 @@ TcpRexmitTimeout (
Tcb->LossRecover = Tcb->SndNxt;
Tcb->LossTimes++;
- if (Tcb->LossTimes > Tcb->MaxRexmit &&
+ if ((Tcb->LossTimes > Tcb->MaxRexmit) &&
!TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_CONNECT)) {
DEBUG ((EFI_D_ERROR, "TcpRexmitTimeout: connection closed "
@@ -167,7 +188,6 @@ TcpRexmitTimeout (
TcpSetTimer (Tcb, TCP_TIMER_REXMIT, Tcb->Rto);
Tcb->CongestState = TCP_CONGEST_LOSS;
-
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_RTT_ON);
}
@@ -177,12 +197,10 @@ TcpRexmitTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpProbeTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
//
@@ -193,7 +211,8 @@ TcpProbeTimeout (
//
if ((TcpDataToSend (Tcb, 1) != 0) && (TcpToSendData (Tcb, 1) > 0)) {
- ASSERT (TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_REXMIT));
+ ASSERT (TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_REXMIT) != 0);
+ Tcb->ProbeTimerOn = FALSE;
return ;
}
@@ -207,12 +226,10 @@ TcpProbeTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpKeepaliveTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
Tcb->KeepAliveProbes++;
@@ -240,12 +257,10 @@ TcpKeepaliveTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpFinwait2Timeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
DEBUG ((EFI_D_WARN, "TcpFinwait2Timeout: connection closed "
@@ -260,12 +275,10 @@ TcpFinwait2Timeout (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
Tcp2MSLTimeout (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
DEBUG ((EFI_D_WARN, "Tcp2MSLTimeout: connection closed "
@@ -276,18 +289,15 @@ Tcp2MSLTimeout (
/**
- Update the timer status and the next expire time
- according to the timers to expire in a specific
- future time slot.
+ Update the timer status and the next expire time according to the timers
+ to expire in a specific future time slot.
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpUpdateTimer (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
UINT16 Index;
@@ -318,14 +328,12 @@ TcpUpdateTimer (
@param Timer The index of the timer to be enabled.
@param TimeOut The timeout value of this timer.
- @return None.
-
**/
VOID
TcpSetTimer (
- IN TCP_CB *Tcb,
- IN UINT16 Timer,
- IN UINT32 TimeOut
+ IN OUT TCP_CB *Tcb,
+ IN UINT16 Timer,
+ IN UINT32 TimeOut
)
{
TCP_SET_TIMER (Tcb->EnabledTimer, Timer);
@@ -341,13 +349,11 @@ TcpSetTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance.
@param Timer The index of the timer to be cleared.
- @return None.
-
**/
VOID
TcpClearTimer (
- IN TCP_CB *Tcb,
- IN UINT16 Timer
+ IN OUT TCP_CB *Tcb,
+ IN UINT16 Timer
)
{
TCP_CLEAR_TIMER (Tcb->EnabledTimer, Timer);
@@ -360,12 +366,10 @@ TcpClearTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpClearAllTimer (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
Tcb->EnabledTimer = 0;
@@ -378,16 +382,15 @@ TcpClearAllTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpSetProbeTimer (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
- if (!TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_PROBE)) {
- Tcb->ProbeTime = Tcb->Rto;
+ if (!Tcb->ProbeTimerOn) {
+ Tcb->ProbeTime = Tcb->Rto;
+ Tcb->ProbeTimerOn = TRUE;
} else {
Tcb->ProbeTime <<= 1;
@@ -410,12 +413,10 @@ TcpSetProbeTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpSetKeepaliveTimer (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_NO_KEEPALIVE)) {
@@ -448,12 +449,10 @@ TcpSetKeepaliveTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance.
- @return None.
-
**/
VOID
TcpBackoffRto (
- IN TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
//
@@ -481,9 +480,7 @@ TcpBackoffRto (
/**
Heart beat timer handler.
- @param Context Context of the timer event, ignored.
-
- @return None.
+ @param Context Context of the timer event, ignored.
**/
VOID
@@ -554,15 +551,17 @@ TcpTickingDpc (
//
if ((Next->BackLink != Entry) ||
(Tcb->EnabledTimer == 0)) {
-
- goto NextConnection;
+ break;
}
}
}
-
- TcpUpdateTimer (Tcb);
-NextConnection:
- ;
+
+ //
+ // If the Tcb still exist or some timer is set, update the timer
+ //
+ if (Index == TCP_TIMER_NUMBER) {
+ TcpUpdateTimer (Tcb);
+ }
}
}
@@ -572,8 +571,6 @@ NextConnection:
@param Event Timer event signaled, ignored.
@param Context Context of the timer event, ignored.
- @return None.
-
**/
VOID
EFIAPI
@@ -582,6 +579,6 @@ TcpTicking (
IN VOID *Context
)
{
- NetLibQueueDpc (TPL_CALLBACK, TcpTickingDpc, Context);
+ QueueDpc (TPL_CALLBACK, TcpTickingDpc, Context);
}