]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
update file header
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiProto.c
index 7db57506b9ba28f89f4610c673c21bf4d1e44462..c3ef7818c4021aee14d62cc70e3762047e8de97a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  The implementation of IScsi protocol based on RFC3720\r
+  The implementation of IScsi protocol based on RFC3720.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2008, 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
@@ -10,13 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 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
-  IScsiProto.c\r
-\r
-Abstract:\r
-  The implementation of IScsi protocol based on RFC3720\r
-\r
 **/\r
 \r
 #include "IScsiImpl.h"\r
@@ -26,12 +19,8 @@ UINT32 mDataSegPad = 0;
 /**\r
   Attach the iSCSI connection to the iSCSI session. \r
 \r
-  @param  Session[in] The iSCSI session.\r
-\r
-  @param  Conn[in]    The iSCSI connection.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Session The iSCSI session.\r
+  @param[in]  Conn    The iSCSI connection.\r
 **/\r
 VOID\r
 IScsiAttatchConnection (\r
@@ -47,10 +36,7 @@ IScsiAttatchConnection (
 /**\r
   Detach the iSCSI connection from the session it belongs to. \r
 \r
-  @param  Conn[in] The iSCSI connection.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Conn The iSCSI connection.\r
 **/\r
 VOID\r
 IScsiDetatchConnection (\r
@@ -65,12 +51,12 @@ IScsiDetatchConnection (
 /**\r
   Check the sequence number according to RFC3720. \r
 \r
-  @param  ExpSN[in]   The currently expected sequence number.\r
-\r
-  @param  NewSN[in]   The sequence number to check.\r
-\r
-  @retval EFI_SUCCESS The check passed and the ExpSN is increased.\r
+  @param[in]  ExpSN   The currently expected sequence number.\r
+  @param[in]  NewSN  The sequence number to check.\r
 \r
+  @retval EFI_SUCCESS         The check passed and the ExpSN is increased.\r
+  @retval EFI_NOT_READY       Response was sent due to a retransmission request.\r
+  @retval EFI_PROTOCOL_ERROR  Some kind of iSCSI protocol error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiCheckSN (\r
@@ -99,14 +85,9 @@ IScsiCheckSN (
 /**\r
   Update the sequence numbers for the iSCSI command.\r
 \r
-  @param  Session[in]  The iSCSI session.\r
-\r
-  @param  MaxCmdSN[in] Maximum CmdSN from the target.\r
-\r
-  @param  ExpCmdSN[in] Next expected CmdSN from the target.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Session  The iSCSI session.\r
+  @param[in]  MaxCmdSN Maximum CmdSN from the target.\r
+  @param[in]  ExpCmdSN Next expected CmdSN from the target.\r
 **/\r
 VOID\r
 IScsiUpdateCmdSN (\r
@@ -131,14 +112,11 @@ IScsiUpdateCmdSN (
 /**\r
   This function does the iSCSI connection login.\r
 \r
-  @param  Conn[in]           The iSCSI connection to login.\r
+  @param[in]  Conn           The iSCSI connection to login.\r
 \r
   @retval EFI_SUCCESS        The iSCSI connection is logged into the iSCSI target.\r
-\r
   @retval EFI_TIMEOUT        Timeout happened during the login procedure.\r
-\r
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r
-\r
+  @retval Others             Some unexpected error happened.  \r
 **/\r
 EFI_STATUS\r
 IScsiConnLogin (\r
@@ -186,10 +164,7 @@ IScsiConnLogin (
 /**\r
   Reset the iSCSI connection.\r
 \r
-  @param  Conn[in] The iSCSI connection to reset.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Conn The iSCSI connection to reset.\r
 **/\r
 VOID\r
 IScsiConnReset (\r
@@ -202,12 +177,10 @@ IScsiConnReset (
 /**\r
   Create a TCP connection for the iSCSI session.\r
 \r
-  @param  Private[in] The iSCSI driver data.\r
-\r
-  @param  Session[in] Maximum CmdSN from the target.\r
-\r
-  @retval The newly created iSCSI connection.\r
+  @param[in]  Private The iSCSI driver data.\r
+  @param[in]  Session Maximum CmdSN from the target.\r
 \r
+  @return The newly created iSCSI connection.\r
 **/\r
 ISCSI_CONNECTION *\r
 IScsiCreateConnection (\r
@@ -283,10 +256,7 @@ IScsiCreateConnection (
 /**\r
   Destroy an iSCSI connection.\r
 \r
-  @param  Conn[in] The connection to destroy.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Conn The connection to destroy.\r
 **/\r
 VOID\r
 IScsiDestroyConnection (\r
@@ -302,14 +272,11 @@ IScsiDestroyConnection (
 /**\r
   Login the iSCSI session.\r
 \r
-  @param  Private[in]          The iSCSI driver data.\r
+  @param[in]  Private          The iSCSI driver data.\r
 \r
   @retval EFI_SUCCESS          The iSCSI session login procedure finished.\r
-\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
-  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.\r
-\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiSessionLogin (\r
@@ -361,15 +328,12 @@ IScsiSessionLogin (
   Build and send the iSCSI login request to the iSCSI target according to\r
   the current login stage.\r
 \r
-  @param  Conn[in]             The connection in the iSCSI login phase.\r
+  @param[in]  Conn             The connection in the iSCSI login phase.\r
 \r
   @retval EFI_SUCCESS          The iSCSI login request PDU is built and sent on this\r
                                connection.\r
-\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
-  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.\r
-\r
+  @retval EFI_DEVICE_ERROR     Some kind of device error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiSendLoginReq (\r
@@ -399,14 +363,10 @@ IScsiSendLoginReq (
 /**\r
   Receive and process the iSCSI login response.\r
 \r
-  @param  Conn[in]             The connection in the iSCSI login phase.\r
-\r
+  @param[in]  Conn             The connection in the iSCSI login phase.\r
+  \r
   @retval EFI_SUCCESS          The iSCSI login response PDU is received and processed.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
-  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.\r
-\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiReceiveLoginRsp (\r
@@ -438,19 +398,15 @@ IScsiReceiveLoginRsp (
   The DataSegmentLength and the actual size of the net buffer containing this PDU will be\r
   updated.\r
 \r
-  @param  Pdu[in]              The iSCSI PDU whose data segment the key-value pair will\r
+  @param[in]  Pdu              The iSCSI PDU whose data segment the key-value pair will\r
                                be added to.\r
-\r
-  @param  Key[in]              The key name string.\r
-\r
-  @param  Value[in]            The value string.\r
+  @param[in]  Key              The key name string.\r
+  @param[in]  Value            The value string.\r
 \r
   @retval EFI_SUCCESS          The key-valu pair is added to the PDU's datasegment and\r
                                the correspondence length fields are updated.\r
-\r
   @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to add the key-value\r
                                pair.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiAddKeyValuePair (\r
@@ -513,10 +469,10 @@ IScsiAddKeyValuePair (
 /**\r
   Prepare the iSCSI login request to be sent according to the current login status.\r
 \r
-  @param  Conn[in] The connection in the iSCSI login phase.\r
-\r
-  @retval The pointer to the net buffer containing the iSCSI login request built.\r
+  @param[in]  Conn The connection in the iSCSI login phase.\r
 \r
+  @return The pointer to the net buffer containing the iSCSI login request built.\r
+  @retval Others    Some unexpected error happened.\r
 **/\r
 NET_BUF *\r
 IScsiPrepareLoginReq (\r
@@ -605,14 +561,13 @@ IScsiPrepareLoginReq (
 /**\r
   Process the iSCSI Login Response.\r
 \r
-  @param  Conn[in] The connection on which the iSCSI login response is received.\r
-\r
-  @param  Pdu[in]  The iSCSI login response PDU.\r
+  @param[in]  Conn The connection on which the iSCSI login response is received.\r
+  @param[in]  Pdu  The iSCSI login response PDU.\r
 \r
   @retval EFI_SUCCESS        The iSCSI login response PDU is processed and all check are passed.\r
-\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r
-\r
+  @retval EFI_MEDIA_CHANGED  Target is redirected.\r
+  @retval Others             Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiProcessLoginRsp (\r
@@ -813,19 +768,15 @@ IScsiProcessLoginRsp (
   Updated the target information according the data received in the iSCSI\r
   login response with an target redirection status.\r
 \r
-  @param  Session[in]          The iSCSI session.\r
-\r
-  @param  Data[in]             The data segment which should contain the\r
-                               TargetAddress key-value list.\r
-\r
-  @param  Len[in]              Length of the data.\r
-\r
+  @param[in] Session          The iSCSI session.\r
+  @param[in] Data             The data segment which should contain the\r
+                              TargetAddress key-value list.\r
+  @param[in] Len              Length of the data.\r
+  \r
   @retval EFI_SUCCESS          The target address is updated.\r
-\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
   @retval EFI_NOT_FOUND        The TargetAddress key is not found.\r
-\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiUpdateTargetAddress (\r
@@ -864,7 +815,7 @@ IScsiUpdateTargetAddress (
 \r
     IpStr = TargetAddress;\r
 \r
-    while (*TargetAddress && (*TargetAddress != ':') && (*TargetAddress != ',')) {\r
+    while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {\r
       //\r
       // NULL, ':' or ',' ends the IPv4 string.\r
       //\r
@@ -913,10 +864,7 @@ IScsiUpdateTargetAddress (
 /**\r
   The callback function to free the net buffer list.\r
 \r
-  @param  Arg[in] The opaque parameter.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Arg The opaque parameter.\r
 **/\r
 VOID\r
 IScsiFreeNbufList (\r
@@ -932,10 +880,7 @@ IScsiFreeNbufList (
 /**\r
   The callback function called in NetBufFree, it does nothing.\r
 \r
-  @param  Arg[in] The opaque parameter.\r
-\r
-  @retval None.\r
-\r
+  @param[in]   Arg  The opaque parameter.\r
 **/\r
 VOID\r
 IScsiNbufExtFree (\r
@@ -950,23 +895,18 @@ IScsiNbufExtFree (
   net buffer. The digest check will be conducted in this function if needed and the digests\r
   will be trimmed from the PDU buffer.\r
 \r
-  @param  Conn[in]         The iSCSI connection to receive data from.\r
-\r
-  @param  Pdu[out]         The received iSCSI pdu.\r
-\r
-  @param  Context[in]      The context used to describe information on the caller provided\r
+  @param[in]   Conn        The iSCSI connection to receive data from.\r
+  @param[out]  Pdu         The received iSCSI pdu.\r
+  @param[in]   Context     The context used to describe information on the caller provided\r
                            buffer to receive data segment of the iSCSI pdu, it's optional.\r
+  @param[in]  HeaderDigest Whether there will be header digest received.\r
+  @param[in]  DataDigest   Whether there will be data digest.\r
+  @param[in]  TimeoutEvent The timeout event, it's optional.\r
 \r
-  @param  HeaderDigest[in] Whether there will be header digest received.\r
-\r
-  @param  DataDigest[in]   Whether there will be data digest.\r
-\r
-  @param  TimeoutEvent[in] The timeout event, it's optional.\r
-\r
-  @retval EFI_SUCCESS      An iSCSI pdu is received.\r
-\r
-  @retval EFI_TIMEOUT      Timeout happenend.\r
-\r
+  @retval EFI_SUCCESS          An iSCSI pdu is received.\r
+  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiReceivePdu (\r
@@ -1151,14 +1091,12 @@ ON_EXIT:
 /**\r
   Check and get the result of the prameter negotiation.\r
 \r
-  @param  Conn[in]           The connection in iSCSI login.\r
-\r
-  @param  Pdu[in]            The iSCSI response PDU containing the parameter list.\r
-\r
-  @retval EFI_SUCCESS        The parmeter check is passed and negotiation is finished.\r
-\r
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r
+  @param[in]  Conn          The connection in iSCSI login.\r
+  @param[in]  Transit       Whether need transit.\r
 \r
+  @retval EFI_SUCCESS          The parmeter check is passed and negotiation is finished.\r
+  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.\r
+  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
 **/\r
 EFI_STATUS\r
 IScsiCheckOpParams (\r
@@ -1408,14 +1346,10 @@ ON_ERROR:
 /**\r
   Fill the oprational prameters.\r
 \r
-  @param  Conn[in]             The connection in iSCSI login.\r
-\r
-  @param  Pdu[in]              The iSCSI login request PDU to fill the parameters.\r
+  @param[in]  Conn            The connection in iSCSI login.\r
+  @param[in]  Pdu             The iSCSI login request PDU to fill the parameters.\r
 \r
   @retval EFI_SUCCESS          The parmeters are filled into the iSCSI login request PDU.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to hold the parameters.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiFillOpParams (\r
@@ -1476,15 +1410,12 @@ IScsiFillOpParams (
 /**\r
   Pad the iSCSI AHS or data segment to an integer number of 4 byte words.\r
 \r
-  @param  Pdu[in]              The iSCSI pdu which contains segments to pad.\r
-\r
-  @param  Len[in]              The length of the last semgnet in the PDU.\r
+  @param[in]   Pdu             The iSCSI pdu which contains segments to pad.\r
+  @param[in]   Len             The length of the last semgnet in the PDU.\r
 \r
   @retval EFI_SUCCESS          The segment is padded or no need to pad it.\r
-\r
   @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space to add the\r
                                padding bytes.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiPadSegment (\r
@@ -1512,12 +1443,11 @@ IScsiPadSegment (
 /**\r
   Build a key-value list from the data segment.\r
 \r
-  @param  Data[in] The data segment containing the key-value pairs.\r
-\r
-  @param  Len[in]  Length of the data segment.\r
-\r
-  @retval The key-value list.\r
+  @param[in]  Data The data segment containing the key-value pairs.\r
+  @param[in]  Len  Length of the data segment.\r
 \r
+  @return The key-value list.\r
+  @return NULL Some unexpected error happened.\r
 **/\r
 LIST_ENTRY *\r
 IScsiBuildKeyValueList (\r
@@ -1581,12 +1511,10 @@ ON_ERROR:
   Get the value string by the key name from the key-value list. If found,\r
   the key-value entry will be removed from the list.\r
 \r
-  @param  KeyValueList[in] The key-value list.\r
-\r
-  @param  Key[in]          The key name to find.\r
-\r
-  @retval The value string.\r
+  @param[in]  KeyValueList The key-value list.\r
+  @param[in]  Key          The key name to find.\r
 \r
+  @return The value string.\r
 **/\r
 CHAR8 *\r
 IScsiGetValueByKeyFromList (\r
@@ -1618,10 +1546,7 @@ IScsiGetValueByKeyFromList (
 /**\r
   Free the key-value list.\r
 \r
-  @param  KeyValueList[in] The key-value list.\r
-  \r
-  @retval None.\r
-\r
+  @param[in]  KeyValueList The key-value list.\r
 **/\r
 VOID\r
 IScsiFreeKeyValueList (\r
@@ -1644,14 +1569,11 @@ IScsiFreeKeyValueList (
 /**\r
   Normalize the iSCSI name according to RFC.\r
 \r
-  @param  Name[in]           The iSCSI name.\r
-\r
-  @param  Len[in]            length of the iSCSI name.\r
+  @param[in]  Name          The iSCSI name.\r
+  @param[in]  Len           length of the iSCSI name.\r
 \r
   @retval EFI_SUCCESS        The iSCSI name is valid and normalized.\r
-\r
   @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the IQN format.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiNormalizeName (\r
@@ -1696,14 +1618,12 @@ IScsiNormalizeName (
 /**\r
   Create an iSCSI task control block.\r
 \r
-  @param  Conn[in]             The connection on which the task control block will be created.\r
-\r
-  @param  Tcb[out]             The newly created task control block.\r
+  @param[in]   Conn           The connection on which the task control block will be created.\r
+  @param[out]  Tcb            The newly created task control block.\r
 \r
   @retval EFI_SUCCESS          The task control block is created.\r
-\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
+  @retval EFI_NOT_READY        The target can not accept new commands.\r
 **/\r
 EFI_STATUS\r
 IScsiNewTcb (\r
@@ -1750,10 +1670,7 @@ IScsiNewTcb (
 /**\r
   Delete the tcb from the connection and destroy it.\r
 \r
-  @param  Tcb The tcb to delete.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Tcb The tcb to delete.\r
 **/\r
 VOID\r
 IScsiDelTcb (\r
@@ -1768,12 +1685,10 @@ IScsiDelTcb (
 /**\r
   Find the task control block by the initator task tag.\r
 \r
-  @param  TcbList[in]          The tcb list.\r
-\r
-  @param  InitiatorTaskTag[in] The initiator task tag.\r
-\r
-  @retval The task control block found.\r
+  @param[in]  TcbList         The tcb list.\r
+  @param[in]  InitiatorTaskTag The initiator task tag.\r
 \r
+  @return The task control block found.\r
 **/\r
 ISCSI_TCB *\r
 IScsiFindTcbByITT (\r
@@ -1802,14 +1717,11 @@ IScsiFindTcbByITT (
 /**\r
   Create a data segment, pad it and calculate the CRC if needed.\r
 \r
-  @param  Data[in]       The data to fill into the data segment.\r
-\r
-  @param  Len[in]        Length of the data.\r
-\r
-  @param  DataDigest[in] Whether to calculate CRC for this data segment.\r
-\r
-  @retval The net buffer wrapping the data segment.\r
+  @param[in]  Data       The data to fill into the data segment.\r
+  @param[in]  Len        Length of the data.\r
+  @param[in]  DataDigest Whether to calculate CRC for this data segment.\r
 \r
+  @return The net buffer wrapping the data segment.\r
 **/\r
 NET_BUF *\r
 IScsiNewDataSegment (\r
@@ -1845,14 +1757,12 @@ IScsiNewDataSegment (
   Create a iSCSI SCSI command PDU to encapsulate the command issued\r
   by SCSI through the EXT SCSI PASS THRU Protocol.\r
 \r
-  @param  Packet[in] The EXT SCSI PASS THRU request packet containing the SCSI command.\r
-\r
-  @param  Lun[in]    The LUN.\r
-\r
-  @param  Tcb[in]    The tcb assocated with this SCSI command.\r
-\r
-  @retval The created iSCSI SCSI command PDU.\r
+  @param[in]  Packet The EXT SCSI PASS THRU request packet containing the SCSI command.\r
+  @param[in]  Lun    The LUN.\r
+  @param[in]  Tcb    The tcb assocated with this SCSI command.\r
 \r
+  @return The  created iSCSI SCSI command PDU.\r
+  @return NULL Some unexpected error happened.\r
 **/\r
 NET_BUF *\r
 IScsiNewScsiCmdPdu (\r
@@ -2019,18 +1929,14 @@ ON_EXIT:
 /**\r
   Create a new iSCSI SCSI Data Out PDU.\r
 \r
-  @param  Data[in]   The data to put into the Data Out PDU.\r
-\r
-  @param  Len[in]    Length of the data.\r
-\r
-  @param  DataSN[in] The DataSN of the Data Out PDU.\r
-\r
-  @param  Tcb[in]    The task control block of this Data Out PDU.\r
-\r
-  @param  Lun[in]    The LUN.\r
-\r
-  @retval The net buffer wrapping the Data Out PDU.\r
+  @param[in]  Data   The data to put into the Data Out PDU.\r
+  @param[in]  Len    Length of the data.\r
+  @param[in]  DataSN The DataSN of the Data Out PDU.\r
+  @param[in]  Tcb    The task control block of this Data Out PDU.\r
+  @param[in]  Lun    The LUN.\r
 \r
+  @return The net buffer wrapping the Data Out PDU.\r
+  @return NULL Some unexpected error happened.\r
 **/\r
 NET_BUF *\r
 IScsiNewDataOutPdu (\r
@@ -2112,14 +2018,12 @@ IScsiNewDataOutPdu (
 /**\r
   Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.\r
 \r
-  @param  Data[in] The data  which will be carried by the sequence of iSCSI SCSI Data Out PDUs.\r
-\r
-  @param  Tcb[in]  The task control block of the data to send out.\r
-\r
-  @param  Lun[in]  The LUN the data will be sent to.\r
-\r
-  @retval A list of net buffers with each of them wraps an iSCSI SCSI Data Out PDU.\r
+  @param[in]  Data The data  which will be carried by the sequence of iSCSI SCSI Data Out PDUs.\r
+  @param[in]  Tcb  The task control block of the data to send out.\r
+  @param[in]  Lun  The LUN the data will be sent to.\r
 \r
+  @return A list of net buffers with each of them wraps an iSCSI SCSI Data Out PDU.\r
+  @return NULL Some unexpected error happened.\r
 **/\r
 LIST_ENTRY *\r
 IScsiGenerateDataOutPduSequence (\r
@@ -2187,16 +2091,13 @@ ON_EXIT:
 /**\r
   Send the Data in a sequence of Data Out PDUs one by one.\r
 \r
-  @param  Data[in]             The data to carry by Data Out PDUs.\r
-\r
-  @param  Lun[in]              The LUN the data will be sent to.\r
-\r
-  @param  Tcb[in]              The task control block.\r
+  @param[in]  Data            The data to carry by Data Out PDUs.\r
+  @param[in]  Lun             The LUN the data will be sent to.\r
+  @param[in]  Tcb             The task control block.\r
 \r
   @retval EFI_SUCCES           The data is sent out to the LUN.\r
-\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiSendDataOutPduSequence (\r
@@ -2240,17 +2141,15 @@ IScsiSendDataOutPduSequence (
 /**\r
   Process the received iSCSI SCSI Data In PDU.\r
 \r
-  @param  Pdu[in]            The Data In PDU received.\r
-\r
-  @param  Tcb[in]            The task control block.\r
-\r
-  @param  Packet[in][out]    The EXT SCSI PASS THRU request packet.\r
-\r
-  @retval EFI_SUCCES         The check on the Data IN PDU is passed and some update\r
-                             actions are taken.\r
-\r
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.\r
+  @param[in]        Pdu      The Data In PDU received.\r
+  @param[in]        Tcb      The task control block.\r
+  @param[in, out]   Packet   The EXT SCSI PASS THRU request packet.\r
 \r
+  @retval EFI_SUCCES           The check on the Data IN PDU is passed and some update\r
+                               actions are taken.\r
+  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol errror happened.\r
+  @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the request.\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiOnDataInRcvd (\r
@@ -2328,18 +2227,14 @@ IScsiOnDataInRcvd (
 /**\r
   Process the received iSCSI R2T PDU.\r
 \r
-  @param  Pdu[in]            The R2T PDU received.\r
-\r
-  @param  Tcb[in]            The task control block.\r
-\r
-  @param  Lun[in]            The Lun.\r
-\r
-  @param  Packet[in][out]    The EXT SCSI PASS THRU request packet.\r
+  @param[in]       Pdu       The R2T PDU received.\r
+  @param[in]       Tcb       The task control block.\r
+  @param[in]       Lun       The Lun.\r
+  @param[in, out]  Packet    The EXT SCSI PASS THRU request packet.\r
 \r
   @retval EFI_SUCCES         The R2T PDU is valid and the solicited data is sent out.\r
-\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.\r
-\r
+  @retval Others             Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiOnR2TRcvd (\r
@@ -2396,16 +2291,14 @@ IScsiOnR2TRcvd (
 /**\r
   Process the received iSCSI SCSI Response PDU.\r
 \r
-  @param  Pdu[in]            The Response PDU received.\r
-\r
-  @param  Tcb[in]            The task control block.\r
-\r
-  @param  Packet[in][out]    The EXT SCSI PASS THRU request packet.\r
+  @param[in]       Pdu      The Response PDU received.\r
+  @param[in]       Tcb      The task control block.\r
+  @param[in, out]  Packet   The EXT SCSI PASS THRU request packet.\r
 \r
   @retval EFI_SUCCES         The Response PDU is processed.\r
-\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.\r
-\r
+  @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the request.\r
+  @retval Others             Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiOnScsiRspRcvd (\r
@@ -2499,15 +2392,12 @@ IScsiOnScsiRspRcvd (
 /**\r
   Process the received NOP In PDU.\r
 \r
-  @param  Pdu[in]            The NOP In PDU received.\r
-\r
-  @param  Tcb[in]            The task control block.\r
+  @param[in]  Pdu            The NOP In PDU received.\r
+  @param[in]  Tcb            The task control block.\r
 \r
   @retval EFI_SUCCES         The NOP In PDU is processed and the related sequence\r
                              numbers are updated.\r
-\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiOnNopInRcvd (\r
@@ -2543,20 +2433,17 @@ IScsiOnNopInRcvd (
 /**\r
   Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.\r
 \r
-  @param  PassThru[in]     The EXT SCSI PASS THRU protocol.\r
-\r
-  @param  Target[in]       The target ID.\r
-\r
-  @param  Lun[in]          The LUN.\r
-\r
-  @param  Packet[in][out]  The request packet containing IO request, SCSI command\r
-                           buffer and buffers to read/write.\r
-\r
-  @retval EFI_SUCCES       The SCSI command is executed and the result is updated to \r
-                           the Packet.\r
-\r
-  @retval EFI_DEVICE_ERROR Some unexpected error happened.\r
-\r
+  @param[in]       PassThru  The EXT SCSI PASS THRU protocol.\r
+  @param[in]       Target    The target ID.\r
+  @param[in]       Lun       The LUN.\r
+  @param[in, out]  Packet    The request packet containing IO request, SCSI command\r
+                             buffer and buffers to read/write.\r
+                             \r
+  @retval EFI_SUCCES           The SCSI command is executed and the result is updated to \r
+                               the Packet.\r
+  @retval EFI_DEVICE_ERROR     Some unexpected error happened.\r
+  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+  @retval Others               Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiExecuteScsiCommand (\r
@@ -2657,7 +2544,7 @@ IScsiExecuteScsiCommand (
     //\r
     // Start the timeout timer.\r
     //\r
-    if (Timeout) {\r
+    if (Timeout != 0) {\r
       Status = gBS->SetTimer (Conn->TimeoutEvent, TimerRelative, Timeout);\r
       if (EFI_ERROR (Status)) {\r
         goto ON_EXIT;\r
@@ -2734,12 +2621,10 @@ ON_EXIT:
 /**\r
   Reinstate the session on some error.\r
 \r
-  @param  Private[in] The iSCSI driver data.\r
+  @param[in]  Private The iSCSI driver data.\r
 \r
   @retval EFI_SUCCES  The session is reinstated from some error.\r
-\r
-  @retval other       Reinstatement failed.\r
-\r
+  @retval Other       Reinstatement failed.\r
 **/\r
 EFI_STATUS\r
 IScsiSessionReinstatement (\r
@@ -2769,12 +2654,8 @@ IScsiSessionReinstatement (
 /**\r
   Initialize some session parameters before login.\r
 \r
-  @param  Session[in]  The iSCSI session.\r
-\r
-  @param  Recovery[in] Whether the request is from a fresh new start or recovery.\r
-\r
-  @retval None.\r
-\r
+  @param[in]  Session  The iSCSI session.\r
+  @param[in]  Recovery Whether the request is from a fresh new start or recovery.\r
 **/\r
 VOID\r
 IScsiSessionInit (\r
@@ -2825,10 +2706,9 @@ IScsiSessionInit (
   Abort the iSCSI session, that is, reset all the connection and free the\r
   resources.\r
 \r
-  @param  Session[in] The iSCSI session.\r
+  @param[in]  Session The iSCSI session.\r
 \r
   @retval EFI_SUCCES  The session is aborted.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiSessionAbort (\r