]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeNetLib/NetBuffer.c
Remove #include <Protocol/LoadedImage.h>
[mirror_edk2.git] / MdeModulePkg / Library / DxeNetLib / NetBuffer.c
index fcc55a170a66355ce8bbe5fe9bedff2149d4326d..897152946eeefb9d37f9c6762c5717b448bbd3dc 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+  Network library.\r
+  \r
+Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -8,18 +9,9 @@ http://opensource.org/licenses/bsd-license.php
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  NetBuffer.c\r
-\r
-Abstract:\r
-\r
-\r
-\r
 **/\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Library/NetLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -34,10 +26,10 @@ Abstract:
   has the BlockOpNum's NET_BLOCK_OP, and its associated NET_VECTOR has the\r
   BlockNum's NET_BLOCK.\r
 \r
-  @param  BlockNum              The number of NET_BLOCK in the Vector of net buffer\r
-  @param  BlockOpNum            The number of NET_BLOCK_OP in the net buffer\r
+  @param[in]  BlockNum              The number of NET_BLOCK in the Vector of net buffer\r
+  @param[in]  BlockOpNum            The number of NET_BLOCK_OP in the net buffer\r
 \r
-  @retval *                     Pointer to the allocated NET_BUF. If NULL  the\r
+  @return                       Pointer to the allocated NET_BUF. If NULL, the\r
                                 allocation failed due to resource limit.\r
 \r
 **/\r
@@ -92,9 +84,9 @@ FreeNbuf:
   Allocate a single block NET_BUF. Upon allocation, all the\r
   free space is in the tail room.\r
 \r
-  @param  Len                   The length of the block.\r
+  @param[in]  Len              The length of the block.\r
 \r
-  @retval *                     Pointer to the allocated NET_BUF. If NULL  the\r
+  @return                       Pointer to the allocated NET_BUF. If NULL  the\r
                                 allocation failed due to resource limit.\r
 \r
 **/\r
@@ -144,11 +136,9 @@ FreeNBuf:
 \r
 \r
 /**\r
-  Free the vector\r
-\r
-  @param  Vector                Pointer to the NET_VECTOR to be freed.\r
+  Free the vector.\r
 \r
-  @return None.\r
+  @param[in]  Vector                Pointer to the NET_VECTOR to be freed.\r
 \r
 **/\r
 VOID\r
