From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 954BC222A54FF for ; Wed, 3 Jan 2018 22:10:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 22:15:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,506,1508828400"; d="scan'208";a="17355663" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 03 Jan 2018 22:15:04 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 3 Jan 2018 22:15:04 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 3 Jan 2018 22:15:03 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Thu, 4 Jan 2018 14:15:01 +0800 From: "Fu, Siyuan" To: "Wang, Fan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Wang, Fan" , "Wu, Jiaxin" Thread-Topic: [edk2] [Patch] MdeModulePkg/DxeUdpIoLib: Did some code enhancement for UdpIoLib Thread-Index: AQHThSGbkvtgme0U0EKzYF9S/gNYMKNjOzwQ Date: Thu, 4 Jan 2018 06:15:00 +0000 Message-ID: References: <1515045735-9004-1-git-send-email-fan.wang@intel.com> In-Reply-To: <1515045735-9004-1-git-send-email-fan.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWZkYTY2MWYtNzk5Mi00YWFmLWFiNjYtYTQ3NTkxMzQzZWU0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJzTlJxXC9NQ3c1ZDZsdzBCOFhLSGR5Ylh1eVM3cVFrelVPSVlWVUVJUlwvc2dtQ3YrdEE1WWJtQVozc0w1MTg5YlUifQ== dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/DxeUdpIoLib: Did some code enhancement for UdpIoLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 06:10:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Fan + If Udp version is not Udp4 or Udp6, then ASSERT(). It's better to update "Udp4" and "Udp6" to " UDP_IO_UDP4_VERSION" and " UDP= _IO_UDP6_VERSION" Other parts are good with me. Reviewed-by: Fu Siyuan > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > fanwang2 > Sent: Thursday, January 4, 2018 2:02 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Wang, Fan ; Fu, > Siyuan ; Wu, Jiaxin > Subject: [edk2] [Patch] MdeModulePkg/DxeUdpIoLib: Did some code > enhancement for UdpIoLib >=20 > From: Wang Fan >=20 > * Added some ASSERT descriptions for library APIs. > * Added "Optional" option for Context parameter in UdpIoCancelDgrams(). > * Added function return status check for UdpIoFreeIo(). >=20 > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Jiaxin Wu > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan > --- > MdeModulePkg/Include/Library/UdpIoLib.h | 16 ++++- > MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c | 90 ++++++++++++++++++--= - > ----- > 2 files changed, 78 insertions(+), 28 deletions(-) >=20 > diff --git a/MdeModulePkg/Include/Library/UdpIoLib.h > b/MdeModulePkg/Include/Library/UdpIoLib.h > index e0b44ce..86a11a9 100644 > --- a/MdeModulePkg/Include/Library/UdpIoLib.h > +++ b/MdeModulePkg/Include/Library/UdpIoLib.h > @@ -195,11 +195,13 @@ BOOLEAN > IN VOID *Context > ); >=20 > /** > Cancel all the sent datagram that pass the selection criteria of > ToCancel. > + > If ToCancel is NULL, all the datagrams are cancelled. > + If Udp version is not Udp4 or Udp6, then ASSERT(). >=20 > @param[in] UdpIo The UDP_IO to cancel packet. > @param[in] IoStatus The IoStatus to return to the packet > owners. > @param[in] ToCancel The select funtion to test whether t= o > cancel this > packet or not. > @@ -210,17 +212,20 @@ VOID > EFIAPI > UdpIoCancelDgrams ( > IN UDP_IO *UdpIo, > IN EFI_STATUS IoStatus, > IN UDP_IO_TO_CANCEL ToCancel, OPTIONAL > - IN VOID *Context > + IN VOID *Context OPTIONAL > ); >=20 > /** > Creates a UDP_IO to access the UDP service. It creates and configures > a UDP child. >=20 > + If Configure is NULL, then ASSERT(). > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > It locates the UDP service binding prototype on the Controller > parameter > uses the UDP service binding prototype to create a UDP child (also > known as > a UDP instance) configures the UDP child by calling Configure function > prototype. > Any failures in creating or configuring the UDP child return NULL for > failure. >=20 > @@ -245,15 +250,18 @@ UdpIoCreateIo ( > ); >=20 > /** > Free the UDP_IO and all its related resources. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > The function cancels all sent datagrams and receive requests. >=20 > @param[in] UdpIo The UDP_IO to free. >=20 > @retval EFI_SUCCESS The UDP_IO is freed. > + @retval Others Failed to free UDP_IO. >=20 > **/ > EFI_STATUS > EFIAPI > UdpIoFreeIo ( > @@ -262,10 +270,12 @@ UdpIoFreeIo ( >=20 > /** > Cleans up the UDP_IO without freeing it. Call this function > if you intend to later re-use the UDP_IO. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > This function releases all transmitted datagrams and receive requests > and configures NULL for the UDP instance. >=20 > @param[in] UdpIo The UDP_IO to clean up. >=20 > **/ > @@ -276,10 +286,12 @@ UdpIoCleanIo ( > ); >=20 > /** > Send a packet through the UDP_IO. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > The packet will be wrapped in UDP_TX_TOKEN. Function Callback will be > called > when the packet is sent. The optional parameter EndPoint overrides the > default > address pair if specified. >=20 > @param[in] UdpIo The UDP_IO to send the packet throug= h. > @@ -322,10 +334,12 @@ UdpIoCancelSentDatagram ( > ); >=20 > /** > Issue a receive request to the UDP_IO. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > This function is called when upper-layer needs packet from UDP for > processing. > Only one receive request is acceptable at a time. Therefore, one commo= n > usage model is > to invoke this function inside its Callback function when the former > packet > is processed. >=20 > diff --git a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c > b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c > index 4861095..e2d3466 100644 > --- a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c > +++ b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c > @@ -408,10 +408,13 @@ UdpIoCreateRxToken ( > } >=20 > /** > Wrap a transmit request into a new created UDP_TX_TOKEN. >=20 > + If Packet is NULL, then ASSERT(). > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > @param[in] UdpIo The UdpIo to send packet to. > @param[in] Packet The user's packet. > @param[in] EndPoint The local and remote access point. > @param[in] Gateway The overrided next hop. > @param[in] CallBack The function to call when > transmission completed. > @@ -578,10 +581,13 @@ UdpIoCreateTxToken ( >=20 > /** > Creates a UDP_IO to access the UDP service. It creates and configures > a UDP child. >=20 > + If Configure is NULL, then ASSERT(). > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > It locates the UDP service binding prototype on the Controller > parameter > uses the UDP service binding prototype to create a UDP child (also > known as > a UDP instance) configures the UDP child by calling Configure function > prototype. > Any failures in creating or configuring the UDP child return NULL for > failure. >=20 > @@ -747,11 +753,13 @@ FREE_MEM: > return NULL; > } >=20 > /** > Cancel all the sent datagram that pass the selection criteria of > ToCancel. > + > If ToCancel is NULL, all the datagrams are cancelled. > + If Udp version is not Udp4 or Udp6, then ASSERT(). >=20 > @param[in] UdpIo The UDP_IO to cancel packet. > @param[in] IoStatus The IoStatus to return to the packet > owners. > @param[in] ToCancel The select funtion to test whether t= o > cancel this > packet or not. > @@ -762,11 +770,11 @@ VOID > EFIAPI > UdpIoCancelDgrams ( > IN UDP_IO *UdpIo, > IN EFI_STATUS IoStatus, > IN UDP_IO_TO_CANCEL ToCancel, OPTIONAL > - IN VOID *Context > + IN VOID *Context OPTIONAL > ) > { > LIST_ENTRY *Entry; > LIST_ENTRY *Next; > UDP_TX_TOKEN *TxToken; > @@ -789,23 +797,27 @@ UdpIoCancelDgrams ( > } >=20 > /** > Free the UDP_IO and all its related resources. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > The function will cancel all sent datagram and receive request. >=20 > @param[in] UdpIo The UDP_IO to free. >=20 > @retval EFI_SUCCESS The UDP_IO is freed. > + @retval Others Failed to free UDP_IO. >=20 > **/ > EFI_STATUS > EFIAPI > UdpIoFreeIo ( > IN UDP_IO *UdpIo > ) > { > + EFI_STATUS Status; > UDP_RX_TOKEN *RxToken; >=20 > ASSERT ((UdpIo->UdpVersion =3D=3D UDP_IO_UDP4_VERSION) || > (UdpIo->UdpVersion =3D=3D UDP_IO_UDP6_VERSION)); >=20 > @@ -820,53 +832,71 @@ UdpIoFreeIo ( > UdpIoCancelDgrams (UdpIo, EFI_ABORTED, NULL, NULL); >=20 > if (UdpIo->UdpVersion =3D=3D UDP_IO_UDP4_VERSION) { >=20 > if ((RxToken =3D UdpIo->RecvRequest) !=3D NULL) { > - UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &RxToken- > >Token.Udp4); > + Status =3D UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, > &RxToken->Token.Udp4); > + if (EFI_ERROR (Status)) { > + return Status; > + } > } >=20 > // > // Close then destroy the Udp4 child > // > - gBS->CloseProtocol ( > - UdpIo->UdpHandle, > - &gEfiUdp4ProtocolGuid, > - UdpIo->Image, > - UdpIo->Controller > - ); > + Status =3D gBS->CloseProtocol ( > + UdpIo->UdpHandle, > + &gEfiUdp4ProtocolGuid, > + UdpIo->Image, > + UdpIo->Controller > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } >=20 > - NetLibDestroyServiceChild ( > - UdpIo->Controller, > - UdpIo->Image, > - &gEfiUdp4ServiceBindingProtocolGuid, > - UdpIo->UdpHandle > - ); > + Status =3D NetLibDestroyServiceChild ( > + UdpIo->Controller, > + UdpIo->Image, > + &gEfiUdp4ServiceBindingProtocolGuid, > + UdpIo->UdpHandle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } >=20 > } else { >=20 > if ((RxToken =3D UdpIo->RecvRequest) !=3D NULL) { > - UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken- > >Token.Udp6); > + Status =3D UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, > &RxToken->Token.Udp6); > + if (EFI_ERROR (Status)) { > + return Status; > + } > } >=20 > // > // Close then destroy the Udp6 child > // > - gBS->CloseProtocol ( > - UdpIo->UdpHandle, > - &gEfiUdp6ProtocolGuid, > - UdpIo->Image, > - UdpIo->Controller > - ); > + Status =3D gBS->CloseProtocol ( > + UdpIo->UdpHandle, > + &gEfiUdp6ProtocolGuid, > + UdpIo->Image, > + UdpIo->Controller > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } >=20 > - NetLibDestroyServiceChild ( > - UdpIo->Controller, > - UdpIo->Image, > - &gEfiUdp6ServiceBindingProtocolGuid, > - UdpIo->UdpHandle > - ); > + Status =3D NetLibDestroyServiceChild ( > + UdpIo->Controller, > + UdpIo->Image, > + &gEfiUdp6ServiceBindingProtocolGuid, > + UdpIo->UdpHandle > + ); > + if (EFI_ERROR (Status)) { > + return Status; > } > + } >=20 > if (!IsListEmpty(&UdpIo->Link)) { > RemoveEntryList (&UdpIo->Link); > } >=20 > @@ -877,10 +907,12 @@ UdpIoFreeIo ( >=20 > /** > Clean up the UDP_IO without freeing it. The function is called when > user wants to re-use the UDP_IO later. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > It will release all the transmitted datagrams and receive request. It > will > also configure NULL for the UDP instance. >=20 > @param[in] UdpIo The UDP_IO to clean up. >=20 > @@ -918,10 +950,12 @@ UdpIoCleanIo ( > } >=20 > /** > Send a packet through the UDP_IO. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > The packet will be wrapped in UDP_TX_TOKEN. Function Callback will be > called > when the packet is sent. The optional parameter EndPoint overrides the > default > address pair if specified. >=20 > @param[in] UdpIo The UDP_IO to send the packet throug= h. > @@ -1028,10 +1062,12 @@ UdpIoCancelSentDatagram ( > } >=20 > /** > Issue a receive request to the UDP_IO. >=20 > + If Udp version is not Udp4 or Udp6, then ASSERT(). > + > This function is called when upper-layer needs packet from UDP for > processing. > Only one receive request is acceptable at a time so a common usage > model is > to invoke this function inside its Callback function when the former > packet > is processed. >=20 > -- > 1.9.5.msysgit.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel