From nobody Sat Nov 2 14:42:36 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1489653359400247.01419961291504; Thu, 16 Mar 2017 01:35:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CEB1A80407; Thu, 16 Mar 2017 01:35:57 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D07A980406 for ; Thu, 16 Mar 2017 01:35:55 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2017 01:35:55 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.130]) by fmsmga005.fm.intel.com with ESMTP; 16 Mar 2017 01:35:53 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489653355; x=1521189355; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=efyGg0RNrJnIOReVOYN7/odvRAdy9DVjR4MKc1w1Tk4=; b=PQ+LuIWzLPSHcJ551ZRczBupHuTSEjbTHzAHf69pCZWaJKlCixtv3Ggv LUXJR9gDmxEqcz63wq5QThihItz0tQ==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="76907085" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Thu, 16 Mar 2017 16:35:48 +0800 Message-Id: <1489653350-62316-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1489653350-62316-1-git-send-email-jiaxin.wu@intel.com> References: <1489653350-62316-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 1/2] MdeModulePke/Mtftp4Dxe: Add windowsize option support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch is to support the tftp windowsize option that allows the client and server to negotiate a window size of consecutive blocks to send as an alternative for replacing the single-block lockstep schema. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 5 ++- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.h | 11 +++++- .../Universal/Network/Mtftp4Dxe/Mtftp4Option.c | 12 +++++- .../Universal/Network/Mtftp4Dxe/Mtftp4Option.h | 6 ++- .../Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c | 44 ++++++++++++++++--= ---- .../Universal/Network/Mtftp4Dxe/Mtftp4Support.c | 14 +++---- .../Universal/Network/Mtftp4Dxe/Mtftp4Support.h | 16 +------- .../Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 41 +++++++++++++++++-= -- 8 files changed, 104 insertions(+), 45 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeMod= ulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index a2583a4..9d4de42 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -1,10 +1,10 @@ /** @file Interface routine for Mtftp4. =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -78,10 +78,12 @@ Mtftp4CleanOperation ( ZeroMem (&Instance->RequestOption, sizeof (MTFTP4_OPTION)); =20 Instance->Operation =3D 0; =20 Instance->BlkSize =3D MTFTP4_DEFAULT_BLKSIZE; + Instance->SentAckNo =3D 0; + Instance->WindowSize =3D 1; Instance->LastBlock =3D 0; Instance->ServerIp =3D 0; Instance->ListeningPort =3D 0; Instance->ConnectedPort =3D 0; Instance->Gateway =3D 0; @@ -438,10 +440,11 @@ Mtftp4Start ( // Set the operation parameters from the configuration or override data. // Config =3D &Instance->Config; Instance->Token =3D Token; Instance->BlkSize =3D MTFTP4_DEFAULT_BLKSIZE; + Instance->WindowSize =3D MTFTP4_DEFAULT_WINDOWSIZE; =20 CopyMem (&Instance->ServerIp, &Config->ServerIp, sizeof (IP4_ADDR)); Instance->ServerIp =3D NTOHL (Instance->ServerIp); =20 Instance->ListeningPort =3D Config->InitialServerPort; diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h b/MdeMod= ulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h index 527fd1d..733bc5d 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h @@ -6,12 +6,13 @@ RFC1350 - THE TFTP PROTOCOL (REVISION 2) RFC2090 - TFTP Multicast Option RFC2347 - TFTP Option Extension RFC2348 - TFTP Blocksize Option RFC2349 - TFTP Timeout Interval and Transfer Size Options + RFC7440 - TFTP Windowsize Option =20 -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -54,10 +55,11 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL; =20 #define MTFTP4_DEFAULT_SERVER_PORT 69 #define MTFTP4_DEFAULT_TIMEOUT 3 #define MTFTP4_DEFAULT_RETRY 5 #define MTFTP4_DEFAULT_BLKSIZE 512 +#define MTFTP4_DEFAULT_WINDOWSIZE 1 #define MTFTP4_TIME_TO_GETMAP 5 =20 #define MTFTP4_STATE_UNCONFIGED 0 #define MTFTP4_STATE_CONFIGED 1 #define MTFTP4_STATE_DESTROY 2 @@ -119,10 +121,17 @@ struct _MTFTP4_PROTOCOL { UINT16 BlkSize; UINT16 LastBlock; LIST_ENTRY Blocks; =20 // + // The last sent ack number.=20 + // + UINT16 SentAckNo; + + UINT16 WindowSize; + + // // The server's communication end point: IP and two ports. one for // initial request, one for its selected port. // IP4_ADDR ServerIp; UINT16 ListeningPort; diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c b/MdeM= odulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c index e40561a..da6aee0 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c @@ -1,9 +1,9 @@ /** @file Routines to process MTFTP4 options. =20 -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -14,10 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 #include "Mtftp4Impl.h" =20 CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] =3D { "blksize", + "windowsize", "timeout", "tsize", "multicast" }; =20 @@ -479,10 +480,19 @@ Mtftp4ParseOption ( } } =20 MtftpOption->Exist |=3D MTFTP4_MCAST_EXIST; =20 + } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "windowsiz= e")) { + Value =3D NetStringToU32 (This->ValueStr); + + if (Value < 1) { + return EFI_INVALID_PARAMETER; + } + + MtftpOption->WindowSize =3D (UINT16) Value; + MtftpOption->Exist |=3D MTFTP4_WINDOWSIZE_EXIST; } else if (Request) { // // Ignore the unsupported option if it is a reply, and return // EFI_UNSUPPORTED if it's a request according to the UEFI spec. // diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h b/MdeM= odulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h index b7fdbf2..b86d77d 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h @@ -1,9 +1,9 @@ /** @file Routines to process MTFTP4 options. =20 -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -14,23 +14,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 =20 #ifndef __EFI_MTFTP4_OPTION_H__ #define __EFI_MTFTP4_OPTION_H__ =20 -#define MTFTP4_SUPPORTED_OPTIONS 4 +#define MTFTP4_SUPPORTED_OPTIONS 5 #define MTFTP4_OPCODE_LEN 2 #define MTFTP4_ERRCODE_LEN 2 #define MTFTP4_BLKNO_LEN 2 #define MTFTP4_DATA_HEAD_LEN 4 =20 #define MTFTP4_BLKSIZE_EXIST 0x01 #define MTFTP4_TIMEOUT_EXIST 0x02 #define MTFTP4_TSIZE_EXIST 0x04 #define MTFTP4_MCAST_EXIST 0x08 +#define MTFTP4_WINDOWSIZE_EXIST 0x10 =20 typedef struct { UINT16 BlkSize; + UINT16 WindowSize; UINT8 Timeout; UINT32 Tsize; IP4_ADDR McastIp; UINT16 McastPort; BOOLEAN Master; diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c b/MdeModu= lePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c index e983d79..5454d6c 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c @@ -1,10 +1,10 @@ /** @file Routines to process Rrq (download). =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -97,10 +97,13 @@ Mtftp4RrqSendAck ( IN UINT16 BlkNo ) { EFI_MTFTP4_PACKET *Ack; NET_BUF *Packet; + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; =20 Packet =3D NetbufAlloc (sizeof (EFI_MTFTP4_ACK_HEADER)); if (Packet =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } @@ -113,11 +116,16 @@ Mtftp4RrqSendAck ( ASSERT (Ack !=3D NULL); =20 Ack->Ack.OpCode =3D HTONS (EFI_MTFTP4_OPCODE_ACK); Ack->Ack.Block[0] =3D HTONS (BlkNo); =20 - return Mtftp4SendPacket (Instance, Packet); + Status =3D Mtftp4SendPacket (Instance, Packet); + if (!EFI_ERROR (Status)) { + Instance->SentAckNo =3D BlkNo; + } + + return Status; } =20 =20 /** Deliver the received data block to the user, which can be saved @@ -156,11 +164,11 @@ Mtftp4RrqSaveBlock ( =20 // // This is the last block, save the block no // if (DataLen < Instance->BlkSize) { - Completed =3D TRUE; + Completed =3D TRUE; Instance->LastBlock =3D Block; Mtftp4SetLastBlockNum (&Instance->Blocks, Block); } =20 // @@ -255,23 +263,23 @@ Mtftp4RrqHandleData ( EFI_STATUS Status; UINT16 BlockNum; INTN Expected; =20 *Completed =3D FALSE; + Status =3D EFI_SUCCESS; BlockNum =3D NTOHS (Packet->Data.Block); Expected =3D Mtftp4GetNextBlockNum (&Instance->Blocks); =20 ASSERT (Expected >=3D 0); =20 // - // If we are active and received an unexpected packet, retransmit - // the last ACK then restart receiving. If we are passive, save - // the block. + // If we are active and received an unexpected packet, transmit + // the ACK for the block we received, then restart receiving the=20 + // expected one. If we are passive, save the block. // if (Instance->Master && (Expected !=3D BlockNum)) { - Mtftp4Retransmit (Instance); - return EFI_SUCCESS; + return Mtftp4RrqSendAck (Instance, (UINT16) (Expected - 1)); } =20 Status =3D Mtftp4RrqSaveBlock (Instance, Packet, Len); =20 if (EFI_ERROR (Status)) { @@ -307,14 +315,17 @@ Mtftp4RrqHandleData ( =20 } else { BlockNum =3D (UINT16) (Expected - 1); } =20 - Mtftp4RrqSendAck (Instance, BlockNum); + if (Instance->WindowSize =3D=3D (BlockNum - Instance->SentAckNo) || Ex= pected < 0) { + Status =3D Mtftp4RrqSendAck (Instance, BlockNum); + } + =20 } =20 - return EFI_SUCCESS; + return Status; } =20 =20 /** Validate whether the options received in the server's OACK packet is val= id. @@ -347,14 +358,15 @@ Mtftp4RrqOackValid ( if ((Reply->Exist &~Request->Exist) !=3D 0) { return FALSE; } =20 // - // Server can only specify a smaller block size to be used and + // Server can only specify a smaller block size and window size to be us= ed and // return the timeout matches that requested. // if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) !=3D 0)&& (Reply->BlkSize > = Request->BlkSize)) || + (((Reply->Exist & MTFTP4_WINDOWSIZE_EXIST) !=3D 0)&& (Reply->WindowSi= ze > Request->WindowSize)) || (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) !=3D 0) && (Reply->Timeout != =3D Request->Timeout))) { return FALSE; } =20 // @@ -527,11 +539,11 @@ Mtftp4RrqHandleOack ( =20 if ((Reply.Exist & MTFTP4_MCAST_EXIST) !=3D 0) { =20 // // Save the multicast info. Always update the Master, only update the - // multicast IP address, block size, timeoute at the first time. If IP + // multicast IP address, block size, window size, timeoute at the firs= t time. If IP // address is updated, create a UDP child to receive the multicast. // Instance->Master =3D Reply.Master; =20 if (Instance->McastIp =3D=3D 0) { @@ -596,10 +608,14 @@ Mtftp4RrqHandleOack ( // Update the parameters used. // if (Reply.BlkSize !=3D 0) { Instance->BlkSize =3D Reply.BlkSize; } + + if (Reply.WindowSize !=3D 0) { + Instance->WindowSize =3D Reply.WindowSize; + } =20 if (Reply.Timeout !=3D 0) { Instance->Timeout =3D Reply.Timeout; } =20 } =20 @@ -609,10 +625,14 @@ Mtftp4RrqHandleOack ( =20 if (Reply.BlkSize !=3D 0) { Instance->BlkSize =3D Reply.BlkSize; } =20 + if (Reply.WindowSize !=3D 0) { + Instance->WindowSize =3D Reply.WindowSize; + } + if (Reply.Timeout !=3D 0) { Instance->Timeout =3D Reply.Timeout; } } =20 diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c b/Mde= ModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c index c625fda..83e6837 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c @@ -1,9 +1,9 @@ /** @file Support routines for Mtftp. =20 -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -218,19 +218,19 @@ Mtftp4RemoveBlockNum ( // transfers of unlimited size. There is no consensus, however, whet= her=20 // the counter should wrap around to zero or to one. Many implementa= tions=20 // wrap to zero, because this is the simplest to implement. Here we = choose=20 // this solution. // - *TotalBlock =3D Num; - =20 + *TotalBlock =3D Num; + if (Range->Round > 0) { - *TotalBlock +=3D Range->Bound + MultU64x32 ((UINTN) (Range->Round -1= ), (UINT32) (Range->Bound + 1)) + 1; - } + *TotalBlock +=3D Range->Bound + MultU64x32 ((UINTN) (Range->Round= -1), (UINT32) (Range->Bound + 1)) + 1; + } =20 if (Range->Start > Range->Bound) { - Range->Start =3D 0; - Range->Round ++; + Range->Start =3D 0; + Range->Round ++; } =20 if ((Range->Start > Range->End) || Completed) { RemoveEntryList (&Range->Link); FreePool (Range); diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h b/Mde= ModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h index 802e386..4b7e2b0 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h @@ -1,9 +1,9 @@ /** @file Support routines for MTFTP. =20 -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -172,24 +172,10 @@ Mtftp4SendError ( IN UINT16 ErrCode, IN UINT8 *ErrInfo ); =20 /** - Retransmit the last packet for the instance. - - @param Instance The Mtftp instance - - @retval EFI_SUCCESS The last packet is retransmitted. - @retval Others Failed to retransmit. - -**/ -EFI_STATUS -Mtftp4Retransmit ( - IN MTFTP4_PROTOCOL *Instance - ); - -/** The timer ticking function for the Mtftp service instance. =20 @param Event The ticking event @param Context The Mtftp service instance =20 diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c b/MdeModu= lePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c index e825714..ea4de93 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c @@ -1,9 +1,9 @@ /** @file Routines to process Wrq (upload). =20 -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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
=20 @@ -19,21 +19,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. /** Build then send a MTFTP data packet for the MTFTP upload session. =20 @param Instance The MTFTP upload session. @param BlockNum The block number to send. + @param Completed Return whether the upload has finished. =20 @retval EFI_OUT_OF_RESOURCES Failed to build the packet. @retval EFI_ABORTED The consumer of this child directs to abor= t the transmission by return an error through Pa= cketNeeded. @retval EFI_SUCCESS The data is sent. =20 **/ EFI_STATUS Mtftp4WrqSendBlock ( IN OUT MTFTP4_PROTOCOL *Instance, - IN UINT16 BlockNum + IN UINT16 BlockNum, + OUT BOOLEAN *Completed ) { EFI_MTFTP4_PACKET *Packet; EFI_MTFTP4_TOKEN *Token; NET_BUF *UdpPacket; @@ -66,19 +68,23 @@ Mtftp4WrqSendBlock ( if (Token->Buffer !=3D NULL) { Start =3D MultU64x32 (BlockNum - 1, Instance->BlkSize); =20 if (Token->BufferSize < Start + Instance->BlkSize) { DataLen =3D (UINT16) (Token->BufferSize - Start); + if (DataLen =3D=3D 0) { + *Completed =3D TRUE; + return EFI_SUCCESS; + } + =20 Instance->LastBlock =3D BlockNum; Mtftp4SetLastBlockNum (&Instance->Blocks, BlockNum); } =20 if (DataLen > 0) { NetbufAllocSpace (UdpPacket, DataLen, FALSE); CopyMem (Packet->Data.Data, (UINT8 *) Token->Buffer + Start, DataLen= ); - } - + }=20 } else { // // Get data from PacketNeeded // DataBuf =3D NULL; @@ -101,10 +107,15 @@ Mtftp4WrqSendBlock ( ); =20 return EFI_ABORTED; } =20 + if (DataLen =3D=3D 0) { + *Completed =3D TRUE; + return EFI_SUCCESS; + } + if (DataLen < Instance->BlkSize) { Instance->LastBlock =3D BlockNum; Mtftp4SetLastBlockNum (&Instance->Blocks, BlockNum); } =20 @@ -144,10 +155,15 @@ Mtftp4WrqHandleAck ( ) { UINT16 AckNum; INTN Expected; UINT64 TotalBlock; + + INTN Index; + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; =20 *Completed =3D FALSE; AckNum =3D NTOHS (Packet->Ack.Block[0]); Expected =3D Mtftp4GetNextBlockNum (&Instance->Blocks); =20 @@ -191,11 +207,19 @@ Mtftp4WrqHandleAck ( =20 return EFI_TFTP_ERROR; } } =20 - return Mtftp4WrqSendBlock (Instance, (UINT16) Expected); + for (Index =3D 0; Index < Instance->WindowSize; Index++) { + if (!EFI_ERROR (Status) && !(*Completed)) { + Status =3D Mtftp4WrqSendBlock (Instance, (UINT16) (Expected + Index)= , Completed); + } else { + break; + } + } + + return Status; } =20 =20 /** Check whether the received OACK is valid.=20 @@ -225,14 +249,15 @@ Mtftp4WrqOackValid ( if ((Reply->Exist & ~Request->Exist) !=3D 0) { return FALSE; } =20 // - // Server can only specify a smaller block size to be used and + // Server can only specify a smaller block size and window size to be us= ed and // return the timeout matches that requested. // if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) !=3D 0) && (Reply->BlkSize >= Request->BlkSize)) || + (((Reply->Exist & MTFTP4_WINDOWSIZE_EXIST) !=3D 0)&& (Reply->WindowSi= ze > Request->WindowSize)) || (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) !=3D 0) && (Reply->Timeout != =3D Request->Timeout))) { return FALSE; } =20 return TRUE; @@ -302,10 +327,14 @@ Mtftp4WrqHandleOack ( =20 if (Reply.BlkSize !=3D 0) { Instance->BlkSize =3D Reply.BlkSize; } =20 + if (Reply.WindowSize !=3D 0) { + Instance->WindowSize =3D Reply.WindowSize; + } + if (Reply.Timeout !=3D 0) { Instance->Timeout =3D Reply.Timeout; } =20 // --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel