]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
Update UefiHiiLib to support new defined IFR related HII APIs.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiProto.c
index c3ef7818c4021aee14d62cc70e3762047e8de97a..952150c01c489dc4d4da04f4d79c7bfaee665324 100644 (file)
@@ -1,5 +1,5 @@
 /** @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.<BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -19,13 +19,13 @@ UINT32 mDataSegPad = 0;
 /**\r
   Attach the iSCSI connection to the iSCSI session. \r
 \r
-  @param[in]  Session The iSCSI session.\r
-  @param[in]  Conn    The iSCSI connection.\r
+  @param[in, out]  Session The iSCSI session.\r
+  @param[in, out]  Conn    The iSCSI connection.\r
 **/\r
 VOID\r
 IScsiAttatchConnection (\r
-  IN ISCSI_SESSION     *Session,\r
-  IN ISCSI_CONNECTION  *Conn\r
+  IN OUT ISCSI_SESSION     *Session,\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   InsertTailList (&Session->Conns, &Conn->Link);\r
@@ -36,11 +36,11 @@ IScsiAttatchConnection (
 /**\r
   Detach the iSCSI connection from the session it belongs to. \r
 \r
-  @param[in]  Conn The iSCSI connection.\r
+  @param[in, out]  Conn The iSCSI connection.\r
 **/\r
 VOID\r
 IScsiDetatchConnection (\r
-  IN ISCSI_CONNECTION  *Conn\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   RemoveEntryList (&Conn->Link);\r
@@ -51,8 +51,8 @@ IScsiDetatchConnection (
 /**\r
   Check the sequence number according to RFC3720. \r
 \r
-  @param[in]  ExpSN   The currently expected sequence number.\r
-  @param[in]  NewSN  The sequence number to check.\r
+  @param[in, out]  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
@@ -60,8 +60,8 @@ IScsiDetatchConnection (
 **/\r
 EFI_STATUS\r
 IScsiCheckSN (\r
-  IN UINT32  *ExpSN,\r
-  IN UINT32  NewSN\r
+  IN OUT UINT32  *ExpSN,\r
+  IN UINT32      NewSN\r
   )\r
 {\r
   if (!ISCSI_SEQ_EQ (NewSN, *ExpSN)) {\r
@@ -85,15 +85,15 @@ IScsiCheckSN (
 /**\r
   Update the sequence numbers for the iSCSI command.\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
+  @param[in, out]  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
-  IN ISCSI_SESSION  *Session,\r
-  IN UINT32         MaxCmdSN,\r
-  IN UINT32         ExpCmdSN\r
+  IN OUT ISCSI_SESSION  *Session,\r
+  IN UINT32             MaxCmdSN,\r
+  IN UINT32             ExpCmdSN\r
   )\r
 {\r
   if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) {\r
@@ -112,15 +112,15 @@ IScsiUpdateCmdSN (
 /**\r
   This function does the iSCSI connection login.\r
 \r
-  @param[in]  Conn           The iSCSI connection to login.\r
+  @param[in, out]  Conn      The iSCSI connection to login.\r
 \r
   @retval EFI_SUCCESS        The iSCSI connection is logged into the iSCSI target.\r
   @retval EFI_TIMEOUT        Timeout happened during the login procedure.\r
-  @retval Others             Some unexpected error happened.  \r
+  @retval Others             Other errors as indicated.  \r
 **/\r
 EFI_STATUS\r
 IScsiConnLogin (\r
-  IN ISCSI_CONNECTION  *Conn\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -164,11 +164,11 @@ IScsiConnLogin (
 /**\r
   Reset the iSCSI connection.\r
 \r
-  @param[in]  Conn The iSCSI connection to reset.\r
+  @param[in, out]  Conn The iSCSI connection to reset.\r
 **/\r
 VOID\r
 IScsiConnReset (\r
-  IN ISCSI_CONNECTION  *Conn\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   Tcp4IoReset (&Conn->Tcp4Io);\r
@@ -205,7 +205,7 @@ IScsiCreateConnection (
   Conn->ExpStatSN       = 0;\r
   Conn->PartialReqSent  = FALSE;\r
   Conn->PartialRspRcvd  = FALSE;\r
-  Conn->CID             = Session->NextCID++;\r
+  Conn->Cid             = Session->NextCid++;\r
 \r
   Status = gBS->CreateEvent (\r
                   EVT_TIMER,\r
@@ -276,7 +276,7 @@ IScsiDestroyConnection (
 \r
   @retval EFI_SUCCESS          The iSCSI session login procedure finished.\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-  @retval Others               Some unexpected error happened.\r
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiSessionLogin (\r
@@ -366,7 +366,7 @@ IScsiSendLoginReq (
   @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
-  @retval Others               Some unexpected error happened.\r
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiReceiveLoginRsp (\r
@@ -398,10 +398,10 @@ IScsiReceiveLoginRsp (
   The DataSegmentLength and the actual size of the net buffer containing this PDU will be\r
   updated.\r
 \r
-  @param[in]  Pdu              The iSCSI PDU whose data segment the key-value pair will\r
+  @param[in, out]  Pdu         The iSCSI PDU whose data segment the key-value pair will\r
                                be added to.\r
-  @param[in]  Key              The key name string.\r
-  @param[in]  Value            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
@@ -410,7 +410,7 @@ IScsiReceiveLoginRsp (
 **/\r
 EFI_STATUS\r
 IScsiAddKeyValuePair (\r
-  IN NET_BUF          *Pdu,\r
+  IN OUT NET_BUF      *Pdu,\r
   IN CHAR8            *Key,\r
   IN CHAR8            *Value\r
   )\r
@@ -469,14 +469,14 @@ IScsiAddKeyValuePair (
 /**\r
   Prepare the iSCSI login request to be sent according to the current login status.\r
 \r
-  @param[in]  Conn The connection in the iSCSI login phase.\r
+  @param[in, out]  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
+  @retval Others    Other errors as indicated.\r
 **/\r
 NET_BUF *\r
 IScsiPrepareLoginReq (\r
-  IN ISCSI_CONNECTION  *Conn\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   ISCSI_SESSION       *Session;\r
@@ -501,9 +501,9 @@ IScsiPrepareLoginReq (
   ISCSI_SET_STAGES (LoginReq, Conn->CurrentStage, Conn->NextStage);\r
   LoginReq->VersionMax        = ISCSI_VERSION_MAX;\r
   LoginReq->VersionMin        = ISCSI_VERSION_MIN;\r
-  LoginReq->TSIH              = HTONS (Session->TSIH);\r
+  LoginReq->Tsih              = HTONS (Session->Tsih);\r
   LoginReq->InitiatorTaskTag  = HTONL (Session->InitiatorTaskTag);\r
-  LoginReq->CID               = HTONS (Conn->CID);\r
+  LoginReq->Cid               = HTONS (Conn->Cid);\r
   LoginReq->CmdSN             = HTONL (Session->CmdSN);\r
 \r
   //\r
@@ -514,7 +514,7 @@ IScsiPrepareLoginReq (
   // with their increasing StatSN values.\r
   //\r
   LoginReq->ExpStatSN = HTONL (Conn->ExpStatSN);\r
-  CopyMem (LoginReq->ISID, Session->ISID, sizeof (LoginReq->ISID));\r
+  CopyMem (LoginReq->Isid, Session->Isid, sizeof (LoginReq->Isid));\r
 \r
   if (Conn->PartialRspRcvd) {\r
     //\r
@@ -561,18 +561,18 @@ IScsiPrepareLoginReq (
 /**\r
   Process the iSCSI Login Response.\r
 \r
-  @param[in]  Conn The connection on which the iSCSI login response is received.\r
-  @param[in]  Pdu  The iSCSI login response PDU.\r
+  @param[in, out]  Conn The connection on which the iSCSI login response is received.\r
+  @param[in, out]  Pdu  The iSCSI login response PDU.\r
 \r
   @retval EFI_SUCCESS        The iSCSI login response PDU is processed and all check are passed.\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r
   @retval EFI_MEDIA_CHANGED  Target is redirected.\r
-  @retval Others             Some unexpected error happened.\r
+  @retval Others             Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiProcessLoginRsp (\r
-  IN ISCSI_CONNECTION  *Conn,\r
-  IN NET_BUF           *Pdu\r
+  IN OUT ISCSI_CONNECTION  *Conn,\r
+  IN OUT NET_BUF           *Pdu\r
   )\r
 {\r
   EFI_STATUS            Status;\r
@@ -655,7 +655,7 @@ IScsiProcessLoginRsp (
       (CurrentStage != Conn->CurrentStage) ||\r
       (!Conn->TransitInitiated && Transit) ||\r
       (Transit && (NextStage != Conn->NextStage)) ||\r
-      (CompareMem (Session->ISID, LoginRsp->ISID, sizeof (LoginRsp->ISID)) != 0) ||\r
+      (CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0) ||\r
       (LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag)\r
       ) {\r
     //\r
@@ -722,14 +722,14 @@ IScsiProcessLoginRsp (
     //\r
     // In security negotiation stage, let CHAP module handle it.\r
     //\r
-    Status = IScsiCHAPOnRspReceived (Conn, Transit);\r
+    Status = IScsiCHAPOnRspReceived (Conn);\r
     break;\r
 \r
   case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:\r
     //\r
     // Response received with negotiation resonse on iSCSI parameters, check them.\r
     //\r
-    Status = IScsiCheckOpParams (Conn, Transit);\r
+    Status = IScsiCheckOpParams (Conn);\r
     break;\r
 \r
   default:\r
@@ -753,7 +753,7 @@ IScsiProcessLoginRsp (
       // CurrentStage is iSCSI Full Feature, it's the Login-Final Response,\r
       // get the TSIH from the Login Response.\r
       //\r
-      Session->TSIH = NTOHS (LoginRsp->TSIH);\r
+      Session->Tsih = NTOHS (LoginRsp->Tsih);\r
     }\r
   }\r
   //\r
@@ -768,21 +768,21 @@ IScsiProcessLoginRsp (
   Updated the target information according the data received in the iSCSI\r
   login response with an target redirection status.\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
+  @param[in, out] 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
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
   @retval EFI_NOT_FOUND        The TargetAddress key is not found.\r
-  @retval Others               Some unexpected error happened.\r
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiUpdateTargetAddress (\r
-  IN ISCSI_SESSION  *Session,\r
-  IN CHAR8          *Data,\r
-  IN UINT32         Len\r
+  IN OUT ISCSI_SESSION  *Session,\r
+  IN CHAR8              *Data,\r
+  IN UINT32             Len\r
   )\r
 {\r
   LIST_ENTRY      *KeyValueList;\r
@@ -906,7 +906,7 @@ IScsiNbufExtFree (
   @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
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiReceivePdu (\r
@@ -971,9 +971,14 @@ IScsiReceivePdu (
   Len = ISCSI_GET_DATASEG_LEN (Header);\r
   if (Len == 0) {\r
     //\r
-    // No data segment.\r
+    // No data segment.Form the pdu from a list of pdu segments.\r
     //\r
-    goto FORM_PDU;\r
+    *Pdu = NetbufFromBufList (NbufList, 0, 0, IScsiFreeNbufList, NbufList);\r
+    if (*Pdu == NULL) {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      goto ON_EXIT;\r
+    }\r
+    return Status;\r
   }\r
   //\r
   // Get the length of the padding bytes of the data segment.\r
@@ -1067,7 +1072,6 @@ IScsiReceivePdu (
     NetbufTrim (DataSeg, PadLen, NET_BUF_TAIL);\r
   }\r
 \r
-FORM_PDU:\r
   //\r
   // Form the pdu from a list of pdu segments.\r
   //\r
@@ -1091,8 +1095,7 @@ ON_EXIT:
 /**\r
   Check and get the result of the prameter negotiation.\r
 \r
-  @param[in]  Conn          The connection in iSCSI login.\r
-  @param[in]  Transit       Whether need transit.\r
+  @param[in, out]  Conn          The connection in iSCSI login.\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
@@ -1100,8 +1103,7 @@ ON_EXIT:
 **/\r
 EFI_STATUS\r
 IScsiCheckOpParams (\r
-  IN ISCSI_CONNECTION  *Conn,\r
-  IN BOOLEAN           Transit\r
+  IN OUT ISCSI_CONNECTION  *Conn\r
   )\r
 {\r
   EFI_STATUS      Status;\r
@@ -1204,16 +1206,11 @@ IScsiCheckOpParams (
   Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));\r
 \r
   //\r
-  // MaxRecvDataSegmentLength, result function is Mininum.\r
+  // MaxRecvDataSegmentLength is declarative.\r
   //\r
   Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH);\r
   if (Value != NULL) {\r
-    //\r
-    // MaxRecvDataSegmentLength is declarative.\r
-    //\r
-    NumericValue                    = AsciiStrDecimalToUintn (Value);\r
-\r
-    Conn->MaxRecvDataSegmentLength  = (UINT32) MIN (Conn->MaxRecvDataSegmentLength, NumericValue);\r
+    Conn->MaxRecvDataSegmentLength = (UINT32) AsciiStrDecimalToUintn (Value);\r
   }\r
   //\r
   // MaxBurstLength, result funtion is Mininum.\r
@@ -1346,15 +1343,15 @@ ON_ERROR:
 /**\r
   Fill the oprational prameters.\r
 \r
-  @param[in]  Conn            The connection in iSCSI login.\r
-  @param[in]  Pdu             The iSCSI login request PDU to fill the parameters.\r
+  @param[in]       Conn        The connection in iSCSI login.\r
+  @param[in, out]  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
 EFI_STATUS\r
 IScsiFillOpParams (\r
   IN ISCSI_CONNECTION  *Conn,\r
-  IN NET_BUF           *Pdu\r
+  IN OUT NET_BUF       *Pdu\r
   )\r
 {\r
   ISCSI_SESSION *Session;\r
@@ -1410,8 +1407,8 @@ IScsiFillOpParams (
 /**\r
   Pad the iSCSI AHS or data segment to an integer number of 4 byte words.\r
 \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
+  @param[in, out]  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
   @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space to add the\r
@@ -1419,8 +1416,8 @@ IScsiFillOpParams (
 **/\r
 EFI_STATUS\r
 IScsiPadSegment (\r
-  IN NET_BUF  *Pdu,\r
-  IN UINT32   Len\r
+  IN OUT NET_BUF  *Pdu,\r
+  IN UINT32       Len\r
   )\r
 {\r
   UINT32  PadLen;\r
@@ -1447,7 +1444,7 @@ IScsiPadSegment (
   @param[in]  Len  Length of the data segment.\r
 \r
   @return The key-value list.\r
-  @return NULL Some unexpected error happened.\r
+  @retval NULL Other errors as indicated.\r
 **/\r
 LIST_ENTRY *\r
 IScsiBuildKeyValueList (\r
@@ -1511,14 +1508,14 @@ 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[in]  KeyValueList The key-value list.\r
-  @param[in]  Key          The key name to find.\r
+  @param[in, out]  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
-  IN LIST_ENTRY      *KeyValueList,\r
+  IN OUT LIST_ENTRY  *KeyValueList,\r
   IN CHAR8           *Key\r
   )\r
 {\r
@@ -1569,16 +1566,16 @@ IScsiFreeKeyValueList (
 /**\r
   Normalize the iSCSI name according to RFC.\r
 \r
-  @param[in]  Name          The iSCSI name.\r
-  @param[in]  Len           length of the iSCSI name.\r
+  @param[in, out]  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
   @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the IQN format.\r
 **/\r
 EFI_STATUS\r
 IScsiNormalizeName (\r
-  IN CHAR8  *Name,\r
-  IN UINTN  Len\r
+  IN OUT CHAR8  *Name,\r
+  IN UINTN      Len\r
   )\r
 {\r
   UINTN Index;\r
@@ -1762,7 +1759,7 @@ IScsiNewDataSegment (
   @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
+  @retval NULL Other errors as indicated.\r
 **/\r
 NET_BUF *\r
 IScsiNewScsiCmdPdu (\r
@@ -1936,7 +1933,7 @@ ON_EXIT:
   @param[in]  Lun    The LUN.\r
 \r
   @return The net buffer wrapping the Data Out PDU.\r
-  @return NULL Some unexpected error happened.\r
+  @retval NULL Other errors as indicated.\r
 **/\r
 NET_BUF *\r
 IScsiNewDataOutPdu (\r
@@ -2023,7 +2020,7 @@ IScsiNewDataOutPdu (
   @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
+  @retval NULL Other errors as indicated.\r
 **/\r
 LIST_ENTRY *\r
 IScsiGenerateDataOutPduSequence (\r
@@ -2097,7 +2094,7 @@ ON_EXIT:
 \r
   @retval EFI_SUCCES           The data is sent out to the LUN.\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-  @retval Others               Some unexpected error happened.\r
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiSendDataOutPduSequence (\r
@@ -2149,7 +2146,7 @@ IScsiSendDataOutPduSequence (
                                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
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiOnDataInRcvd (\r
@@ -2234,7 +2231,7 @@ IScsiOnDataInRcvd (
 \r
   @retval EFI_SUCCES         The R2T PDU is valid and the solicited data is sent out.\r
   @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.\r
-  @retval Others             Some unexpected error happened.\r
+  @retval Others             Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiOnR2TRcvd (\r
@@ -2298,7 +2295,7 @@ IScsiOnR2TRcvd (
   @retval EFI_SUCCES         The Response PDU is processed.\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
+  @retval Others             Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiOnScsiRspRcvd (\r
@@ -2441,9 +2438,9 @@ IScsiOnNopInRcvd (
                              \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_DEVICE_ERROR     Session state was not as required.\r
   @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-  @retval Others               Some unexpected error happened.\r
+  @retval Others               Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
 IScsiExecuteScsiCommand (\r
@@ -2621,14 +2618,14 @@ ON_EXIT:
 /**\r
   Reinstate the session on some error.\r
 \r
-  @param[in]  Private The iSCSI driver data.\r
+  @param[in, out]  Private The iSCSI driver data.\r
 \r
   @retval EFI_SUCCES  The session is reinstated from some error.\r
   @retval Other       Reinstatement failed.\r
 **/\r
 EFI_STATUS\r
 IScsiSessionReinstatement (\r
-  IN ISCSI_DRIVER_DATA  *Private\r
+  IN OUT ISCSI_DRIVER_DATA  *Private\r
   )\r
 {\r
   ISCSI_SESSION *Session;\r
@@ -2654,13 +2651,13 @@ IScsiSessionReinstatement (
 /**\r
   Initialize some session parameters before login.\r
 \r
-  @param[in]  Session  The iSCSI session.\r
-  @param[in]  Recovery Whether the request is from a fresh new start or recovery.\r
+  @param[in, out]  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
-  IN ISCSI_SESSION  *Session,\r
-  IN BOOLEAN        Recovery\r
+  IN OUT ISCSI_SESSION  *Session,\r
+  IN BOOLEAN            Recovery\r
   )\r
 {\r
   UINT32  Random;\r
@@ -2671,22 +2668,22 @@ IScsiSessionInit (
 \r
     Random              = NET_RANDOM (NetRandomInitSeed ());\r
 \r
-    Session->ISID[0]    = ISID_BYTE_0;\r
-    Session->ISID[1]    = ISID_BYTE_1;\r
-    Session->ISID[2]    = ISID_BYTE_2;\r
-    Session->ISID[3]    = ISID_BYTE_3;\r
-    Session->ISID[4]    = (UINT8) Random;\r
-    Session->ISID[5]    = (UINT8) (Random >> 8);\r
+    Session->Isid[0]    = ISID_BYTE_0;\r
+    Session->Isid[1]    = ISID_BYTE_1;\r
+    Session->Isid[2]    = ISID_BYTE_2;\r
+    Session->Isid[3]    = ISID_BYTE_3;\r
+    Session->Isid[4]    = (UINT8) Random;\r
+    Session->Isid[5]    = (UINT8) (Random >> 8);\r
 \r
     InitializeListHead (&Session->Conns);\r
     InitializeListHead (&Session->TcbList);\r
   }\r
 \r
-  Session->TSIH                 = 0;\r
+  Session->Tsih                 = 0;\r
 \r
   Session->CmdSN                = 1;\r
   Session->InitiatorTaskTag     = 1;\r
-  Session->NextCID              = 1;\r
+  Session->NextCid              = 1;\r
 \r
   Session->TargetPortalGroupTag = 0;\r
   Session->MaxConnections       = ISCSI_MAX_CONNS_PER_SESSION;\r
@@ -2706,13 +2703,13 @@ IScsiSessionInit (
   Abort the iSCSI session, that is, reset all the connection and free the\r
   resources.\r
 \r
-  @param[in]  Session The iSCSI session.\r
+  @param[in, out]  Session The iSCSI session.\r
 \r
   @retval EFI_SUCCES  The session is aborted.\r
 **/\r
 EFI_STATUS\r
 IScsiSessionAbort (\r
-  IN ISCSI_SESSION  *Session\r
+  IN OUT ISCSI_SESSION  *Session\r
   )\r
 {\r
   ISCSI_DRIVER_DATA *Private;\r