@@ -195,9 +185,7 @@ NetbufFreeVector (
 /**\r
   Free the buffer and its associated NET_VECTOR.\r
 \r
-  @param  Nbuf                  Pointer to the NET_BUF to be freed.\r
-\r
-  @return None.\r
+  @param[in]  Nbuf                  Pointer to the NET_BUF to be freed.\r
 \r
 **/\r
 VOID\r
@@ -225,9 +213,10 @@ NetbufFree (
 /**\r
   Create a copy of NET_BUF that share the associated NET_DATA.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer to be cloned.\r
+  @param[in]  Nbuf              Pointer to the net buffer to be cloned.\r
 \r
-  @retval *                     Pointer to the cloned net buffer.\r
+  @return                       Pointer to the cloned net buffer.If NULL, the\r
+                                allocation failed due to resource limit.\r
 \r
 **/\r
 NET_BUF  *\r
@@ -270,19 +259,20 @@ NetbufClone (
   Create a duplicated copy of Nbuf, data is copied. Also leave some\r
   head space before the data.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer to be cloned.\r
-  @param  Duplicate             Pointer to the net buffer to duplicate to, if NULL\r
-                                a new net  buffer is allocated.\r
-  @param  HeadSpace             Length of the head space to reserve\r
+  @param[in]       Nbuf                  Pointer to the net buffer to be cloned.\r
+  @param[in, out]  Duplicate             Pointer to the net buffer to duplicate to, if NULL\r
+                                         a new net  buffer is allocated.\r
+  @param[in]      HeadSpace              Length of the head space to reserve.\r
 \r
-  @retval *                     Pointer to the duplicated net buffer.\r
+  @return                       Pointer to the duplicated net buffer.If NULL, the\r
+                                allocation failed due to resource limit.\r
 \r
 **/\r
 NET_BUF  *\r
 EFIAPI\r
 NetbufDuplicate (\r
   IN NET_BUF                *Nbuf,\r
-  IN NET_BUF                *Duplicate        OPTIONAL,\r
+  IN OUT NET_BUF            *Duplicate        OPTIONAL,\r
   IN UINT32                 HeadSpace\r
   )\r
 {\r
@@ -315,15 +305,13 @@ NetbufDuplicate (
 /**\r
   Free a list of net buffers.\r
 \r
-  @param  Head                  Pointer to the head of linked net buffers.\r
-\r
-  @return None.\r
+  @param[in, out]  Head              Pointer to the head of linked net buffers.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 NetbufFreeList (\r
-  IN LIST_ENTRY             *Head\r
+  IN OUT LIST_ENTRY         *Head\r
   )\r
 {\r
   LIST_ENTRY                *Entry;\r
@@ -350,11 +338,11 @@ NetbufFreeList (
   returns the fragment that contains the byte which is used mainly by\r
   the buffer implementation itself.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Offset                The index or offset of the byte\r
-  @param  Index                 Index of the fragment that contains the block\r
+  @param[in]   Nbuf                  Pointer to the net buffer.\r
+  @param[in]   Offset                The index or offset of the byte.\r
+  @param[out]  Index                 Index of the fragment that contains the block.\r
 \r
-  @retval *                     Pointer to the nth byte of data in the net buffer.\r
+  @return *                     Pointer to the nth byte of data in the net buffer.\r
                                 If NULL, there is no such data in the net buffer.\r
 \r
 **/\r
@@ -404,18 +392,16 @@ NetbufGetByte (
   are set to the bulk's head and tail respectively. So, this\r
   function alone can't be used by NetbufAlloc.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Bulk                  Pointer to the data.\r
-  @param  Len                   Length of the bulk data.\r
-  @param  Index                 The data block index in the net buffer the bulk\r
-                                data should belong to.\r
-\r
-  @return None.\r
-\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer.\r
+  @param[in]       Bulk                  Pointer to the data.\r
+  @param[in]       Len                   Length of the bulk data.\r
+  @param[in]       Index                 The data block index in the net buffer the bulk\r
+                                         data should belong to.\r
+                                \r
 **/\r
 VOID\r
 NetbufSetBlock (\r
-  IN NET_BUF                *Nbuf,\r
+  IN OUT NET_BUF            *Nbuf,\r
   IN UINT8                  *Bulk,\r
   IN UINT32                 Len,\r
   IN UINT32                 Index\r
@@ -446,18 +432,16 @@ NetbufSetBlock (
   structure is left untouched. Some times, there is no 1:1 relationship\r
   between NET_BLOCK and NET_BLOCK_OP. For example, that in NetbufGetFragment.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Bulk                  Pointer to the data.\r
-  @param  Len                   Length of the bulk data.\r
-  @param  Index                 The data block index in the net buffer the bulk\r
-                                data should belong to.\r
-\r
-  @return None.\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer.\r
+  @param[in]       Bulk                  Pointer to the data.\r
+  @param[in]       Len                   Length of the bulk data.\r
+  @param[in]       Index                 The data block index in the net buffer the bulk\r
+                                         data should belong to.\r
 \r
 **/\r
 VOID\r
 NetbufSetBlockOp (\r
-  IN NET_BUF                *Nbuf,\r
+  IN OUT NET_BUF            *Nbuf,\r
   IN UINT8                  *Bulk,\r
   IN UINT32                 Len,\r
   IN UINT32                 Index\r
@@ -483,9 +467,7 @@ NetbufSetBlockOp (
   need to create a new NET_VECTOR. But, we want to avoid data copy by sharing\r
   the old NET_VECTOR.\r
 \r
-  @param  Arg                   Point to the old NET_VECTOR\r
-\r
-  @return NONE\r
+  @param[in]  Arg                   Point to the old NET_VECTOR.\r
 \r
 **/\r
 VOID\r
@@ -507,14 +489,15 @@ NetbufGetFragmentFree (
   created but the associated data in NET_VECTOR is shared.\r
   This function exists to do IP packet fragmentation.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer to be cloned.\r
-  @param  Offset                Starting point of the data to be included in new\r
-                                buffer.\r
-  @param  Len                   How many data to include in new data\r
-  @param  HeadSpace             How many bytes of head space to reserve for\r
-                                protocol header\r
+  @param[in]  Nbuf                  Pointer to the net buffer to be cloned.\r
+  @param[in]  Offset                Starting point of the data to be included in new\r
+                                    buffer.\r
+  @param[in]  Len                   How many data to include in new data.\r
+  @param[in]  HeadSpace             How many bytes of head space to reserve for\r
+                                    protocol header.\r
 \r
-  @retval *                     Pointer to the cloned net buffer.\r
+  @return                       Pointer to the cloned net buffer.If NULL, the\r
+                                allocation failed due to resource limit.\r
 \r
 **/\r
 NET_BUF  *\r
@@ -687,17 +670,17 @@ FreeChild:
 /**\r
   Build a NET_BUF from external blocks.\r
 \r
-  @param  ExtFragment           Pointer to the data block.\r
-  @param  ExtNum                The number of the data block.\r
-  @param  HeadSpace             The head space to be reserved.\r
-  @param  HeadLen               The length of the protocol header, This function\r
-                                will pull that number of data into a linear block.\r
-  @param  ExtFree               Pointer to the caller provided free function.\r
-  @param  Arg                   The argument passed to ExtFree when ExtFree is\r
-                                called.\r
+  @param[in]  ExtFragment           Pointer to the data block.\r
+  @param[in]  ExtNum                The number of the data block.\r
+  @param[in]  HeadSpace             The head space to be reserved.\r
+  @param[in]  HeadLen               The length of the protocol header, This function\r
+                                    will pull that number of data into a linear block.\r
+  @param[in]  ExtFree               Pointer to the caller provided free function.\r
+  @param[in]  Arg                   The argument passed to ExtFree when ExtFree is\r
+                                    called.\r
 \r
-  @retval *                     Pointer to the net buffer built from the data\r
-                                blocks.\r
+  @return                    Pointer to the net buffer built from the data blocks.\r
+                             If NULL, the allocation failed due to resource limit.\r
 \r
 **/\r
 NET_BUF  *\r
@@ -822,7 +805,7 @@ NetbufFromExt (
   Vector       = Nbuf->Vector;\r
   Vector->Free = ExtFree;\r
   Vector->Arg  = Arg;\r
-  Vector->Flag = (FirstBlockLen ? NET_VECTOR_OWN_FIRST : 0);\r
+  Vector->Flag = ((FirstBlockLen != 0) ? NET_VECTOR_OWN_FIRST : 0);\r
 \r
   //\r
   // Set the first block up which may contain\r
@@ -847,7 +830,7 @@ NetbufFromExt (
   Vector->Len     = TotalLen + HeadSpace;\r
   Nbuf->TotalSize = TotalLen;\r
 \r
-  if (SavedIndex) {\r
+  if (SavedIndex != 0) {\r
     ExtFragment[SavedIndex] = SavedFragment;\r
   }\r
 \r
@@ -863,11 +846,11 @@ FreeFirstBlock:
   Build a fragment table to contain the fragments in the\r
   buffer. This is the opposite of the NetbufFromExt.\r
 \r
-  @param  Nbuf                  Point to the net buffer\r
-  @param  ExtFragment           Pointer to the data block.\r
-  @param  ExtNum                The number of the data block.\r
+  @param[in]       Nbuf                  Point to the net buffer.\r
+  @param[in, out]  ExtFragment           Pointer to the data block.\r
+  @param[in, out]  ExtNum                The number of the data block.\r
 \r
-  @retval EFI_BUFFER_TOO_SMALL  The number of non-empty block is bigger than ExtNum\r
+  @retval EFI_BUFFER_TOO_SMALL  The number of non-empty block is bigger than ExtNum.\r
   @retval EFI_SUCCESS           Fragment table built.\r
 \r
 **/\r
@@ -875,8 +858,8 @@ EFI_STATUS
 EFIAPI\r
 NetbufBuildExt (\r
   IN NET_BUF                *Nbuf,\r
-  IN NET_FRAGMENT           *ExtFragment,\r
-  IN UINT32                 *ExtNum\r
+  IN OUT NET_FRAGMENT       *ExtFragment,\r
+  IN OUT UINT32             *ExtNum\r
   )\r
 {\r
   UINT32                    Index;\r
@@ -906,15 +889,15 @@ NetbufBuildExt (
 /**\r
   Build a NET_BUF from a list of NET_BUF.\r
 \r
-  @param  BufList               A List of NET_BUF.\r
-  @param  HeadSpace             The head space to be reserved.\r
-  @param  HeaderLen             The length of the protocol header, This function\r
-                                will pull that number of data into a linear block.\r
-  @param  ExtFree               Pointer to the caller provided free function.\r
-  @param  Arg                   The argument passed to ExtFree when ExtFree is\r
-                                called.\r
+  @param[in]   BufList               A List of NET_BUF.\r
+  @param[in]   HeadSpace             The head space to be reserved.\r
+  @param[in]   HeaderLen             The length of the protocol header, This function\r
+                                     will pull that number of data into a linear block.\r
+  @param[in]   ExtFree               Pointer to the caller provided free function.\r
+  @param[in]   Arg                   The argument passed to ExtFree when ExtFree is\r
+                                     called.\r
 \r
-  @retval *                     Pointer to the net buffer built from the data\r
+  @return                       Pointer to the net buffer built from the data\r
                                 blocks.\r
 \r
 **/\r
@@ -986,16 +969,14 @@ NetbufFromBufList (
   of an empty NET_BUF not built from the external. But\r
   it should be enough for the network stack.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Len                   The length of buffer to be reserverd.\r
-\r
-  @return None.\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer.\r
+  @param[in]       Len                   The length of buffer to be reserverd.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 NetbufReserve (\r
-  IN NET_BUF                *Nbuf,\r
+  IN OUT NET_BUF            *Nbuf,\r
   IN UINT32                 Len\r
   )\r
 {\r
@@ -1015,19 +996,19 @@ NetbufReserve (
 /**\r
   Allocate some space from the header or tail of the buffer.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Len                   The length of the buffer to be allocated.\r
-  @param  FromHead              The flag to indicate whether reserve the data from\r
-                                head or tail. TRUE for from head, and FALSE for\r
-                                from tail.\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer.\r
+  @param[in]       Len                   The length of the buffer to be allocated.\r
+  @param [in]      FromHead              The flag to indicate whether reserve the data from\r
+                                         head or tail. TRUE for from head, and FALSE for\r
+                                         from tail.\r
 \r
-  @retval *                     Pointer to the first byte of the allocated buffer.\r
+  @return                       Pointer to the first byte of the allocated buffer.\r
 \r
 **/\r
 UINT8  *\r
 EFIAPI\r
 NetbufAllocSpace (\r
-  IN NET_BUF                *Nbuf,\r
+  IN OUT NET_BUF            *Nbuf,\r
   IN UINT32                 Len,\r
   IN BOOLEAN                FromHead\r
   )\r
@@ -1107,17 +1088,15 @@ NetbufAllocSpace (
 /**\r
   Trim a single NET_BLOCK.\r
 \r
-  @param  BlockOp               Pointer to the NET_BLOCK.\r
-  @param  Len                   The length of the data to be trimmed.\r
-  @param  FromHead              The flag to indicate whether trim data from head or\r
-                                tail. TRUE for from head, and FALSE for from tail.\r
-\r
-  @return None.\r
+  @param[in, out]  BlockOp               Pointer to the NET_BLOCK.\r
+  @param[in]       Len                   The length of the data to be trimmed.\r
+  @param[in]       FromHead              The flag to indicate whether trim data from head or\r
+                                         tail. TRUE for from head, and FALSE for from tail.\r
 \r
 **/\r
 VOID\r
 NetblockTrim (\r
-  IN NET_BLOCK_OP           *BlockOp,\r
+  IN OUT NET_BLOCK_OP       *BlockOp,\r
   IN UINT32                 Len,\r
   IN BOOLEAN                FromHead\r
   )\r
@@ -1137,18 +1116,18 @@ NetblockTrim (
 /**\r
   Trim some data from the header or tail of the buffer.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Len                   The length of the data to be trimmed.\r
-  @param  FromHead              The flag to indicate whether trim data from head or\r
-                                tail. TRUE for from head, and FALSE for from tail.\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer.\r
+  @param[in]       Len                   The length of the data to be trimmed.\r
+  @param[in]      FromHead               The flag to indicate whether trim data from head or\r
+                                         tail. TRUE for from head, and FALSE for from tail.\r
 \r
-  @retval UINTN                 Length of the actually trimmed data.\r
+  @return    Length of the actually trimmed data.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 NetbufTrim (\r
-  IN NET_BUF                *Nbuf,\r
+  IN OUT NET_BUF            *Nbuf,\r
   IN UINT32                 Len,\r
   IN BOOLEAN                FromHead\r
   )\r
@@ -1202,10 +1181,10 @@ NetbufTrim (
 /**\r
   Copy the data from the specific offset to the destination.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
-  @param  Offset                The sequence number of the first byte to copy.\r
-  @param  Len                   Length of the data to copy.\r
-  @param  Dest                  The destination of the data to copy to.\r
+  @param[in]   Nbuf                  Pointer to the net buffer.\r
+  @param[in]   Offset                The sequence number of the first byte to copy.\r
+  @param[in]   Len                   Length of the data to copy.\r
+  @param[in]   Dest                  The destination of the data to copy to.\r
 \r
   @retval UINTN                 The length of the copied data.\r
 \r
@@ -1302,15 +1281,13 @@ NetbufCopy (
 /**\r
   Initiate the net buffer queue.\r
 \r
-  @param  NbufQue               Pointer to the net buffer queue to be initiated.\r
-\r
-  @return None.\r
+  @param[in, out]  NbufQue               Pointer to the net buffer queue to be initiated.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 NetbufQueInit (\r
-  IN NET_BUF_QUEUE          *NbufQue\r
+  IN OUT NET_BUF_QUEUE          *NbufQue\r
   )\r
 {\r
   NbufQue->Signature  = NET_QUE_SIGNATURE;\r
@@ -1326,9 +1303,8 @@ NetbufQueInit (
 /**\r
   Allocate an initialized net buffer queue.\r
 \r
-  None.\r
-\r
-  @retval *                     Pointer to the allocated net buffer queue.\r
+  @return                       Pointer to the allocated net buffer queue.If NULL, the\r
+                                allocation failed due to resource limit.\r
 \r
 **/\r
 NET_BUF_QUEUE  *\r
@@ -1353,9 +1329,7 @@ NetbufQueAlloc (
 /**\r
   Free a net buffer queue.\r
 \r
-  @param  NbufQue               Poitner to the net buffer queue to be freed.\r
-\r
-  @return None.\r
+  @param[in]  NbufQue               Poitner to the net buffer queue to be freed.\r
 \r
 **/\r
 VOID\r
@@ -1378,17 +1352,15 @@ NetbufQueFree (
 /**\r
   Append a buffer to the end of the queue.\r
 \r
-  @param  NbufQue               Pointer to the net buffer queue.\r
-  @param  Nbuf                  Pointer to the net buffer to be appended.\r
-\r
-  @return None.\r
+  @param[in, out]  NbufQue               Pointer to the net buffer queue.\r
+  @param[in, out]  Nbuf                  Pointer to the net buffer to be appended.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 NetbufQueAppend (\r
-  IN NET_BUF_QUEUE          *NbufQue,\r
-  IN NET_BUF                *Nbuf\r
+  IN OUT NET_BUF_QUEUE          *NbufQue,\r
+  IN OUT NET_BUF                *Nbuf\r
   )\r
 {\r
   NET_CHECK_SIGNATURE (NbufQue, NET_QUE_SIGNATURE);\r
@@ -1404,16 +1376,17 @@ NetbufQueAppend (
 /**\r
   Remove a net buffer from head in the specific queue.\r
 \r
-  @param  NbufQue               Pointer to the net buffer queue.\r
+  @param[in, out]  NbufQue               Pointer to the net buffer queue.\r
 \r
-  @retval *                     Pointer to the net buffer removed from the specific\r
+  @return                       Pointer to the net buffer removed from the specific\r
+                                queue. If NULL, there is no net buffer in the specific\r
                                 queue.\r
 \r
 **/\r
 NET_BUF  *\r
 EFIAPI\r
 NetbufQueRemove (\r
-  IN NET_BUF_QUEUE          *NbufQue\r
+  IN OUT NET_BUF_QUEUE          *NbufQue\r
   )\r
 {\r
   NET_BUF                   *First;\r
@@ -1437,20 +1410,22 @@ NetbufQueRemove (
 /**\r
   Copy some data from the buffer queue to the destination.\r
 \r
-  @param  NbufQue               Pointer to the net buffer queue.\r
-  @param  Offset                The sequence number of the first byte to copy.\r
-  @param  Len                   Length of the data to copy.\r
-  @param  Dest                  The destination of the data to copy to.\r
+  @param[in]   NbufQue               Pointer to the net buffer queue.\r
+  @param[in]   Offset                The sequence number of the first byte to copy.\r
+  @param[in]   Len                   Length of the data to copy.\r
+  @param[out]  Dest                  The destination of the data to copy to.\r
 \r
-  @retval UINTN                 The length of the copied data.\r
+  @return       The length of the copied data. If 0, then the length is zero or offset \r
+                suppress the total size of net buffer.\r
 \r
 **/\r
 UINT32\r
+EFIAPI\r
 NetbufQueCopy (\r
   IN NET_BUF_QUEUE          *NbufQue,\r
   IN UINT32                 Offset,\r
   IN UINT32                 Len,\r
-  IN UINT8                  *Dest\r
+  OUT UINT8                 *Dest\r
   )\r
 {\r
   LIST_ENTRY                *Entry;\r
@@ -1534,16 +1509,16 @@ NetbufQueCopy (
   Trim some data from the queue header, release the buffer if\r
   whole buffer is trimmed.\r
 \r
-  @param  NbufQue               Pointer to the net buffer queue.\r
-  @param  Len                   Length of the data to trim.\r
+  @param[in, out]  NbufQue               Pointer to the net buffer queue.\r
+  @param[in]       Len                   Length of the data to trim.\r
 \r
-  @retval UINTN                 The length of the data trimmed.\r
+  @return   The length of the data trimmed, or 0 if length of the data to trim is zero.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 NetbufQueTrim (\r
-  IN NET_BUF_QUEUE          *NbufQue,\r
+  IN OUT NET_BUF_QUEUE      *NbufQue,\r
   IN UINT32                 Len\r
   )\r
 {\r
@@ -1594,15 +1569,13 @@ NetbufQueTrim (
 /**\r
   Flush the net buffer queue.\r
 \r
-  @param  NbufQue               Pointer to the queue to be flushed.\r
-\r
-  @return None.\r
+  @param[in, out]  NbufQue               Pointer to the queue to be flushed.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 NetbufQueFlush (\r
-  IN NET_BUF_QUEUE          *NbufQue\r
+  IN OUT NET_BUF_QUEUE          *NbufQue\r
   )\r
 {\r
   NET_CHECK_SIGNATURE (NbufQue, NET_QUE_SIGNATURE);\r
@@ -1617,10 +1590,10 @@ NetbufQueFlush (
 /**\r
   Compute checksum for a bulk of data.\r
 \r
-  @param  Bulk                  Pointer to the data.\r
-  @param  Len                   Length of the data, in bytes.\r
+  @param[in]   Bulk                  Pointer to the data.\r
+  @param[in]   Len                   Length of the data, in bytes.\r
 \r
-  @retval UINT16                The computed checksum.\r
+  @return    The computed checksum.\r
 \r
 **/\r
 UINT16\r
@@ -1650,7 +1623,7 @@ NetblockChecksum (
   //\r
   // Fold 32-bit sum to 16 bits\r
   //\r
-  while (Sum >> 16) {\r
+  while ((Sum >> 16) != 0) {\r
     Sum = (Sum & 0xffff) + (Sum >> 16);\r
 \r
   }\r
@@ -1662,10 +1635,10 @@ NetblockChecksum (
 /**\r
   Add two checksums.\r
 \r
-  @param  Checksum1             The first checksum to be added.\r
-  @param  Checksum2             The second checksum to be added.\r
+  @param[in]   Checksum1             The first checksum to be added.\r
+  @param[in]   Checksum2             The second checksum to be added.\r
 \r
-  @retval UINT16                The new checksum.\r
+  @return         The new checksum.\r
 \r
 **/\r
 UINT16\r
@@ -1682,7 +1655,7 @@ NetAddChecksum (
   //\r
   // two UINT16 can only add up to a carry of 1.\r
   //\r
-  if (Sum >> 16) {\r
+  if ((Sum >> 16) != 0) {\r
     Sum = (Sum & 0xffff) + 1;\r
 \r
   }\r
@@ -1694,9 +1667,9 @@ NetAddChecksum (
 /**\r
   Compute the checksum for a NET_BUF.\r
 \r
-  @param  Nbuf                  Pointer to the net buffer.\r
+  @param[in]   Nbuf                  Pointer to the net buffer.\r
 \r
-  @retval UINT16                The computed checksum.\r
+  @return    The computed checksum.\r
 \r
 **/\r
 UINT16\r
@@ -1724,7 +1697,7 @@ NetbufChecksum (
 \r
     BlockSum = NetblockChecksum (BlockOp[Index].Head, BlockOp[Index].Size);\r
 \r
-    if (Offset & 0x01) {\r
+    if ((Offset & 0x01) != 0) {\r
       //\r
       // The checksum starts with an odd byte, swap\r
       // the checksum before added to total checksum\r
@@ -1745,12 +1718,12 @@ NetbufChecksum (
   Src, Dst are in network byte order. and Len is\r
   in host byte order.\r
 \r
-  @param  Src                   The source address of the packet.\r
-  @param  Dst                   The destination address of the packet.\r
-  @param  Proto                 The protocol type of the packet.\r
-  @param  Len                   The length of the packet.\r
+  @param[in]   Src                   The source address of the packet.\r
+  @param[in]   Dst                   The destination address of the packet.\r
+  @param[in]   Proto                 The protocol type of the packet.\r
+  @param[in]   Len                   The length of the packet.\r
 \r
-  @retval UINT16                The computed checksum.\r
+  @return   The computed checksum.\r
 \r
 **/\r
 UINT16\r