home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / iscsiprj.zip / draft-ietf-ips-iscsi-12.txt < prev    next >
Text File  |  2002-06-02  |  550KB  |  13,107 lines

  1.                                     iSCSI                   17-April-02
  2.  
  3.  
  4.  
  5.      IPS                                                    Julian Satran
  6.      Internet Draft                                          Daniel Smith
  7.      draft-ietf-ips-iscsi-12.txt                              Kalman Meth
  8.      Category: standards-track                                 Ofer Biran
  9.                                                                 Jim Hafner
  10.                                                                       IBM
  11.  
  12.                                                         Costa Sapuntzakis
  13.                                                                 Mark Bakke
  14.                                                             Cisco Systems
  15.  
  16.                                                             Randy Haagens
  17.                                                    Mallikarjun Chadalapaka
  18.                                                       Hewlett-Packard Co.
  19.  
  20.                                                               Matt Wakeley
  21.                                                      Agilent Technologies
  22.  
  23.                                                         Luciano Dalle Ore
  24.                                                                    Quantum
  25.  
  26.                                                         Paul Von Stamwitz
  27.                                                                    Adaptec
  28.  
  29.                                                               Efri Zeidner
  30.                                                                    SANGate
  31.  
  32.  
  33.  
  34.                                     iSCSI
  35.  
  36.  
  37.  
  38.  
  39.  
  40. Julian Satran              Expires August  2002                        1
  41.  
  42.  
  43.  
  44.  
  45.  
  46.                                    iSCSI                      17-April-02
  47.  
  48. Status of this Memo
  49.  
  50.      This document is an Internet-Draft and fully conforms to all provi-
  51.      sions of Section 10 of [RFC2026]. 
  52.  
  53.      Internet-Drafts are working documents of the Internet Engineering 
  54.      Task Force (IETF), its areas, and its working groups. Note that other 
  55.      groups may also distribute working documents as Internet-Drafts. 
  56.      Internet-Drafts are draft documents valid for a maximum of six months 
  57.      and may be updated, replaced, or made obsolete by other documents at 
  58.      any time. It is inappropriate to use Internet- Drafts as reference 
  59.      material or to cite them other than as "work in progress." 
  60.      The list of current Internet-Drafts can be accessed at http://
  61.      www.ietf.org/ietf/1id-abstracts.txt 
  62.      The list of Internet-Draft Shadow Directories can be accessed at 
  63.      http://www.ietf.org/shadow.html.
  64.  
  65.  
  66. Abstract
  67.  
  68.      The Small Computer Systems Interface (SCSI) is a popular family of 
  69.      protocols for communicating with I/O devices, especially storage 
  70.      devices. This memo describes a transport protocol for SCSI that oper-
  71.      ates on top of TCP. The iSCSI protocol aims to be fully compliant with 
  72.      the requirements laid out in the SCSI Architecture Model - 2 [SAM2] 
  73.      document.
  74.  
  75. Acknowledgements
  76.  
  77.      In addition to the authors, a large group of people contributed to 
  78.      this work through their review, comments and valuable insights. We are 
  79.      grateful to all of them. We are especially grateful to those who found 
  80.      the time and patience to participate in our weekly phone conferences 
  81.      and intermediate meetings in Almaden and Haifa, thus helping to shape 
  82.      this document: John Hufferd, Prasenjit Sarkar, Meir Toledano, John 
  83.      Dowdy, Steve Legg, Alain Azagury (IBM), Dave Nagle (CMU), David Black 
  84.      (EMC), John Matze (Veritas - now with Okapi Software), Steve DeGroote, 
  85.      Mark Schrandt (NuSpeed), Gabi Hecht (Gadzoox), Robert Snively (Bro-
  86.      cade), Nelson Nachum (StorAge), Uri Elzur (Broadcom).  Many more 
  87.      helped clean up and improve this document within the IPS working 
  88.      group. We are especially grateful to David Robinson and Raghavendra 
  89.      Rao (Sun), Charles Monia, Joshua Tseng (Nishan), Somesh Gupta (Sil-
  90.      verback Systems), Michael Krause, Pierre Labat, Santosh Rao, Matthew 
  91.      Burbridge (HP), Stephen Bailey (Sandburst), Robert Elliott, Nick Mar-
  92.  
  93. Julian Satran               Expires August  2002                           2
  94.  
  95.  
  96.  
  97.  
  98.  
  99.                                                              iSCSI                                               17-April-02
  100.  
  101.      tin (Compaq), Steve Senum, Ayman Ghanem (CISCO), Barry Reinhold (Tre-
  102.      bia Networks), Bob Russell (UNH), Bill Lynn (Adaptec), Doug Otis 
  103.      (Sanlight), Robert Griswold and Bill Moody (Crossroads). The recovery 
  104.      chapter was enhanced with help from Stephen Bailey (Sandburst), 
  105.      Somesh Gupta (HP), Venkat Rangan (Rhapsody Networks), Vince Cavanna, 
  106.      Pat Thaler (Agilent), Jonathan Stone (Stanford), Luben Tuikov (Splen-
  107.      tec), Paul Konig (?), Eddy Quicksall (iVivity, Inc.) - Eddy also con-
  108.      tributed with some examples. Last, but not least, thanks to Ralph 
  109.      Weber for keeping us in line with T10 (SCSI) standardization. 
  110.      We would like to thank Steve Hetzler for his unwavering support and 
  111.      for coming up with such a good name for the protocol, Micky Rodeh, Jai 
  112.      Menon, Clod Barrera and Andy Bechtolsheim for helping this work hap-
  113.      pen.
  114.  
  115.      At the time of the writing, this document has to be considered in con-
  116.      junction with the "Naming & Discovery"[NDT], "Boot"[BOOT] and "Secur-
  117.      ing iSCSI, iFCP and FCIP"[SEC-IPS] documents.
  118.  
  119.      The "Naming & Discovery" document is authored by:
  120.  
  121.        Mark Bakke (Cisco), Joe Czap, Jim Hafner, John Hufferd, Kaladhar 
  122.              Voruganti (IBM), Howard Hall (Pirus), Jack Harwood (EMC), 
  123.              Yaron Klein (SANRAD), Lawrence Lamers (San Valley Systems), 
  124.              Todd Sperry (Adaptec) and Joshua Tseng (Nishan).                                                                          
  125.                                                          
  126.      The "Boot" document is authored by:
  127.  
  128.        Prasenjit Sarkar (IBM), Duncan Missimer (HP) and Costa Sapuntz-
  129.              akis (CISCO).                                                        
  130.  
  131.      The "Securing iSCSI, iFCP and FCIP" document is authored by:
  132.  
  133.        Bernard Aboba, William Dixon (Microsoft), David Black (EMC),
  134.        Joseph Tardo, Uri Elzur (Broadcom), Mark Bakke, Steve Senum 
  135.              (Cisco Systems), Howard Herbert, Jesse Walker (Intel), Julian 
  136.              Satran, Ofer Biran and Charles Kunzinger (IBM).
  137.                                                                        
  138.  
  139.      We are grateful to all of them for their good work and for helping us 
  140.      correlate this document with the ones they produced.
  141.  
  142. Conventions used in this document
  143.  
  144.      In examples, "I->" and "T->" indicate iSCSI PDUs sent by the initiator 
  145.      and target respectively.
  146.  
  147. Julian Satran                                  Expires August  2002                                                                   3
  148.  
  149.  
  150.  
  151.  
  152.  
  153.                                   iSCSI                         17-April-02
  154.  
  155.  
  156.      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 
  157.      "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 
  158.      document are to be interpreted as described in RFC2119.
  159.  
  160. Change Log
  161.  
  162.      The following changes were made from draft-ietf-ips-iSCSI-11 to 
  163.      draft-ietf-ips-iSCSI-12:
  164.  
  165.        - Clarify the use of A bit and DataACK at the end of data
  166.        - Clarified checking to be done for abort task and removed Ref-
  167.          erenced task tag from task management response
  168.        - Range separator is tilde.
  169.        - Fixed the paragraph numbering in the appendices.
  170.        - Clarified the expected target behavior in a lost F-bit sce-
  171.          nario when responding to Abort Task Set/Clear Task Set.
  172.        - Added the TargetPortalGroupTag key as a Login/operational key, 
  173.          and its usage semantics were added to Section 4.3 Login Phase.
  174.        - Clarified the language in Section 6.1.2 Allegiance Reassign-
  175.          ment and Section 6.2 Usage Of Reject PDU in Recovery.
  176.        - Clarified the states corresponding to full-feature phase oper-
  177.          ation in connection and session state diagrams in Chapter 5.
  178.        - Delivering all negotiated unsolicited data is mandatory
  179.        - Delivering all the data for an R2T is mandatory
  180.        - Added a timeout guidance section to Chapter 8
  181.        - Added normative naming text (previously in NDT)
  182.        - Clarified no duplicate parameter for login
  183.        - Added a minimum required to support to text length (16k/64k)
  184.        - Changed the name of TSID to TSIH to better reflect its meaning
  185.        - Security - IPsec transport mode is MAY and authentication MUST 
  186.          be used when encryption is used
  187.        - Added to logout a section clarifying the actions to be taken 
  188.          on task termination by the target
  189.        - Removed CRN
  190.        - Changed default time2wait & retain to better express typical 
  191.          ratio
  192.        - Changes SCSI port element separator to comma
  193.        - Async Event data format same as for SCSI response
  194.  
  195.      The following changes were made from draft-ietf-ips-iSCSI-10 to 
  196.      draft-ietf-ips-iSCSI-11:
  197.  
  198.        - ACA is SHOULD
  199.        - New format for ISID that allows factory presets
  200.        - New wording in section 9.5.4 that makes it clear that initia-
  201.          tor must discard discontiguous data PDUs during reassignment.
  202.  
  203.  
  204. Julian Satran              Expires August  2002                             4
  205.  
  206.  
  207.  
  208.  
  209.  
  210.                                   iSCSI                      17-April-02
  211.  
  212.      - Removed Parameter1 field definition for "drop the session" 
  213.        Async Message.
  214.      - In state transitions chapter, added Logout timeout to the 
  215.        event set causing T17, and removed the "session close" event 
  216.        from the event set for T6. Changed "status class" to Status-
  217.        Class.
  218.      - Clarified that for ErrorRecoveryLevel < 2, a restart Login PDU 
  219.        terminates all the tasks.
  220.      - Clarified the various subcases of interpretation for 
  221.        Time2Retain and Time2Wait in the Logout Response section.
  222.      - Added a new section in the recovery chapter on connection tim-
  223.        eout management.  
  224.      - The LogoutLoginMinTime and LogoutLoginMaxTime keys are 
  225.        respectively renamed to DefaultTime2Wait and 
  226.        DefaultTime2Retain, since they are used only on non-Logout 
  227.        events and also to better align with the notion of Time2Wait 
  228.        and Time2Retain that the draft already defines.
  229.      - Added the new Appendix on clearing effects.
  230.      - Retired the X-bit in Login PDU to make the bit position 
  231.        reserved.  Moved the content under X-bit description to a new 
  232.        section 4.3.4 that describes "connection reinstatement".
  233.      - Added text to section 6.1.2 that clarifies the expectations on 
  234.        targets during allegiance reassignment. 
  235.      - Minor changes in error recovery algorithms to change NextCmdSN 
  236.        to CmdSN in the Session data structure.
  237.      - Added a new section 4.3.5 defining the term "session rein-
  238.        statement".
  239.      - Added a new transition N11 to target session state diagram, to 
  240.        address the session reinstatement event. Enhancing the event 
  241.        set for N3(T) and N6(I & T) for the same event.  Adding the 
  242.        same event to the event sets for target transitions T8, T13, 
  243.        T15, T16, T17, T18, and M2 (I & T).
  244.      - Addressed the case of active TTTs when ABORT TASK SET/CLEAR 
  245.        TASK SET is in progress in section 9.5 and section 9.6.
  246.      - Added a new Section 9.6.2 Task Management actions on task sets 
  247.        that describes the exact timeline of events on a task set task 
  248.        management function.
  249.      - Clarified the usage of ITT for DataACK type of SNACK.
  250.      - Added error code for inexistent session to login response
  251.      - Changed the FIM SHOULD to should(!)
  252.      - Added a TTT field for Data-In when A bit is 1 and to the cor-
  253.        responding SNACK. To make it consistent changed slightly the 
  254.        layout of Data-IN, SCSI Response and SNACK.
  255.      - Clarified the use of LUN with all PDUs holding TTT
  256.      - Removed the ? value from negotiations
  257.      - Unified text negotiations (login, ffp and formats) in one 
  258.        chapter
  259.      - Clarified AHSLength and DataLength for all PDUs
  260.      - Clarified use of Reject
  261.  
  262.  
  263. Julian Satran            Expires August  2002                             5
  264.  
  265.  
  266.  
  267.  
  268.  
  269.                                      iSCSI                      17-April-02
  270.  
  271.        - Replaced Protocol Error with Negotiation Failure in negotia-
  272.          tions
  273.        - Removed FFP command before login from Reject Causes
  274.        - Added Invalid Request During Login to Login Errors
  275.        - Added tape text
  276.        - Clarified Security Text
  277.        - Aligned marker negotiations with the overall negotiations and 
  278.          added numeric range to the negotiation forms
  279.        - Changed target network architecture example in Overview
  280.        - Clarified T bit use in Login Reject
  281.        - Version back to 00
  282.  
  283.  
  284.      The following changes were made from draft-ietf-ips-iSCSI-09 to 
  285.      draft-ietf-ips-iSCSI-10:
  286.  
  287.        - Clarifying MaxOutstandingR2T
  288.        - Widening the scope of Reject reason code 0x09 to mean "Invalid 
  289.          PDU field".
  290.        - Changes in the "iSCSI connection termination" section to make 
  291.          the terminology usage consistent with the rest of the draft.
  292.        - Adding transition T18 in standard connection state diagram, 
  293.          and its description.
  294.        - Other minor wording changes in the state transitions chapter  
  295.          to address "session close" case and others.
  296.        - Adding a new state Q5(IN_CONTINUE) to the target session state 
  297.          diagram to resolve transitions N8 and N9 off Q2.
  298.        - Removed the AHS drop bit feature.
  299.        - Removed the qualifier field in Task Management Response PDU, 
  300.          and added a new response "Function authorization failed".
  301.        - Clarified the fate of regular SCSI reservations on a session 
  302.          timeout, compared to a transient session failure.
  303.        - Added wording in R2T section to address the case of receiving 
  304.          a smaller write data sequence than was asked for in an R2T.
  305.        - Changes and fixes in recovery algorithms to be consistent with 
  306.          the rest of the draft.
  307.        - Changed the "Invalid SNACK" Reject reason code to "Invalid 
  308.          data ACK" since the invalid SNACK is already covered under 
  309.          "Protocol error".  Also treating DataSN and R2TSN equivalently 
  310.          in this case.
  311.        - Change in the SNACK section to require a Reject "Protocol 
  312.          error" on an invalid SNACK.
  313.        - Time2Retain 0 in Logout Response indicates connection/session 
  314.          can't recover
  315.        - Coordinate DataSequenceInOrder with Error recovery level and 
  316.          MaxOutstandingR2T, also stating that only the last read/write 
  317.          sequence is recoverable under digest error recovery if DataSe-
  318.          quenceInOrder=Yes
  319.        - Alias designation format appendix is again out(!) - T10 has 
  320.          decided it will go in SPC3
  321.  
  322. Julian Satran                 Expires August  2002                          6
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                     iSCSI                     17-April-02
  329.  
  330.        - Task Management synchronization moved to the target (task man-
  331.          agement response given after task management action and con-
  332.          firmed delivery of all previous responses)
  333.        - Removed the don't care value in numerical negotiations
  334.        - Changed Marker negotiation to allow it to be closed in one 
  335.          round
  336.        - Marker position is not dependent of the length of the login 
  337.          phase
  338.        - Statement made that reserved bits do not have to be checked at 
  339.          the beginning of Chapter 9
  340.        - InitialR2T, BidiInitialR2T and ImmediateData changed to LO
  341.        - I bit (equivalent) in responses made 0
  342.        - Added a "double response" version for the ? key value to 
  343.        - ? value can be used only outside Login
  344.        - added :, [ and ] as allowed in key values
  345.        - allow 0 in LogoutLoginMax and Min
  346.        - after task reassign no SNACK mandated, the function must be 
  347.          performed by target with information made available by reas-
  348.          sign
  349.        - removed the third party command section - SCSI now handles 
  350.          everything needed (including iSCSI aliasing)
  351.  
  352.      The following changes were made from draft-ietf-ips-iSCSI-08 to 
  353.      draft-ietf-ips-iSCSI-09:
  354.  
  355.        - Added Task management response "task management function not 
  356.          supported"
  357.        - Negotiation (numeric) responder driven
  358.        - Added vendor specific data to reject
  359.        - Allow logout in discovery sessions
  360.        - Variable DataPDULength - renamed MaxRecvPDULength
  361.        - Key=value pairs can span PDU boundaries
  362.        - Uniform treatment of text exchange resets
  363.        - Reintroduced DataACK as a special form of SNACK
  364.        - Extended ISID in the Login Request 
  365.        - Removed 0 as a "no limit value" (residue from mode pages)
  366.        - Reintroduced LogoutLoginMinTime
  367.        - Digests moved to Operational Keys 
  368.        - Removed X bit in all commands and replaced it in Login and 
  369.          added a cleaning rule to CmdSN numbering
  370.        - Several simplifications in state transition section - standard 
  371.          connection and session state diagrams are separately described 
  372.          for initiators and targets 
  373.        - Several minor technical and language changes in the error 
  374.          recovery section
  375.        - Added Irrelevant to negotiations
  376.        - Clarification to logout behavior
  377.        - Clarification to command ordering
  378.        - On SCSI timeout task abort instead of session failure
  379.  
  380.  
  381. Julian Satran                Expires August  2002                           7
  382.  
  383.  
  384.  
  385.  
  386.  
  387.                                      iSCSI                      17-April-02
  388.  
  389.        - Changed version to 0x03 - ALL VERSION NUMBERS are temporary up 
  390.          to "Rafting" (take them with a grain of salt)
  391.  
  392.  
  393.      The following changes were made from draft-ietf-ips-iSCSI-07 to 
  394.      draft-ietf-ips-iSCSI-08:
  395.  
  396.        - Clarified the use of initiator task tag with regard to the 
  397.          SCSI tag in Section 9.2.1.7 Initiator Task Tag
  398.        - Added a clarification to Section 2.2.2.1 Command Numbering and 
  399.          Acknowledging - response to a command should not precede 
  400.          acknowledgment.
  401.        - Added clarification to Section 9.7 SCSI Data-out & SCSI Data-
  402.          in - good status in Data-In must be supported by initiators
  403.        - Clarified InitiatorName is required at login in Section 4.3.1 
  404.          Login Phase Start
  405.        - Another clarification for SecurityContextComplete in Section 
  406.          4.3.2 iSCSI Security Negotiation
  407.        - Added "command not supported in this session type" to reject 
  408.          reasons
  409.        - Discovery session implies MaxConnections = 1
  410.        - Second appearance of TargetAddress  deleted
  411.        - Padding forbidden for non-end-of-sequence data PDUs
  412.        - Removed Boot and Copenhagener Session types
  413.        - Changed explanation of ExpDataSN 
  414.        - Removed/corrected response 05 in Section 9.4.3 Response
  415.        - Brought Section 2.2.6 iSCSI Names in line with NDT draft
  416.        - Fixed the syntax in accordance with [RFC2372] and [RFC2373]
  417.        - Removed forgotten references to the default iSCSI target
  418.        - Counters back to Reject Response
  419.        - Clarification - SendTargets admissible only in full feature 
  420.          phase
  421.        - Changed name of DataOrder and DataDeliveryOrder to DataSequen-
  422.          ceOrder and DataPDUInOrder and clarified appendix text
  423.        - Padding bytes SHOULD be sent as 0 (instead of MUST be 0)
  424.        - UA attention behavior for various resets deleted - replaced 
  425.          with reference to SAM2
  426.        - Removed AccessID 
  427.        - OpParmReset generalized
  428.        - Clarified the definition of full-feature phase in Section 
  429.          2.2.4 iSCSI Full Feature Phase
  430.        - Added new Reject reason codes, tabular listing and a pointer 
  431.          to Section 9.14.3 Reason Code
  432.        - Added additional Reject usage semantics on CmdSN and DataSN to 
  433.          Section 9.14.3 Reason Code
  434.        - Added a new Logout Response code for failure
  435.        - Renamed BUSY as RECOVERY_START, removed RECOVERY_DONE, and 
  436.          merged T11 and T14 transitions into T11-(1,2) in Section 5 
  437.          State Transitions.
  438.  
  439.  
  440. Julian Satran                 Expires August  2002                          8
  441.  
  442.  
  443.  
  444.  
  445.  
  446.                                    iSCSI                      17-April-02
  447.  
  448.      - Corrected initiator handling of format errors
  449.      - Clarified usage of command replay
  450.      - Removed the delivery in same order as presented from Text 
  451.        Response
  452.      - Clarified RefCmdSN function fro abort task
  453.      - Corrected length field for AHS of type Extended CDB
  454.      - Removed LUN from text management response
  455.      - Clarified F bit for Bidirectional commands
  456.      - Removed the Async iSCSI event "target reset"
  457.      - Removed wording in Section 9.6 Task Management Function 
  458.        Response linking SCSI mode pages to Async Messages
  459.      - Changed the ASC/ASCQ values to better mean "not enough unso-
  460.        licited data"
  461.      - Names examples include date
  462.      - Removed references to S bit in Section 9.4 SCSI Response
  463.      - Fixed NOP to simplify and avoid it consuming CmdSN
  464.      - Fixed CRC and examples
  465.      - Added the T, CSG & NSG fields to Login Command & Response, 
  466.        rewrote Chapter 3, changed all examples in Appendix C. - Login 
  467.        Phase Examples - to fit the above changes
  468.      - Key=value confined to one response
  469.      - Add command restart/replay to task management
  470.      - Removed cryptographic digests
  471.      - Removed "proxy required" status code
  472.      - Re-named and fixed descriptions of status codes
  473.      - Re-formatted login examples for clarity 
  474.      - SCSI/iSCSI parameters - fixed Section 3 SCSI Mode Parameters 
  475.        for iSCSI, out DataPDULength, DataSequenceOrder
  476.      - Changed all sense keys to aborted command in the table in Sec-
  477.        tion 9.4.2 Status
  478.      - Rearranged requests to have all SCSI related grouped etc.
  479.      - Fixed Task Management Function Request ABORT TASK and removed 
  480.        the part about it in Chapter 8.
  481.      - Reintroduced aliases (the data format) in an appendix. The 
  482.        aliasing mechanism once part of iSCSI is part of [SPC3]
  483.      - Login negotiations - using only login request response 
  484.        (instead of former login and text)
  485.      - F bit in login changed name to T bit
  486.      - Stated defaults for mode parameters in chapter 3
  487.      - Updated Chapter 7 to reflect the current consensus on security
  488.      - Changed all sense keys to aborted command in the table in 
  489.        2.4.2
  490.      - Minor language clarifications in sections 1.2.3, 1.2.5, 1.2.6, 
  491.        1.2.8.
  492.      - Added a new Reject reason code "Task in progress" and clari-
  493.        fied language in the same section.
  494.      - Added more description to the session state transitions in 
  495.        Chapter 5.
  496.      - Several changes in Chapter 6 corresponding to the new task 
  497.        management function "reassign".  Other language changes in 
  498.  
  499. Julian Satran               Expires August  2002                          9
  500.  
  501.  
  502.  
  503.  
  504.  
  505.                                      iSCSI                      17-April-02
  506.  
  507.             Chapter 6 for better description. Format errors are mandated 
  508.             to cause session failures.
  509.        - Renamed the erstwhile error recovery levels as error recovery 
  510.             classes, and renamed "within-session" recovery to "connection 
  511.             recovery" to better reflect the mechanics.
  512.        - Added Section 6.13 Error Recovery Hierarchy to define the 
  513.             error recovery hierarchy.
  514.        - Modifications to error recovery algorithms in Appendix F.
  515.        - Added a new Reject reason code "Invalid SNACK", added DataSN 
  516.             to Reject PDU.
  517.        - Changed Section 9.17 Reject to use the "Invalid SNACK" reason 
  518.             code.
  519.        - Removed a Logout reason code in Section 9.14 Logout Request to 
  520.             be consistent with Section 9.9 Asynchronous Message.
  521.        - Collapsed the two event fields in Async Event and added vendor 
  522.             specific event
  523.        - Immediate data can be negotiated anytime (consistency)
  524.        - Removed replay as a protocol notion and all references to it
  525.        - SNACK RunLength 0 means all
  526.        - Cleaning the bookmark mechanism for text
  527.        - New T10 approved ASC/ASQ codes
  528.        - Added a incipient definitions section - thanks to Eddy Quick-
  529.             sall
  530.        - Change OpParmReset from Yes/No to default/current
  531.        - Added Base64 to encode large strings
  532.        - The 255 limit for key values is now "unless specified other-
  533.             wise"
  534.        - Cleaned SNACK format
  535.        - Removed ExpR2TSN from SCSI command response it is too late
  536.        - MaxBurstSize/FirstBurstSize back as key=value
  537.        - Removed LogoutLoginMinTime (value provided in exchange)
  538.        - Clear language on component function in generating ISID/TSID
  539.        - Negotiation breaking is done through abort/reject
  540.        - Removed all iSCSI mode pages
  541.         
  542.  
  543.      The following changes were made from draft-ietf-ips-iSCSI-06 to 
  544.      draft-ietf-ips-iSCSI-07:
  545.  
  546.        - Clarified the "fate" of immediate commands and resources man-
  547.             dated (1.2.2.1) and introduced a reject-code for rejected 
  548.             immediate commands
  549.        - Clarify CmdSN handling and checking order for ITT and CmdSN 
  550.             1.2.2.1
  551.        - Added a statement to the effect that a receiver must be able 
  552.             to accept 0 length Data Segments to 2.7.6. Added also a state-
  553.             ment to 2.2.1 that a zero-length data segment implies a zero-
  554.             length digest
  555.        - SCSI MODE SELECT will not really set the parameters (will not 
  556.             cause an error either). The parameters will be set exclusively 
  557.  
  558. Julian Satran                 Expires August  2002                        10
  559.  
  560.  
  561.  
  562.  
  563.  
  564.                                    iSCSI                     17-April-02
  565.  
  566.        with text mode and can be retrieved with either text or Mode-
  567.        SENSE. This enables us to disable their change after the Login 
  568.        negotiation. Also added to the negotiation (1.2.4) the value 
  569.        "?" with special meaning of enquiry
  570.      - Changed "task" to "command" wherever relevant
  571.      - EMDP usage in line with other SCSI protocols. EMDP governs how 
  572.        a target may request data and deliver. Similar to FCP a sepa-
  573.        rate (protocol) parameter governs data PDU ordering within 
  574.        Sequence (DataPDUInOrder). Cleaned wording of DataOrder. 
  575.        Fixed final bit to define sequences in input stream. 
  576.      - Added a "persistent state" part (1.2.8)
  577.      - Some Task Management commands may require authorization or may 
  578.        not be implemented. If not authorized they will return as if 
  579.        executed with a qualifier indicating "not authorized" or "not 
  580.        implemented" (clear LU and the resets)
  581.      - Task management commands and responses are "generalized" to 
  582.        all iSCSI tagged commands (they are named now Task Management 
  583.        command and response). Their behavior with respect to their 
  584.        CmdSN is clarified and mandated 
  585.      - The logic to update ExpCmdSN etc. moved to 1.2.2.1
  586.      - Explicitly specified that a target can "initiate" negotiating 
  587.        a parameter (offering)(1.2.4)
  588.      - Returned the "direction" bit and a set of codes similar to 
  589.        version 05
  590.      - Introduced a "special" session type (CopyManagerSession) to be 
  591.        used between a Copy Manager and all of its target; it may help 
  592.        define authentication and limit the type f commands to be exe-
  593.        cuted in such a session
  594.      - Added 8.4 - How to Abort Safely a Command that Was Not 
  595.        Received
  596.      - Fixed the Logout Text
  597.      - AHSLength is now the first field in the AHS 
  598.      - Fixed wording in 2.35 indicating AHS is mandatory for Bi-
  599.        directional commands
  600.      - All key=value responses have to be explicit (none, not-under-
  601.        stood etc.); no more selection by hiatus
  602.      - Targets can also offer key=value pairs (i.e., initiate negoti-
  603.        ation) stated explicitly in 2.9.3
  604.      - Logout has a CmdSN field
  605.      - The Status SNACK can be discarded if the target has no such 
  606.        recovery
  607.      - Some parameters have been removed and replaced by "reasonable" 
  608.        defaults (read arbitrary defaults!); many others can't be 
  609.        changed anymore while the session is in full-feature phase
  610.      - NOP-Out specifies how LUN is generated when used (copied from 
  611.        NOP-In)
  612.      - Initial Marker-Less Interval is not a parameter anymore
  613.      - A response with F=1 during negotiation may not contain 
  614.        key=value pairs that may require additional answers from the 
  615.        initiator
  616.  
  617. Julian Satran            Expires August  2002                          11
  618.  
  619.  
  620.  
  621.  
  622.  
  623.                                    iSCSI                     17-April-02
  624.  
  625.      - Clarified the meaning of the F bit on Write commands with 
  626.        regard to immediate and unsolicited data; F bit 0 means that 
  627.        unsolicited data will follow while F bit 1 means that this is 
  628.        the last of them (if any)
  629.      - You can have both immediate and unsolicited Data-Out PDUs
  630.      - DataPDULength and FirstBurstSize of 0 are allowed and mean 
  631.        unlimited length
  632.      - Task management command behavior relative to their own CmdSN 
  633.        is now stated in no uncertain terms (they are mandated to exe-
  634.        cute as if issued at CmdSN and, in case of aborts and clear/
  635.        reset no additional response/status is expected for those com-
  636.        mands after the task management command response 
  637.      - DataSN field in R2T renamed as R2TSN (better reflects seman-
  638.        tics) and SNACK explicitly says that it requests Data or R2T.
  639.      - A session can have only one outstanding text request (not 
  640.        sequence)
  641.      - Text for Login Response 0301 changed (removed the maintenance 
  642.        mention)
  643.      - Clarified when ExpDataSN is reserved in SCSI Response
  644.      - Clarified the text and parameter (timers) for iSCSI event 
  645.      - Padding bytes should be 0 (2.1)
  646.      - TotalAHSLength in 2.1.1.1 includes padding
  647.      - DataSegmentLength in 2.1.1.2 excludes padding 
  648.      - Clarified bits in AHS type
  649.      - Limit for key/value string lengths (63, 255) in 2.8.3
  650.      - Added an example of SCSI event to Asynchronous Message
  651.      - Changed "Who" to "Who can send" in appendix
  652.      - Clarified meaning of parameters on 2.18.1 - Asynchronous Mes-
  653.        sage - iSCSI Event
  654.      - Clarified the required initiator behavior at logout (not send-
  655.        ing other commands) and how one expects the TCP close to be 
  656.        performed in 2.14
  657.      - Added a Login Response code indicating that a session can't 
  658.        include a given connection (0208) 
  659.      - Clarified transition to full feature phase (per session and 
  660.        per connection and the role of the leading connection) in 
  661.        1.2.5
  662.      - Corrected "one outstanding text request per connection" 
  663.        instead of "per session"
  664.      - For the Login Response TSID must be valid only if Login is 
  665.        accepted and the F bit is 1
  666.      - Added examples illustrating DataSN and R2TSN (from Eddy Quick-
  667.        sall)
  668.      - Added more text to the task management command 2.5
  669.      - Removed EnableACA and its dependents (in task management) and 
  670.        stated the requirement for a Unit Attention conform to SAM2
  671.      - iSCSI Target Name if used on a connection other than the first 
  672.        must be the same as on the first (4.1)
  673.      - Fixed the examples in the Login appendix to correspond to the 
  674.        new keys
  675.  
  676. Julian Satran               Expires August  2002                       12
  677.  
  678.  
  679.  
  680.  
  681.  
  682.                                 iSCSI                         17-April-02
  683.  
  684.      - Fixed SCSI Response Flags and made them consistent with the 
  685.        Data-In PDU
  686.      - All specified keys except X-* MUST be accepted (2.8.3)
  687.      - Hexadecimal notation is 0xab123cd (not 0x'ab123cd')
  688.      - Clarified CmdSN usage in immediate commands and the meaning of 
  689.        "execution engine" in 1.2.2.1
  690.      - Reject response that prevent the creation of a SCSI task or 
  691.        result in a SCSI task being terminated must be followed by a 
  692.        SCSI Response with a Check Condition status 2.19.1
  693.      - Additional Runs (AddRuns) dropped from the SNACK request (too 
  694.        complex). With it disappeared also the implicit acknowledge-
  695.        ment of sequences "between runs"
  696.      - PDUs delivered because of SNACK will be exact replicas of the 
  697.        original PDUs (including all flags) 2.16
  698.      - Added CommandReplaySupport key to negotiate support for full 
  699.        command replay (a command can be replayed after the status has 
  700.        been issued but has not been acknowledged) and a reject cause 
  701.        of unsupported command reply
  702.      - Added CommandFailoverSupport key to negotiate support for com-
  703.        mand allegiance change (command retry on another connection)
  704.      - Status SNACK for an acknowledged status is a protocol error 
  705.        (cause for reject)
  706.      - Reject cause "Command In Progress" when requesting replay 
  707.        before status is issued and while command is running 
  708.      - Premature SNACKs are silently discarded (2.16)
  709.      - Status SNACK has to supported only if within command or within 
  710.        connection recovery is supported. If within session recovery 
  711.        is supported SNACK can be discarded and followed by an Async. 
  712.        Message requesting logout
  713.      - StatSN added to Logout Response 
  714.      - Added "CID not found" to Logout Response reason codes 
  715.      - Async Message - iSCSI event 2 (request logout) has to be sent 
  716.        on the connection to be dropped. Wording fixed.
  717.      - Naming changes - iqn (stands for iSCSI qualified name) intro-
  718.        duced as a replacement to fqn. Iqn prefixes also reversed 
  719.        names
  720.      - text in 8.3 revised (task management implementation mechanism) 
  721.      - Fixed bit 7 byte 1 in Task Management response to 1 (consis-
  722.        tency) 
  723.      - Clarified in 1.2.2 behavior when "command window" is 0 (MaxC-
  724.        mdSN = ExpCmdSN -1)
  725.      - Added state transitions part (new part 6)
  726.      - Refreshed recovery chapter (new part 7)
  727.      - Added an appendix with detailed recovery mechanisms (Appendix 
  728.        E)
  729.      - Added session types a brief explanation in part 1
  730.      - Added DiscoverySession key and SendTargets appendix
  731.      - SCSI response made to fit having both a Status and a Response 
  732.        field. Needed for target errors that result in a check condi-
  733.  
  734.  
  735. Julian Satran            Expires August  2002                          13
  736.  
  737.  
  738.  
  739.  
  740.  
  741.                                    iSCSI                    17-April-02
  742.  
  743.        tion and ACA. In line with SAM2 that requires both fields 
  744.        (former versions where modeled on FCP).
  745.      - The security appendix list SRP as mandatory to implement
  746.      - Clarified initial CmdSN and the role of TSID as a serializer
  747.      - Long Text Responses - additional fields added to the text 
  748.        request and text response
  749.      - Added a SCSI to iSCSI concept mapping section 1.5
  750.      - Clarified SNACK wording to indicate that in general command. 
  751.        Request, iSCSI command and iSCSI command have the same mean-
  752.        ing. Also status, response or numbered response.
  753.      - Changed InitStatSN and clarified how it increases
  754.      - Added requirement for a 0x00 delimiter after each key=value
  755.      - Added binary negotiations (Yes|No) explicitly to 1.2.4
  756.      - All keys and values in the spec are case sensitive (stated in 
  757.        the text request)
  758.      - Changed the "operational parameters sent before the security. 
  759.        MAY be discarded" into MUST be discarded 
  760.      - Changed the login reject 0201 to read - Security Negotiation 
  761.        Failed 
  762.      - Added to 2.3.1 a paragraph about mandatory consistencies 
  763.      - Stated clearly that F bit pairing is "local" (per/pair) and 
  764.        not per negotiation
  765.      - Clarified dependent parameter status
  766.      - Added CRC Example
  767.      - Added OpParmReset=Yes
  768.      - SecurityContextComplete is mandatory if any option offered
  769.      - Added a warning about the implications of not sending all 
  770.        unsolicited data to part 8
  771.      - Added a recommendation to send unsolicited data at FirstBurst-
  772.        Size and a response (error) for targets not supporting less
  773.      - Many more minor editorial changes, clarifications, typos etc.
  774.      - Responses in same position in SCSI response, logout, task etc.
  775.  
  776.  
  777.  
  778.  
  779.  
  780. Julian Satran               Expires August  2002                       14
  781.  
  782.  
  783.  
  784.  
  785.  
  786. Table of Contents                  iSCSI                     17-April-02
  787.  
  788.  Status of this Memo . . . . . . . . . . . . . . . . . . . . . . . . . 2
  789.  Abstract  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
  790.  Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . . . . 2
  791.  Conventions used in this document . . . . . . . . . . . . . . . . . . 3
  792.  Change Log  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
  793. 1. Definitions   . . . . . . . . . . . . . . . . . . . . . . . . . . .22
  794. 2. Overview  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
  795.      2.1 SCSI Concepts  . . . . . . . . . . . . . . . . . . . . . . . . .26
  796.      2.2 iSCSI Concepts and Functional Overview   . . . . . . . . . . . .27
  797.        2.2.1 Layers and Sessions   . . . . . . . . . . . . . . . . . . .27
  798.        2.2.2 Ordering and iSCSI Numbering  . . . . . . . . . . . . . . .28
  799.           2.2.2.1 Command Numbering and Acknowledging  . . . . . . . . .29
  800.           2.2.2.2 Response/Status Numbering and Acknowledging  . . . . .32
  801.           2.2.2.3 Data Sequencing  . . . . . . . . . . . . . . . . . . .32
  802.        2.2.3 iSCSI Login   . . . . . . . . . . . . . . . . . . . . . . .33
  803.        2.2.4 iSCSI Full Feature Phase  . . . . . . . . . . . . . . . . .34
  804.        2.2.5 iSCSI Connection Termination  . . . . . . . . . . . . . . .37
  805.        2.2.6 iSCSI Names   . . . . . . . . . . . . . . . . . . . . . . .37
  806.           2.2.6.1 iSCSI Name Requirements  . . . . . . . . . . . . . . .38
  807.           2.2.6.2 iSCSI Name Encoding  . . . . . . . . . . . . . . . . .40
  808.           2.2.6.3 iSCSI Name Structure   . . . . . . . . . . . . . . . .40
  809.            2.2.6.3.1 Type "iqn." (iSCSI Qualified Name)  . . . . . . .41
  810.            2.2.6.3.2 Type "eui." (IEEE EUI-64 format)  . . . . . . . .42
  811.        2.2.7 Persistent State  . . . . . . . . . . . . . . . . . . . . .43
  812.        2.2.8 Message Synchronization and Steering  . . . . . . . . . . .43
  813.           2.2.8.1 Rationale  . . . . . . . . . . . . . . . . . . . . . .43
  814.           2.2.8.2 Synchronization (sync) and Steering Functional Model  44
  815.           2.2.8.3 Sync and Steering and Other Encapsulation Layers   . .46
  816.           2.2.8.4 Sync/Steering and iSCSI PDU Size   . . . . . . . . . .47
  817.      2.3 iSCSI Session Types  . . . . . . . . . . . . . . . . . . . . . .48
  818.      2.4 SCSI to iSCSI Concepts Mapping Model   . . . . . . . . . . . . .48
  819.        2.4.1 iSCSI Architecture Model  . . . . . . . . . . . . . . . . .49
  820.        2.4.2 SCSI Architecture Model   . . . . . . . . . . . . . . . . .51
  821.        2.4.3 Consequences of the Model   . . . . . . . . . . . . . . . .53
  822.           2.4.3.1 I_T Nexus State  . . . . . . . . . . . . . . . . . . .54
  823.           2.4.3.2 SCSI Mode Pages  . . . . . . . . . . . . . . . . . . .54
  824.      2.5 Request/Response Summary   . . . . . . . . . . . . . . . . . . .55
  825.        2.5.1 Request/Response types carrying SCSI payload  . . . . . . .55
  826.           2.5.1.1 SCSI-Command   . . . . . . . . . . . . . . . . . . . .55
  827.           2.5.1.2 SCSI-Response  . . . . . . . . . . . . . . . . . . . .55
  828.           2.5.1.3 Task Management Function Request   . . . . . . . . . .56
  829.           2.5.1.4 Task Management Function Response  . . . . . . . . . .57
  830.           2.5.1.5 SCSI Data-out and SCSI Data-in   . . . . . . . . . . .57
  831.  
  832. Julian Satran               Expires August  2002                       15
  833.  
  834.  
  835.  
  836.  
  837.  
  838. Table of Contents                  iSCSI                     17-April-02
  839.  
  840.           2.5.1.6 Ready To Transfer (R2T)  . . . . . . . . . . . . . . .58
  841.        2.5.2 Requests/Responses carrying SCSI and iSCSI Payload  . . . .58
  842.           2.5.2.1 Asynchronous Message   . . . . . . . . . . . . . . . .58
  843.        2.5.3 Requests/Responses carrying iSCSI Only Payload  . . . . . .58
  844.           2.5.3.1 Text Request and Text Response   . . . . . . . . . . .58
  845.           2.5.3.2 Login Request and Login Response   . . . . . . . . . .59
  846.           2.5.3.3 Logout Request and Response  . . . . . . . . . . . . .60
  847.           2.5.3.4  SNACK Request   . . . . . . . . . . . . . . . . . . .60
  848.           2.5.3.5 Reject   . . . . . . . . . . . . . . . . . . . . . . .60
  849.           2.5.3.6 NOP-Out Request and NOP-In Response  . . . . . . . . .61
  850. 3. SCSI Mode Parameters for iSCSI  . . . . . . . . . . . . . . . . . .62
  851. 4. Login and Full Feature Phase Negotiation  . . . . . . . . . . . . .63
  852.      4.1 Text Format  . . . . . . . . . . . . . . . . . . . . . . . . . .63
  853.      4.2 Text Mode Negotiation  . . . . . . . . . . . . . . . . . . . . .63
  854.      4.3 Login Phase  . . . . . . . . . . . . . . . . . . . . . . . . . .66
  855.        4.3.1 Login Phase Start   . . . . . . . . . . . . . . . . . . . .68
  856.        4.3.2 iSCSI Security Negotiation  . . . . . . . . . . . . . . . .71
  857.        4.3.3 Operational Parameter Negotiation During the Login Phase  .72
  858.        4.3.4 Connection reinstatement  . . . . . . . . . . . . . . . . .72
  859.        4.3.5 Session reinstatement, closure and timeout  . . . . . . . .73
  860.           4.3.5.1 Loss of Nexus notification   . . . . . . . . . . . . .74
  861.        4.3.6 Session continuation and failure  . . . . . . . . . . . . .74
  862.      4.4 Operational Parameter Negotiation Outside the Login Phase  . . .74
  863. 5. State Transitions   . . . . . . . . . . . . . . . . . . . . . . . .76
  864.      5.1 Standard Connection State Diagrams   . . . . . . . . . . . . . .76
  865.        5.1.1 Standard Connection State Diagram for an Initiator  . . . .76
  866.        5.1.2 Standard Connection State Diagram for a Target  . . . . . .78
  867.        5.1.3 State Descriptions for Initiators and Targets   . . . . . .80
  868.        5.1.4 State Transition Descriptions for Initiators and Targets  .81
  869.      5.2 Connection Cleanup State Diagram for Initiators and Targets  . .84
  870.        5.2.1 State Descriptions for Initiators and Targets   . . . . . .86
  871.        5.2.2 State Transition Descriptions for Initiators and Targets  .87
  872.      5.3 Session State Diagrams   . . . . . . . . . . . . . . . . . . . .88
  873.        5.3.1 Session State Diagram for a Target  . . . . . . . . . . . .89
  874.        5.3.2 State Descriptions for Initiators and Targets   . . . . . .91
  875.        5.3.3 State Transition Descriptions for Initiators and Targets  .91
  876. 6. iSCSI Error Handling and Recovery   . . . . . . . . . . . . . . . .93
  877.      6.1 Retry and Reassign in Recovery   . . . . . . . . . . . . . . . .93
  878.        6.1.1 Usage of Retry  . . . . . . . . . . . . . . . . . . . . . .93
  879.        6.1.2 Allegiance Reassignment   . . . . . . . . . . . . . . . . .94
  880.      6.2 Usage Of Reject PDU in Recovery  . . . . . . . . . . . . . . . .95
  881.      6.3 Connection timeout management  . . . . . . . . . . . . . . . . .95
  882.        6.3.1 Timeouts on transport exception events  . . . . . . . . . .96
  883.  
  884. Julian Satran               Expires August  2002                       16
  885.  
  886.  
  887.  
  888.  
  889.  
  890. Table of Contents                  iSCSI                     17-April-02
  891.  
  892.        6.3.2 Timeouts on planned decommissioning   . . . . . . . . . . .96
  893.      6.4 Format Errors  . . . . . . . . . . . . . . . . . . . . . . . . .96
  894.      6.5 Digest Errors  . . . . . . . . . . . . . . . . . . . . . . . . .96
  895.      6.6 Sequence Errors  . . . . . . . . . . . . . . . . . . . . . . . .98
  896.      6.7 SCSI Timeouts  . . . . . . . . . . . . . . . . . . . . . . . . .98
  897.      6.8 Negotiation Failures   . . . . . . . . . . . . . . . . . . . . .99
  898.      6.9 Protocol Errors  . . . . . . . . . . . . . . . . . . . . . . . 100
  899.      6.10 Connection Failures   . . . . . . . . . . . . . . . . . . . . 100
  900.      6.11 Session Errors  . . . . . . . . . . . . . . . . . . . . . . . 101
  901.      6.12 Recovery Classes  . . . . . . . . . . . . . . . . . . . . . . 101
  902.        6.12.1 Recovery Within-command  . . . . . . . . . . . . . . . . 102
  903.        6.12.2 Recovery Within-connection   . . . . . . . . . . . . . . 103
  904.        6.12.3 Connection Recovery  . . . . . . . . . . . . . . . . . . 103
  905.        6.12.4 Session Recovery   . . . . . . . . . . . . . . . . . . . 104
  906.      6.13 Error Recovery Hierarchy  . . . . . . . . . . . . . . . . . . 104
  907. 7. Security Considerations   . . . . . . . . . . . . . . . . . . . . 107
  908.      7.1 iSCSI Security Mechanisms  . . . . . . . . . . . . . . . . . . 107
  909.      7.2 In-band Initiator-Target Authentication  . . . . . . . . . . . 108
  910.      7.3 IPsec  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
  911.        7.3.1 Data Integrity and Authentication   . . . . . . . . . . . 109
  912.        7.3.2 Confidentiality   . . . . . . . . . . . . . . . . . . . . 109
  913.        7.3.3 Policy, Security Associations and Key Management  . . . . 110
  914. 8. Notes to Implementers   . . . . . . . . . . . . . . . . . . . . . 112
  915.      8.1 Multiple Network Adapters  . . . . . . . . . . . . . . . . . . 112
  916.        8.1.1 Conservative Reuse of ISIDs   . . . . . . . . . . . . . . 112
  917.        8.1.2 iSCSI Name, ISID and TPGT Use   . . . . . . . . . . . . . 113
  918.      8.2 Autosense and Auto Contingent Allegiance (ACA)   . . . . . . . 115
  919.      8.3 iSCSI timeouts   . . . . . . . . . . . . . . . . . . . . . . . 115
  920.      8.4 Command Retry and Cleaning Old Command Instances   . . . . . . 115
  921.      8.5 Synch and Steering Layer and Performance   . . . . . . . . . . 115
  922.      8.6 Considerations for State-dependent devices   . . . . . . . . . 116
  923.        8.6.1 Determining the proper ErrorRecoveryLevel   . . . . . . . 116
  924. 9. iSCSI PDU Formats   . . . . . . . . . . . . . . . . . . . . . . . 118
  925.      9.1 iSCSI PDU Length and Padding   . . . . . . . . . . . . . . . . 118
  926.      9.2 PDU Template, Header, and Opcodes  . . . . . . . . . . . . . . 118
  927.        9.2.1 Basic Header Segment (BHS)  . . . . . . . . . . . . . . . 119
  928.           9.2.1.1 I  . . . . . . . . . . . . . . . . . . . . . . . . . 120
  929.           9.2.1.2 Opcode   . . . . . . . . . . . . . . . . . . . . . . 120
  930.           9.2.1.3 Opcode-specific Fields   . . . . . . . . . . . . . . 121
  931.           9.2.1.4 TotalAHSLength   . . . . . . . . . . . . . . . . . . 121
  932.           9.2.1.5 DataSegmentLength  . . . . . . . . . . . . . . . . . 121
  933.           9.2.1.6 LUN  . . . . . . . . . . . . . . . . . . . . . . . . 121
  934.           9.2.1.7 Initiator Task Tag   . . . . . . . . . . . . . . . . 122
  935.  
  936. Julian Satran               Expires August  2002                       17
  937.  
  938.  
  939.  
  940.  
  941.  
  942. Table of Contents                  iSCSI                     17-April-02
  943.  
  944.        9.2.2 Additional Header Segment (AHS)   . . . . . . . . . . . . 122
  945.           9.2.2.1 AHSType  . . . . . . . . . . . . . . . . . . . . . . 122
  946.           9.2.2.2 AHSLength  . . . . . . . . . . . . . . . . . . . . . 123
  947.           9.2.2.3 Extended CDB AHS   . . . . . . . . . . . . . . . . . 123
  948.           9.2.2.4 Bidirectional Expected Read-Data Length AHS  . . . . 123
  949.        9.2.3 Header Digest and Data Digest   . . . . . . . . . . . . . 123
  950.        9.2.4 Data Segment  . . . . . . . . . . . . . . . . . . . . . . 124
  951.      9.3 SCSI Command . . . . . . . . . . . . . . . . . . . . . . . . . 125
  952.        9.3.1 Flags and Task Attributes (byte 1)  . . . . . . . . . . . 125
  953.        9.3.2 CmdSN - Command Sequence Number   . . . . . . . . . . . . 126
  954.        9.3.3 ExpStatSN   . . . . . . . . . . . . . . . . . . . . . . . 126
  955.        9.3.4 Expected Data Transfer Length   . . . . . . . . . . . . . 126
  956.        9.3.5 CDB - SCSI Command Descriptor Block   . . . . . . . . . . 127
  957.        9.3.6 Data Segment - Command Data   . . . . . . . . . . . . . . 127
  958.      9.4 SCSI Response  . . . . . . . . . . . . . . . . . . . . . . . . 128
  959.        9.4.1 Flags (byte 1)  . . . . . . . . . . . . . . . . . . . . . 128
  960.        9.4.2 Status  . . . . . . . . . . . . . . . . . . . . . . . . . 129
  961.        9.4.3 Response  . . . . . . . . . . . . . . . . . . . . . . . . 130
  962.        9.4.4 Residual Count  . . . . . . . . . . . . . . . . . . . . . 131
  963.        9.4.5 Bidirectional Read Residual Count   . . . . . . . . . . . 131
  964.        9.4.6 Data Segment - Sense and Response Data Segment  . . . . . 131
  965.           9.4.6.1 SenseLength  . . . . . . . . . . . . . . . . . . . . 132
  966.        9.4.7 ExpDataSN   . . . . . . . . . . . . . . . . . . . . . . . 132
  967.        9.4.8 StatSN - Status Sequence Number   . . . . . . . . . . . . 132
  968.        9.4.9 ExpCmdSN - Next Expected CmdSN from this Initiator  . . . 132
  969.        9.4.10 MaxCmdSN - Maximum CmdSN from this Initiator   . . . . . 133
  970.      9.5 Task Management Function Request . . . . . . . . . . . . . . . 134
  971.        9.5.1 Function  . . . . . . . . . . . . . . . . . . . . . . . . 134
  972.        9.5.2 LUN   . . . . . . . . . . . . . . . . . . . . . . . . . . 137
  973.        9.5.3 Referenced Task Tag   . . . . . . . . . . . . . . . . . . 137
  974.        9.5.4 RefCmdSN  . . . . . . . . . . . . . . . . . . . . . . . . 137
  975.        9.5.5 ExpDataSN   . . . . . . . . . . . . . . . . . . . . . . . 137
  976.      9.6 Task Management Function Response  . . . . . . . . . . . . . . 139
  977.        9.6.1 Response  . . . . . . . . . . . . . . . . . . . . . . . . 139
  978.        9.6.2 Task Management actions on task sets  . . . . . . . . . . 141
  979.      9.7 SCSI Data-out & SCSI Data-in . . . . . . . . . . . . . . . . . 142
  980.        9.7.1 F (Final) Bit   . . . . . . . . . . . . . . . . . . . . . 144
  981.        9.7.2 A (Acknowledge) bit   . . . . . . . . . . . . . . . . . . 144
  982.        9.7.3 Target Transfer Tag   . . . . . . . . . . . . . . . . . . 145
  983.        9.7.4 StatSN  . . . . . . . . . . . . . . . . . . . . . . . . . 145
  984.        9.7.5 DataSN  . . . . . . . . . . . . . . . . . . . . . . . . . 145
  985.        9.7.6 Buffer Offset   . . . . . . . . . . . . . . . . . . . . . 146
  986.        9.7.7 DataSegmentLength   . . . . . . . . . . . . . . . . . . . 146
  987.  
  988. Julian Satran               Expires August  2002                       18
  989.  
  990.  
  991.  
  992.  
  993.  
  994. Table of Contents                  iSCSI                     17-April-02
  995.  
  996.        9.7.8 Flags (byte 1)  . . . . . . . . . . . . . . . . . . . . . 146
  997.      9.8 Ready To Transfer (R2T)  . . . . . . . . . . . . . . . . . . . 148
  998.        9.8.1 R2TSN   . . . . . . . . . . . . . . . . . . . . . . . . . 149
  999.        9.8.2 StatSN  . . . . . . . . . . . . . . . . . . . . . . . . . 149
  1000.        9.8.3 Desired Data Transfer Length and Buffer Offset  . . . . . 149
  1001.        9.8.4 Target Transfer Tag   . . . . . . . . . . . . . . . . . . 150
  1002.      9.9 Asynchronous Message . . . . . . . . . . . . . . . . . . . . . 151
  1003.        9.9.1 AsyncEvent  . . . . . . . . . . . . . . . . . . . . . . . 152
  1004.        9.9.2 AsyncVCode  . . . . . . . . . . . . . . . . . . . . . . . 153
  1005.        9.9.3 Sense Data and iSCSI Event Data   . . . . . . . . . . . . 153
  1006.           9.9.3.1 SenseLength  . . . . . . . . . . . . . . . . . . . . 154
  1007.      9.10 Text Request  . . . . . . . . . . . . . . . . . . . . . . . . 155
  1008.        9.10.1 F (Final) Bit  . . . . . . . . . . . . . . . . . . . . . 155
  1009.        9.10.2 Initiator Task Tag   . . . . . . . . . . . . . . . . . . 156
  1010.        9.10.3 Target Transfer Tag  . . . . . . . . . . . . . . . . . . 156
  1011.        9.10.4 Text   . . . . . . . . . . . . . . . . . . . . . . . . . 157
  1012.      9.11 Text Response . . . . . . . . . . . . . . . . . . . . . . . . 158
  1013.        9.11.1 F (Final) Bit  . . . . . . . . . . . . . . . . . . . . . 158
  1014.        9.11.2 Initiator Task Tag   . . . . . . . . . . . . . . . . . . 159
  1015.        9.11.3 Target Transfer Tag  . . . . . . . . . . . . . . . . . . 159
  1016.        9.11.4 Text Response Data   . . . . . . . . . . . . . . . . . . 160
  1017.      9.12 Login Request . . . . . . . . . . . . . . . . . . . . . . . . 161
  1018.        9.12.1 T (Transit) Bit  . . . . . . . . . . . . . . . . . . . . 162
  1019.        9.12.2 CSG and NSG  . . . . . . . . . . . . . . . . . . . . . . 162
  1020.        9.12.3 Version-max  . . . . . . . . . . . . . . . . . . . . . . 162
  1021.        9.12.4 Version-min  . . . . . . . . . . . . . . . . . . . . . . 162
  1022.        9.12.5 ISID   . . . . . . . . . . . . . . . . . . . . . . . . . 163
  1023.        9.12.6 TSIH   . . . . . . . . . . . . . . . . . . . . . . . . . 164
  1024.        9.12.7 Connection ID - CID  . . . . . . . . . . . . . . . . . . 164
  1025.        9.12.8 CmdSN  . . . . . . . . . . . . . . . . . . . . . . . . . 165
  1026.        9.12.9 ExpStatSN  . . . . . . . . . . . . . . . . . . . . . . . 165
  1027.        9.12.10 Login Parameters  . . . . . . . . . . . . . . . . . . . 165
  1028.      9.13 Login Response  . . . . . . . . . . . . . . . . . . . . . . . 166
  1029.        9.13.1 Version-max  . . . . . . . . . . . . . . . . . . . . . . 166
  1030.        9.13.2 Version-active   . . . . . . . . . . . . . . . . . . . . 167
  1031.        9.13.3 TSIH   . . . . . . . . . . . . . . . . . . . . . . . . . 167
  1032.        9.13.4 StatSN   . . . . . . . . . . . . . . . . . . . . . . . . 167
  1033.        9.13.5 Status-Class and Status-Detail   . . . . . . . . . . . . 167
  1034.        9.13.6 T (Transit) bit  . . . . . . . . . . . . . . . . . . . . 170
  1035.      9.14 Logout Request  . . . . . . . . . . . . . . . . . . . . . . . 171
  1036.        9.14.1 CID  . . . . . . . . . . . . . . . . . . . . . . . . . . 172
  1037.        9.14.2 ExpStatSN  . . . . . . . . . . . . . . . . . . . . . . . 172
  1038.        9.14.3 Reason Code  . . . . . . . . . . . . . . . . . . . . . . 173
  1039.  
  1040. Julian Satran               Expires August  2002                       19
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046. Table of Contents                  iSCSI                     17-April-02
  1047.  
  1048.        9.14.4 Implicit termination of tasks  . . . . . . . . . . . . . 173
  1049.      9.15 Logout Response . . . . . . . . . . . . . . . . . . . . . . . 174
  1050.        9.15.1 Response   . . . . . . . . . . . . . . . . . . . . . . . 174
  1051.        9.15.2 Time2Wait  . . . . . . . . . . . . . . . . . . . . . . . 175
  1052.        9.15.3 Time2Retain  . . . . . . . . . . . . . . . . . . . . . . 175
  1053.      9.16  SNACK Request  . . . . . . . . . . . . . . . . . . . . . . . 177
  1054.        9.16.1 Type   . . . . . . . . . . . . . . . . . . . . . . . . . 178
  1055.        9.16.2 BegRun   . . . . . . . . . . . . . . . . . . . . . . . . 179
  1056.        9.16.3 RunLength  . . . . . . . . . . . . . . . . . . . . . . . 179
  1057.      9.17 Reject  . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
  1058.        9.17.1 Reason   . . . . . . . . . . . . . . . . . . . . . . . . 181
  1059.        9.17.2 DataSN   . . . . . . . . . . . . . . . . . . . . . . . . 182
  1060.        9.17.3 StatSN, ExpCmdSN and MaxCmdSN  . . . . . . . . . . . . . 182
  1061.        9.17.4 Complete Header of Bad PDU   . . . . . . . . . . . . . . 182
  1062.      9.18 NOP-Out . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
  1063.        9.18.1 Initiator Task Tag   . . . . . . . . . . . . . . . . . . 184
  1064.        9.18.2 Target Transfer Tag  . . . . . . . . . . . . . . . . . . 184
  1065.        9.18.3 Ping Data  . . . . . . . . . . . . . . . . . . . . . . . 184
  1066.      9.19 NOP-In  . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
  1067.        9.19.1 Target Transfer Tag  . . . . . . . . . . . . . . . . . . 186
  1068.        9.19.2 LUN  . . . . . . . . . . . . . . . . . . . . . . . . . . 186
  1069. 10. iSCSI Security Keys and Values   . . . . . . . . . . . . . . . . 187
  1070.      10.1 AuthMethod  . . . . . . . . . . . . . . . . . . . . . . . . . 187
  1071.      10.2 Kerberos  . . . . . . . . . . . . . . . . . . . . . . . . . . 188
  1072.      10.3 Simple Public-Key Mechanism (SPKM)  . . . . . . . . . . . . . 189
  1073.      10.4 Secure Remote Password (SRP)  . . . . . . . . . . . . . . . . 190
  1074.      10.5 Challenge Handshake Authentication Protocol (CHAP)  . . . . . 191
  1075. 11. Login/Text Operational Keys  . . . . . . . . . . . . . . . . . . 193
  1076.      11.1 HeaderDigest and DataDigest   . . . . . . . . . . . . . . . . 193
  1077.      11.2 MaxConnections  . . . . . . . . . . . . . . . . . . . . . . . 195
  1078.      11.3 SendTargets   . . . . . . . . . . . . . . . . . . . . . . . . 195
  1079.      11.4 TargetName  . . . . . . . . . . . . . . . . . . . . . . . . . 195
  1080.      11.5 InitiatorName   . . . . . . . . . . . . . . . . . . . . . . . 196
  1081.      11.6 TargetAlias   . . . . . . . . . . . . . . . . . . . . . . . . 196
  1082.      11.7 InitiatorAlias  . . . . . . . . . . . . . . . . . . . . . . . 197
  1083.      11.8 TargetAddress   . . . . . . . . . . . . . . . . . . . . . . . 197
  1084.      11.9 TargetPortalGroupTag  . . . . . . . . . . . . . . . . . . . . 198
  1085.      11.10 InitialR2T   . . . . . . . . . . . . . . . . . . . . . . . . 198
  1086.      11.11 BidiInitialR2T   . . . . . . . . . . . . . . . . . . . . . . 199
  1087.      11.12 ImmediateData  . . . . . . . . . . . . . . . . . . . . . . . 199
  1088.      11.13 MaxRecvPDULength   . . . . . . . . . . . . . . . . . . . . . 200
  1089.      11.14 MaxBurstSize   . . . . . . . . . . . . . . . . . . . . . . . 201
  1090.      11.15 FirstBurstSize   . . . . . . . . . . . . . . . . . . . . . . 201
  1091.  
  1092. Julian Satran               Expires August  2002                       20
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098. Table of Contents                  iSCSI                     17-April-02
  1099.  
  1100.      11.16 DefaultTime2Wait   . . . . . . . . . . . . . . . . . . . . . 202
  1101.      11.17 DefaultTime2Retain   . . . . . . . . . . . . . . . . . . . . 202
  1102.      11.18 MaxOutstandingR2T  . . . . . . . . . . . . . . . . . . . . . 203
  1103.      11.19 DataPDUInOrder   . . . . . . . . . . . . . . . . . . . . . . 203
  1104.      11.20 DataSequenceInOrder  . . . . . . . . . . . . . . . . . . . . 203
  1105.      11.21 ErrorRecoveryLevel   . . . . . . . . . . . . . . . . . . . . 204
  1106.      11.22 SessionType  . . . . . . . . . . . . . . . . . . . . . . . . 205
  1107.      11.23 The Vendor Specific Key Format   . . . . . . . . . . . . . . 205
  1108. 12. IANA Considerations  . . . . . . . . . . . . . . . . . . . . . . 206
  1109.  References and Bibliography . . . . . . . . . . . . . . . . . . . . 207
  1110.  Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . . . 209
  1111. Appendix A. Sync and Steering with Fixed Interval Markers  . . . . . 212
  1112.      A.1 Markers At Fixed Intervals   . . . . . . . . . . . . . . . . . 212
  1113.      A.2 Initial Marker-less Interval   . . . . . . . . . . . . . . . . 213
  1114.      A.3 Negotiation  . . . . . . . . . . . . . . . . . . . . . . . . . 213
  1115.         A.3.1 OFMarker, IFMarker  . . . . . . . . . . . . . . . . . . . 213
  1116.         A.3.2 OFMarkInt, IFMarkInt  . . . . . . . . . . . . . . . . . . 214
  1117. Appendix B. Examples   . . . . . . . . . . . . . . . . . . . . . . . 216
  1118.      B.2 Write Operation Example  . . . . . . . . . . . . . . . . . . . 217
  1119.      B.3 R2TSN/DataSN use Examples  . . . . . . . . . . . . . . . . . . 217
  1120.      B.4 CRC Examples   . . . . . . . . . . . . . . . . . . . . . . . . 221
  1121. Appendix C. Login Phase Examples   . . . . . . . . . . . . . . . . . 223
  1122. Appendix D. SendTargets Operation  . . . . . . . . . . . . . . . . . 232
  1123. Appendix E. Algorithmic Presentation of Error Recovery Classes   . . 236
  1124.      E.2 Within-command Error Recovery Algorithms   . . . . . . . . . . 237
  1125.         E.2.1 Procedure Descriptions  . . . . . . . . . . . . . . . . . 237
  1126.         E.2.2 Initiator Algorithms  . . . . . . . . . . . . . . . . . . 238
  1127.         E.2.3 Target Algorithms   . . . . . . . . . . . . . . . . . . . 240
  1128.      E.3 Within-connection Recovery Algorithms  . . . . . . . . . . . . 242
  1129.         E.3.1 Procedure Descriptions  . . . . . . . . . . . . . . . . . 242
  1130.         E.3.2 Initiator Algorithms  . . . . . . . . . . . . . . . . . . 243
  1131.         E.3.3 Target Algorithms   . . . . . . . . . . . . . . . . . . . 246
  1132.      E.4 Connection Recovery Algorithms   . . . . . . . . . . . . . . . 246
  1133.         E.4.1 Procedure Descriptions  . . . . . . . . . . . . . . . . . 246
  1134.         E.4.2 Initiator Algorithms  . . . . . . . . . . . . . . . . . . 247
  1135.         E.4.3 Target Algorithms   . . . . . . . . . . . . . . . . . . . 249
  1136. Appendix F. Clearing effects of various events on targets  . . . . . 251
  1137.      F.2 Clearing effects on SCSI objects   . . . . . . . . . . . . . . 256
  1138.  Full Copyright Statement  . . . . . . . . . . . . . . . . . . . . . 260
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144. Julian Satran               Expires August  2002                       21
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.                                     iSCSI                     17-April-02
  1151.  
  1152. 1. Definitions
  1153.  
  1154.      - Alias: An alias string could also be associated with an iSCSI Node. 
  1155.      The alias allows an organization to associate a user-friendly string 
  1156.      with the iSCSI Name. However, the alias string is not a substitute for 
  1157.      the iSCSI Name.
  1158.  
  1159.      - CID (Connection ID): Connections within a session are identified by 
  1160.      a connection ID. It is a unique ID for this connection within the ses-
  1161.      sion for the initiator. It is generated by the initiator and presented 
  1162.      to the target during login requests and during logouts that close con-
  1163.      nections.
  1164.  
  1165.      - Connection: Communication between the initiator and target occurs 
  1166.      over one or more TCP connections. The TCP connections carry control 
  1167.      messages, SCSI commands, parameters, and data within iSCSI Protocol 
  1168.      Data Units (iSCSI PDUs). 
  1169.  
  1170.      - iSCSI Initiator Name: The iSCSI Initiator Name specifies the world-
  1171.      wide unique name of the initiator.
  1172.  
  1173.      - iSCSI Initiator Node: The "initiator". 
  1174.  
  1175.      - iSCSI Layer: This layer builds/receives iSCSI PDUs and relays/
  1176.      receives them to/from one or more TCP connections that form an initi-
  1177.      ator-target "session". 
  1178.  
  1179.      - iSCSI Name: The name of an iSCSI initiator or iSCSI target. 
  1180.  
  1181.      - iSCSI Node: The iSCSI Node represents a single iSCSI initiator or 
  1182.      iSCSI target. There are one or more iSCSI Nodes within a Network 
  1183.      Entity. The iSCSI Node is accessible via one or more Network Portals. 
  1184.      An iSCSI Node is identified by its iSCSI Name. The separation of the 
  1185.      iSCSI Name from the addresses used by and for the iSCSI node allows 
  1186.      multiple iSCSI nodes to use the same addresses, and the same iSCSI 
  1187.      node to use multiple addresses. 
  1188.  
  1189.      - iSCSI Target Name: The iSCSI Target Name specifies the worldwide 
  1190.      unique name of the target. 
  1191.  
  1192.      - iSCSI Target Node: The "target". 
  1193.  
  1194.  
  1195.  
  1196. Julian Satran               Expires August  2002                          22
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.                                      iSCSI                    17-April-02
  1203.  
  1204.      - iSCSI Task: An iSCSI task is an iSCSI request for which a response 
  1205.      is expected. 
  1206.  
  1207.      - iSCSI Transfer Direction: The iSCSI transfer direction is defined 
  1208.      with regard to the initiator. Outbound or outgoing transfers are 
  1209.      transfers from the initiator to the target, while inbound or incoming 
  1210.      transfers are from the target to the initiator. 
  1211.  
  1212.      - I_T nexus: According to [SAM2], the I_T nexus is a relationship 
  1213.      between a SCSI Initiator Port and a SCSI Target Port. For iSCSI, this 
  1214.      relationship is a session, defined as a relationship between an iSCSI 
  1215.      Initiator's end of session (SCSI Initiator Port) and the iSCSI Tar-
  1216.      get's Portal Group. The I_T nexus can be identified by the conjunction 
  1217.      of the SCSI port names; that is, the I_T nexus identifier is the tuple 
  1218.      (iSCSI Initiator Name + 'i'+ ISID, iSCSI Target Name + 't'+ Portal 
  1219.      Group Tag).  
  1220.  
  1221.      - Network Entity: The Network Entity represents a device or gateway 
  1222.      that is accessible from the IP network. A Network Entity must have one 
  1223.      or more Network Portals, each of which can be used to gain access to 
  1224.      the IP network by some iSCSI Nodes contained in that Network Entity. 
  1225.  
  1226.      - Network Portal: The Network Portal is a component of a Network 
  1227.      Entity that has a TCP/IP network address and that may be used by an 
  1228.      iSCSI Node within that Network Entity for the connection(s) within one 
  1229.      of its iSCSI sessions. A Network Portal in an initiator is identified 
  1230.      by its IP address. A Network Portal in a target is identified by its 
  1231.      IP address and its listening TCP port.
  1232.  
  1233.      - Originator - in a negotiation or exchange the party that initiates 
  1234.      the negotiation or exchange.
  1235.  
  1236.      - PDU (Protocol Data Unit): The initiator and target divide their com-
  1237.      munications into messages. The term "iSCSI protocol data unit" (iSCSI 
  1238.      PDU) is used for these messages. 
  1239.  
  1240.      - Portal Groups: iSCSI supports multiple connections within the same 
  1241.      session; some implementations will have the ability to combine con-
  1242.      nections in a session across multiple Network Portals. A Portal Group 
  1243.      defines a set of Network Portals within an iSCSI Node that collec-
  1244.      tively supports the capability of coordinating a session with connec-
  1245.      tions spanning these portals. Not all Network Portals within a Portal 
  1246.  
  1247. Julian Satran               Expires August  2002                          23
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.                                    iSCSI                      17-April-02
  1254.  
  1255.      Group need participate in every session connected through that Portal 
  1256.      Group. One or more Portal Groups may provide access to an iSCSI Node. 
  1257.      Each Network Portal as utilized by a given iSCSI Node belongs to 
  1258.      exactly one portal group within that node. 
  1259.  
  1260.      - Portal Group Tag: This simple integer value between 1 and 65535 
  1261.      identifies the Portal Group within an iSCSI Node. All Network Portals 
  1262.      with the same portal group tag in the context of a given iSCSI Node 
  1263.      are in the same Portal Group. 
  1264.  
  1265.      - Responder: In a negotiation or exchange, the party that responds to 
  1266.      the originator of the negotiation or exchange.
  1267.  
  1268.      - SCSI Device: This is the SAM2 term for an entity that contains other 
  1269.      SCSI entities. For example, a SCSI Initiator Device contains one or 
  1270.      more SCSI Initiator Ports and zero or more application clients; a SCSI 
  1271.      Target Device contains one or more SCSI Target Ports and one or more 
  1272.      logical units. For iSCSI, the SCSI Device is the component within an 
  1273.      iSCSI Node that provides the SCSI functionality. As such, there can be 
  1274.      at most one SCSI Device within a given iSCSI Node. Access to the SCSI 
  1275.      Device can only be achieved in an iSCSI normal operational session. 
  1276.      The SCSI Device Name is defined to be the iSCSI Name of the node and 
  1277.      its use is mandatory in the iSCSI protocol. 
  1278.  
  1279.      - SCSI Layer: This builds/receives SCSI CDBs (Command Descriptor 
  1280.      Blocks) and relays/receives them with the remaining command execute 
  1281.      parameters to/from the iSCSI Layer. 
  1282.  
  1283.      - Session: The group of TCP connections that link an initiator with a 
  1284.      target, form a session (loosely equivalent to a SCSI I-T nexus). TCP 
  1285.      connections can be added and removed from a session. Across all con-
  1286.      nections within a session, an initiator sees one "target image".
  1287.       
  1288.      - SSID (Session ID): A session between an iSCSI initiator and an iSCSI 
  1289.      target is defined by a session ID that is tuple composed of an initi-
  1290.      ator part (ISID) and a target part (Target Portal Group Tag). The ISID 
  1291.      is explicitly specified by the initiator at session establishment.  
  1292.      The Target Portal Group Tag is implied by the initiator through the 
  1293.      selection of the TCP end-point at connection establishment. The Tar-
  1294.      getPortalGroupTag key may also be returned by the target as a confir-
  1295.      mation during session establishment. 
  1296.  
  1297.  
  1298.  
  1299. Julian Satran               Expires August  2002                          24
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.                                       iSCSI                      17-April-02
  1306.  
  1307.      - SCSI Initiator Port: This maps to the endpoint of an iSCSI normal 
  1308.      operational session. An iSCSI normal operational session is negoti-
  1309.      ated through the login process between an iSCSI initiator node and an 
  1310.      iSCSI target node. At successful completion of this process, a SCSI 
  1311.      Initiator Port is created within the SCSI Initiator Device. The SCSI 
  1312.      Initiator Port Name and SCSI Initiator Port Identifier are both 
  1313.      defined to be the iSCSI Initiator Name together with (a) a label that 
  1314.      identifies it as an initiator port name/identifier and (b) the ISID 
  1315.      portion of the session identifier. 
  1316.  
  1317.      - SCSI Port: This is the SAM2 term for an entity in a SCSI Device that 
  1318.      provides the SCSI functionality to interface with a service delivery 
  1319.      subsystem or transport. For iSCSI, the definition of the SCSI Initia-
  1320.      tor Port and the SCSI Target Port are different. 
  1321.  
  1322.      - SCSI Port Name: A name made up as UTF-8 characters and is basically 
  1323.      the iSCSI Name + 'i' or 't' + ISID or Portal Group Tag. 
  1324.  
  1325.      - SCSI Target Port: This maps to an iSCSI Target Portal Group. 
  1326.  
  1327.      - SCSI Target Port Name and SCSI Target Port Identifier: These are 
  1328.      both defined to be the iSCSI Target Name together with (a) a label 
  1329.      that identifies it as a target port name/identifier and (b) the portal 
  1330.      group tag. 
  1331.  
  1332.      - Target Portal Group Tag: a numerical identifier (16 bit) for an 
  1333.      iSCSI Target Portal Group 
  1334.  
  1335.      - TSIH (Target Session Identifying Handle): The TSIH is a target 
  1336.      assigned tag for a session with a specific named initiator. The target 
  1337.      is generating it during session establishment and its internal format 
  1338.      and content are not defined by this protocol except for the value 0 
  1339.      that is reserved and used by the initiator to indicate a new session.  
  1340.      It is given to the target, during additional connection establishment 
  1341.      for the same session. 
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347. Julian Satran                  Expires August  2002                       25
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.                                       iSCSI                   17-April-02
  1354.  
  1355. 2. Overview
  1356.  
  1357. 2.1  SCSI Concepts
  1358.  
  1359.      The SCSI Architecture Model-2 [SAM2] describes, in detail, the archi-
  1360.      tecture of the SCSI family of I/O protocols. This section provides a 
  1361.      brief background of the SCSI architecture and is intended to familiar-
  1362.      ize readers with its terminology. 
  1363.  
  1364.      At the highest level, SCSI is a family of interfaces for requesting 
  1365.      services from I/O devices, including hard drives, tape drives, CD and 
  1366.      DVD drives, printers, and scanners. In SCSI terminology, an individ-
  1367.      ual I/O device is called a "logical unit" (LU).
  1368.       
  1369.      SCSI is a client-server architecture. Clients of a SCSI interface are 
  1370.      called "initiators". Initiators issue SCSI "commands" to request ser-
  1371.      vice from a logical unit. The "device server" on the logical unit 
  1372.      accepts SCSI commands and processes them. 
  1373.  
  1374.      A "SCSI transport" maps the client-server SCSI protocol to a specific 
  1375.      interconnect. Initiators are one endpoint of a SCSI transport. The 
  1376.      "target" is the other endpoint. A target can contain multiple Logical 
  1377.      Units (LUs). Each Logical Unit has an address within a target called a 
  1378.      Logical Unit Number (LUN).
  1379.  
  1380.      A SCSI task is a SCSI command or possibly a linked set of SCSI com-
  1381.      mands. Some LUs support multiple pending (queued) tasks, but the queue 
  1382.      of tasks is managed by the target. The target uses an initiator pro-
  1383.      vided "task tag" to distinguish between tasks. Only one command in a 
  1384.      task can be outstanding at any given time. 
  1385.  
  1386.      Each SCSI command results in an optional data phase and a required 
  1387.      response phase. In the data phase, information can travel from the 
  1388.      initiator to target (e.g., WRITE), target to initiator (e.g., READ), 
  1389.      or in both directions. In the response phase, the target returns the 
  1390.      final status of the operation, including any errors. A response termi-
  1391.      nates a SCSI command. 
  1392.  
  1393.      Command Descriptor Blocks (CDB) are the data structures used to con-
  1394.      tain the command parameters that an initiator hands to a target. The 
  1395.      CDB content and structure is defined by [SAM] and device-type specific 
  1396.      SCSI standards.
  1397.  
  1398.  
  1399.  
  1400. Julian Satran                  Expires August  2002                     26
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.                                      iSCSI                      17-April-02
  1407.  
  1408.  
  1409. 2.2  iSCSI Concepts and Functional Overview
  1410.  
  1411.      The iSCSI protocol is a mapping of the SCSI remote procedure invoca-
  1412.      tion model (see [SAM]) over the TCP protocol. SCSI commands are car-
  1413.      ried by iSCSI requests and SCSI responses and status are carried by 
  1414.      iSCSI responses. iSCSI also uses the request response mechanism for 
  1415.      iSCSI protocol mechanisms.
  1416.  
  1417.      For the remainder of this document, the terms "initiator" and "target" 
  1418.      refer to "iSCSI initiator node" and "iSCSI target node", respectively 
  1419.      (see Section 2.4.1 iSCSI Architecture Model) unless otherwise quali-
  1420.      fied.
  1421.  
  1422.      In keeping with similar protocols, the initiator and target divide 
  1423.      their communications into messages. This document uses the term 
  1424.      "iSCSI protocol data unit" (iSCSI PDU) for these messages.
  1425.  
  1426.      For performance reasons, iSCSI allows a "phase-collapse". A command 
  1427.      and its associated data may be shipped together from initiator to tar-
  1428.      get, and data and responses may be shipped together from targets.
  1429.  
  1430.      The iSCSI transfer direction is defined with regard to the initiator. 
  1431.      Outbound or outgoing transfers are transfers from initiator to tar-
  1432.      get, while inbound or incoming transfers are from target to initiator.
  1433.  
  1434.      An iSCSI task is an iSCSI request for which a response is expected.
  1435.  
  1436.      In this document "iSCSI request", "iSCSI command", request, or 
  1437.      (unqualified) command have the same meaning. Also, unless otherwise 
  1438.      specified, status, response, or numbered response have the same mean-
  1439.      ing.
  1440.  
  1441. 2.2.1  Layers and Sessions
  1442.  
  1443.      The following conceptual layering model is used to specify initiator 
  1444.      and target actions and how they relate to transmitted and received 
  1445.      Protocol Data Units:
  1446.  
  1447.        -The SCSI layer builds/receives SCSI CDBs (Command Descriptor 
  1448.              Blocks) and relays/receives them with the remaining command 
  1449.              execute parameters (cf. SAM2) to/from ->.
  1450.  
  1451.  
  1452.  
  1453. Julian Satran                 Expires August  2002                           27
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.                                      iSCSI                    17-April-02
  1460.  
  1461.        -The iSCSI layer that builds/receives iSCSI PDUs and relays/
  1462.          receives them to/from one or more TCP connections that form an 
  1463.          initiator-target "session".
  1464.  
  1465.      Communication between the initiator and target occurs over one or more 
  1466.      TCP connections. The TCP connections carry control messages, SCSI 
  1467.      commands, parameters, and data within iSCSI Protocol Data Units 
  1468.      (iSCSI PDUs). The group of TCP connections that link an initiator with 
  1469.      a target, form a session (loosely equivalent to a SCSI I-T nexus - see 
  1470.      Section 2.4.2 SCSI Architecture Model). A session is defined by a ses-
  1471.      sion ID that is composed of an initiator part and a target part. TCP 
  1472.      connections can be added and removed from a session. Connections 
  1473.      within a session are identified by a connection ID (CID). 
  1474.  
  1475.      Across all connections within a session, an initiator sees one "target 
  1476.      image". All target identifying elements, such as LUN, are the same.  A 
  1477.      target also sees one "initiator image" across all connections within a 
  1478.      session. Initiator identifying elements, such as the Initiator Task 
  1479.      Tag are global across the session regardless of the connection on 
  1480.      which they are sent or received. 
  1481.  
  1482.      iSCSI targets and initiators MUST support at least one TCP connection 
  1483.      and MAY support several connections in a session. For error recovery 
  1484.      purposes, targets and initiators that support a single active connec-
  1485.      tion in a session may have to support two connections during recovery. 
  1486.  
  1487. 2.2.2  Ordering and iSCSI Numbering
  1488.  
  1489.      iSCSI uses Command and Status numbering schemes and a Data sequencing 
  1490.      scheme.
  1491.  
  1492.      Command numbering is session-wide and is used for ordered command 
  1493.      delivery over multiple connections. It can also be used as a mechanism 
  1494.      for command flow control over a session.
  1495.  
  1496.      Status numbering is per connection and is used to enable missing sta-
  1497.      tus detection and recovery in the presence of transient or permanent 
  1498.      communication errors.
  1499.  
  1500.      Data sequencing is per command or part of a command (R2T triggered 
  1501.      sequence) and is used to detect missing data and/or R2T PDUs due to 
  1502.      header digest errors.
  1503.  
  1504.  
  1505.  
  1506. Julian Satran                 Expires August  2002                        28
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.                                    iSCSI                         17-April-02
  1513.  
  1514.      Typically, fields in the iSCSI PDUs communicate the Sequence Numbers 
  1515.      between the initiator and target. During periods when traffic on a 
  1516.      connection is unidirectional, iSCSI NOP-Out/In PDUs may be utilized 
  1517.      to synchronize the command and status ordering counters of the target 
  1518.      and initiator.
  1519.  
  1520. 2.2.2.1  Command Numbering and Acknowledging
  1521.  
  1522.      iSCSI supports ordered command delivery within a session. All com-
  1523.      mands (initiator-to-target PDUs) are numbered.
  1524.  
  1525.      Many SCSI activities are related to a task (SAM2). The task is identi-
  1526.      fied by the Initiator Task Tag for the life of the task.
  1527.  
  1528.      Commands in transit from the initiator to the target are numbered by 
  1529.      iSCSI; the number is carried by the iSCSI PDU as CmdSN (Command-
  1530.      Sequence-Number). The numbering is session-wide. Outgoing iSCSI 
  1531.      request PDUs carry this number. The iSCSI initiator allocates CmdSNs 
  1532.      with a 32-bit unsigned counter (modulo 2**32). Comparisons and arith-
  1533.      metic on CmdSN use Serial Number Arithmetic as defined in [RFC1982] 
  1534.      where SERIAL_BITS = 32.
  1535.  
  1536.      Commands meant for immediate delivery are marked with an immediate 
  1537.      delivery flag; they also carry CmdSN. CmdSN does not advance for com-
  1538.      mands marked for immediate delivery.
  1539.       
  1540.      Command numbering starts with the first login request on the first 
  1541.      connection of a session (the leading login on the leading connection) 
  1542.      and command numbers are incremented by 1 for every non-immediate com-
  1543.      mand issued afterwards. 
  1544.       
  1545.      If immediate delivery is used with task management commands, these 
  1546.      commands may reach the target before the tasks on which they are sup-
  1547.      posed to act. However, their CmdSN is a marker of their position in 
  1548.      the stream of commands. The task management command MUST carry the 
  1549.      CmdSN that is given to the next non-immediate command. The initiator 
  1550.      and target must ensure that the task management commands act as spec-
  1551.      ified by SAM2. For example, both commands and responses appear as if 
  1552.      delivered in order.
  1553.  
  1554.      Beyond the scope of this document is the means by which one may 
  1555.      request immediate delivery for a command or by which iSCSI decides by 
  1556.      itself to mark a PDU for immediate delivery. 
  1557.  
  1558.  
  1559. Julian Satran               Expires August  2002                          29
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.                                      iSCSI                      17-April-02
  1566.  
  1567.  
  1568.      The number of commands used for immediate delivery is not limited and 
  1569.      their delivery to execution is not acknowledged through the numbering 
  1570.      scheme. Immediate commands can be rejected by the iSCSI target due to 
  1571.      lack of resources. An iSCSI target MUST be able to handle at least one 
  1572.      immediate task management command and one immediate non-task-manage-
  1573.      ment iSCSI request per connection at any time.
  1574.       
  1575.      With the exception of the commands marked for immediate delivery, the 
  1576.      iSCSI target layer MUST deliver the commands for execution in the 
  1577.      order specified by CmdSN. Commands marked for immediate delivery may 
  1578.      be handed over by the iSCSI target layer for execution as soon as 
  1579.      detected. iSCSI may avoid delivering some commands for execution if 
  1580.      required by a prior SCSI or iSCSI action (e.g., CLEAR TASK SET Task 
  1581.      Management request received before all the commands on which it was 
  1582.      supposed to act). Delivery for execution means delivery to the SCSI 
  1583.      execution engine or an iSCSI-SCSI protocol specific execution engine 
  1584.      (e.g., for text requests).
  1585.  
  1586.      On any given connection, the iSCSI initiator MUST send the commands in 
  1587.      increasing order of CmdSN, except for commands that are retransmitted 
  1588.      due to digest error recovery and connection recovery.
  1589.  
  1590.      The initiator and target are assumed to have the following three reg-
  1591.      isters that are unique session wide and that define the numbering 
  1592.      mechanism:
  1593.  
  1594.            - CmdSN - the current command Sequence Number, advanced by 1 on 
  1595.            each command shipped except for commands marked for immediate 
  1596.            delivery. CmdsN always contains the number to be assigned 
  1597.            next. 
  1598.            - ExpCmdSN - the next expected command by the target. The tar-
  1599.            get acknowledges all commands up to, but not including, this 
  1600.            number. The initiator has to mark the acknowledged commands as 
  1601.            such as soon as a PDU with the corresponding ExpCmdSN is 
  1602.            received. The target iSCSI layer sets the ExpCmdSN to the 
  1603.            largest non-immediate CmdSN that it can deliver for execution 
  1604.            plus 1 (no holes in the CmdSN sequence). 
  1605.            - MaxCmdSN - the maximum number to be shipped. The queuing 
  1606.            capacity of the receiving iSCSI layer is MaxCmdSN - ExpCmdSN + 
  1607.            1. 
  1608.  
  1609.      ExpCmdSN and MaxCmdSN are derived from target-to-initiator PDU 
  1610.      fields. Comparisons and arithmetic on ExpCmdSN and MaxCmdSN MUST use 
  1611.  
  1612.  
  1613. Julian Satran                 Expires August  2002                        30
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.                                       iSCSI                    17-April-02
  1620.  
  1621.      Serial Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 
  1622.      32.
  1623.  
  1624.      The target MUST NOT transmit a MaxCmdSN that is less than the last 
  1625.      ExpCmdSN-1. For non-immediate commands, the CmdSN field can take any 
  1626.      value from ExpCmdSN to MaxCmdSN. The target MUST silently ignore any 
  1627.      non-immediate command outside of this range or non-immediate dupli-
  1628.      cates within the range. Note that the CmdSN carried by immediate com-
  1629.      mands may lie outside the ExpCmdSN to MaxCmdSN range (e.g., if the 
  1630.      initiator has previously sent a non-immediate PDU carrying the CmdSN 
  1631.      equal to MaxCmdSN - i.e., target window is closed). For group task 
  1632.      management requests issued as immediate commands CmdSN indicates the 
  1633.      scope of the group action (e.g., on ABORT TASK SET - what commands get 
  1634.      aborted).
  1635.  
  1636.      MaxCmdSN and ExpCmdSN fields are processed by the initiator as fol-
  1637.      lows:
  1638.  
  1639.        -If the PDU MaxCmdSN is less than the PDU ExpCmdSN-1 (in Serial 
  1640.             Arithmetic Sense), they are both ignored.
  1641.        -If the PDU MaxCmdSN is less than the local MaxCmdSN (in Serial 
  1642.             Arithmetic Sense), it is ignored; otherwise, it updates the 
  1643.             local MaxCmdSN.
  1644.        -If the PDU ExpCmdSN is less than the local ExpCmdSN (in Serial 
  1645.             Arithmetic Sense), it is ignored; otherwise, it updates the 
  1646.             local ExpCmdSN.
  1647.  
  1648.      This sequence is required since updates may arrive out of order being 
  1649.      that they travel on different TCP connections.
  1650.  
  1651.      iSCSI initiators and targets MUST support the command numbering 
  1652.      scheme. 
  1653.  
  1654.      A numbered iSCSI request will not change its allocated CmdSN, regard-
  1655.      less of the number of times and circumstances in which it is reissued 
  1656.      (see Section 6.1.1 Usage of Retry). At the target, it is assumed that 
  1657.      CmdSN is relevant only while the command has not created any state 
  1658.      related to its execution (execution state); afterwards, CmdSN becomes 
  1659.      irrelevant. Testing for the execution state (represented by identify-
  1660.      ing the Initiator Task Tag) is assumed to precede any other action at 
  1661.      the target, and is followed by ordering and delivery if no execution 
  1662.      state is found or delivery if an execution state is found.
  1663.  
  1664.  
  1665.  
  1666. Julian Satran                  Expires August  2002                         31
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.                                       iSCSI                      17-April-02
  1673.  
  1674.      If an initiator issues a command retry for a command with CmdSN R on a 
  1675.      connection when the session CmdSN register is Q, it MUST NOT advance 
  1676.      the CmdSN past R + 2**31 -1 unless a different non-immediate command 
  1677.      with CmdSN equal or greater than Q was issued on the same connection 
  1678.      if the connection is still operational, and the reception of the com-
  1679.      mand is acknowledged by the target (see Section 8.4 Command Retry and 
  1680.      Cleaning Old Command Instances).  The second non-immediate command 
  1681.      when sent, MUST be sent in-order after the retried command on the same 
  1682.      connection.
  1683.  
  1684.      A target MUST NOT issue a command response or DATA-In PDU with status 
  1685.      before acknowledging the command. However, the acknowledgement can be 
  1686.      included in the response or Data-in PDU itself.
  1687.  
  1688. 2.2.2.2  Response/Status Numbering and Acknowledging
  1689.  
  1690.      Responses in transit from the target to the initiator are numbered. 
  1691.      The StatSN (Status Sequence Number) is used for this purpose. StatSN 
  1692.      is a counter maintained per connection. ExpStatSN is used by the ini-
  1693.      tiator to acknowledge status. The status sequence number space is 
  1694.      32bit integers and the arithmetic operations are the regular 
  1695.      mod(2**32) arithmetic.
  1696.  
  1697.      Status numbering starts with the Login response to the first Login 
  1698.      request of the connection. The Login response includes an initial 
  1699.      value for status numbering (any initial value is valid).
  1700.  
  1701.      To enable command recovery, the target MAY maintain enough state 
  1702.      information to enable data and status recovery after a connection 
  1703.      failure. A target can discard all the state information maintained for 
  1704.      recovery after the status delivery is acknowledged through ExpStatSN.
  1705.  
  1706.      A large absolute difference between StatSN and ExpStatSN may indicate 
  1707.      a failed connection. Initiators undertake recovery actions if the 
  1708.      difference is greater than an implementation defined constant that 
  1709.      SHOULD NOT exceed 2**31-1. 
  1710.  
  1711.      Initiators and Targets MUST support the response-numbering scheme.
  1712.  
  1713. 2.2.2.3  Data Sequencing
  1714.  
  1715.      Data and R2T PDUs, transferred as part of some command execution, MUST 
  1716.      be sequenced. The DataSN field is used for data sequencing. For input 
  1717.      (read) data PDUs, DataSN starts with 0 for the first data PDU of an 
  1718.  
  1719. Julian Satran                  Expires August  2002                       32
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.                                    iSCSI                      17-April-02
  1726.  
  1727.      input command and advances by 1 for each subsequent data PDU. For out-
  1728.      put data PDUs, DataSN starts with 0 for the first data PDU of a 
  1729.      sequence (the initial unsolicited sequence or any data PDU sequence 
  1730.      issued to satisfy an R2T) and advances by 1 for each subsequent data 
  1731.      PDU. R2Ts are also sequenced per command. For example, the first R2T 
  1732.      has an R2TSN of 0 and advances by 1 for each subsequent R2T. For bidi-
  1733.      rectional commands, the target uses the DataSN/R2TSN to sequence 
  1734.      Data-In and R2T PDUs in one continuous sequence (undifferentiated). 
  1735.      Unlike command and status, data PDUs and R2Ts are not acknowledged by 
  1736.      a field in regular outgoing PDUs.  Data-In PDUs can be acknowledged on 
  1737.      demand by a special form of the SNACK PDU.  Data and R2T PDUs are 
  1738.      implicitly acknowledged by status. The DataSN/R2TSN field enables the 
  1739.      initiator to detect missing data or R2T PDUs. 
  1740.  
  1741.      For any given write command, a target must have issued less than 2**32 
  1742.      R2Ts. Any input or output data sequence MUST contain less than 2**32 
  1743.      numbered PDUs.
  1744.  
  1745.  
  1746. 2.2.3  iSCSI Login
  1747.  
  1748.      The purpose of the iSCSI login is to enable a TCP connection for iSCSI 
  1749.      use, authenticate the parties, negotiate the session's parameters and 
  1750.      mark the connection as belonging to an iSCSI session.
  1751.       
  1752.      A session is used to identify all the connections with a given initi-
  1753.      ator that belong to the same I_T nexus to a target. (See Section 2.4.2 
  1754.      SCSI Architecture Model for more details on how a session relates to 
  1755.      an I_T nexus).
  1756.  
  1757.      The targets listen on a well-known TCP port or other TCP port for 
  1758.      incoming connections. The initiator begins the login process by con-
  1759.      necting to one of these TCP ports. 
  1760.  
  1761.      As part of the login process, the initiator and target MAY wish to 
  1762.      authenticate each other and set a security association protocol for 
  1763.      the session. This can occur in many different ways and is subject to 
  1764.      negotiation. 
  1765.  
  1766.      In order to protect the TCP connection, an IPsec security association 
  1767.      MAY be established before the Login request. Using IPsec security for 
  1768.      iSCSI is specified in Chapter 7 and in [SEC-IPS]. 
  1769.  
  1770.  
  1771.  
  1772. Julian Satran               Expires August  2002                          33
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.                                     iSCSI                     17-April-02
  1779.  
  1780.      The iSCSI Login Phase is carried through Login requests and responses. 
  1781.      Once suitable authentication has occurred and operational parameters 
  1782.      have been set, the initiator may start to send SCSI commands. How the 
  1783.      target chooses to authorize an initiator is beyond the scope of this 
  1784.      document. A more detailed description of the Login Phase can be found 
  1785.      in Chapter 4.
  1786.  
  1787.  
  1788.      The login PDU includes the ISID part of the session ID (SSID). The 
  1789.      target portal group servicing the login is implied by the selection of 
  1790.      the connection end-point. For a new session, the TSIH is null. As part 
  1791.      of the response, the target generates a TSIH. 
  1792.  
  1793.      During session establishment, the target identifies the SCSI initia-
  1794.      tor port (the "I" in the "I_T nexus") through the value pair (Initia-
  1795.      torName, ISID) (InitiatorName is described later in this part). Any 
  1796.      persistent state (e.g., persistent reservations) on the target that 
  1797.      is associated with a SCSI initiator port is identified based on this 
  1798.      value pair. Any state associated with the SCSI target port (the "T" in 
  1799.      the "I_T nexus") is identified externally by the TargetName and portal 
  1800.      group tag (see Section 2.4.1 iSCSI Architecture Model) and internally 
  1801.      in an implementation dependent way. As ISID is used to identify a per-
  1802.      sistent state, it is subject to reuse restrictions (see Section 2.4.3 
  1803.      Consequences of the Model).
  1804.  
  1805.      Before the Full Feature Phase is established, only Login Request and 
  1806.      Login Response PDUs are allowed. Any other PDU, when received at ini-
  1807.      tiator or target, is a protocol error and MUST result in the connec-
  1808.      tion being terminated. Login requests and responses MUST be used 
  1809.      exclusively during Login.  On any connection the login phase MUST 
  1810.      immediately succeed TCP connection establishment and a single login 
  1811.      phase is allowed before tearing down a connection.
  1812.  
  1813. 2.2.4  iSCSI Full Feature Phase
  1814.  
  1815.      Once the initiator is authorized to do so, the iSCSI session is in the 
  1816.      iSCSI Full Feature Phase. A session is in Full Feature Phase after 
  1817.      successfully finishing the login phase on the first (leading) connec-
  1818.      tion of a session.  A connection is in Full Feature Phase if the ses-
  1819.      sion is in Full Feature Phase and the connection login has completed 
  1820.      successfully. An iSCSI connection is not in Full Feature Phase a) when 
  1821.      it does not have an established transport connection, or b) when it 
  1822.      has a valid transport connection, but a successful login was not per-
  1823.  
  1824.  
  1825. Julian Satran               Expires August  2002                          34
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.                                      iSCSI                       17-April-02
  1832.  
  1833.      formed or the connection is currently logged out. In a normal Full 
  1834.      Feature Phase, the initiator may send SCSI commands and data to the 
  1835.      various LUs on the target by wrapping them in iSCSI PDUs that go over 
  1836.      the established iSCSI session. 
  1837.  
  1838.      For an iSCSI request issued over a TCP connection, the corresponding 
  1839.      response and/or requested PDU(s) MUST be sent over the same connection 
  1840.      by default. We call this "connection allegiance". If the original con-
  1841.      nection fails before the command is completed, the connection alle-
  1842.      giance of the command may be explicitly reassigned to a different 
  1843.      transport connection as described in detail in Section 6.1 Retry and 
  1844.      Reassign in Recovery.
  1845.  
  1846.      For SCSI commands that require data and/or a parameter transfer, the 
  1847.      (optional) data and the status for a command MUST be sent over the 
  1848.      same TCP connection to which the SCSI command is currently allegiant, 
  1849.      illustrating the above rule.    
  1850.  
  1851.      Thus, if an initiator issues a READ command, the target MUST send the 
  1852.      requested data, if any, followed by the status to the initiator over 
  1853.      the same TCP connection that was used to deliver the SCSI command. If 
  1854.      an initiator issues a WRITE command, the initiator MUST send the data, 
  1855.      if any, for that command over the same TCP connection that was used to 
  1856.      deliver the SCSI command. The target MUST return Ready To Transfer 
  1857.      (R2T), if any, and the status over the same TCP connection that was 
  1858.      used to deliver the SCSI command. Retransmission requests (SNACK 
  1859.      PDUs) and the data and status that they generate MUST also use the 
  1860.      same connection.
  1861.  
  1862.      However, consecutive commands that are part of a SCSI linked command-
  1863.      chain task MAY use different connections. Connection allegiance is 
  1864.      strictly per-command and not per-task. During the iSCSI Full Feature 
  1865.      Phase, the initiator and target MAY interleave unrelated SCSI com-
  1866.      mands, their SCSI Data, and responses over the session. 
  1867.  
  1868.      Outgoing SCSI data (initiator to target user data or command parame-
  1869.      ters) is sent as either solicited data or unsolicited data. Solicited 
  1870.      data is sent in response to R2T PDUs. Unsolicited data can be sent as 
  1871.      part of an iSCSI command PDU ("immediate data") or in separate iSCSI 
  1872.      data PDUs. An initiator may send unsolicited data as immediate up to 
  1873.      the negotiated maximum PDU size or in a separate PDU sequence (up to 
  1874.      the FirstBurstSize). All subsequent data MUST be solicited. The maxi-
  1875.  
  1876.  
  1877. Julian Satran                 Expires August  2002                        35
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.                                    iSCSI                      17-April-02
  1884.  
  1885.      mum size of an individual data PDU or the immediate-part of the first 
  1886.      unsolicited burst MAY be negotiated at login. 
  1887.  
  1888.      Targets operate in either solicited (R2T) data mode or unsolicited 
  1889.      (non R2T) data mode. The maximum amount of unsolicited data that can 
  1890.      be sent with a command is negotiated at login as the. A target MAY 
  1891.      separately enable immediate data without enabling the more general 
  1892.      (separate data PDUs) form of unsolicited data. 
  1893.  
  1894.      Unsolicited data on write are meant to reduce the effect of latency on 
  1895.      throughput (no R2T is needed to start sending data).  In addition, 
  1896.      immediate data are meant to reduce the protocol overhead (both band-
  1897.      width and execution time).
  1898.  
  1899.      An iSCSI initiator MAY choose to send no unsolicited data, only imme-
  1900.      diate data or FirstBurstSize bytes of unsolicited data with a command. 
  1901.      If any non-immediate unsolicited data is sent, the total unsolicited 
  1902.      data MUST be either the negotiated amount or all the data if the total 
  1903.      amount is less than the negotiated amount for unsolicited data.
  1904.  
  1905.      An initiator MUST honor an R2T data request for a valid outstanding 
  1906.      command (i.e., carrying a valid Initiator Task Tag) and deliver all 
  1907.      the requested data provided the command is supposed to deliver outgo-
  1908.      ing data and the R2T specifies data within the command bounds. The 
  1909.      initiator actions on receiving an R2T request that specifies data all 
  1910.      or part outside the command bounds is unspecified.
  1911.       
  1912.      It is considered an error for an initiator to send unsolicited data 
  1913.      PDUs to a target that operates in R2T mode (only solicited data is 
  1914.      allowed). It is also an error for an initiator to send more data, 
  1915.      whether immediate or as separate PDUs, than the iSCSI limit for first 
  1916.      burst. 
  1917.  
  1918.      A target SHOULD NOT silently discard data and request retransmission 
  1919.      through R2T. Initiators SHOULD NOT keep track of the data transferred 
  1920.      to or from the target (scoreboarding); targets perform residual count 
  1921.      calculation. Incoming data for initiators is always implicitly solic-
  1922.      ited. SCSI data packets are matched to their corresponding SCSI com-
  1923.      mands by using Tags specified in the protocol.
  1924.  
  1925.      Initiator tags for pending commands are unique initiator-wide for a 
  1926.      session. Target tags are not strictly specified by the protocol. It is 
  1927.      assumed that these tags are used by the target to tag (alone or in 
  1928.  
  1929. Julian Satran               Expires August  2002                        36
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.                                       iSCSI                   17-April-02
  1936.  
  1937.      combination with the LUN) the solicited data. Target tags are gener-
  1938.      ated by the target and "echoed" by the initiator. The above mechanisms 
  1939.      are designed to accomplish efficient data delivery and a large degree 
  1940.      of control over the data flow. 
  1941.  
  1942.      iSCSI initiators and targets MUST also enforce some ordering rules. 
  1943.      Unsolicited data MUST be sent on every connection in the same order in 
  1944.      which commands were sent. A target that receives data out of order MAY 
  1945.      terminate the session.
  1946.  
  1947. 2.2.5  iSCSI Connection Termination
  1948.  
  1949.      An iSCSI connection may be terminated by use of a transport connection 
  1950.      shutdown, or a transport reset.  Transport reset is assumed to be an 
  1951.      exceptional event.
  1952.  
  1953.      Graceful TCP connection shutdowns are done by sending TCP FINs. A 
  1954.      graceful transport connection shutdown SHOULD be initiated by either 
  1955.      party only when the connection is not in iSCSI full-feature phase.  A 
  1956.      target MAY terminate a full-feature phase connection on internal 
  1957.      exception events, but it SHOULD announce the fact through an Asynchro-
  1958.      nous Message PDU.  Connection termination with outstanding commands 
  1959.      may require recovery actions.
  1960.  
  1961.      If a connection is terminated while in full-feature phase, connection 
  1962.      cleanup (section 5) is required as a prelude to recovery. By doing 
  1963.      connection cleanup before starting recovery, the initiator and target 
  1964.      can avoid receiving stale PDUs after recovery. In this case, the ini-
  1965.      tiator sends a Logout request on one of the operational connections of 
  1966.      a session that indicates which iSCSI connection should be logged out.
  1967.  
  1968. 2.2.6  iSCSI Names
  1969.  
  1970.      Both targets and initiators require names for the purpose of identifi-
  1971.      cation, and so that iSCSI storage resources can be managed regardless 
  1972.      of location (address).  An iSCSI node name is also the SCSI device 
  1973.      name of an iSCSI device.  The iSCSI name of a SCSI device is the prin-
  1974.      cipal object used in authentication of targets to initiators and ini-
  1975.      tiators to targets.  This name is also used to identify and manage 
  1976.      iSCSI storage resources.
  1977.          
  1978.      iSCSI names must be unique within the operation domain of the end 
  1979.      user. However, since the operation domain of an IP network is poten-
  1980.      tially worldwide, the iSCSI name formats are architected to be world 
  1981.  
  1982. Julian Satran                  Expires August  2002                       37
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.                                      iSCSI                      17-April-02
  1989.  
  1990.      wide unique.  To assist naming authorities in the construction of 
  1991.      world wide unique names, iSCSI provides two name formats for different 
  1992.      types of naming authorities.
  1993.  
  1994.      iSCSI names are associated with iSCSI nodes, not iSCSI network adapter 
  1995.      cards, to ensure the replacement of network adapter cards does not 
  1996.      require reconfiguration of all SCSI and iSCSI resource allocation 
  1997.      information.
  1998.  
  1999.      Some SCSI commands require that protocol-specific identifiers be com-
  2000.      municated within SCSI CDBs. See Section 2.4.2 SCSI Architecture Model 
  2001.      for the definition of the SCSI port name/identifier for iSCSI ports. 
  2002.  
  2003.      An initiator may discover the iSCSI Target Names to which it has 
  2004.      access, along with their addresses, using the SendTargets text 
  2005.      request, or other techniques discussed in [NDT].
  2006.  
  2007. 2.2.6.1  iSCSI Name Requirements 
  2008.  
  2009.      Each iSCSI node, whether an initiator or target, MUST have an iSCSI 
  2010.      name.
  2011.  
  2012.      Initiators and targets MUST support the receipt of iSCSI names of up 
  2013.      to the maximum length of 255 bytes.
  2014.  
  2015.      The initiator MUST present both its iSCSI Initiator Name and the iSCSI 
  2016.      Target Name to which it wishes to connect in the first login request 
  2017.      of a new session or connection. The only exception is if a discovery 
  2018.      session (see Section 2.3 iSCSI Session Types) is to be established; 
  2019.      the iSCSI Initiator Name is still required, but the iSCSI Target Name 
  2020.      may be ignored. 
  2021.       
  2022.      iSCSI names MUST adhere to the following requirements: 
  2023.       
  2024.           a)  iSCSI names MUST be globally unique.  No two initiators or tar-
  2025.           gets should have the same name.
  2026.           b)  iSCSI names MUST be permanent.  An iSCSI initiator or target 
  2027.           has the same name for its lifetime.
  2028.           c)  iSCSI names do not imply a location or address.  An iSCSI ini-
  2029.           tiator or target can move, or have multiple addresses.  A change of 
  2030.           address does not imply a change of name.
  2031.           d)  iSCSI names MUST NOT rely on a central name broker; the naming 
  2032.           authority must be distributed.  
  2033.  
  2034.  
  2035. Julian Satran                 Expires August  2002                        38
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.                                         iSCSI                       17-April-02
  2042.  
  2043.             e)  iSCSI names MUST support integration with existing unique nam-
  2044.             ing schemes. 
  2045.             f)  iSCSI names MUST rely on existing naming authorities.  iSCSI 
  2046.             does not have to create its own naming authority. 
  2047.  
  2048.      The encoding of an iSCSI name also has some requirements: 
  2049.       
  2050.             a)  iSCSI names MUST have a single encoding method when transmitted 
  2051.             over various protocols. 
  2052.             b)  iSCSI names MUST be relatively simple to compare.  The algo-
  2053.             rithm for comparing two iSCSI names for equivalence must not rely 
  2054.             on any external server.
  2055.             c)  iSCSI names MUST be composed of displayable characters only. 
  2056.             iSCSI names should be kept as simple as possible.  They MUST pro-
  2057.             vide for the use of international character sets, and MUST NOT 
  2058.             allow the use of different names that would be identical except for 
  2059.             their case.  Whitespace characters MUST NOT be allowed.
  2060.             d)  iSCSI names MUST be transport-friendly.  They must be trans-
  2061.             ported using both binary and ASCII-based protocols. 
  2062.  
  2063.      An iSCSI name really names a logical software entity, and is not tied 
  2064.      to a port or other hardware that can be changed.  For instance, an 
  2065.      initiator name should name the iSCSI initiator node, not a particular 
  2066.      NIC or HBA card.  When multiple NICs are used, they should generally 
  2067.      all present the same iSCSI initiator name to the targets, since they 
  2068.      are just paths to the same SCSI layer.  In most operating systems, the 
  2069.      named entity is the operating system image. 
  2070.         
  2071.      A target name should similarly not be tied to hardware interfaces 
  2072.      which can be changed.  A target name should identify the logical tar-
  2073.      get, and must be the same for the target regardless of the physical 
  2074.      portion being addressed.  This assists iSCSI initiators in determin-
  2075.      ing that two targets it has discovered are really two paths to the 
  2076.      same target. 
  2077.         
  2078.      The iSCSI name is designed to fulfill the functional requirements for 
  2079.      Uniform Resource Names (URN) [RFC1737].  For example, it is required 
  2080.      that the name have a global scope, independent of address or location, 
  2081.      and that it be persistent and globally unique.  Names must be extensi-
  2082.      ble, and scale with the use of naming authorities.  The encoding of 
  2083.      the name should be readable by a human, as well as be machine-read-
  2084.      able.  See [RFC1737] for further requirements.
  2085.  
  2086.  
  2087. Julian Satran                   Expires August  2002                         39
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.                                            iSCSI                   17-April-02
  2094.  
  2095. 2.2.6.2  iSCSI Name Encoding 
  2096.  
  2097.      An iSCSI name MUST be a UTF-8 encoding of a string of Unicode charac-
  2098.      ters,  with the following properties: 
  2099.       
  2100.           - it is in Normalization Form C (see "Unicode Normalization 
  2101.                Forms" [UNICODE])
  2102.           - it contains only the following types of characters:
  2103.  
  2104.                    - ASCII dash character ('-'=U+002d) 
  2105.                    - ASCII dot character ('.'=U+002e) 
  2106.                    - Any character allowed by the output of the iSCSI string-
  2107.                    prep template (described in [STPREP-iSCSI])
  2108.            
  2109.           - when encoded in UTF-8, it is no larger than 255 bytes 
  2110.       
  2111.      The stringprep process is described in [STPREP]; iSCSI's use of the 
  2112.      stringprep process is described in [STPREP-iSCSI].  Stringprep is a 
  2113.      method designed by the Internationalized Domain Name (IDN) working 
  2114.      group to translate human-typed strings into a format that can be com-
  2115.      pared as opaque strings.  Strings must not include punctuation, spac-
  2116.      ing, diacritical marks, or other characters that could get in the way 
  2117.      of readability. The stringprep process also converts strings into 
  2118.      equivalent strings of lower-case characters. 
  2119.  
  2120.      Note that in most cases, the Stringprep process does not need to be    
  2121.      implemented if the names are generated using only lower-case (any 
  2122.      character set) alpha-numeric characters.
  2123.  
  2124.      Once iSCSI names encoded in UTF-8 are "normalized" (there is one and 
  2125.      only one representation for each possible name), they may be safely 
  2126.      compared byte-for-byte. 
  2127.  
  2128. 2.2.6.3  iSCSI Name Structure 
  2129.  
  2130.      An iSCSI name consists of two parts - a type designator followed by a 
  2131.      unique name string. 
  2132.  
  2133.      The iSCSI name does not define any new naming authorities.  Instead, 
  2134.      it supports two existing ways of designating naming authorities: an 
  2135.      iSCSI-Qualified Name, using domain names to identify a naming author-
  2136.      ity, and the EUI format, where the IEEE Registration Authority assists 
  2137.      in the formation of world wide unique names (EUI-64 format). 
  2138.  
  2139.  
  2140. Julian Satran                       Expires August  2002                    40
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.                                          iSCSI                   17-April-02
  2147.  
  2148.      The type designator strings that may currently be used are: 
  2149.  
  2150.        iqn.       - iSCSI Qualified name 
  2151.        eui.       - Remainder of the string is an IEEE EUI-64 identi-
  2152.              fier, in ASCII-encoded hexadecimal. 
  2153.         
  2154.      As these two naming authority designators will suffice in nearly every 
  2155.      case for both software and hardware-based entities, the creation of 
  2156.      additional type designators is prohibited.  One of these two type 
  2157.      strings MUST be used when constructing an iSCSI name; any type string 
  2158.      not listed here is not allowed, as they cannot be guaranteed to be 
  2159.      unique. 
  2160.          
  2161. 2.2.6.3.1  Type "iqn." (iSCSI Qualified Name) 
  2162.  
  2163.      This iSCSI name type can be used by any organization which owns a 
  2164.      domain name.  This naming format is useful when an end user or service 
  2165.      provider wishes to assign iSCSI names for targets and/or initiators. 
  2166.  
  2167.      To generate names of this type, the person or organization generating 
  2168.      the name must own a DNS domain name.  This domain name does not have 
  2169.      to be active, and does not have to resolve to an address; it just 
  2170.      needs to be reserved to prevent others from generating iSCSI names 
  2171.      using the same domain name.
  2172.  
  2173.      Since a domain name can expire, be acquired by another entity, and 
  2174.      might be used to generate iSCSI names by both owners, the domain name 
  2175.      must be additionally qualified by a date during which the naming 
  2176.      authority owned the domain name.  A date code is provided as part of 
  2177.      the "iqn." format for this reason.
  2178.  
  2179.      The iSCSI qualified name string consists of: 
  2180.  
  2181.        -  The string "iqn.", used to distinguish these names from 
  2182.              "eui." formatted names. 
  2183.        -  A date code, in yyyy-mm format.  This date MUST be a date 
  2184.              during which the naming authority owned the domain name used 
  2185.              in this format, and SHOULD be the date on which the domain 
  2186.              name was acquired by this naming authority.  This date code 
  2187.              uses the Gregorian calendar.  All four digits in the year must 
  2188.              be present.  Both digits of the month must be present, with 
  2189.              January == "01" and December == "12".  The dash must be 
  2190.              included.
  2191.        -  Another ".". 
  2192.  
  2193.  
  2194. Julian Satran                  Expires August  2002                          41
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.                                          iSCSI                    17-April-02
  2201.  
  2202.           -  The reversed domain name of the naming authority (person or 
  2203.              organization) creating this iSCSI name.
  2204.           -  Another ".".
  2205.           -  Any string, within the character set and length boundaries, 
  2206.              that the owner of the domain name deems appropriate.  This may 
  2207.              contain product types, serial numbers, host identifiers, soft-
  2208.              ware keys, or anything else that makes sense to uniquely iden-
  2209.              tify the initiator or target.  Everything after the reversed 
  2210.              domain name, followed by another dot ".", can be assigned as 
  2211.              desired by the owner of the domain name.  It is the responsi-
  2212.              bility of the entity that is the naming authority to ensure 
  2213.              that the iSCSI names it assigns are world wide unique. For 
  2214.              example, "ACME Storage Arrays, Inc.", might own the domain 
  2215.              name "acme.com". 
  2216.       
  2217.      The following are examples of iSCSI qualified names that might be
  2218.      generated by "ACME Storage Arrays, Inc."
  2219.                      
  2220.                     Organization    Subgroup Naming Authority 
  2221.                         Naming      and/or string defined by 
  2222.           Type  Date     Auth       "acme.com" Naming Authority 
  2223.           +--++-----+ +------+ +--------------------------------+ 
  2224.           |  ||     | |      | |                                | 
  2225.             
  2226.           iqn.2001-04.com.acme.diskarrays-sn-a8675309 
  2227.           iqn.2001-04.com.acme.storage:tape.sys1.xyz 
  2228.           iqn.2001-04.com.acme.storage.tape:sys1.xyz 
  2229.       
  2230. 2.2.6.3.2  Type "eui." (IEEE EUI-64 format) 
  2231.  
  2232.          
  2233.      The IEEE Registration Authority provides a service for assigning glo-
  2234.      bally unique identifiers [EUI].  The EUI-64 format is in use as a glo-
  2235.      bal identifier in other network protocols such as Fibre Channel. See 
  2236.      http://standards.ieee.org/regauth/oui/index.shtml - for more informa-
  2237.      tion on registering for EUI identifiers.
  2238.  
  2239.      The format is "eui." followed by an EUI-64 identifier (16 ASCII-
  2240.      encoded hexidecimal digits).
  2241.  
  2242.      Example iSCSI name : 
  2243.  
  2244.            Type  EUI-64 identifier (ASCII-encoded hexidecimal)
  2245.            +--++--------------+ 
  2246.            |  ||              | 
  2247.            eui.02004567A425678D 
  2248.  
  2249.  
  2250. Julian Satran                     Expires August  2002                       42
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.                                    iSCSI                       17-April-02
  2257.  
  2258.      The IEEE EUI-64 iSCSI name format might be used when a manufacturer is 
  2259.      already registered with the IEEE Registration Authority and uses EUI-
  2260.      64 formatted world wide unique names for its products.
  2261.  
  2262.      More examples of name construction are discussed in [NDT].
  2263.  
  2264.  
  2265. 2.2.7  Persistent State
  2266.  
  2267.      iSCSI does not require any persistent state maintenance across ses-
  2268.      sions. However in some cases, SCSI requires persistent identification 
  2269.      of the SCSI initiator port name (for iSCSI, the InitiatorName plus the 
  2270.      ISID portion of the session identifier). (See Section 2.4.2 SCSI 
  2271.      Architecture Model and Section 2.4.3 Consequences of the Model.)
  2272.  
  2273.      iSCSI sessions do not persist through power cycles and boot opera-
  2274.      tions.
  2275.  
  2276.      All iSCSI session and connection parameters are re-initialized on 
  2277.      session and connection creation.
  2278.  
  2279.      Commands persist beyond connection termination if the session per-
  2280.      sists and command recovery within the session is supported. However, 
  2281.      when a connection is dropped, command execution, as perceived by iSCSI 
  2282.      (i.e., involving iSCSI protocol exchanges for the affected task), is 
  2283.      suspended until a new allegiance is established by the 'task reassign' 
  2284.      task management function. (See Section 9.5 Task Management Function 
  2285.      Request.)
  2286.  
  2287. 2.2.8  Message Synchronization and Steering
  2288.  
  2289. 2.2.8.1  Rationale
  2290.  
  2291.      iSCSI presents a mapping of the SCSI protocol onto TCP. This encapsu-
  2292.      lation is accomplished by sending iSCSI PDUs of varying lengths. 
  2293.      Unfortunately, TCP does not have a built-in mechanism for signaling 
  2294.      message boundaries at the TCP layer. iSCSI overcomes this obstacle by 
  2295.      placing the message length in the iSCSI message header. This serves to 
  2296.      delineate the end of the current message as well as the beginning of 
  2297.      the next message.
  2298.  
  2299.      In situations where IP packets are delivered in order from the net-
  2300.      work, iSCSI message framing is not an issue and messages are processed 
  2301.      one after the other. In the presence of IP packet reordering, (i.e., 
  2302.  
  2303. Julian Satran               Expires August  2002                          43
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.                                      iSCSI                    17-April-02
  2310.  
  2311.      frames being dropped) legacy TCP implementations store the "out of 
  2312.      order" TCP segments in temporary buffers until the missing TCP seg-
  2313.      ments arrive, upon which the data must be copied to the application 
  2314.      buffers. In iSCSI, it is desirable to steer the SCSI data within these 
  2315.      out of order TCP segments into the pre-allocated SCSI buffers rather 
  2316.      than store them in temporary buffers. This decreases the need for ded-
  2317.      icated reassembly buffers as well as the latency and bandwidth related 
  2318.      to extra copies.
  2319.  
  2320.      Relying solely on the "message length" information from the iSCSI mes-
  2321.      sage header may make it impossible to find iSCSI message boundaries in 
  2322.      subsequent TCP segments due to the loss of a TCP segment that contains 
  2323.      the iSCSI message length. The missing TCP segment(s) must be received 
  2324.      before any of the following segments can be steered to the correct 
  2325.      SCSI buffers (due to the inability to determine the iSCSI message 
  2326.      boundaries). Since these segments cannot be steered to the correct 
  2327.      location, they must be saved in temporary buffers that must then be 
  2328.      copied to the SCSI buffers. 
  2329.  
  2330.      Different schemes can be used to recover synchronization. One of these 
  2331.      schemes is detailed in Appendix A. - Sync and Steering with Fixed 
  2332.      Interval Markers -. To make these schemes work, iSCSI implementations 
  2333.      have to make sure that the appropriate protocol layers are provided 
  2334.      with enough information to implement a synchronization and/or data 
  2335.      steering mechanism. 
  2336.  
  2337. 2.2.8.2  Synchronization (sync) and Steering Functional Model
  2338.  
  2339.      We assume that iSCSI is implemented according to the following layer-
  2340.      ing scheme:
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346. Julian Satran                Expires August  2002                       44
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.                                   iSCSI                         17-April-02
  2353.  
  2354.           +------------------------+       
  2355.           |        SCSI            |
  2356.           +------------------------+
  2357.           |       iSCSI            |
  2358.           +------------------------+
  2359.           |  Sync and Steering     |
  2360.           |  +-------------------+ |
  2361.           |  |      TCP          | |
  2362.           |  +-------------------+ |
  2363.           +------------------------+
  2364.           | Lower Functional Layers|
  2365.           |        (LFL)           |
  2366.           +------------------------+ 
  2367.           |         IP             |
  2368.           +------------------------+ 
  2369.           |        Link            |
  2370.           +------------------------+ 
  2371.  
  2372.  
  2373.      In this model, LFL can be IPsec (a mechanism changing the IP stream 
  2374.      and invisible to TCP). We assume that Sync and Steering operates just 
  2375.      underneath iSCSI. An implementation may choose to place Sync and 
  2376.      Steering somewhere else in the stack if it can translate the informa-
  2377.      tion kept by iSCSI in terms valid for the chosen layer.
  2378.  
  2379.      According to our layering model, iSCSI considers the information it 
  2380.      delivers to the Sync and Steering layer (headers and payloads) as a 
  2381.      contiguous stream of bytes mapped to the positive integers from 0 to 
  2382.      infinity. In practice, though, iSCSI is not expected to handle infi-
  2383.      nitely long streams; stream addressing will wrap around at 2**32-1. 
  2384.  
  2385.      This model assumes that the iSCSI layer will deliver complete PDUs to 
  2386.      underlying layers in single (atomic) operations. The underlying layer 
  2387.      does not need to examine the stream content to discover the PDU bound-
  2388.      aries. If a specific implementation performs PDU delivery to the Sync 
  2389.      and Steering layer through multiple operations, it MUST bracket an 
  2390.      operation set used to deliver a single PDU in a manner that the Sync 
  2391.      and Steering Layer can understand. 
  2392.  
  2393.      The Sync and Steering Layer (which is OPTIONAL) MUST retain the PDU 
  2394.      end address within the stream for every delivered iSCSI PDU.
  2395.      To enable the Sync and Steering operation to perform Steering, addi-
  2396.      tional information, including identifying tags and buffer offsets, 
  2397.  
  2398. Julian Satran              Expires August  2002                           45
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.                                       iSCSI                   17-April-02
  2405.  
  2406.      MUST also be retained for every sent PDU. The Sync and Steering Layer 
  2407.      is required to add enough information to every sent data item (IP 
  2408.      packet, TCP packet or some other superstructure) to enable the 
  2409.      receiver to steer it to a memory location independent of any other 
  2410.      piece.
  2411.  
  2412.      If the transmission stream is built dynamically, this information is 
  2413.      used to insert Sync and Steering information in the transmission 
  2414.      stream (at first transmission or at re-transmission) either through a 
  2415.      globally accessible table or a call-back mechanism. If the transmis-
  2416.      sion stream is built statically, the Sync and Steering information is 
  2417.      inserted in the transmission stream when data are first presented to 
  2418.      sync and steering. 
  2419.                   
  2420.      The retained information can be released whenever the transmitted 
  2421.      data is acknowledged by the receiver. (in the case of dynamically 
  2422.      built streams, by deletion from the global table or by an additional 
  2423.      callback).
  2424.  
  2425.      On the outgoing path, the Sync and Steering layer MUST map the outgo-
  2426.      ing stream addresses from iSCSI stream addresses to TCP stream 
  2427.      sequence numbers. 
  2428.  
  2429.      On the incoming path, the Sync and Steering layer extracts the Sync 
  2430.      and Steering information from the TCP stream. It then helps steer 
  2431.      (place) the data stream to its final location and/or recover iSCSI PDU 
  2432.      boundaries when some TCP packets are lost or received out of order. 
  2433.      The data stream seen by the receiving iSCSI layer is identical to the 
  2434.      data stream that left the sending iSCSI layer. The Sync and Steering 
  2435.      information is kept until the PDUs to which it refers are completely 
  2436.      processed by the iSCSI layer.
  2437.  
  2438.      On the incoming path, the Sync and Steering layer does not change the 
  2439.      way TCP notifies iSCSI about in-order data arrival. All data place-
  2440.      ments, in-order or out-of-order, performed by the Sync and Steering 
  2441.      layer are hidden from iSCSI while conventional, in order, data arrival 
  2442.      notifications generated by TCP are passed through to iSCSI
  2443.  
  2444. 2.2.8.3  Sync and Steering and Other Encapsulation Layers
  2445.  
  2446.      We recognize that in many environments the following is a more appro-
  2447.      priate layering model:
  2448.  
  2449.  
  2450.  
  2451. Julian Satran                  Expires August  2002                       46
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.                                    iSCSI                      17-April-02
  2458.  
  2459.           +----------------------------------+       
  2460.           |             SCSI                 |
  2461.           +----------------------------------+
  2462.           |            iSCSI                 |
  2463.           +----------------------------------+
  2464.           |   Upper Functional Layers (UFL)  |   
  2465.           +----------------------------------+   
  2466.           |     Sync and Steering            |
  2467.           |  +-----------------------------+ |
  2468.           |  |            TCP              | |
  2469.           |  +-----------------------------+ |
  2470.           +----------------------------------+ 
  2471.           |   Lower Functional Layers (LFL)  |
  2472.           +----------------------------------+ 
  2473.           |              IP                  |
  2474.           +----------------------------------+ 
  2475.           |             Link                 |
  2476.           +----------------------------------+ 
  2477.  
  2478.      In this model, UFL can be TLS (see[RFC2246]) or some other transport 
  2479.      conversion mechanism (a mechanism that changes the TCP stream, but 
  2480.      that is transparent to iSCSI).
  2481.  
  2482.      To be effective and act on reception of TCP packets out of order, Sync 
  2483.      and Steering has to be underneath UFL, and Sync and Steering data must 
  2484.      be left out of any UFL transformation (encryption, compression, pad-
  2485.      ding etc.). However, Sync and Steering MUST take into account the 
  2486.      additional data inserted in the stream by UFL. Sync and Steering MAY 
  2487.      also restrict the type of transformations UFL may perform on the 
  2488.      stream. 
  2489.  
  2490.      This makes implementation of Sync and Steering in the presence of oth-
  2491.      erwise opaque UFLs less attractive.
  2492.  
  2493. 2.2.8.4  Sync/Steering and iSCSI PDU Size 
  2494.  
  2495.      When a large iSCSI message is sent, the TCP segment(s) that contain 
  2496.      the iSCSI header may be lost. The remaining TCP segment(s) up to the 
  2497.      next iSCSI message must be buffered (in temporary buffers) since the 
  2498.      iSCSI header that indicates to which SCSI buffers the data is to be 
  2499.      steered was lost. To minimize the amount of buffering, it is recom-
  2500.      mended that the iSCSI PDU size be restricted to a small value (perhaps 
  2501.  
  2502.  
  2503.  
  2504. Julian Satran               Expires August  2002                          47
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.                                    iSCSI                         17-April-02
  2511.  
  2512.      a few TCP segments in length). During login, each end of the iSCSI 
  2513.      session specifies the maximum iSCSI PDU size it will accept.
  2514.  
  2515. 2.3  iSCSI Session Types
  2516.  
  2517.      iSCSI defines two types of sessions:
  2518.  
  2519.         a)  Normal operational session - an unrestricted session.
  2520.         b)  Discovery-session - a session opened only for target discovery; 
  2521.         the target MAY accept only text requests with the SendTargets key 
  2522.         and a logout request with reason "close the session".
  2523.  
  2524.      The session type is defined during login with key=value parameter in 
  2525.      the login command.
  2526.  
  2527. 2.4  SCSI to iSCSI Concepts Mapping Model
  2528.  
  2529.      The following diagram shows an example of how multiple iSCSI Nodes     
  2530.      (targets in this case) can coexist within the same Network Entity     
  2531.      and can share Network Portals (IP addresses and TCP ports). Other more 
  2532.      complex configurations are also possible. See  Section 2.4.1 iSCSI 
  2533.      Architecture Model for detailed descriptions of the components of 
  2534.      these diagrams.
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540. Julian Satran               Expires August  2002                          48
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.                                      iSCSI                    17-April-02
  2547.  
  2548.                    +-----------------------------------+
  2549.                    |  Network Entity (iSCSI Client)    |
  2550.                    |                                   |
  2551.                    |         +-------------+           |
  2552.                    |         | iSCSI Node  |           |
  2553.                    |         | (Initiator) |           |
  2554.                    |         +-------------+           |
  2555.                    |            |       |              |
  2556.                    | +--------------+ +--------------+ |
  2557.                    | |Network Portal| |Network Portal| |
  2558.                    | |   10.1.30.4  | |   10.1.40.6  | |
  2559.                    +-+--------------+-+--------------+-+
  2560.                             |               |
  2561.                             |  IP Networks  |
  2562.                             |               |
  2563.                    +-+--------------+-+--------------+-+
  2564.                    | |Network Portal| |Network Portal| |
  2565.                    | |  10.1.30.21  | |   10.1.40.3  | |
  2566.                    | | TCP Port 3260| | TCP Port 3260| |
  2567.                    | +--------------+ +--------------+ |
  2568.                    |        |               |          |
  2569.                    |        -----------------          |
  2570.                    |           |         |             |
  2571.                    |  +-------------+ +--------------+ |
  2572.                    |  | iSCSI Node  | | iSCSI Node   | |
  2573.                    |  |  (Target)   | |  (Target)    | |
  2574.                    |  +-------------+ +--------------+ |
  2575.                    |                                   |
  2576.                    |   Network Entity (iSCSI Server)   |
  2577.                    +-----------------------------------+
  2578.  
  2579. 2.4.1  iSCSI Architecture Model
  2580.  
  2581.      This section describes the part of the iSCSI architecture model that 
  2582.      has the most bearing on the relationship between iSCSI and the SCSI 
  2583.      Architecture Model.
  2584.  
  2585.         a)  Network Entity - represents a device or gateway that is acces-
  2586.         sible from the IP network. A Network Entity must have one or more 
  2587.         Network Portals (see item d), each of which can be used by some 
  2588.         iSCSI Nodes (see item (b)) contained in that Network Entity to gain 
  2589.         access to the IP network.
  2590.  
  2591.  
  2592.  
  2593. Julian Satran               Expires August  2002                        49
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.                                 iSCSI                      17-April-02
  2600.  
  2601.      b)  iSCSI Node - represents a single iSCSI initiator or iSCSI tar-
  2602.      get. There are one or more iSCSI Nodes within a Network Entity. The 
  2603.      iSCSI Node is accessible via one or more Network Portals (see item 
  2604.      d). An iSCSI Node is identified by its iSCSI Name (see Section 
  2605.      2.2.6 iSCSI Names and Chapter 11). The separation of the iSCSI Name 
  2606.      from the addresses used by and for the iSCSI node allows multiple 
  2607.      iSCSI nodes to use the same addresses, and the same iSCSI node to 
  2608.      use multiple addresses.
  2609.       
  2610.      c)  An alias string could also be associated with an iSCSI Node. 
  2611.      The alias allows an organization to associate a user friendly 
  2612.      string with the iSCSI Name. However, the alias string is not a sub-
  2613.      stitute for the iSCSI Name.
  2614.  
  2615.      d)  Network Portal - a component of a Network Entity that has a 
  2616.      TCP/IP network address and that may be used by an iSCSI Node within 
  2617.      that Network Entity for the connection(s) within one of its iSCSI 
  2618.      sessions. In an initiator, it is identified by its IP address. In a 
  2619.      target, it is identified by its IP address and its listening TCP 
  2620.      port.
  2621.  
  2622.      e)  Portal Groups - iSCSI supports multiple connections within the 
  2623.      same session; some implementations will have the ability to com-
  2624.      bine connections in a session across multiple Network Portals. A 
  2625.      Portal Group defines a set of Network Portals within an iSCSI Node 
  2626.      that collectively supports the capability of coordinating a ses-
  2627.      sion with connections that span these portals. Not all Network Por-
  2628.      tals within a Portal Group need to participate in every session 
  2629.      connected through that Portal Group. One or more Portal Groups may 
  2630.      provide access to an iSCSI Node. Each Network Portal, as utilized 
  2631.      by a given iSCSI Node, belongs to exactly one portal group within 
  2632.      that node. Portal Groups are identified within an iSCSI Node by a 
  2633.      portal group tag, a simple integer value between 1 and 65535 (see 
  2634.      Section 11.3 SendTargets). All Network Portals with the same por-
  2635.      tal group tag in the context of a given iSCSI Node are in the same 
  2636.      Portal Group. 
  2637.  
  2638.      Both iSCSI Initiators and iSCSI Targets have portal groups, though 
  2639.      only the iSCSI Target Portal Groups are used directly in the iSCSI 
  2640.      protocol (e.g., in SendTargets). See Section Section 8.1.1 Conser-
  2641.      vative Reuse of ISIDs  for references to the Initiator Portal 
  2642.      Groups.
  2643.  
  2644.  
  2645. Julian Satran            Expires August  2002                          50
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.                                       iSCSI                         17-April-02
  2652.  
  2653.         f)  Portals within a Portal Group are expected to have similar 
  2654.         hardware characteristics, as SCSI port specific mode pages                 
  2655.         may affect all portals within a portal group. (See Section 2.4.3.2 
  2656.         SCSI Mode Pages).
  2657.  
  2658.      The following diagram shows an example of one such configuration on a 
  2659.      target and how a session that shares Network Portals within a Portal 
  2660.      Group may be established.
  2661.  
  2662.        ----------------------------IP Network---------------------
  2663.               |               |                    |
  2664.          +----|---------------|-----+         +----|---------+
  2665.          | +---------+  +---------+ |         | +---------+  |
  2666.          | | Network |  | Network | |         | | Network |  |
  2667.          | | Portal  |  | Portal  | |         | | Portal  |  |
  2668.          | +--|------+  +---------+ |         | +---------+  |
  2669.          |    |               |     |         |    |         |
  2670.          |    |    Portal     |     |         |    | Portal  |
  2671.          |    |    Group 1    |     |         |    | Group 2 |
  2672.          +--------------------------+         +--------------+
  2673.               |               |                    | 
  2674.      +--------|---------------|--------------------|---------------------+
  2675.      |        |               |                    |                     |
  2676.      |   +----------------------------+  +-----------------------------+ |
  2677.      |   | iSCSI Session (Target side)|  | iSCSI Session (Target side) | |
  2678.      |   |                            |  |                             | |
  2679.      |   |       (TSIH = 56)          |  |       (TSIH = 48)           | |
  2680.      |   +----------------------------+  +-----------------------------+ |
  2681.      |                                                                   |
  2682.      |                      iSCSI Target Node                            |
  2683.      |              (within Network Entity, not shown)                   |
  2684.      +-------------------------------------------------------------------+
  2685.  
  2686. 2.4.2  SCSI Architecture Model
  2687.  
  2688.      This section describes the relationship between the SCSI Architecture 
  2689.      Model [SAM2] and constructs of the SCSI device, SCSI port and I_T 
  2690.      nexus, and the iSCSI constructs, described above.
  2691.  
  2692.      This relationship implies implementation requirements in order to 
  2693.      conform to the SAM2 model and other SCSI operational functions. These 
  2694.      requirements are detailed in Section 2.4.3 Consequences of the Model.
  2695.  
  2696.  
  2697.  
  2698. Julian Satran                 Expires August  2002                            51
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.                                 iSCSI                      17-April-02
  2705.  
  2706.      a) SCSI Device - the SAM2 term for an entity that contains other 
  2707.        SCSI entities. For example, a SCSI Initiator Device contains 
  2708.        one or more SCSI Initiator Ports and zero or more application 
  2709.        clients. A SCSI Target Device contains one or more SCSI Target 
  2710.        Ports and one or more logical units. For iSCSI, the SCSI 
  2711.        Device is the component within an iSCSI Node that provides the 
  2712.        SCSI functionality. As such, there can be one SCSI Device, at 
  2713.        most, within a given iSCSI Node. Access to the SCSI Device can 
  2714.        only be achieved in an iSCSI normal operational session (see 
  2715.        Section 2.3 iSCSI Session Types). The SCSI Device Name is 
  2716.        defined to be the iSCSI Name of the node and its use is manda-
  2717.        tory in the iSCSI protocol.
  2718.  
  2719.      b) SCSI Port - the SAM2 term for an entity in a SCSI Device that 
  2720.        provides the SCSI functionality to interface with a service 
  2721.        delivery subsystem or transport. For iSCSI, the definition of 
  2722.        SCSI Initiator Port and SCSI Target Port are different.
  2723.  
  2724.       SCSI Initiator Port: This maps to the endpoint of an iSCSI nor-
  2725.        mal operational session (see Section 2.3 iSCSI Session Types). 
  2726.        An iSCSI normal operational session is negotiated through the 
  2727.        login process between an iSCSI initiator node and an iSCSI 
  2728.        target node. At successful completion of this process, a SCSI 
  2729.        Initiator Port is created within the SCSI Initiator Device. 
  2730.        The SCSI Initiator Port Name and SCSI Initiator Port Identi-
  2731.        fier are both defined to be the iSCSI Initiator Name together 
  2732.        with (a) a label that identifies it as an initiator port name/
  2733.        identifier and (b) the ISID portion of the session identifier.
  2734.  
  2735.       SCSI Target Port: This maps to an iSCSI target Portal Group. 
  2736.        The SCSI Target Port Name and the SCSI Target Port Identifier 
  2737.        are both defined to be the iSCSI Target Name together with (a) 
  2738.        a label that identifies it as a target port name/identifier 
  2739.        and (b) the portal group tag.
  2740.  
  2741.       The SCSI Port Name is mandatory in iSCSI. When used in SCSI 
  2742.       parameter data, the SCSI port name should be formatted as:
  2743.       - The iSCSI Name in UTF-8 format, followed by
  2744.       - a comma separator (1byte), followed by
  2745.       - the ASCII character 'i' (for SCSI Initiator Port) or the 
  2746.        ASCII character 't' (for SCSI Target Port), followed by 
  2747.       - a comma separator (1byte), followed by
  2748.       - zero to 3 null pad bytes so that the complete format is a 
  2749.        multiple of four bytes long, followed by 
  2750.       - the 6byte value of the ISID (for SCSI initiator port) or the 
  2751.        2byte value of the portal group tag (for SCSI target port) in 
  2752.        network byte order (BigEndian).
  2753.        SCSI port names have a maximum length of 264 bytes for initi-
  2754.        ator ports, 260 bytes for target ports, and must be a multiple 
  2755.        of four bytes long. The ASCII character 'i' or 't' is the 
  2756.  
  2757. Julian Satran            Expires August  2002                          52
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.                                     iSCSI                     17-April-02
  2764.  
  2765.          label that identifies this port as either a SCSI Initiator 
  2766.          Port or a SCSI Target Port. This ASCII character also provides 
  2767.          the interpretation and size of the remaining six bytes (initi-
  2768.          ator) or two bytes (target).
  2769.  
  2770.        c) I_T nexus - a relationship between a SCSI Initiator Port and 
  2771.          a SCSI Target Port, according to [SAM2]. For iSCSI, this rela-
  2772.          tionship is a session, defined as a relationship between an 
  2773.          iSCSI Initiator's end of the session (SCSI Initiator Port) and 
  2774.          the iSCSI Target's Portal Group. The I_T nexus can be identi-
  2775.          fied by the conjunction of the SCSI port names. That is, the 
  2776.          I_T nexus identifier is the tuple (iSCSI Initiator Name + 'i' 
  2777.          + ISID, iSCSI Target Name + 't' + Portal Group Tag).
  2778.  
  2779.        NOTE: The I_T nexus identifier is not equal to the session iden-
  2780.          tifier (SSID).
  2781.  
  2782.  
  2783. 2.4.3  Consequences of the Model
  2784.  
  2785.      This section describes implementation and behavioral requirements    
  2786.      that result from the mapping of SCSI constructs to the iSCSI con-
  2787.      structs defined above. Between a given SCSI initiator port and a given 
  2788.      SCSI target port, only one I_T nexus (session) can exist. That is, no 
  2789.      more than one nexus relationship (parallel nexus) is allowed.  There-
  2790.      fore, between a given iSCSI initiator node and an iSCSI target node, 
  2791.      at any given time, only one session can exist with a given session 
  2792.      identifier (SSID).
  2793.  
  2794.      These assumptions lead to the following conclusions and requirements:
  2795.  
  2796.      ISID RULE: Between a given iSCSI Initiator and iSCSI Target Portal 
  2797.      Group (SCSI target port), there can be only one session with a given 
  2798.      value for ISID that identifies the SCSI initiator port. See Section 
  2799.      9.12.5 ISID.
  2800.  
  2801.      The structure of the ISID that contains a naming authority component 
  2802.      (see Section 9.12.5 ISID and [NDT]) provides a mechanism to facilitate 
  2803.      compliance with the ISID rule (See also Section 8.1.1 Conservative 
  2804.      Reuse of ISIDs).
  2805.  
  2806.      The iSCSI Initiator Node is expected to manage the assignment of ISIDs 
  2807.      prior to session initiation. The "ISID RULE" does not preclude the use 
  2808.      of the same ISID from the same iSCSI Initiator with different Target 
  2809.      Portal Groups on the same iSCSI target or on other iSCSI targets (see 
  2810.      Section 8.1.1 Conservative Reuse of ISIDs). Allowing this would be 
  2811.  
  2812. Julian Satran               Expires August  2002                          53
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.                                       iSCSI                     17-April-02
  2819.  
  2820.      analogous to a single SCSI Initiator Port having relationships 
  2821.      (nexus) with multiple SCSI target ports on the same SCSI target device 
  2822.      or SCSI target ports on other SCSI target devices. It is also possible 
  2823.      to have multiple sessions with different ISIDs to the same Target Por-
  2824.      tal Group. Each such session would be considered to be with a differ-
  2825.      ent initiator even when the sessions originate from the same initiator 
  2826.      device. The same ISID may be used by a different iSCSI initiator 
  2827.      because it is the iSCSI Name together with the ISID that identifies 
  2828.      the SCSI Initiator Port.
  2829.  
  2830.      NOTE: A consequence of the ISID RULE and the specification for the I_T 
  2831.      nexus identifier is that two nexus with the same identifier should 
  2832.      never exist at the same time.
  2833.  
  2834.      TSIH RULE: The iSCSI Target selects a non-zero value for the TSIH at 
  2835.      session creation (when an initiator presents a 0 value at Login).  
  2836.      After being selected the same TSIH value MUST be used whenever initi-
  2837.      ator or target refer to the given session and a TSIH is required.
  2838.  
  2839. 2.4.3.1  I_T Nexus State
  2840.  
  2841.      Certain nexus relationships contain an explicit state (e.g., initia-
  2842.      tor-specific mode pages) that may need to be preserved by the target 
  2843.      (or more correctly stated, the device server in a logical unit) 
  2844.      through changes or failures in the iSCSI layer (e.g., session fail-
  2845.      ures). In order for that state to be restored, the iSCSI initiator 
  2846.      should re-establish its session (re-login) to the same Target Portal 
  2847.      Group using the previous ISID. That is, it should perform session 
  2848.      recovery as described in Chapter 6. This is because the SCSI initiator 
  2849.      port identifier and the SCSI target port identifier (or relative tar-
  2850.      get port) form the datum that the SCSI logical unit device server uses 
  2851.      to identify the I_T nexus.
  2852.  
  2853. 2.4.3.2  SCSI Mode Pages
  2854.  
  2855.      If the SCSI logical unit device server does not maintain initiator-
  2856.      specific mode pages, and an initiator makes changes to port-specific 
  2857.      mode pages, the changes may affect all other initiators logged in to 
  2858.      that iSCSI Target through the same Target Portal Group.
  2859.  
  2860.      Changes via mode pages to the behavior of a portal group via one iSCSI 
  2861.      node should not affect the behavior of this portal group with respect 
  2862.      to other iSCSI Target Nodes, even if the underlying implementation of 
  2863.  
  2864.  
  2865. Julian Satran               Expires August  2002                          54
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.                                     iSCSI                        17-April-02
  2872.  
  2873.      a portal group serves multiple iSCSI Target Nodes in the same Network 
  2874.      Entity.
  2875.  
  2876. 2.5  Request/Response Summary
  2877.  
  2878.      This section lists and briefly describes all the iSCSI PDU types 
  2879.      (request and responses).
  2880.  
  2881.      All iSCSI PDUs are built as a set of one or more header segments 
  2882.      (basic and auxiliary) and zero or one data segments. The header group 
  2883.      and the data segment may be followed by a CRC (digest).
  2884.  
  2885.      The basic header segment has a fixed length of 48 bytes.
  2886.  
  2887. 2.5.1  Request/Response types carrying SCSI payload
  2888.  
  2889. 2.5.1.1  SCSI-Command 
  2890.  
  2891.      This request carries the SCSI CDB and all the other SCSI execute com-
  2892.      mand procedure call (see [SAM2]) IN arguments such as task attributes, 
  2893.      Command Reference Number, Expected Data Transfer Length for one or 
  2894.      both transfer directions (the later for bidirectional commands), and 
  2895.      Task Tag. The I_T_L nexus is derived by the initiator and target from 
  2896.      the LUN field in the request and the I_T nexus implicit in the session 
  2897.      identification.
  2898.  
  2899.      In addition, the SCSI-command PDU carries information required for 
  2900.      the proper operation of the iSCSI protocol - the command sequence num-
  2901.      ber (CmdSN) and the expected status number on the connection it is 
  2902.      issued (ExpStatSN).
  2903.  
  2904.      Part or all of the SCSI output (write) data associated with the SCSI 
  2905.      command may be sent as part of the SCSI-Command PDU as a data segment.
  2906.  
  2907. 2.5.1.2  SCSI-Response
  2908.  
  2909.      The SCSI-Response carries all the SCSI execute command procedure call 
  2910.      (see [SAM2]) OUT arguments and the SCSI execute command procedure call 
  2911.      return value.
  2912.      It contains the residual counts from the operation if any, and an 
  2913.      indication of whether the counts represent an overflow or an under-
  2914.      flow, and the SCSI status if the status is valid or a response code (a 
  2915.      non-zero return value for the execute-command procedure call) if the 
  2916.      status is not valid.
  2917.  
  2918.  
  2919. Julian Satran                Expires August  2002                         55
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.                                       iSCSI                    17-April-02
  2926.  
  2927.  
  2928.      For a valid status that indicates that the command is executed but 
  2929.      resulted in a exception (e.g., a SCSI CHECK CONDITION), the PDU data 
  2930.      segment contains the associated sense data.
  2931.  
  2932.      Some data segment content may also be associated  (in the data seg-
  2933.      ment) with a non-zero response code.
  2934.  
  2935.      In addition, the SCSI-Response PDU carries information required for 
  2936.      the proper operation of the iSCSI protocol - the number of Data-In PDU 
  2937.      that a target has sent (to enable the initiator to check that all 
  2938.      arrived) - ExpDataSN, the Status Sequence Number on this connection - 
  2939.      StatSN and the next Expected Command Sequence Number at target - ExpC-
  2940.      mdSN, the Maximum CmdSN acceptable at target from this initiator.
  2941.  
  2942. 2.5.1.3  Task Management Function Request
  2943.  
  2944.      The task management function request provides an initiator with a way 
  2945.      to explicitly control the execution of one or more SCSI Tasks or iSCSI 
  2946.      functions. The PDU carries a function identifier (which task manage-
  2947.      ment function to perform) and enough information to unequivocally 
  2948.      identify the task or task-set on which to perform the action even if 
  2949.      the task(s) to act upon has not yet arrived or has been discarded due 
  2950.      to an error.
  2951.  
  2952.      The referenced tag identifies an individual task if the function 
  2953.      refers to an individual task.
  2954.  
  2955.      The I_T_L nexus identifies task sets and is carried by the LUN (and 
  2956.      implied by the session identification).
  2957.  
  2958.      For task sets, the CmdSN of the task management function request helps  
  2959.      identify the tasks upon which to act, namely all tasks associated with 
  2960.      a LUN and having a CmdSN preceding the task management function 
  2961.      request CmdSN.
  2962.  
  2963.      The task management function request execution is completely per-
  2964.      formed at the target, (i.e., any coordination between responses to the 
  2965.      tasks affected and the task management function request response is 
  2966.      done by the target).
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972. Julian Satran                Expires August  2002                         56
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.                                    iSCSI                      17-April-02
  2979.  
  2980. 2.5.1.4  Task Management Function Response
  2981.  
  2982.      The Task Management Function Response carries an indication of func-
  2983.      tion completion for a Task Management Function Request including how 
  2984.      it completed (response and qualifier) and additional information for 
  2985.      failure responses (Referenced Task Tag - if an abort task failed).
  2986.  
  2987.      After the task management response indicating task management func-
  2988.      tion completion, the initiator will not receive any additional 
  2989.      responses from the affected tasks.
  2990.  
  2991. 2.5.1.5  SCSI Data-out and SCSI Data-in
  2992.  
  2993.      The SCSI Data-out and SCSI Data-in are the main vehicles by which SCSI 
  2994.      data payload is carried between initiator and target. Data payload is 
  2995.      associated with a specific SCSI command through the Initiator Task 
  2996.      Tag. For the target convenience, outgoing solicited data also carries 
  2997.      a Target Transfer Tag (copied from R2T) and the LUN.
  2998.      Each PDU contains the payload length and the data offset relative to 
  2999.      the buffer address contained in the SCSI exec command procedure call. 
  3000.  
  3001.      In each direction, the data transfer is split into "sequences". An 
  3002.      end-of-sequence is indicated by the F bit.
  3003.  
  3004.      An outgoing sequence is either unsolicited (only the first sequence 
  3005.      can be unsolicited) or is a complete payload sent in response to an 
  3006.      R2T "prompt".
  3007.  
  3008.      Input sequences are built to enable the direction switching for bidi-
  3009.      rectional commands.
  3010.  
  3011.      For input the target may request positive acknowledgement of input 
  3012.      data. This is limited to sessions that support error recovery and is 
  3013.      implemented through the A bit in the SCSI Data-in PDU header.
  3014.  
  3015.      Data-in and Data-out PDUs also carry the DataSN to enable the initia-
  3016.      tor and target to detect missing PDUs (discarded due to an error).
  3017.  
  3018.      StatSN is also carried by the Data-In PDUs.
  3019.  
  3020.      To enable a SCSI command to be executed involving a minimum number of 
  3021.      messages, the last SCSI Data-in PDU passed for a command may also con-
  3022.      tain the status if the status indicated termination with no exceptions 
  3023.      (no sense or response involved).
  3024.  
  3025. Julian Satran               Expires August  2002                        57
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.                                     iSCSI                     17-April-02
  3032.  
  3033.  
  3034.  
  3035. 2.5.1.6  Ready To Transfer (R2T)
  3036.  
  3037.      R2T is the mechanism by which the SCSI target "prompts" the initiator 
  3038.      for output data. R2T passes the offset of the requested data relative 
  3039.      to the buffer address from the execute command procedure call and the 
  3040.      length of the solicited data to the initiator.
  3041.  
  3042.      To help the SCSI target to associate resulting Data-out with an R2T, 
  3043.      the R2T carries the Target Transfer Tag copied by the initiator in the 
  3044.      solicited SCSI Data-out PDUs. There are no protocol specific require-
  3045.      ments with regard to the value of these tags, but it is assumed that 
  3046.      together with the LUN, they will enable the target to associate data 
  3047.      with an R2T.
  3048.  
  3049.      R2T also carries information required for proper operation of the 
  3050.      iSCSI protocol, such as an R2TSN (to enable an initiator to detect a 
  3051.      missing R2T), StatSN, ExpCmdSN and MaxCmdSN.
  3052.  
  3053. 2.5.2  Requests/Responses carrying SCSI and iSCSI Payload
  3054.  
  3055. 2.5.2.1  Asynchronous Message
  3056.  
  3057.      Asynchronous Messages are used to carry SCSI asynchronous events 
  3058.      (AEN) and iSCSI asynchronous messages.
  3059.  
  3060.      When carrying an AEN, the event details are reported as sense data in 
  3061.      the data segment.
  3062.  
  3063. 2.5.3  Requests/Responses carrying iSCSI Only Payload
  3064.  
  3065. 2.5.3.1  Text Request and Text Response
  3066.  
  3067.      Text requests and responses are designed as a parameter negotiation 
  3068.      vehicle and as a vehicle for future extension.
  3069.  
  3070.      In the data segment key=value, Text Requests/Responses carry text 
  3071.      information with a simple syntax.
  3072.  
  3073.      Text Request/Responses may form extended sequences using the same 
  3074.      Initiator Task Tag. The initiator uses the F (Final) flag bit in the 
  3075.      text request header to indicate its readiness to terminate a sequence. 
  3076.      The target uses the F (Final) flag bit in the text response header to 
  3077.      indicate its consent to sequence termination.
  3078.  
  3079. Julian Satran               Expires August  2002                          58
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.                                   iSCSI                      17-April-02
  3086.  
  3087.  
  3088.      Text Request/Responses also use the Target Transfer Tag to indicate 
  3089.      continuation of an operation or a new beginning. A target that wishes 
  3090.      to continue an operation will set the Target Transfer Tag in a Text 
  3091.      Response to a value different from the default 0xffffffff. An initia-
  3092.      tor willing to continue will copy this value into the Target Transfer 
  3093.      Tag of the next Text Request. If the initiator wants to reset the tar-
  3094.      get (start fresh) it will set the Target Transfer Tag to 0xffffffff.
  3095.  
  3096.      Although a complete exchange is always started by the initiator, spe-
  3097.      cific parameter negotiations may be initiated by the initiator or tar-
  3098.      get. 
  3099.  
  3100. 2.5.3.2  Login Request and Login Response
  3101.  
  3102.      Login Requests and Responses are used exclusively during the login 
  3103.      phase of each connection to set up the session and connection parame-
  3104.      ters (the login phase consists of a sequence of login requests and 
  3105.      responses carrying the same Initiator Task Tag).
  3106.  
  3107.      A connection is identified by an arbitrarily selected connection-ID 
  3108.      (CID) that is unique within a session.
  3109.  
  3110.      Similar to the Text Requests and Responses, Login Requests/Responses 
  3111.      carry  key=value text information with a simple syntax in the data 
  3112.      segment.
  3113.  
  3114.      The Login phase proceeds through several stages (security negotia-
  3115.      tion, operational parameter negotiation) that are selected with two 
  3116.      binary coded fields in the header - the "current stage" (CSG) and the 
  3117.      "next stage" (NSG) with the appearance of the later being signaled by 
  3118.      the "transit" flag (T).
  3119.  
  3120.      The first login phase of a session plays a special role (it is called 
  3121.      the leading login) and some header fields are determined by the lead-
  3122.      ing login (e.g., the version number, the maximum number of connec-
  3123.      tions, the session identification etc.).
  3124.  
  3125.      The command counting initial value is also set by the leading login.
  3126.  
  3127.      Status counting for each connection is initiated by the connection 
  3128.      login.
  3129.  
  3130.  
  3131.  
  3132. Julian Satran              Expires August  2002                        59
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.                                     iSCSI                     17-April-02
  3139.  
  3140.      A login request may indicate an implied logout (cleanup) of the con-
  3141.      nection to be logged in (we call this a connection restart) through 
  3142.      the X flag in the first login request header.
  3143.  
  3144. 2.5.3.3  Logout Request and Response
  3145.  
  3146.      Logout Requests and Responses are used for the orderly closing of con-
  3147.      nections for recovery or maintenance. The logout request may be issued 
  3148.      following a target prompt (through an asynchronous message) or at an 
  3149.      initiators initiative. When issued on the connection to be logged out 
  3150.      no other request may follow it.
  3151.  
  3152.      The Logout response indicates that the connection or session cleanup 
  3153.      is completed and no other responses will arrive on the connection (if 
  3154.      received on the logging-out connection). The Logout Response indi-
  3155.      cates also how long the target will keep on holding resources for 
  3156.      recovery (e.g., command execution that continues on a new connection) 
  3157.      in Time2Retain and how long the initiator must wait before proceeding 
  3158.      with recovery in Time2Wait.
  3159.  
  3160. 2.5.3.4   SNACK Request
  3161.  
  3162.      With the SNACK Request, the initiator requests retransmission of num-
  3163.      bered-responses or data from the target. A single SNACK request covers 
  3164.      a contiguous set of missing items called a run of a given type of 
  3165.      items (the type is indicate in a type field in the PDU header). The 
  3166.      run is composed of an initial item (StatSN, DataSN, R2TSN) and the 
  3167.      number of missed Status, Data, or R2T PDUs. For long data-in 
  3168.      sequences, the target may request (at predefined minimum intervals) a 
  3169.      positive acknowledgement for the data sent. A SNACK request with a 
  3170.      type field that indicates ACK and the number of Data-In PDUs acknowl-
  3171.      edged conveys this positive acknowledgement. 
  3172.  
  3173. 2.5.3.5  Reject
  3174.  
  3175.      Reject enables the target to report an iSCSI error condition (proto-
  3176.      col, unsupported option etc.) that uses a Reason field in the PDU 
  3177.      header and includes the complete header of the bad PDU in the Reject 
  3178.      PDU data segment.
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184. Julian Satran               Expires August  2002                        60
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.                                    iSCSI                       17-April-02
  3191.  
  3192. 2.5.3.6  NOP-Out Request and NOP-In Response
  3193.  
  3194.      This request/response pair may be used by an initiator and target as a 
  3195.      "ping" mechanism to verify that a connection/session is still active 
  3196.      and all its components are operational. Such a ping may be triggered 
  3197.      by the initiator or target. The triggering party indicates that it 
  3198.      wants a reply by setting a value different from the default 0xffffffff 
  3199.      in the corresponding Initiator/Target Transfer Tag.   
  3200.  
  3201.      NOP-In/NOP-Out may also be used "unidirectional" to convey to the ini-
  3202.      tiator/target command, status or data counter values when there is no 
  3203.      other "carrier" and there is a need to update the initiator/target.
  3204.  
  3205.  
  3206.  
  3207.  
  3208.         
  3209.         
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215. Julian Satran               Expires August  2002                        61
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.                                   iSCSI            17-April-02
  3222.  
  3223. 3. SCSI Mode Parameters for iSCSI
  3224.  
  3225.      There are no iSCSI specific mode pages.
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231. Julian Satran              Expires August  2002             62
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.                                      iSCSI                    17-April-02
  3238.  
  3239. 4. Login and Full Feature Phase Negotiation
  3240.  
  3241. 4.1  Text Format
  3242.  
  3243.      The initiator and target send a set of key=value or key=list pairs 
  3244.      encoded in UTF-8 Unicode. All the text keys and text values specified 
  3245.      in this document are to be presented and interpreted in the case they 
  3246.      appear in this document. They are case sensitive. Text keys and values 
  3247.      MUST ONLY contain letters (a-z, A-Z), digits (0-9), space (0x20), 
  3248.      point (.)(0x2e), minus (-)(0x2d), plus (+)(0x2b), commercial at 
  3249.      (@)(0x40) and underscore (_)(0x5f). The key and value are separated 
  3250.      by a '=' (0x3d) delimiter. Every key=value pair (including the last or 
  3251.      only pair) MUST be followed by one null (0x00) delimiter. Text values 
  3252.      may also contain colon (:)(0x3a) and brackets ([ and ])(0x5b and 
  3253.      0x5d). 
  3254.  
  3255.      Character strings are represented as plain text. Binary items can be 
  3256.      encoded using their decimal representation (with or without leading 
  3257.      zeros) or hexadecimal representation (e.g., 8190 is 0x1ffe).  Upper 
  3258.      and lower case letters may be used interchangeably in hexadecimal 
  3259.      notation (i.e., 0x1aBc, 0x1AbC, 0X1aBc, and 0x1ABC are equivalent). 
  3260.      Binary items can also be encoded using the more compact Base64 encod-
  3261.      ing as specified by [RFC2045] preceded by the 0b.  A list is a set of 
  3262.      values separated by comma (0x2c). A numeric range is a a set of two 
  3263.      binary items separated by tilde (~)(0x7e).
  3264.  
  3265.      Key names MUST NOT exceed 63 bytes.  If not otherwise specified, the 
  3266.      maximum length of an individual value (not its encoded representa-
  3267.      tion) is 255 bytes not including the delimiter (comma or null).
  3268.  
  3269.      Any iSCSI target or initiator MUST support receiving at least 16384 
  3270.      bytes of key=value data in a negotiation sequence except when indicat-
  3271.      ing support for very long authentication items such as public key cer-
  3272.      tificates in which case they MUST support receiving at least 64 
  3273.      kilobytes of key=value data.
  3274.  
  3275. 4.2  Text Mode Negotiation
  3276.  
  3277.      During login, and thereafter, some session or connection parameters 
  3278.      are negotiated through an exchange of textual information.
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284. Julian Satran               Expires August  2002                          63
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.                                    iSCSI                      17-April-02
  3291.  
  3292.      The initiator starts the negotiation through a Text/Login request and 
  3293.      indicates when it is ready for completion (by setting to 1 and keeping 
  3294.      to 1 the F bit in a Text Request or the T bit in the Login Request).
  3295.  
  3296.      The general format of text negotiation is:
  3297.  
  3298.        Originator-> <key>=<valuex>
  3299.        Responder-> <key>=<valuey>|NotUnderstood|Irrelevant|Reject
  3300.  
  3301.      The originator can either be the initiator or the target and the 
  3302.      responder can either be the target or initiator, respectively. Target 
  3303.      requests are not limited to respond to key=value pairs as offered by 
  3304.      the initiator. The target may offer key=value pairs of its own. 
  3305.  
  3306.      All negotiations are stateless and explicit (i.e., the result MUST be 
  3307.      based only on newly exchanged values). There is no such thing as 
  3308.      implicit offers. If an explicit offer is not made then a reply cannot 
  3309.      be expected.
  3310.  
  3311.      The value offered can be an integer, a range defined by lower and 
  3312.      upper value - both integers separated by tilde, a single literal con-
  3313.      stant a Boolean value (Yes or No), or a list of comma separated, lit-
  3314.      eral constant values. A range MAY ONLY be offered if it is explicitly 
  3315.      allowed for a key. A selected value can be an integer, a single lit-
  3316.      eral constant or a Boolean value.
  3317.  
  3318.      In literal list negotiation, the originator sends a list of options 
  3319.      (literal constants which may include "None") for each key in its order 
  3320.      of preference.
  3321.  
  3322.      The responding party answers with the first value that it supports and 
  3323.      is allowed to use for the specific originator selected from the orig-
  3324.      inator list.
  3325.  
  3326.      The constant "None" MUST always be used to indicate a missing func-
  3327.      tion. However, None is a valid selection only if it is explicitly 
  3328.      offered. 
  3329.  
  3330.      If a responder does not understand any particular value in a list it 
  3331.      MUST ignore it. If a responder does not support, does not understand 
  3332.      or is not allowed to use all of the offered options with a specific 
  3333.      originator, it MAY use the constant "Reject".  The selection of a 
  3334.  
  3335.  
  3336.  
  3337. Julian Satran               Expires August  2002                          64
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.                                      iSCSI                     17-April-02
  3344.  
  3345.      value not admissible under the selection rules is considered a negoti-
  3346.      ation failure and is handled accordingly.
  3347.  
  3348.  
  3349.      For numerical, numerical range and single literal negotiations, the 
  3350.      responding party MUST respond with the required key. The value it 
  3351.      selects, based on the selection rule specific to the key, becomes the 
  3352.      negotiation result. For a numerical range the value selected must be 
  3353.      an integer within the offered range or "Reject" (if the range is unac-
  3354.      ceptable).  An offer of a value not admissible MAY be answered with 
  3355.      the constant "Reject". The selection of a value not admissible under 
  3356.      the selection rules is considered a negotiation failure and is handled 
  3357.      accordingly. 
  3358.  
  3359.      For Boolean negotiations (keys taking the values Yes or No), the 
  3360.      responding party MUST respond with the required key and the result of 
  3361.      the negotiation when the received value does not determine that result 
  3362.      by itself. The last value transmitted becomes the negotiation result. 
  3363.      The rules for selecting the value with which to respond are expressed 
  3364.      as Boolean functions of the value received and the value that the 
  3365.      responding party would select in the absence of knowledge of the 
  3366.      received value.
  3367.       
  3368.      Specifically, the two cases in which responses are OPTIONAL are:
  3369.  
  3370.           - The Boolean function is "AND" and the value "No" is received. 
  3371.            The outcome of the negotiation is "No".
  3372.           - The Boolean function is "OR" and the value "Yes" is received. 
  3373.            The outcome of the negotiation is "Yes".
  3374.  
  3375.      Responses are REQUIRED in all other cases, and the value chosen and 
  3376.      sent by the responder becomes the outcome of the negotiation.
  3377.  
  3378.      An offer of a value not admissible MAY be answered with the constant 
  3379.      "Reject". The selection of a value not admissible under the selection 
  3380.      rules is considered a negotiation failure and is handled accordingly.
  3381.  
  3382.      If a specific key is not relevant for the current negotiation, the 
  3383.      responder may answer with the constant "Irrelevant" for all types of 
  3384.      negotiation.  However the negotiation is not considered as failed if 
  3385.      the response is Irrelevant.
  3386.  
  3387.  
  3388.  
  3389.  
  3390. Julian Satran                Expires August  2002                         65
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.                                    iSCSI                      17-April-02
  3397.  
  3398.      Any other key not understood by the responder may be ignored by the 
  3399.      responder without affecting the basic function. However, the Text 
  3400.      Response for a key not understood MUST be key=NotUnderstood.
  3401.  
  3402.      The constants "None", "Reject", "Irrelevant", and "NotUnderstood" are 
  3403.      reserved and must only be used as described here. 
  3404.  
  3405.      Some basic key=value pairs are described in Chapter 11. All keys in 
  3406.      Chapter 11, except for the X- extension format, MUST be supported by 
  3407.      iSCSI initiators and targets and MUST NOT be answered with NotUnder-
  3408.      stood. 
  3409.  
  3410.      Manufacturers may introduce new keys by prefixing them with X- fol-
  3411.      lowed by their (reversed) domain name. For example the company owning 
  3412.      the domain acme.com can issue: 
  3413.  
  3414.        X-com.acme.bar.foo.do_something=3
  3415.  
  3416. 4.3  Login Phase
  3417.  
  3418.      The login phase establishes an iSCSI session between an initiator and 
  3419.      a target. It sets the iSCSI protocol parameters, security parameters, 
  3420.      and authenticates the initiator and target to each other.
  3421.  
  3422.      The login phase is implemented via login request and responses only. 
  3423.      The whole login phase is considered as a single task and has a single 
  3424.      Initiator Task Tag (similar to the linked SCSI commands).
  3425.  
  3426.      The default MaxRecvPDULength is used during Login.
  3427.  
  3428.      The login phase sequence of commands and responses proceeds as fol-
  3429.      lows:
  3430.  
  3431.        - Login initial request 
  3432.        - Login partial response (optional) 
  3433.        - More Login requests and responses (optional)
  3434.        - Login Final-Response (mandatory)
  3435.  
  3436.      The initial login request of any connection MUST include the Initia-
  3437.      torName key=value pair. The initial login request of the first connec-
  3438.      tion of a session MAY also include the SessionType key=value pair. For 
  3439.      any connection within a session whose type is not "Discovery", the 
  3440.      first login request MUST also include the key=value pair TargetName.
  3441.  
  3442.  
  3443. Julian Satran               Expires August  2002                        66
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.                                       iSCSI                   17-April-02
  3450.  
  3451.      The Login Final-response accepts or rejects the Login Command.
  3452.  
  3453.      The Login Phase MAY include a SecurityNegotiation stage and a LoginOp-
  3454.      erationalNegotiation stage and MUST include at least one of them, but 
  3455.      the included stage MAY be empty except for the mandatory names. 
  3456.  
  3457.      The login requests and responses contain a field that indicates the 
  3458.      negotiation stage (SecurityNegotiation or LoginOperationalNegotia-
  3459.      tion). If both stages are used, the SecurityNegotiation MUST precede 
  3460.      the LoginOperationalNegotiation.
  3461.  
  3462.      Some operational parameters can be negotiated outside login through 
  3463.      text request/response.
  3464.       
  3465.      Security MUST be completely negotiated within the Login Phase. How to 
  3466.      use underlying IPsec security is specified in Chapter 7 and in [SEC-
  3467.      IPS].
  3468.  
  3469.      In some environments, a target or an initiator is not interested in 
  3470.      authenticating its counterpart. It is possible to bypass authentica-
  3471.      tion through the Login request and response.
  3472.  
  3473.      The initiator and target MAY want to negotiate authentication parame-
  3474.      ters. Once this negotiation is completed, the channel is considered 
  3475.      secure.
  3476.  
  3477.      Most of the negotiation keys are only allowed in a specific stage. The 
  3478.      SecurityNegotiation keys appear in Chapter 10 and the LoginOperation-
  3479.      alNegotiation keys appear in Chapter 11.  Only a limited set of keys 
  3480.      (marked as Declarative in Chapter 11) may be used in any of the two 
  3481.      stages.
  3482.  
  3483.      Neither the initiator nor the target should attempt to negotiate a 
  3484.      parameter more than once during any login stage. Attempting to do so 
  3485.      will result in the termination of the login and connection.
  3486.  
  3487.      Any given Login request or response belongs to a specific stage; this 
  3488.      determines the negotiation keys allowed with the command or response.
  3489.  
  3490.      Stage transition is performed through a command exchange (request/
  3491.      response) that carries the T bit and the same current stage code. Dur-
  3492.      ing this exchange, the next stage is selected by the target and MUST 
  3493.      NOT exceed the value stated by the initiator. The initiator can 
  3494.  
  3495. Julian Satran                  Expires August  2002                      67
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.                                     iSCSI                     17-April-02
  3502.  
  3503.      request a transition whenever it is ready, but a target can respond 
  3504.      with a transition only after one is offered by the initiator. 
  3505.  
  3506.      In a negotiation sequence, the T bit settings in one pair of login 
  3507.      request-responses have no bearing on the T bit settings of the next 
  3508.      pair. An initiator that has a T bit set to 1 in one pair and is 
  3509.      answered with a T bit setting of 0 may issue the next request with T 
  3510.      bit set to 0.
  3511.  
  3512.      When a transition is requested by the initiator and acknowledged by 
  3513.      the target both initiator and target switch to the selected stage.
  3514.  
  3515.      Targets MUST NOT submit parameters that require an additional initia-
  3516.      tor login request in a login response with the T bit set to 1.
  3517.  
  3518.      Stage transitions during login (including entering and exit) are pos-
  3519.      sible only as outlined in the following table:
  3520.  
  3521.      +-----------------------------------------------------------+
  3522.      |From     To ->   | Security    | Operational | FullFeature |  
  3523.      |  |              |             |             |             | 
  3524.      |  V              |             |             |             |
  3525.      +-----------------------------------------------------------+
  3526.      | (start)         |  yes        |  yes        |  no         |   
  3527.      +-----------------------------------------------------------+
  3528.      | Security        |  no         |  yes        |  yes        |
  3529.      +-----------------------------------------------------------+
  3530.      | Operational     |  no         |  no         |  yes        |
  3531.      +-----------------------------------------------------------+
  3532.  
  3533.      The Login Final-Response that accepts a Login Command can come only as 
  3534.      a response to a Login command with the T bit set to 1, and both the 
  3535.      command and response MUST have FullFeaturePhase in the NSG field.
  3536.  
  3537.      Neither the initiator nor the target should attempt to negotiate a 
  3538.      parameter more than once during login If detected by the target this 
  3539.      MUST result in a Login reject (initiator error). The initiator MUST 
  3540.      drop the connection.
  3541.  
  3542. 4.3.1  Login Phase Start
  3543.  
  3544.      The login phase starts with a login request from the initiator to the 
  3545.      target. The initial login request includes:
  3546.  
  3547.  
  3548. Julian Satran                Expires August  2002                         68
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.                                   iSCSI                        17-April-02
  3555.  
  3556.  
  3557.        -Protocol version supported by the initiator.
  3558.        -iSCSI Initiator Name and iSCSI Target Name
  3559.        -ISID, TSIH and connection Ids.
  3560.        -The negotiation stage that the initiator is ready to enter.
  3561.  
  3562.      A login may create a new session or it may add a connection to an 
  3563.      existing session. Between a given iSCSI Initiator (defined by an Ini-
  3564.      tiatorName) and a given iSCSI target defined by an iSCSI TargetName 
  3565.      and a Target Portal Group Tag login results are defined by the follow-
  3566.      ing table:
  3567.  
  3568.  
  3569.      +-------------------------------------------------------------------+
  3570.      |ISID       | TSIH        | CID    |     Target action              |
  3571.      +-------------------------------------------------------------------+
  3572.      |new        | non-zero    | any    |     fail the login             |
  3573.      |           |             |        |     ("session does not exist") |
  3574.      +-------------------------------------------------------------------+
  3575.      |new        | zero        | any    |     instantiate a new session  |
  3576.      +-------------------------------------------------------------------+
  3577.      |existing   | zero        | any    |     do session reinstatement   |
  3578.      +-------------------------------------------------------------------+
  3579.      |existing   | valid       | new    |     add a new connection to    |
  3580.      |           | (existing)  |        |     the session                |
  3581.      +-------------------------------------------------------------------+
  3582.      |existing   | valid       |existing|     do connection reinstatement|
  3583.      |           | (existing)  |        |                                |
  3584.      +-------------------------------------------------------------------+
  3585.      |existing   | invalid     | any    |         fail the login         |
  3586.      |           |(inexistent) |        |     ("session does not exist") |
  3587.      +-------------------------------------------------------------------+
  3588.  
  3589.  
  3590.      Optionally, the login request may include:
  3591.  
  3592.        -Security parameters OR
  3593.        -iSCSI operational parameters AND/OR
  3594.        -The next negotiation stage that the initiator is ready to 
  3595.          enter.
  3596.  
  3597.      The target can answer the login in the following ways:
  3598.  
  3599.  
  3600.  
  3601. Julian Satran              Expires August  2002                         69
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.                                    iSCSI                         17-April-02
  3608.  
  3609.        -Login Response with Login Reject. This is an immediate rejec-
  3610.          tion from the target that causes the connection to terminate 
  3611.          and the session to terminate if this is the first (or only) 
  3612.          connection of a new session. The T bit and the CSG and NSG 
  3613.          fields are reserved.
  3614.        -Login Response with Login Accept as a final response (T bit set 
  3615.          to 1 and the NSG in both command and response are set to Full-
  3616.          FeaturePhase). The response includes the protocol version sup-
  3617.          ported by the target and the session ID, and may include iSCSI 
  3618.          operational or security parameters (that depend on the current 
  3619.          stage).
  3620.        -Login Response with Login Accept as a partial response (NSG not 
  3621.          set to FullFeaturePhase in both request and response) that 
  3622.          indicates the start of a negotiation sequence. The response 
  3623.          includes the protocol version supported by the target and 
  3624.          either security or iSCSI parameters (when no security mecha-
  3625.          nism is chosen) supported by the target.
  3626.  
  3627.      If the initiator decides to forego the SecurityNegotiation stage, it 
  3628.      issues the Login with the CSG set to LoginOperationalNegotiation and 
  3629.      the target may reply with a Login Response that indicates that it is 
  3630.      unwilling to accept the connection without SecurityNegotiation and 
  3631.      will terminate the connection.
  3632.  
  3633.      If the initiator is willing to negotiate security, but is unwilling to 
  3634.      make the initial parameter offer and may accept a connection without 
  3635.      security, it issues the Login with the T bit set to 1, the CSG set to 
  3636.      SecurityNegotiation, and NSG set to LoginOperationalNegotiation. If 
  3637.      the target is also ready to forego security, the Login response is 
  3638.      empty and has T bit set to 1, the CSG set to SecurityNegotiation, and 
  3639.      NSG set to LoginOperationalNegotiation.
  3640.  
  3641.      An initiator that can operate without security and with all the oper-
  3642.      ational parameters taking the default values issues the Login with the 
  3643.      T bit set to 1, the CSG set to LoginOperationalNegotiation, and NSG 
  3644.      set to FullFeaturePhase. If the target is also ready to forego secu-
  3645.      rity and can finish its LoginOperationalNegotiation, the Login 
  3646.      response has T bit set to 1, the CSG set to LoginOperationalNegotia-
  3647.      tion, and NSG set to FullFeaturePhase in the next stage.
  3648.  
  3649.      The first Login Response PDU during the Login phase from the iSCSI 
  3650.      target SHOULD return the TargetPortalGroupTag key that contains the 
  3651.      tag value of the iSCSI portal group servicing the Login Request PDU.  
  3652.      If the iSCSI target implementation supports altering the portal group 
  3653.      configuration (including adding, deleting, and swapping of portals in 
  3654.  
  3655.  
  3656. Julian Satran               Expires August  2002                          70
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.                                      iSCSI                     17-April-02
  3663.  
  3664.      a portal group), it MUST return the TargetPortalGroupTag key carrying 
  3665.      the tag value of the servicing portal group. If the reconfiguration of 
  3666.      iSCSI portal groups is a concern in a given environment, the iSCSI 
  3667.      initiator MUST use this key to ascertain that it had indeed initiated 
  3668.      the Login phase with the intended target portal group.
  3669.  
  3670. 4.3.2  iSCSI Security Negotiation
  3671.  
  3672.      The security exchange sets the security mechanism and authenticates
  3673.      the initiator user and the target to each other. The exchange proceeds 
  3674.      according to the authentication method chosen in the negotiation 
  3675.      phase and is conducted using the login requests and responses 
  3676.      key=value parameters.
  3677.  
  3678.      An initiator directed negotiation proceeds as follows:
  3679.  
  3680.        -The initiator sends a login request with an ordered list of the 
  3681.          options it supports (authentication algorithm). The options 
  3682.          are listed in the initiator's order of preference. The initi-
  3683.          ator MAY also send proprietary options. 
  3684.        -The target MUST reply with the first option in the list it sup-
  3685.          ports and is allowed to use for the specific initiator unless 
  3686.          it does not support any in which case it MUST answer with 
  3687.          "Reject" (see also Section 4.2 Text Mode Negotiation). The 
  3688.          parameters are encoded in UTF8 as key=value. For security 
  3689.          parameters, see Chapter 10.
  3690.  
  3691.        -The initiator must be aware of the imminent completion of the 
  3692.          SecurityNegotiation stage and MUST set the T bit to 1 and the 
  3693.          NSG to what it would like the next stage to be. The target 
  3694.          will answer with a Login response with the T bit set to 1 and 
  3695.          the NSG to what it would like the next stage to be. The next 
  3696.          stage selected will be the one the target selected. If the 
  3697.          next stage is FullFeaturePhase, the target MUST respond with a 
  3698.          Login Response with the Session ID and the protocol version. 
  3699.  
  3700.  
  3701.      If the security negotiation fails at the target, then the target MUST 
  3702.      send the appropriate Login Response PDU. If the security negotiation 
  3703.      fails at the initiator, the initiator SHOULD close the connection. 
  3704.  
  3705.      It should be noted that the negotiation might also be directed by the 
  3706.      target if the initiator does support security, but is not ready to 
  3707.      direct the negotiation (offer options). 
  3708.  
  3709.  
  3710.  
  3711. Julian Satran                 Expires August  2002                        71
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.                                    iSCSI                      17-April-02
  3718.  
  3719. 4.3.3  Operational Parameter Negotiation During the Login Phase
  3720.  
  3721.      Operational parameter negotiation during the login MAY be done:
  3722.  
  3723.        - Starting with the first Login request if the initiator does 
  3724.          not offer any security/ integrity option.
  3725.        - Starting immediately after the security negotiation if the 
  3726.          initiator and target perform such a negotiation.
  3727.  
  3728.      Operational parameter negotiation MAY involve several Login request-
  3729.      response exchanges started and terminated by the initiator. The ini-
  3730.      tiator MUST indicate its intent to terminate the negotiation by set-
  3731.      ting the T bit to 1; the target sets the T bit to 1 on the last 
  3732.      response.
  3733.  
  3734.      If the target responds to a Login request with the T bit set to 1 with 
  3735.      a Login response with the T bit set to 0, the initiator should keep 
  3736.      sending the Login request (even empty) with the T bit set to 1, while 
  3737.      it still wants to switch stage, until it receives the Login Response 
  3738.      with the T bit set to 1.
  3739.  
  3740.      Whenever parameter action or acceptance are dependent on other param-
  3741.      eters, the dependent parameters MUST be sent after the parameters on 
  3742.      which they depend. If they are sent within the same command, a 
  3743.      response for a parameter might imply responses for others.
  3744.  
  3745.      Some session specific parameters can be specified only during the 
  3746.      login phase begun by a login command that contains a null TSIH - the 
  3747.      leading login phase (e.g., the maximum number of connections that can 
  3748.      be used for this session).
  3749.  
  3750.      A session is operational once it has at least one connection in Full-
  3751.      FeaturePhase. New or replacement connections can be added to a session 
  3752.      only after the session is operational. 
  3753.  
  3754.      For operational parameters, see Chapter 11.
  3755.  
  3756. 4.3.4  Connection reinstatement
  3757.  
  3758.      Connection reinstatement is the process of initiator logging in with a 
  3759.      ISID-TSIH-CID combination that is possibly active from the target's 
  3760.      perspective - thus implicitly logging out the connection state 
  3761.      machine corresponding to the CID and reinstating a new full-feature 
  3762.      phase iSCSI connection in its place (with the same CID).  Thus, the 
  3763.  
  3764.  
  3765. Julian Satran               Expires August  2002                         72
  3766.  
  3767.  
  3768.  
  3769.  
  3770.  
  3771.                                    iSCSI                      17-April-02
  3772.  
  3773.      TSIH in the Login PDU MUST be non-zero and CID does not change during 
  3774.      a connection reinstatement.  The Login command  performs the logout 
  3775.      function of the old connection if an explicit logout was not performed 
  3776.      earlier. In sessions with a single connection, this may imply the 
  3777.      opening of a second connection with the sole purpose of cleaning up 
  3778.      the first. Targets should support opening a second connection even 
  3779.      when they do not support multiple connections in full feature phase.  
  3780.  
  3781.      If the operational ErrorRecoveryLevel is 2, connection reinstatement 
  3782.      enables future task reassignment.  If the operational ErrorRecovery-
  3783.      Level is less than 2, connection reinstatement is the replacement of 
  3784.      the old CID without enabling task reassignment.  In this case, all the 
  3785.      tasks that were active on the old CID are internally terminated.
  3786.  
  3787.      The initiator connection state MUST be CLEANUP_WAIT (section 5.1) for 
  3788.      attempting a connection reinstatement.
  3789.  
  3790.      In practical terms, beside the implicit logout connection reinstate-
  3791.      ment is equivalent to a new connection login.
  3792.  
  3793. 4.3.5  Session reinstatement, closure and timeout
  3794.  
  3795.      Session reinstatement is the process of initiator logging in with an 
  3796.      ISID that is possibly active from the target's perspective - thus 
  3797.      implicitly logging out the session state machine corresponding to the 
  3798.      ISID and reinstating a new iSCSI session in its place (with the same 
  3799.      ISID).  Thus, the TSIH in the Login PDU MUST be zero to signal session 
  3800.      reinstatement.  All the tasks that were active on the old session are 
  3801.      internally terminated on a session reinstatement.
  3802.  
  3803.      The initiator session state MUST be FAILED (Section 5.3 Session State 
  3804.      Diagrams) for attempting a session reinstatement.
  3805.  
  3806.      Session closure is an event defined to be either of the following:
  3807.  
  3808.        - a successful "session close" logout 
  3809.        - a successful "connection close" logout for the last full-fea-
  3810.          ture phase connection when no associated connection states are 
  3811.          waiting for cleanup (Section 5.2 Connection Cleanup State Dia-
  3812.          gram for Initiators and Targets) and no associated task states 
  3813.          are waiting for reassignment.
  3814.  
  3815.      Session timeout is an event defined to occur when the last connection 
  3816.      state timeout happens and no tasks are waiting for reassignment.  This 
  3817.  
  3818. Julian Satran               Expires August  2002                         73
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.                                   iSCSI                         17-April-02
  3825.  
  3826.      takes the session to the FREE state (N6 transition in the session 
  3827.      state diagram).
  3828.  
  3829. 4.3.5.1  Loss of Nexus notification
  3830.  
  3831.      iSCSI Layer provides the SCSI layer with the "I_T nexus loss" notifi-
  3832.      cation when any one of the following events happens:
  3833.  
  3834.         a)  A successful completion of session reinstatement
  3835.         b)  A session closure event
  3836.         c)  A session timeout event
  3837.  
  3838.      Certain SCSI object clearing actions may result upon this notifica-
  3839.      tion in the SCSI end nodes, as documented in Appendix F. - Clearing 
  3840.      effects of various events on targets -.
  3841.  
  3842.  
  3843. 4.3.6  Session continuation and failure
  3844.  
  3845.      Session continuation is the process by which the state of a pre-exist-
  3846.      ing session is continued to be in use by either connection reinstate-
  3847.      ment (Section 4.3.4 Connection reinstatement), or by adding a 
  3848.      connection with a new CID. Either of these actions associates the new 
  3849.      transport connection with the pre-existing session state.
  3850.  
  3851.      Session failure is an event where the last full-feature phase connec-
  3852.      tion reaches the CLEANUP_WAIT (Section 5.2 Connection Cleanup State 
  3853.      Diagram for Initiators and Targets) state, or completes a successful 
  3854.      recovery logout thus causing all active tasks (that are formerly alle-
  3855.      giant to the connection) to start waiting for task reassignment.
  3856.  
  3857. 4.4  Operational Parameter Negotiation Outside the Login Phase
  3858.  
  3859.      Some operational parameters MAY be negotiated outside (after) the 
  3860.      login phase.
  3861.  
  3862.      Parameter negotiation in full feature phase is done through Text 
  3863.      requests and responses. Operational parameter negotiation MAY involve 
  3864.      several text request-response exchanges, which the indicator always 
  3865.      starts and terminates and uses the same Initiator Task Tag. The initi-
  3866.      ator MUST indicate its intent to terminate the negotiation by setting 
  3867.      the F bit to 1; the target sets the F bit to 1 on the last response.
  3868.  
  3869.  
  3870.  
  3871. Julian Satran              Expires August  2002                           74
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.                                    iSCSI                        17-April-02
  3878.  
  3879.      If to a text request with the F bit set to 1 the target responds with 
  3880.      a text response with the F bit set to 0, the initiator should keep 
  3881.      sending the text request (even empty) with the F bit set to 1, while 
  3882.      it still wants to finish the negotiation, until it receives the text 
  3883.      response with the F bit set to 1. Responding to a text request with 
  3884.      the F bit set to 1 with an empty (no key=value pairs) response with 
  3885.      the F bit set to 0 is not an error but is discouraged. 
  3886.  
  3887.      Targets MUST NOT submit parameters that require an additional initia-
  3888.      tor text request in a text response with the F bit set to 1.
  3889.  
  3890.      In a negotiation sequence, the F bit settings in one pair of text 
  3891.      request-responses have no bearing on the F bit settings of the next 
  3892.      pair. An initiator that has the F bit set to 1 in a request and being 
  3893.      answered with an F bit setting of 0 may have the next request issued 
  3894.      with the F bit set to 0. 
  3895.  
  3896.      Whenever parameter action or acceptance is dependent on other parame-
  3897.      ters, the dependent parameters MUST be sent after the parameters on 
  3898.      which they depend; if sent within the same command, a response for a 
  3899.      parameter might imply responses for others.
  3900.  
  3901.      Whenever the target responds with the F bit set to 0, it MUST set the 
  3902.      Target Transfer Tag to a value other than the default 0xffffffff.
  3903.  
  3904.      An initiator MAY reset an operational parameter negotiation by issu-
  3905.      ing a Text request with the Target Transfer Tag set to the value 
  3906.      0xffffffff after receiving a response with the Target Transfer Tag set 
  3907.      to a value other than 0xffffffff. A target may reset an operational 
  3908.      parameter negotiation by answering a Text request with a Reject.
  3909.  
  3910.      Neither the initiator nor the target should attempt to negotiate a 
  3911.      parameter more than once during any negotiation sequence without an 
  3912.      intervening reset. If detected by the target this MUST result in a 
  3913.      Reject with a reason of "protocol error". The initiator MUST reset the 
  3914.      negotiation as outlined above.
  3915.  
  3916.  
  3917.      Parameters negotiated by a text exchange negotiation sequence become 
  3918.      effective only after the negotiation sequence is completed.
  3919.  
  3920.  
  3921.  
  3922.  
  3923. Julian Satran               Expires August  2002                          75
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.                                       iSCSI                   17-April-02
  3930.  
  3931. 5. State Transitions
  3932.  
  3933.      iSCSI connections and iSCSI sessions go through several well-defined 
  3934.      states from the time they are created to the time they are cleared.
  3935.  
  3936.      An iSCSI connection is a transport connection used for carrying out 
  3937.      iSCSI activity.  The connection state transitions are described in two 
  3938.      separate, but dependent state diagrams for ease in understanding.  The 
  3939.      first diagram, "standard connection state diagram", describes the 
  3940.      connection state transitions when the iSCSI connection is not waiting 
  3941.      for or undergoing a cleanup by way of an explicit or implicit Logout.  
  3942.      The second diagram, "connection cleanup state diagram", describes the 
  3943.      connection state transitions while performing the iSCSI connection 
  3944.      cleanup.
  3945.  
  3946.      The "session state diagram" describes the state transitions an iSCSI 
  3947.      session would go through during its lifetime, and it depends on the 
  3948.      states of possibly multiple iSCSI connections that participate in the 
  3949.      session.
  3950.  
  3951. 5.1  Standard Connection State Diagrams
  3952.  
  3953. 5.1.1  Standard Connection State Diagram for an Initiator
  3954.  
  3955.      Symbolic names for States:
  3956.  
  3957.            S1: FREE
  3958.            S2: XPT_WAIT 
  3959.            S4: IN_LOGIN
  3960.            S5: LOGGED_IN
  3961.            S6: IN_LOGOUT
  3962.            S7: LOGOUT_REQUESTED
  3963.            S8: CLEANUP_WAIT
  3964.  
  3965.      States S5, S6 and S7 constitute the full-feature phase operation of 
  3966.      the connection.
  3967.       
  3968.      The state diagram is as follows:
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974. Julian Satran                  Expires August  2002                     76
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.                                   iSCSI                          17-April-02
  3981.  
  3982.  
  3983.                          -------<-------------+
  3984.              +--------->/ S1    \<----+       |
  3985.           T13|       +->\       /<-+   \      |
  3986.              |      /    ---+---    \   \     |
  3987.              |     /        |     T2 \   |    |
  3988.              |  T8 |        |T1       |  |    |
  3989.              |     |        |        /   |T7  |
  3990.              |     |        |       /    |    |
  3991.              |     |        |      /     |    |
  3992.              |     |        V     /     /     |
  3993.              |     |     ------- /     /      |
  3994.              |     |    / S2    \     /       |
  3995.              |     |    \       /    /        |
  3996.              |     |     ---+---    /         |
  3997.              |     |        |T4    /          |
  3998.              |     |        V     /           | T18
  3999.              |     |     ------- /            |
  4000.              |     |    / S4    \             |
  4001.              |     |    \       /             |
  4002.              |     |     ---+---              |         T15
  4003.              |     |        |T5      +--------+---------+
  4004.              |     |        |       /T16+-----+------+  |
  4005.              |     |        |      /   -+-----+--+   |  |
  4006.              |     |        |     /   /  S7   \  |T12|  |
  4007.              |     |        |    / +->\       /<-+   V  V
  4008.              |     |        |   / /    -+-----       -------
  4009.              |     |        |  / /T11   |T10        /  S8   \
  4010.              |     |        V / /       V  +----+   \       /
  4011.              |     |      ---+-+-      ----+--  |    -------
  4012.              |     |     / S5    \T9  / S6    \<+    ^
  4013.              |     +-----\       /--->\       / T14  |
  4014.              |            -------      --+----+------+T17
  4015.              +---------------------------+
  4016.  
  4017.      The following state transition table represents the above diagram.  
  4018.      Each row represents the starting state for a given transition, which 
  4019.      after taking a transition marked in a table cell would end in the 
  4020.      state represented by the column of the cell. For example, from state 
  4021.      S1, the connection takes the T1 transition to arrive at state S2. The 
  4022.      fields marked "-" correspond to undefined transitions.
  4023.  
  4024.  
  4025.  
  4026. Julian Satran              Expires August  2002                           77
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.                                       iSCSI                  17-April-02
  4033.  
  4034.         +-----+---+---+---+---+----+---+
  4035.         |S1   |S2 |S4 |S5 |S6 |S7  |S8 |
  4036.      ---+-----+---+---+---+---+----+---+
  4037.       S1| -   |T1 | - | - | - | -  | - | 
  4038.      ---+-----+---+---+---+---+----+---+
  4039.       S2|T2   |-  |T4 | - | - | -  | - | 
  4040.      ---+-----+---+---+---+---+----+---+
  4041.       S4|T7   |-  |-  |T5 | - | -  | - | 
  4042.      ---+-----+---+---+---+---+----+---+
  4043.       S5|T8   |-  |-  | - |T9 |T11 |T15| 
  4044.      ---+-----+---+---+---+---+----+---+
  4045.       S6|T13  |-  |-  | - |T14|-   |T17| 
  4046.      ---+-----+---+---+---+---+----+---+
  4047.       S7|T18  |-  |-  | - |T10|T12 |T16| 
  4048.      ---+-----+---+---+---+---+----+---+
  4049.       S8| -   |-  |-  | - | - | -  | - |
  4050.      ---+-----+---+---+---+---+----+---+
  4051.       
  4052. 5.1.2  Standard Connection State Diagram for a Target
  4053.  
  4054.      Symbolic names for States:
  4055.            S1: FREE
  4056.            S3: XPT_UP 
  4057.            S4: IN_LOGIN
  4058.            S5: LOGGED_IN 
  4059.            S6: IN_LOGOUT
  4060.            S7: LOGOUT_REQUESTED
  4061.            S8: CLEANUP_WAIT
  4062.  
  4063.      States S5, S6 and S7 constitute the full-feature phase operation of 
  4064.      the connection.
  4065.       
  4066.      The state diagram is as follows:
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072. Julian Satran                  Expires August  2002                   78
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.                                   iSCSI                          17-April-02
  4079.  
  4080.                          -------<-------------+
  4081.              +--------->/ S1    \<----+       |
  4082.           T13|       +->\       /<-+   \      |
  4083.              |      /    ---+---    \   \     |
  4084.              |     /        |     T6 \   |    |
  4085.              |  T8 |        |T3       |  |    |
  4086.              |     |        |        /   |T7  |
  4087.              |     |        |       /    |    |
  4088.              |     |        |      /     |    |
  4089.              |     |        V     /     /     |
  4090.              |     |     ------- /     /      |
  4091.              |     |    / S3    \     /       |
  4092.              |     |    \       /    /        | T18
  4093.              |     |     ---+---    /         |
  4094.              |     |        |T4    /          |
  4095.              |     |        V     /           |
  4096.              |     |     ------- /            |
  4097.              |     |    / S4    \             |
  4098.              |     |    \       /             |
  4099.              |     |     ---+---         T15  |
  4100.              |     |        |T5      +--------+---------+
  4101.              |     |        |       /T16+-----+------+  |
  4102.              |     |        |      /  -+-----+---+   |  |
  4103.              |     |        |     /   /  S7   \  |T12|  |
  4104.              |     |        |    / +->\       /<-+   V  V
  4105.              |     |        |   / /    -+-----       -------
  4106.              |     |        |  / /T11   |T10        /  S8   \
  4107.              |     |        V / /       V           \       /
  4108.              |     |      ---+-+-      -------       -------
  4109.              |     |     / S5    \T9  / S6    \        ^
  4110.              |     +-----\       /--->\       /        |
  4111.              |            -------      --+----+--------+T17
  4112.              +---------------------------+
  4113.  
  4114.  
  4115.      The following state transition table represents the above diagram, 
  4116.      and follows the conventions described for the initiator diagram.
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122. Julian Satran              Expires August  2002                           79
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.                                          iSCSI                17-April-02
  4129.  
  4130.         +-----+---+---+---+---+----+---+
  4131.         |S1   |S3 |S4 |S5 |S6 |S7  |S8 |
  4132.      ---+-----+---+---+---+---+----+---+
  4133.       S1| -   |T3 | - | - | - | -  | - | 
  4134.      ---+-----+---+---+---+---+----+---+
  4135.       S3|T6   |-  |T4 | - | - | -  | - | 
  4136.      ---+-----+---+---+---+---+----+---+
  4137.       S4|T7   |-  |-  |T5 | - | -  | - | 
  4138.      ---+-----+---+---+---+---+----+---+
  4139.       S5|T8   |-  |-  | - |T9 |T11 |T15| 
  4140.      ---+-----+---+---+---+---+----+---+
  4141.       S6|T13  |-  |-  | - |-  |-   |T17| 
  4142.      ---+-----+---+---+---+---+----+---+
  4143.       S7|T18  |-  |-  | - |T10|T12 |T16| 
  4144.      ---+-----+---+---+---+---+----+---+
  4145.       S8| -   |-  |-  | - | - | -  | - |
  4146.      ---+-----+---+---+---+---+----+---+
  4147.       
  4148. 5.1.3  State Descriptions for Initiators and Targets
  4149.  
  4150.      State descriptions for the standard connection state diagram are as 
  4151.      follows:
  4152.      -S1: FREE
  4153.              -initiator: State on instantiation, or after successful con-
  4154.                  nection closure.
  4155.              -target: State on instantiation, or after successful connec-
  4156.                  tion closure.
  4157.      -S2: XPT_WAIT
  4158.              -initiator: Waiting for a response to its transport connection 
  4159.                  establishment request.
  4160.              -target: Illegal
  4161.      -S3: XPT_UP
  4162.              -initiator: Illegal
  4163.              -target: Waiting for the Login process to commence.
  4164.      -S4: IN_LOGIN
  4165.              -initiator: Waiting for the Login process to conclude, possi-
  4166.                  bly involving several PDU exchanges.
  4167.              -target: Waiting for the Login process to conclude, possibly 
  4168.                  involving several PDU exchanges.
  4169.      -S5: LOGGED_IN
  4170.              -initiator: In full-feature phase, waiting for all internal, 
  4171.                  iSCSI, and transport events.
  4172.  
  4173.  
  4174.  
  4175. Julian Satran                     Expires August  2002                  80
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.                                        iSCSI                     17-April-02
  4182.  
  4183.                 -target: In full-feature phase, waiting for all internal, 
  4184.                 iSCSI, and transport events.
  4185.      -S6: IN_LOGOUT
  4186.                 -initiator: Waiting for a Logout response.
  4187.                 -target: Waiting for an internal event signaling completion of 
  4188.                 logout processing.
  4189.      -S7: LOGOUT_REQUESTED
  4190.                 -initiator: Waiting for an internal event signaling readiness 
  4191.                 to proceed with Logout.
  4192.                 -target: Waiting for the Logout process to start after having 
  4193.                 requested a Logout via an Async Message.
  4194.      -S8: CLEANUP_WAIT
  4195.                 -initiator: Waiting for the context and/or resources to ini-
  4196.                 tiate the cleanup processing for this CSM.
  4197.                 -target: Waiting for the cleanup process to start for this 
  4198.                 CSM.
  4199. 5.1.4  State Transition Descriptions for Initiators and Targets
  4200.  
  4201.      -T1: 
  4202.                 -initiator: Transport connect request was made (ex: TCP SYN 
  4203.                 sent).
  4204.                 -target: Illegal
  4205.      -T2: 
  4206.                 -initiator: Transport connection request timed out, or a 
  4207.                 transport reset was received, or an internal event of receiv-
  4208.                 ing a Logout response (success) on another connection for a  
  4209.                 "close the session"  Logout command was received. 
  4210.                 -target:Illegal
  4211.      -T3: 
  4212.                 -initiator: Illegal
  4213.                 -target: Received a valid transport connection request that 
  4214.                 establishes the transport connection.
  4215.      -T4: 
  4216.                 -initiator: Transport connection established, thus prompting 
  4217.                 the initiator to start the iSCSI Login.
  4218.                 -target: Initial iSCSI Login command was received.
  4219.      -T5: 
  4220.                 -initiator: The final iSCSI Login response with a Status-Class 
  4221.                 of zero was received.
  4222.                 -target: The final iSCSI Login command to conclude the Login 
  4223.                 phase was received, thus prompting the target to send the 
  4224.                 final iSCSI Login response with a Status-Class of zero.
  4225.      -T6: 
  4226.  
  4227.  
  4228. Julian Satran                 Expires August  2002                           81
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.                                        iSCSI                      17-April-02
  4235.  
  4236.                 -initiator: Illegal
  4237.                 -target: Timed out waiting for an iSCSI Login, or transport 
  4238.                 disconnect indication was received, or transport reset was 
  4239.                 received, or an internal event indicating a transport time-
  4240.                 out was received. In all these cases, the connection is to be 
  4241.                 closed.
  4242.      -T7: 
  4243.                 -initiator: The final iSCSI Login response was received with a 
  4244.                 non-zero Status-Class, or Login timed out, or transport dis-
  4245.                 connect indication was received, or transport reset was 
  4246.                 received, or an internal event indicating a transport time-
  4247.                 out was received, or an internal event of receiving a Logout 
  4248.                 response (success) on another connection for a  "close the 
  4249.                 session"  Logout command was received. In all these cases, 
  4250.                 the transport connection is closed.
  4251.                 -target: The final iSCSI Login command to conclude the Login 
  4252.                 phase was received, prompting the target to send the final 
  4253.                 iSCSI Login response with a non-zero Status-Class, or Login 
  4254.                 timed out, or transport disconnect indication was received, 
  4255.                 or transport reset was received, or an internal event indi-
  4256.                 cating a transport timeout was received, or an internal event 
  4257.                 of sending a Logout response (success) on another connection 
  4258.                 for a  "close the session"  Logout command was received. In 
  4259.                 all these cases, the connection is to be closed.
  4260.      -T8: 
  4261.                 -initiator: An internal event of receiving a Logout response 
  4262.                 (success) on a another connection for a  "close the session"  
  4263.                 Logout command was received, thus closing this connection 
  4264.                 requiring no further cleanup.
  4265.                 -target: An internal event of sending a Logout response (suc-
  4266.                 cess) on another connection for a "close the session" Logout 
  4267.                 command was received, or an internal event of a successful 
  4268.                 connection/session reinstatement is received, thus prompting 
  4269.                 the target to close this connection cleanly.
  4270.      -T9, T10: 
  4271.                 -initiator: An internal event that indicates the readiness to 
  4272.                 start the Logout process was received, thus prompting an 
  4273.                 iSCSI Logout to be sent by the initiator.
  4274.                 -target: An iSCSI Logout command was received.
  4275.      -T11, T12: 
  4276.                 -initiator: Async PDU with AsyncEvent "Request Logout" was 
  4277.                 received. 
  4278.  
  4279.  
  4280. Julian Satran                 Expires August  2002                          82
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.                                        iSCSI                     17-April-02
  4287.  
  4288.                  -target: An internal event that requires the decommissioning 
  4289.                  of the connection is received, thus causing an Async PDU with 
  4290.                  an AsyncEvent "Request Logout" to be sent.
  4291.      -T13: 
  4292.                  -initiator: An iSCSI Logout response (success) was received, 
  4293.                  or an internal event of receiving a Logout response (success) 
  4294.                  on another connection for a  "close the session"  Logout com-
  4295.                  mand was received.
  4296.                  -target: An internal event was received that indicates suc-
  4297.                  cessful processing of the Logout, which prompts an iSCSI 
  4298.                  Logout response (success) to be sent, or an internal event of 
  4299.                  sending a Logout response (success) on another connection 
  4300.                  for a "close the session" Logout command was received, or an 
  4301.                  internal event of a successful connection/session reinstate-
  4302.                  ment is received. In all these cases, the transport connec-
  4303.                  tion is closed.
  4304.  
  4305.      -T14: 
  4306.                  -initiator: Async PDU with AsyncEvent "Request Logout" was 
  4307.                  received again.
  4308.                  -target: Illegal
  4309.      -T15, T16: 
  4310.                  -initiator: One or more of the following events caused this 
  4311.                  transition:
  4312.                      -Internal event that indicates a transport connection tim-
  4313.                  eout was received thus prompting transport RESET or trans-
  4314.                  port connection closure. 
  4315.                      -A transport RESET. 
  4316.                      -A transport disconnect indication. 
  4317.                      -Async PDU with AsyncEvent "Drop connection" (for this 
  4318.                  CID).
  4319.                      -Async PDU with AsyncEvent "Drop all connections".
  4320.                  -target: One or more of the following events caused this tran-
  4321.                  sition:
  4322.                      -Internal event that indicates a transport connection tim-
  4323.                  eout was received, thus prompting transport RESET or trans-
  4324.                  port connection closure. 
  4325.                      -An internal event of a failed connection/session rein-
  4326.                  statement is received.
  4327.                      -A transport RESET. 
  4328.                      -A transport disconnect indication. 
  4329.  
  4330.  
  4331.  
  4332. Julian Satran                   Expires August  2002                       83
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.                                            iSCSI                       17-April-02
  4339.  
  4340.                      -Internal emergency cleanup event was received which 
  4341.                      prompts an Async PDU with AsyncEvent "Drop connection" (for 
  4342.                      this CID), or event "Drop all connections".
  4343.                  
  4344.      -T17: 
  4345.                  -initiator: One or more of the following events caused this 
  4346.                      transition:
  4347.                      -Logout response (failure, i.e. a non-zero status) was 
  4348.                      received, or Logout timed out.
  4349.                      -Any of the events specified for T15 and T16.
  4350.                  -target:  One or more of the following events caused this 
  4351.                      transition:
  4352.                      -Internal event that indicates a failure of the Logout 
  4353.                      processing was received, which prompts a Logout response 
  4354.                      (failure, i.e. a non-zero status) to be sent. 
  4355.                      -Any of the events specified for T15 and T16.
  4356.      -T18:
  4357.                  -initiator: An internal event of receiving a Logout response 
  4358.                      (success) on another connection for a "close the session"  
  4359.                      Logout command was received.
  4360.                  
  4361.                  -target: An internal event of sending a Logout response (suc-
  4362.                      cess) on another connection for a "close the session"  Logout 
  4363.                      command was received, or an internal event of a successful 
  4364.                      connection/session reinstatement is received.  In both these 
  4365.                      cases, the connection is closed.
  4366.                  
  4367.                  
  4368.  
  4369.      The CLEANUP_WAIT state (S8) implies that there are possible iSCSI 
  4370.      tasks that have not reached conclusion and are still considered busy.
  4371.  
  4372. 5.2  Connection Cleanup State Diagram for Initiators and Targets
  4373.  
  4374.      Symbolic names for states: 
  4375.  
  4376.        R1: CLEANUP_WAIT (same as S8)
  4377.        R2: IN_CLEANUP
  4378.        R3: FREE (same as S1)
  4379.  
  4380.      Whenever a connection state machine (e.g., CSM-C) enters the 
  4381.      CLEANUP_WAIT state (S8), it must go through the state transitions 
  4382.      additionally described in the connection cleanup state diagram either 
  4383.      a) using a separate full-feature phase connection (let's call it CSM-
  4384.  
  4385. Julian Satran                       Expires August  2002                        84
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.                                     iSCSI                     17-April-02
  4392.  
  4393.      E) in the LOGGED_IN state in the same session, or b) using a new 
  4394.      transport connection (let's call it CSM-I) in the FREE state that is 
  4395.      to be added to the same session. In the CSM-E case, an explicit logout 
  4396.      for the CID that corresponds to CSM-C (either as a connection or ses-
  4397.      sion logout) needs to be performed to complete the cleanup. In the 
  4398.      CSM-I case, an implicit logout for the CID that corresponds to CSM-C 
  4399.      needs to be performed by way of connection reinstatement (section 
  4400.      4.3.4) for that CID. In either case, the protocol exchanges on CSM-E 
  4401.      or CSM-I to determine the state transitions for CSM-C. Therefore, this 
  4402.      cleanup state diagram is applicable only to the instance of the con-
  4403.      nection in cleanup (i.e., CSM-C). In the case of an implicit logout 
  4404.      for example, CSM-C reaches FREE (R3) at the time CSM-I reaches 
  4405.      LOGGED_IN. In the case of an explicit logout, CSM-C reaches FREE (R3) 
  4406.      when CSM-E receives a successful logout response while continuing to 
  4407.      be in the LOGGED_IN state. 
  4408.  
  4409.  
  4410.      The following state diagram applies to both initiators and targets.
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416. Julian Satran               Expires August  2002                          85
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.                                       iSCSI                      17-April-02
  4423.  
  4424.                          -------
  4425.                         / R1    \
  4426.                      +--\       /<-+
  4427.                     /    ---+---    \
  4428.                    /        |        \ M3
  4429.                 M1 |        |M2       |
  4430.                    |        |        / 
  4431.                    |        |       / 
  4432.                    |        |      / 
  4433.                    |        V     / 
  4434.                    |     ------- /
  4435.                    |    / R2    \
  4436.                    |    \       /
  4437.                    |     -------
  4438.                    |        |
  4439.                    |        |M4   
  4440.                    |        |  
  4441.                    |        | 
  4442.                    |        | 
  4443.                    |        V
  4444.                    |      -------
  4445.                    |     / R3    \
  4446.                    +---->\       /
  4447.                           -------
  4448.  
  4449.      The following state transition table represents the above diagram, 
  4450.      and follows the same conventions as in earlier sections.
  4451.  
  4452.           +----+----+----+
  4453.           |R1  |R2  |R3  |
  4454.      -----+----+----+----+
  4455.       R1  | -  |M2  |M1  |
  4456.      -----+----+----+----+
  4457.       R2  |M3  | -  |M4  |
  4458.      -----+----+----+----+
  4459.       R3  | -  | -  | -  |
  4460.      -----+----+----+----+
  4461.  
  4462. 5.2.1  State Descriptions for Initiators and Targets
  4463.  
  4464.      -R1: CLEANUP_WAIT (Same as S8)
  4465.              -initiator: Waiting for the internal event to initiate the 
  4466.              cleanup processing for CSM-C.
  4467.  
  4468.  
  4469. Julian Satran                 Expires August  2002                        86
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.                                         iSCSI                      17-April-02
  4476.  
  4477.                 -target: Waiting for the cleanup process to start for CSM-C.
  4478.      -R2: IN_CLEANUP
  4479.                 -initiator: Waiting for the connection cleanup process to con-
  4480.                     clude for CSM-C.
  4481.                 -target: Waiting for the connection cleanup process to con-
  4482.                     clude for CSM-C.
  4483.      -R3: FREE (Same as S1)
  4484.                 -initiator: End state for CSM-C.
  4485.                 -target: End state for CSM-C.
  4486.                 
  4487. 5.2.2  State Transition Descriptions for Initiators and Targets
  4488.  
  4489.      -M1:  One or more of the following events was received:
  4490.                 -initiator: 
  4491.                     -An internal event that indicates connection state time-
  4492.                     out.
  4493.                     -An internal event of receiving a successful Logout 
  4494.                     response on a different connection for a "close the session" 
  4495.                     Logout.
  4496.                 -target: 
  4497.                     -An internal event that indicates connection state time-
  4498.                     out. 
  4499.                     -An internal event of sending a Logout response (success) 
  4500.                     on a different connection for a "close the session" Logout 
  4501.                     command.
  4502.                     
  4503.      -M2:  An implicit/explicit logout process was initiated by the initi-
  4504.      ator.
  4505.                 -In CSM-I usage:
  4506.                     -initiator: An internal event requesting the connection 
  4507.                     (or session) reinstatement was received, thus prompting a 
  4508.                     connection (or session) reinstatement Login to be sent tran-
  4509.                     sitioning CSM-I to state IN_LOGIN.
  4510.                     -target: A connection/session reinstatement Login was 
  4511.                     received while in state XPT_UP.
  4512.                 -In CSM-E usage:
  4513.                     -initiator: An internal event that indicates that an 
  4514.                     explicit logout was sent for this CID in state LOGGED_IN.
  4515.                     -target: An explicit logout was received for this CID in 
  4516.                     state LOGGED_IN.
  4517.      -M3: Logout failure detected 
  4518.                 -In CSM-I usage:
  4519.  
  4520.  
  4521.  
  4522. Julian Satran                    Expires August  2002                        87
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.                                          iSCSI                   17-April-02
  4529.  
  4530.                  -initiator: CSM-I failed to reach LOGGED_IN and arrived 
  4531.                  into FREE instead.
  4532.                  -target: CSM-I failed to reach LOGGED_IN and arrived into 
  4533.                  FREE instead.
  4534.              -In CSM-E usage:
  4535.                  -initiator: CSM-E either moved out of LOGGED_IN, or Logout 
  4536.                  timed out and/or aborted, or Logout response (failure) was 
  4537.                  received.
  4538.                  -target: CSM-E either moved out of LOGGED_IN, or Logout 
  4539.                  timed out and/or aborted, or an internal event that indicates 
  4540.                  a failed Logout processing was received.  A Logout response 
  4541.                  (failure) was sent in the last case.
  4542.              
  4543.  
  4544.      -M4: Successful implicit/explicit logout was performed.
  4545.              - In CSM-I usage:
  4546.                  -initiator: CSM-I reached state LOGGED_IN, or an internal 
  4547.                  event of receiving a Logout response (success) on another 
  4548.                  connection for a "close the session" Logout command was 
  4549.                  received.
  4550.                  -target: CSM-I reached state LOGGED_IN, or an internal 
  4551.                  event of sending a Logout response (success) on a different 
  4552.                  connection for a "close the session" Logout command was 
  4553.                  received.
  4554.              - In CSM-E usage:
  4555.                  -initiator: CSM-E stayed in LOGGED_IN and received a 
  4556.                  Logout response (success), or an internal event of receiving 
  4557.                  a Logout response (success) on another connection for a 
  4558.                  "close the session" Logout command was received.
  4559.                  -target: CSM-E stayed in LOGGED_IN and an internal event 
  4560.                  indicating a successful Logout processing was received, or 
  4561.                  an internal event of sending a Logout response (success) on a 
  4562.                  different connection for a "close the session" Logout com-
  4563.                  mand was received.
  4564.  
  4565. 5.3  Session State Diagrams
  4566.  
  4567.      Session State Diagram for an Initiator
  4568.  
  4569.      Symbolic Names for States:
  4570.  
  4571.        Q1: FREE
  4572.        Q3: LOGGED_IN
  4573.        Q4: FAILED
  4574.  
  4575. Julian Satran                     Expires August  2002                       88
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.                                      iSCSI                   17-April-02
  4582.  
  4583.      State Q3 represents the full-feature phase operation of the session.
  4584.  
  4585.      The state diagram is as follows:
  4586.  
  4587.                               -------
  4588.                              / Q1    \
  4589.                      +------>\       /<-+
  4590.                     /         ---+---   |
  4591.                    /             |      |N3
  4592.                N6 |              |N1    |
  4593.                   |              |      | 
  4594.                   |    N4        |      |
  4595.                   |  +--------+  |     /    
  4596.                   |  |        |  |    /
  4597.                   |  |        |  |   /
  4598.                   |  |        V  V  /
  4599.                  -+--+--      -----+-
  4600.                 / Q4    \ N5 / Q3    \
  4601.                 \       /<---\       /
  4602.                  -------      -------
  4603.  
  4604.      State transition table:
  4605.  
  4606.           +----+----+----+
  4607.           |Q1  |Q3  |Q4  |
  4608.      -----+----+----+----+
  4609.       Q1  | -  |N1  | -  |
  4610.      -----+----+----+----+
  4611.       Q3  |N3  | -  |N5  |
  4612.      -----+----+----+----+
  4613.       Q4  |N6  |N4  | -  |
  4614.      -----+----+----+----+
  4615.  
  4616. 5.3.1  Session State Diagram for a Target
  4617.  
  4618.      Symbolic Names for States:
  4619.  
  4620.        Q1: FREE
  4621.        Q2: ACTIVE
  4622.        Q3: LOGGED_IN
  4623.        Q4: FAILED
  4624.        Q5: IN_CONTINUE
  4625.  
  4626.      State Q3 represents the full-feature phase operation of the session.
  4627.  
  4628. Julian Satran                 Expires August  2002                    89
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.                                   iSCSI                   17-April-02
  4635.  
  4636.  
  4637.  
  4638.      The state diagram is as follows:
  4639.  
  4640.                                         -------
  4641.                    +------------------>/ Q1    \
  4642.                   /    +-------------->\       /<-+
  4643.                   |    |                ---+---   |
  4644.                   |    |                ^  |      |N3
  4645.                N6 |    |N11           N9|  V N1   |
  4646.                   |    |                +------   |
  4647.                   |    |               / Q2    \  |
  4648.                   |    |               \       /  |
  4649.                   |  --+----            +--+---   |
  4650.                   | / Q5    \              |      | 
  4651.                   | \       / N10          |      |
  4652.                   |  +-+---+------------+  |N2   /    
  4653.                   |  ^ |                |  |    /
  4654.                   |N7| |N8              |  |   /
  4655.                   |  | |                |  V  /
  4656.                  -+--+-V                V----+-
  4657.                 / Q4    \ N5           / Q3    \
  4658.                 \       /<-------------\       /
  4659.                  -------                -------
  4660.  
  4661.      State transition table:
  4662.  
  4663.           +----+----+----+----+----+
  4664.           |Q1  |Q2  |Q3  |Q4  |Q5  |
  4665.      -----+----+----+----+----+----+
  4666.       Q1  | -  |N1  | -  | -  | -  |
  4667.      -----+----+----+----+----+----+
  4668.       Q2  |N9  | -  |N2  | -  | -  |
  4669.      -----+----+----+----+----+----+
  4670.       Q3  |N3  | -  | -  |N5  | -  |
  4671.      -----+----+----+----+----+----+
  4672.       Q4  |N6  | -  | -  | -  |N7  |
  4673.      -----+----+----+----+----+----+
  4674.       Q5  |N11 | -  |N10 |N8  | -  |
  4675.      -----+----+----+----+----+----+
  4676.  
  4677.  
  4678.  
  4679.  
  4680. Julian Satran              Expires August  2002                    90
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.                                        iSCSI                     17-April-02
  4687.  
  4688. 5.3.2  State Descriptions for Initiators and Targets
  4689.  
  4690.      -Q1: FREE
  4691.                 -initiator: State on instantiation or after cleanup.
  4692.                 -target: State on instantiation or after cleanup.
  4693.      -Q2: ACTIVE
  4694.                 -initiator: Illegal
  4695.                 -target: The first iSCSI connection in the session transi-
  4696.                 tioned to IN_LOGIN, waiting for it to complete the login pro-
  4697.                 cess.
  4698.      -Q3: LOGGED_IN
  4699.                 -initiator: Waiting for all session events.
  4700.                 -target: Waiting for all session events.
  4701.      -Q4: FAILED
  4702.                 -initiator: Waiting for session recovery or session continua-
  4703.                 tion.
  4704.                 -target: Waiting for session recovery or session continua-
  4705.                 tion.
  4706.      -Q5: IN_CONTINUE
  4707.                 -initiator: Illegal
  4708.                 -target: Waiting for session continuation attempt to reach a 
  4709.                 conclusion.
  4710.  
  4711.  
  4712. 5.3.3  State Transition Descriptions for Initiators and Targets
  4713.  
  4714.      -N1:
  4715.                 -initiator: At least one transport connection reached the 
  4716.                 LOGGED_IN state.
  4717.                 -target: The first iSCSI connection in the session had reached 
  4718.                 the IN_LOGIN state.
  4719.      -N2: 
  4720.                 -initiator: Illegal
  4721.                 -target: At least one transport connection reached the 
  4722.                 LOGGED_IN state.
  4723.      -N3:
  4724.                 -initiator: Graceful closing of the session via session clo-
  4725.                 sure (Section 4.3.6 Session continuation and failure).
  4726.                 -target: Graceful closing of the session via session closure 
  4727.                 (Section 4.3.6 Session continuation and failure). Or a suc-
  4728.                 cessful session reinstatement cleanly closed the session.
  4729.      -N4:
  4730.                 -initiator: A session continuation attempt succeeded.
  4731.                 -target: Illegal
  4732.  
  4733. Julian Satran                  Expires August  2002                        91
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.                                            iSCSI                    17-April-02
  4740.  
  4741.      -N5:
  4742.                 -initiator: Session failure (Section 4.3.6 Session continua-
  4743.                     tion and failure) occurred.
  4744.                 -target: Session failure (Section 4.3.6 Session continuation 
  4745.                     and failure) occurred.
  4746.      -N6: 
  4747.                 -initiator: Session state timeout occurred, or a session rein-
  4748.                     statement cleared this session instance.  This results in the 
  4749.                     freeing of all associated resources and the session state is 
  4750.                     discarded.
  4751.                 -target: Session state timeout occurred, or a session rein-
  4752.                     statement cleared this session instance.  This results in the 
  4753.                     freeing of all associated resources and the session state is 
  4754.                     discarded.
  4755.      -N7:
  4756.                 -initiator: Illegal
  4757.                 -target: A session continuation attempt is initiated.
  4758.      -N8:
  4759.                 -initiator: Illegal
  4760.                 -target: The last session continuation attempt failed.
  4761.      -N9:
  4762.                 -initiator: Illegal
  4763.                 -target: Login attempt on the leading connection failed.
  4764.      -N10:
  4765.                 -initiator: Illegal
  4766.                 -target: A session continuation attempt succeeded.
  4767.      -N11:
  4768.                 -initiator: Illegal
  4769.                 -target: A successful session reinstatement cleanly closed 
  4770.                     the session.
  4771.                 
  4772.                 
  4773.  
  4774.  
  4775.  
  4776.  
  4777.  
  4778. Julian Satran                       Expires August  2002                      92
  4779.  
  4780.  
  4781.  
  4782.  
  4783.  
  4784.                                     iSCSI                     17-April-02
  4785.  
  4786. 6. iSCSI Error Handling and Recovery
  4787.  
  4788.      For any outstanding SCSI command, it is assumed that iSCSI, in con-
  4789.      junction with SCSI at the initiator, is able to keep enough informa-
  4790.      tion to be able to rebuild the command PDU, and that outgoing data is 
  4791.      available (in host memory) for retransmission while the command is 
  4792.      outstanding.  It is also assumed that at target, incoming data (read 
  4793.      data) MAY be kept for recovery or it can be re-read from a device 
  4794.      server.
  4795.  
  4796.      It is further assumed that a target will keep the "status & sense" for 
  4797.      a command it has executed if it supports status retransmission.
  4798.  
  4799.      Many of the recovery details in an iSCSI implementation are a local 
  4800.      matter, beyond the scope of protocol standardization. However, some 
  4801.      external aspects of the processing must be standardized to ensure 
  4802.      interoperability. This section describes a general model for recovery 
  4803.      in support of interoperability. See Appendix E. - Algorithmic Presen-
  4804.      tation of Error Recovery Classes - for further detail. Compliant 
  4805.      implementations do not have to match the implementation details of 
  4806.      this model as presented, but the external behavior of such implementa-
  4807.      tions must correspond to the externally observable characteristics of 
  4808.      the presented model.
  4809.       
  4810. 6.1  Retry and Reassign in Recovery
  4811.  
  4812.      This section summarizes two important and somewhat related iSCSI pro-
  4813.      tocol features used in error recovery.
  4814.  
  4815. 6.1.1  Usage of Retry
  4816.  
  4817.      By resending the same iSCSI command PDU ("retry") in the absence of a 
  4818.      command acknowledgement or response, an initiator attempts to "plug" 
  4819.      (what it thinks are) the discontinuities in CmdSN ordering on the tar-
  4820.      get end.  Discarded command PDUs, due to digest errors, may have cre-
  4821.      ated these discontinuities.
  4822.       
  4823.      Retry MUST NOT be used for reasons other than plugging command 
  4824.      sequence gaps.  In particular, all PDU retransmission (for data, or 
  4825.      status) requests for a currently allegiant command in progress must be 
  4826.      conveyed to the target using only the SNACK mechanism already 
  4827.      described.  This, however, does not constitute a requirement on initi-
  4828.      ators to use SNACK.
  4829.  
  4830.  
  4831. Julian Satran                Expires August  2002                         93
  4832.  
  4833.  
  4834.  
  4835.  
  4836.  
  4837.                                   iSCSI                      17-April-02
  4838.  
  4839.  
  4840.      If initiators, as part of plugging command sequence gaps as described 
  4841.      above, inadvertently issue retries for allegiant commands already in 
  4842.      progress (i.e., targets did not see the discontinuities in CmdSN 
  4843.      ordering), targets MUST silently discard the duplicate requests if 
  4844.      the CmdSN window had not advanced by then.  Targets MUST support the 
  4845.      retry functionality described above.
  4846.  
  4847.      When an iSCSI command is retried, the command PDU MUST carry the orig-
  4848.      inal Initiator Task Tag and the original operational attributes 
  4849.      (e.g., flags, function names, LUN, CDB etc.) as well as the original 
  4850.      CmdSN. The command being retried MUST be sent on the same connection 
  4851.      as the original command unless the original connection was already 
  4852.      successfully logged out. 
  4853.  
  4854. 6.1.2  Allegiance Reassignment
  4855.  
  4856.      By issuing a "task reassign" task management command (Section 9.5.1 
  4857.      Function), the initiator signals its intent to continue an already 
  4858.      active command (but with no current connection allegiance) as part of 
  4859.      connection recovery. This means that a new connection allegiance is 
  4860.      established for the command, that associates it to the connection on 
  4861.      which the task management command is being issued.
  4862.  
  4863.      In reassigning connection allegiance for a command, the targets 
  4864.      SHOULD continue the command from its current state. For example, when 
  4865.      reassigning read commands, the target SHOULD take advantage of Exp-
  4866.      DataSN field provided by the Task Management Function Request (which 
  4867.      must be set to zero if there was no data transfer) and bring the read 
  4868.      command to completion by sending the remaining data and sending (or 
  4869.      resending) the status.  However, targets MAY choose to send/receive 
  4870.      the entire data on a reassignment of connection allegiance, and it is 
  4871.      not considered an error.  For all types of commands, a reassignment 
  4872.      request implies that the task is still considered in progress by the 
  4873.      initiator and the target must conclude the task appropriately.  This 
  4874.      might possibly involve retransmission of data/R2T/status PDUs as nec-
  4875.      essary. 
  4876.  
  4877.  
  4878.      It is optional for targets to support the allegiance reassignment.  
  4879.      This capability is negotiated via the ErrorRecoveryLevel text key at 
  4880.      the login time.  When a target does not support allegiance reassign-
  4881.      ment, it MUST respond with a task management response code of "Task 
  4882.  
  4883.  
  4884. Julian Satran              Expires August  2002                           94
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890.                                     iSCSI                       17-April-02
  4891.  
  4892.      failover not supported".  If allegiance reassignment is supported by 
  4893.      the target, but the task is still allegiant to a different connection, 
  4894.      the target MUST respond with a task management response code of "Task 
  4895.      still allegiant".
  4896.  
  4897. 6.2  Usage Of Reject PDU in Recovery
  4898.  
  4899.      Targets MUST NOT implicitly terminate an active task by sending a    
  4900.      Reject PDU for any PDU exchanged during the life of the task.  If the    
  4901.      target decides to terminate the task, a Response PDU (SCSI, Text, Task 
  4902.      etc.) must be returned by the target to conclude the task.  If the 
  4903.      task had never been active before the Reject (i.e., the Reject is on 
  4904.      the command PDU), targets should not send any further responses since 
  4905.      the command itself is being discarded.
  4906.  
  4907.      The above rule means that the initiators can eventually expect a 
  4908.      response even on Rejects, if the Reject is not for the command itself.  
  4909.      The non-command Rejects only have diagnostic value in logging the 
  4910.      errors, and they can be used for retransmission decisions by the ini-
  4911.      tiators.
  4912.  
  4913.      The CmdSN of the rejected command PDU (if it carried one) MUST NOT be 
  4914.      considered received by the target (i.e., a command sequence gap must 
  4915.      be assumed for the CmdSN), even though the CmdSN can be reliably 
  4916.      ascertained in this case.  
  4917.  
  4918.      When a data PDU is rejected and it's DataSN can be ascertained, a tar-
  4919.      get MUST advance ExpDataSN for the current data burst if a recovery 
  4920.      R2T is being generated. The target MAY advance its ExpDataSN if it 
  4921.      does not attempt to recover the lost data PDU.
  4922.  
  4923. 6.3  Connection timeout management
  4924.  
  4925.      iSCSI defines two session-global timeout values (in seconds) - 
  4926.      Time2Wait and Time2Retain - that are applicable when an iSCSI full-
  4927.      feature phase connection is taken out of service either intentionally 
  4928.      or on an exception. Time2Wait is the initial "respite time" before 
  4929.      attempting an explicit/implicit Logout for the CID in question or task 
  4930.      reassignment for the affected tasks (if any). Time2Retain is the max-
  4931.      imum time after the initial respite interval that the task and/or con-
  4932.      nection state(s) is/are guaranteed to be maintained on the target to 
  4933.      cater to a possible recovery attempt. No recovery attempt should be 
  4934.      made before Time2Wait and task reassignment has to be done within the 
  4935.      Time2Retain.
  4936.  
  4937. Julian Satran               Expires August  2002                          95
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.                                      iSCSI                     17-April-02
  4944.  
  4945.  
  4946. 6.3.1  Timeouts on transport exception events
  4947.  
  4948.      A transport connection shutdown or a transport reset without any 
  4949.      preceding iSCSI protocol interactions informing of the fact causes a
  4950.      full-feature phase iSCSI connection to be abruptly terminated. The 
  4951.      timeout values to be used in this case are the negotiated values of 
  4952.      DefaultTime2Wait (Section 11.16 DefaultTime2Wait) and 
  4953.      DefaultTime2Retain (Section 11.17 DefaultTime2Retain) text keys for 
  4954.      the session.
  4955.  
  4956. 6.3.2  Timeouts on planned decommissioning
  4957.  
  4958.      Any planned decommissioning of a full-feature phase iSCSI connection 
  4959.      is preceded by either a Logout Response PDU, or an Async Message PDU. 
  4960.      The Time2Wait and Time2Retain field values (section 9.15)in a Logout 
  4961.      Response PDU, and the Parameter2 and Parameter3 fields of an Async 
  4962.      Message (AsyncEvent types "drop the connection" or "drop all the con-
  4963.      nections"; section 9.9.1) specify the timeout values to be used in 
  4964.      each of these cases. 
  4965.  
  4966.      These timeout values are applicable only for the affected connection, 
  4967.      and the tasks active on that connection.  These timeout values have no 
  4968.      bearing on initiator timers (if any) that are already running on con-
  4969.      nections or tasks associated with that session.
  4970.  
  4971. 6.4  Format Errors
  4972.  
  4973.      Explicit violations of the PDU layout rules stated in this document 
  4974.      are format errors.  Violations, when detected, usually indicate a 
  4975.      major implementation flaw in one of the parties.
  4976.  
  4977.      When a target or an initiator receives an iSCSI PDU with a format 
  4978.      error, it MUST immediately terminate all transport connections in the 
  4979.      session either with a connection close or with a connection reset and 
  4980.      escalate the format error to session recovery (see Section 6.12.4 Ses-
  4981.      sion Recovery).
  4982.  
  4983. 6.5  Digest Errors
  4984.  
  4985.      The discussion of the legal choices in handling digest errors below 
  4986.      excludes session recovery as an explicit option, but either party 
  4987.      detecting a digest error may choose to escalate the error to session 
  4988.      recovery. 
  4989.  
  4990. Julian Satran                 Expires August  2002                        96
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.                                             iSCSI                  17-April-02
  4997.  
  4998.  
  4999.      When a target receives any iSCSI PDU with a header digest error, it 
  5000.      MUST silently discard the PDU.
  5001.  
  5002.      When a target receives any iSCSI PDU with a payload digest error, it 
  5003.      MUST answer with a Reject iSCSI PDU with a Reason-code of Data-Digest-
  5004.      Error and discard the PDU.
  5005.  
  5006.            - If the discarded PDU is a solicited or unsolicited iSCSI data 
  5007.                 PDU (for immediate data in a command PDU, non-data PDU rule 
  5008.                 below applies), the target MUST do one of the following:
  5009.            a)  Request retransmission with a recovery R2T. [OR]
  5010.            b)  Terminate the task with a response PDU with the reason "proto-
  5011.            col service CRC error" (Section 9.4.3 Response). If the target 
  5012.            chooses to implement this option, it MUST wait to receive all the 
  5013.            data (signaled by a Data PDU with the final bit set for all out-
  5014.            standing R2Ts) before sending the response PDU. A task management 
  5015.            command (similar to an abort task) from the initiator during this 
  5016.            wait may also conclude the task.
  5017.            - No further action is necessary for targets if the discarded 
  5018.                 PDU is a non-data PDU.
  5019.  
  5020.      When an initiator receives any iSCSI PDU with a header digest error, 
  5021.      it MUST discard the PDU.
  5022.  
  5023.      When an initiator receives any iSCSI PDU with a payload digest error, 
  5024.      it MUST discard the PDU.
  5025.        
  5026.            - If the discarded PDU is an iSCSI data PDU, the initiator MUST 
  5027.                 do one of the following:
  5028.            a)  Request the desired data PDU through SNACK. In its turn,   the 
  5029.            target MUST either resend the data PDU or, reject the SNACK with a 
  5030.            Reject PDU with a reason-code of "Data-SNACK Reject" in which case 
  5031.            -
  5032.                      i)  if the status had not already been sent for the com-
  5033.                         mand, the target MUST terminate the command with an 
  5034.                         iSCSI response reason(Section 9.4.3 Response) of "SNACK 
  5035.                         rejected". 
  5036.                      ii)  if the status was already sent, no further action is 
  5037.                         necessary for the target.  Initiator in this case MUST 
  5038.                         internally signal the completion with the "SNACK 
  5039.                         rejected" reason (Section 9.4.3 Response) disregarding 
  5040.                         any received status PDU, but must wait for the status to 
  5041.                         be received before doing so.       [OR]
  5042.  
  5043. Julian Satran                    Expires August  2002                           97
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.                                       iSCSI                   17-April-02
  5050.  
  5051.         b)  Abort the task and terminate the command with an error.
  5052.  
  5053.        - If the discarded PDU is a response PDU, the initiator MUST do 
  5054.          one of the following:
  5055.         a)  Request PDU retransmission with a status SNACK. [OR]
  5056.         b)  Logout the connection for recovery and continue the tasks on a 
  5057.         different connection instance as described in Section 6.1 Retry 
  5058.         and Reassign in Recovery. [OR]
  5059.         c)  Logout to close the connection (abort all the commands associ-
  5060.         ated with the connection).
  5061.  
  5062.        - No further action is necessary for initiators if the discarded 
  5063.          PDU is an unsolicited PDU (e.g., Async, Reject).
  5064.  
  5065. 6.6  Sequence Errors
  5066.  
  5067.      When an initiator receives an iSCSI R2T/data PDU with an out-of-order 
  5068.      R2TSN/DataSN or a SCSI response PDU with an ExpDataSN that implies 
  5069.      missing data PDU(s), it means that the initiator must have hit a 
  5070.      header or payload digest error on one or more earlier R2T/data PDUs. 
  5071.      The initiator MUST address these implied digest errors as described in 
  5072.      Section 6.5 Digest Errors. When a target receives a data PDU with an 
  5073.      out-of-order DataSN, it means that the target must have hit a header 
  5074.      or payload digest error on at least one of the earlier data PDUs. Tar-
  5075.      get MUST address these implied digest errors as described in Section 
  5076.      6.5 Digest Errors.
  5077.  
  5078.      When an initiator receives an iSCSI status PDU with an out-of-order 
  5079.      StatSN that implies missing responses, it MUST address the one or more 
  5080.      missing status PDUs as described in Section 6.5 Digest Errors. As a 
  5081.      side effect of receiving the missing responses, the initiator may dis-
  5082.      cover missing data PDUs. If the initiator wants to recover the missing 
  5083.      data for a command, it MUST NOT acknowledge the received responses 
  5084.      that start from the StatSN of the interested command, until it has 
  5085.      completed receiving all the data PDUs of the command.
  5086.  
  5087.      When an initiator receives duplicate R2TSNs (due to proactive 
  5088.      retransmission of R2Ts by the target) or duplicate DataSNs (due to 
  5089.      proactive SNACKs by the initiator), it MUST discard the duplicates.
  5090.  
  5091. 6.7  SCSI Timeouts
  5092.  
  5093.      An iSCSI initiator MAY attempt to plug a command sequence gap on the 
  5094.      target end (in the absence of an acknowledgement of the command by way 
  5095.  
  5096. Julian Satran               Expires August  2002                          98
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.                                     iSCSI                    17-April-02
  5103.  
  5104.      of ExpCmdSN) before the ULP timeout by retrying the unacknowledged 
  5105.      command, as described in Section 6.1 Retry and Reassign in Recovery.
  5106.  
  5107.      On a ULP timeout for a command (that carried a CmdSN of n), the iSCSI 
  5108.      initiator MUST abort the command by either using the Abort Task task 
  5109.      management function request, or a "close the connection" Logout if it 
  5110.      intends to continue the session.  In using an explicit Abort, if the 
  5111.      ExpCmdSN is still less than (n+1), the target may see the abort 
  5112.      request while missing the original command itself due to one of the 
  5113.      following reasons:
  5114.  
  5115.        - The original command was dropped due to digest error. 
  5116.        - The connection on which the original command was sent was suc-
  5117.          cessfully logged out (on logout, the unacknowledged commands 
  5118.          issued on the connection being logged out are discarded).
  5119.  
  5120.      If the abort request is received and the original command is missing, 
  5121.      targets MUST consider the original command with that RefCmdSN to be 
  5122.      received and issue a task management response with the response code: 
  5123.      "Task does not exist". This response concludes the task on both ends. 
  5124.  
  5125. 6.8  Negotiation Failures
  5126.  
  5127.      Text request and response sequences, when used to set/negotiate oper-
  5128.      ational parameters, constitute the negotiation/parameter setting.  A 
  5129.      negotiation failure is considered one or more of the following:
  5130.  
  5131.        - None of the choices or the stated value is acceptable to one 
  5132.          negotiating side. 
  5133.        - The text request timed out, and possibly terminated.
  5134.        - The text request was answered with a reject.
  5135.  
  5136.  
  5137.      The following two rules are to be used to address negotiation fail-
  5138.      ures:
  5139.  
  5140.        - During Login, any failure in negotiation MUST be considered a 
  5141.          login process failure and the login phase must be terminated, 
  5142.          and with it the connection. If the target detects the failure, 
  5143.          it must terminate the login with the appropriate login 
  5144.          response code.
  5145.           
  5146.        - A failure in negotiation, while in the full-feature phase, 
  5147.          will terminate the entire negotiation sequence that may con-
  5148.          sist of a series of text requests that use the same Initiator 
  5149.          Task Tag.  The operational parameters of the session or the 
  5150.  
  5151. Julian Satran                Expires August  2002                        99
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.                                     iSCSI                     17-April-02
  5158.  
  5159.          connection MUST continue to be the values agreed upon during 
  5160.          an earlier successful negotiation (i.e., any partial results 
  5161.          of this unsuccessful negotiation must be undone).
  5162.  
  5163. 6.9  Protocol Errors
  5164.  
  5165.      The authors recognize that mapping framed messages over a "stream" 
  5166.      connection, such as TCP, make the proposed mechanisms vulnerable to 
  5167.      simple software framing errors. On the other hand, the introduction of 
  5168.      framing mechanisms to limit the effects of these errors may be onerous 
  5169.      on performance for simple implementations.  Command Sequence Numbers 
  5170.      and the above mechanisms for connection drop and re-establishment 
  5171.      help handle this type of mapping errors. 
  5172.  
  5173.      All violations of iSCSI PDU exchange sequences specified in this draft 
  5174.      are also protocol errors.  This category of errors can be only be 
  5175.      addressed by fixing the implementations; iSCSI defines Reject and 
  5176.      response codes to enable this.
  5177.  
  5178. 6.10  Connection Failures
  5179.  
  5180.      iSCSI can keep a session in operation if it is able to keep/establish 
  5181.      at least one TCP connection between the initiator and the target in a 
  5182.      timely fashion.  It is assumed that targets and/or initiators recog-
  5183.      nize a failing connection by either transport level means (TCP), a gap 
  5184.      in the command, a response stream that is not filled for a long time, 
  5185.      or by a failing iSCSI NOP (ping). The latter MAY be used periodically 
  5186.      by highly reliable implementations.  Initiators and targets MAY also 
  5187.      use the keep-alive option on the TCP connection to enable early link 
  5188.      failure detection on otherwise idle links. 
  5189.  
  5190.      On connection failure, the initiator and target MUST do one of the 
  5191.      following:
  5192.  
  5193.        - Attempt connection recovery within the session (Section 6.12.3 
  5194.          Connection Recovery).
  5195.        - Logout the connection with the reason code "closes the connec-
  5196.          tion" (Section 9.14.3 Reason Code), re-issue missing commands, 
  5197.          and implicitly terminate all active commands. This option 
  5198.          requires support for the within-connection recovery class 
  5199.          (Section 6.12.2 Recovery Within-connection).
  5200.        - Perform session recovery (Section 6.12.4 Session Recovery).
  5201.  
  5202.      Either side may choose to escalate to session recovery, and the other 
  5203.      side MUST give it precedence.  On a connection failure, a target MUST 
  5204.  
  5205. Julian Satran                Expires August  2002                       100
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.                                      iSCSI                      17-April-02
  5212.  
  5213.      terminate and/or discard all the active immediate commands regardless 
  5214.      of which of the above options is used (i.e., immediate commands are 
  5215.      not recoverable across connection failures).
  5216.  
  5217. 6.11  Session Errors
  5218.  
  5219.      If all the connections of a session fail and cannot be re-established 
  5220.      in a short time, or if initiators detect protocol errors repeatedly, 
  5221.      an initiator may choose to terminate a session and establish a new 
  5222.      session. 
  5223.      The initiator takes the following actions:
  5224.  
  5225.        - It resets or closes all the transport connections.  
  5226.        - It terminates all outstanding requests with an appropriate 
  5227.          response before initiating a new session.  
  5228.  
  5229.      When the session timeout (the connection state timeout for the last 
  5230.      failed connection) happens on the target, it takes the following 
  5231.      actions:
  5232.  
  5233.        - Resets or closes the TCP connections (closes the session).
  5234.        - Aborts all Tasks in the task set for the corresponding initi-
  5235.          ator.
  5236.  
  5237. 6.12  Recovery Classes 
  5238.  
  5239.      iSCSI enables the following classes of recovery (in the order of 
  5240.      increasing scope of affected iSCSI tasks):
  5241.  
  5242.        - Within a command (i.e., without requiring command restart).
  5243.        - Within a connection (i.e., without requiring the connection to 
  5244.          be rebuilt, but perhaps requiring command restart).
  5245.        - Connection recovery (i.e., perhaps requiring connections to be 
  5246.          rebuilt and commands to be reissued).
  5247.        - Session recovery.
  5248.  
  5249.      The recovery scenarios detailed in the rest of this section are repre-
  5250.      sentative rather than exclusive. In every case, they detail the lowest 
  5251.      class recovery that MAY be attempted. The implementer is left to 
  5252.      decide under which circumstances to escalate to the next recovery 
  5253.      class and/or what recovery classes to implement.  Both the iSCSI tar-
  5254.      get and initiator MAY escalate the error handling to an error recovery 
  5255.      class, which impacts a larger number of iSCSI tasks in any of the 
  5256.      cases identified in the following discussion.
  5257.  
  5258.  
  5259.  
  5260. Julian Satran                 Expires August  2002                      101
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.                                     iSCSI                     17-April-02
  5267.  
  5268.      In all classes, the implementer has the choice of deferring errors to 
  5269.      the SCSI initiator (with an appropriate response code), in which case 
  5270.      the task, if any, has to be removed from the target and all the side-
  5271.      effects, such as ACA, must be considered.
  5272.  
  5273.      Use of within-connection and within-command recovery classes MUST NOT 
  5274.      be attempted before the connection is in full feature phase.
  5275.  
  5276. 6.12.1  Recovery Within-command 
  5277.  
  5278.      At the target, the following cases lend themselves to within-command 
  5279.      recovery:
  5280.  
  5281.        - Lost data PDU - realized through one of the following:
  5282.         a)  Data digest error - dealt with as specified in Section 6.5 
  5283.         Digest Errors, using the option of a recovery R2T.
  5284.         b)  Sequence reception timeout (no data or partial-data-and-no-F-
  5285.         bit) - considered an implicit sequence error and dealt with as 
  5286.         specified in Section 6.6 Sequence Errors, using the option of a 
  5287.         recovery R2T.
  5288.         c)  Header digest error, which manifests as a sequence reception 
  5289.         timeout, or a sequence error - dealt with as specified in Section 
  5290.         6.6 Sequence Errors, using the option of a recovery R2T.
  5291.  
  5292.      At the initiator, the following cases lend themselves to within-com-
  5293.      mand recovery:
  5294.  
  5295.        Lost data PDU or lost R2T - realized through one of the follow-
  5296.          ing:
  5297.         a)  Data digest error - dealt with as specified in Section 6.5 
  5298.         Digest Errors, using the option of a SNACK.
  5299.         b)  Sequence reception timeout (no status) - dealt with as speci-
  5300.         fied in Section 6.6 Sequence Errors, using the option of a SNACK.
  5301.         c)  Header digest error, which manifests as a sequence reception 
  5302.         timeout, or a sequence error - dealt with as specified in Section 
  5303.         6.6 Sequence Errors, using the option of a SNACK.
  5304.  
  5305.      To avoid a race with the target, which may already have a recovery R2T 
  5306.      or a termination response on its way, an initiator SHOULD NOT origi-
  5307.      nate a SNACK for an R2T based on its internal timeouts (if any).   
  5308.      Recovery in this case is better left to the target.
  5309.  
  5310.  
  5311.  
  5312.  
  5313. Julian Satran               Expires August  2002                       102
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.                                     iSCSI                    17-April-02
  5320.  
  5321.      The timeout values used by the initiator and target are outside the 
  5322.      scope of this document.  Sequence reception timeout is generally a 
  5323.      large enough value to allow the data sequence transfer to be complete.
  5324.  
  5325. 6.12.2  Recovery Within-connection
  5326.  
  5327.      At the initiator, the following cases lend themselves to within-con-
  5328.      nection recovery:
  5329.  
  5330.        - Requests not acknowledged for a long time. Requests are 
  5331.          acknowledged explicitly through ExpCmdSN or implicitly by 
  5332.          receiving data and/or status. The initiator MAY retry non-
  5333.          acknowledged commands as specified in Section 6.1 Retry and 
  5334.          Reassign in Recovery.
  5335.  
  5336.        - Lost iSCSI numbered Response. It is recognized by either iden-
  5337.          tifying a data digest error on a Response PDU or a Data-In PDU 
  5338.          carrying the status, or by receiving a Response PDU with a 
  5339.          higher StatSN than expected. In the first case, digest error 
  5340.          handling is done as specified in Section 6.5 Digest Errors 
  5341.          using the option of a SNACK. In the second case, sequence 
  5342.          error handling is done as specified in Section 6.6 Sequence 
  5343.          Errors, using the option of a SNACK.
  5344.  
  5345.      At the target, the following cases lend themselves to within-connec-
  5346.      tion recovery:
  5347.  
  5348.        - Status/Response not acknowledged for a long time. The target 
  5349.          MAY issue a NOP-IN (with a valid Target Transfer Tag or other-
  5350.          wise) that carries the next status sequence number it is going 
  5351.          to use in the StatSN field.  This helps the initiator detect 
  5352.          any missing StatSN(s) and issue a SNACK for the status.
  5353.  
  5354.      The timeout values used by the initiator and the target are outside 
  5355.      the scope of this document.
  5356.  
  5357. 6.12.3  Connection Recovery
  5358.  
  5359.      At an iSCSI initiator, the following cases lend themselves to connec-
  5360.      tion recovery:
  5361.  
  5362.        - TCP connection failure. The initiator MUST close the connec-
  5363.          tion. It then MUST either Logout the failed connection, or 
  5364.          Login with an implied Logout, and reassign connection alle-
  5365.          giance for all commands still in progress associated with the 
  5366.          failed connection on another connection (that MAY be a newly 
  5367.          established connection) using the "Task reassign" task manage-
  5368.  
  5369. Julian Satran              Expires August  2002                         103
  5370.  
  5371.  
  5372.  
  5373.  
  5374.  
  5375.                                    iSCSI                      17-April-02
  5376.  
  5377.          ment function (see Section 9.5.1 Function). Note that for an 
  5378.          initiator a command is in progress as long as it has not 
  5379.          received for a response or a Data-In PDU including status. 
  5380.  
  5381.        - N.B. The logout function is mandatory, while a new connection 
  5382.          establishment is mandatory only if the failed connection was 
  5383.          the last or only connection in the session.
  5384.  
  5385.        - Receiving an Asynchronous Message that indicates one or all 
  5386.          connections in a session has been dropped.  The initiator MUST 
  5387.          handle it as a TCP connection failure for the connection(s) 
  5388.          referred to in the Message.
  5389.  
  5390.      At an iSCSI target, the following cases lend themselves to connection 
  5391.      recovery:
  5392.  
  5393.        - TCP connection failure. The target MUST close the connection 
  5394.          and if more than one connection is available, the target 
  5395.          SHOULD send an Asynchronous Message that indicates it has 
  5396.          dropped the connection. Then, the target will wait for the 
  5397.          initiator to continue recovery.
  5398.  
  5399. 6.12.4  Session Recovery
  5400.  
  5401.      Session recovery should be performed when all other recovery attempts 
  5402.      have failed.  Very simple initiators and targets MAY perform session 
  5403.      recovery on all iSCSI errors and therefore, place the burden of recov-
  5404.      ery on the SCSI layer and above.
  5405.  
  5406.      Session recovery implies the closing of all TCP connections, inter-
  5407.      nally aborting all executing and queued tasks for the given initiator 
  5408.      at the target, terminating all outstanding SCSI commands with an 
  5409.      appropriate SCSI service response at the initiator, and restarting a 
  5410.      session on a new set of connection(s) (TCP connection establishment 
  5411.      and login on all new connections).  
  5412.  
  5413.      For possible clearing effects of session recovery on SCSI and iSCSI 
  5414.      objects, refer to Appendix F. - Clearing effects of various events on 
  5415.      targets -.
  5416.  
  5417. 6.13  Error Recovery Hierarchy
  5418.  
  5419.      The error recovery classes and features described are organized into a 
  5420.      hierarchy for ease in understanding and to limit the myriad of imple-
  5421.      mentation possibilities, with hopes that this significantly contrib-
  5422.  
  5423.  
  5424. Julian Satran               Expires August  2002                        104
  5425.  
  5426.  
  5427.  
  5428.  
  5429.  
  5430.                                       iSCSI                  17-April-02
  5431.  
  5432.      utes to highly interoperable implementations.  The attributes of this 
  5433.      hierarchy are as follows:
  5434.  
  5435.         a)  Each level is a superset of the capabilities of the previous 
  5436.         level. For example, Level 1 support implies supporting all capa-
  5437.         bilities of Level 0 and more. 
  5438.         b)  As a corollary, supporting a higher error recovery level means 
  5439.         increased sophistication and possibly an increase in resource 
  5440.         requirement. 
  5441.         c)  Supporting error recovery level "n" is advertised and negoti-
  5442.         ated by each iSCSI entity by exchanging the text key "ErrorRecov-
  5443.         eryLevel=n".  The lower of the two exchanged values is the 
  5444.         operational ErrorRecoveryLevel for the session.
  5445.  
  5446.      The following diagram represents the error recovery hierarchy.
  5447.  
  5448.                                 +
  5449.                                / \
  5450.                               / 2 \       <-- Connection recovery 
  5451.                              +-----+
  5452.                             /   1   \     <-- Digest failure recovery
  5453.                            +---------+
  5454.                           /     0     \   <-- Session failure recovery
  5455.                          +-------------+
  5456.  
  5457.      The following table lists the error recovery capabilities expected 
  5458.      from the implementations that support each error recovery level.
  5459.  
  5460.      +-------------------+--------------------------------------------+
  5461.      |ErrorRecoveryLevel |  Associated Error recovery capabilities    |
  5462.      +-------------------+--------------------------------------------+
  5463.      |        0          |  Session recovery class                    |
  5464.      |                   |  (Section 6.12.4 Session Recovery)         |
  5465.      +-------------------+--------------------------------------------+
  5466.      |        1          |  Digest failure recovery (See Note below.) |
  5467.      +-------------------+--------------------------------------------+
  5468.      |        2          |  Connection recovery class                 |
  5469.      |                   |  (Section 6.12.3 Connection Recovery)      | 
  5470.      +-------------------+--------------------------------------------+
  5471.  
  5472.      Note: Digest failure recovery is comprised of two recovery classes: 
  5473.      Within-Connection recovery class (Section 6.12.2 Recovery Within-con-
  5474.  
  5475.  
  5476. Julian Satran              Expires August  2002                          105
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.                                   iSCSI                      17-April-02
  5483.  
  5484.      nection) and Within-Command recovery class (Section 6.12.1 Recovery 
  5485.      Within-command).
  5486.  
  5487.      Supporting error recovery level "0" is mandatory, while the rest are 
  5488.      optional to implement.  In implementation terms, the above striation 
  5489.      means that the following incremental sophistication with each level 
  5490.      is required.
  5491.  
  5492.      +-------------------+---------------------------------------------+
  5493.      |Level transition   |  Incremental requirement                    |
  5494.      +-------------------+---------------------------------------------+
  5495.      |        0->1       |  PDU retransmissions on the same connection |
  5496.      +-------------------+---------------------------------------------+
  5497.      |        1->2       |  Retransmission across connections and      |
  5498.      |                   |  allegiance reassignment                    |
  5499.      +-------------------+---------------------------------------------+
  5500.  
  5501.  
  5502.  
  5503.  
  5504.  
  5505. Julian Satran              Expires August  2002                      106
  5506.  
  5507.  
  5508.  
  5509.  
  5510.  
  5511.                                    iSCSI                      17-April-02
  5512.  
  5513. 7. Security Considerations
  5514.  
  5515.      Historically, native storage systems have not had to consider secu-
  5516.      rity because their environments offered minimal security risks. That 
  5517.      is, these environments consisted of storage devices either directly 
  5518.      attached to hosts or connected via a subnet distinctly separate from 
  5519.      the communications network. The use of storage protocols, such as 
  5520.      SCSI, over IP networks requires that security concerns be addressed. 
  5521.      iSCSI implementations MUST provide means of protection against active 
  5522.      attacks (e.g., pretending to be another identity, message insertion, 
  5523.      deletion, modification, and replaying) and passive attacks 
  5524.      (e.g.,eavesdropping, gaining advantage by analyzing the data sent 
  5525.      over the line). 
  5526.  
  5527.      Although technically possible, iSCSI SHOULD NOT be configured without 
  5528.      security. iSCSI without security should be confined, in extreme 
  5529.      cases, to closed environments without any security risk. 
  5530.  
  5531.      The following section describes the security mechanisms provided by 
  5532.      an iSCSI implementation.
  5533.  
  5534. 7.1  iSCSI Security Mechanisms
  5535.  
  5536.      The entities involved in iSCSI security are the initiator, target, and 
  5537.      the IP communication end points. iSCSI scenarios where multiple ini-
  5538.      tiators or targets share a single communication end point are 
  5539.      expected. To accommodate such scenarios, iSCSI uses two separate 
  5540.      security mechanisms: In-band authentication between the initiator and 
  5541.      the target at the iSCSI connection level (carried out by exchange of 
  5542.      iSCSI Login PDUs), and packet protection (integrity, authentication, 
  5543.      and confidentiality) by IPsec at the IP level. The two security mech-
  5544.      anisms complement each other: The in-band authentication provides 
  5545.      end-to-end trust (at login time) between the iSCSI initiator and the 
  5546.      target, while IPsec provides a secure channel between the IP communi-
  5547.      cation end points. 
  5548.  
  5549.      Further details on typical iSCSI scenarios and the relation between 
  5550.      the initiators, targets, and the communication end points can be found 
  5551.      in [SEC-IPS].
  5552.  
  5553.  
  5554.  
  5555.  
  5556.  
  5557. Julian Satran               Expires August  2002                         107
  5558.  
  5559.  
  5560.  
  5561.  
  5562.  
  5563.                                    iSCSI                         17-April-02
  5564.  
  5565. 7.2  In-band Initiator-Target Authentication
  5566.  
  5567.      With this mechanism, the target authenticates the initiator and the 
  5568.      initiator optionally authenticates the target. The authentication is 
  5569.      performed on every new iSCSI connection by an exchange of iSCSI Login 
  5570.      PDUs using a negotiated authentication method. 
  5571.  
  5572.      The authentication method cannot assume an underlying IPsec protec-
  5573.      tion, since IPsec is optional to use. An attacker should gain as lit-
  5574.      tle advantage as possible by inspecting the authentication phase 
  5575.      PDUs. Therefore, a method using clear text (or equivalent) passwords 
  5576.      is not acceptable; on the other hand, identity protection is not 
  5577.      strictly required. 
  5578.  
  5579.      This mechanism protects against an unauthorized login to storage 
  5580.      resources by using a false identity (spoofing). Once the authentica-
  5581.      tion phase is completed, if the underlying IPsec is not used, all PDUs 
  5582.      are sent and received in clear. This mechanism alone (without underly-
  5583.      ing IPsec) should only be used when there is no risk of eavesdropping, 
  5584.      message insertion, deletion, modification, and replaying.  
  5585.  
  5586.      The CHAP authentication method (see [RFC1994]) is vulnerable to an 
  5587.      off-line dictionary attack. In environments where this attack is a 
  5588.      concern, CHAP SHOULD NOT be used without additional protection. 
  5589.      Underlying IPsec encryption provides protection against this attack. 
  5590.  
  5591.  
  5592.      The strength of the SRP authentication method (specified in 
  5593.      [RFC2945]) is dependent on the characteristics of the group being used 
  5594.      (i.e., the prime modulus N and generator g). As described in 
  5595.      [RFC2945], N is required to be a Sophie-German prime (of the form N = 
  5596.      2q + 1, where q is also prime) and the generator g is a primitive root 
  5597.      of GF(n). In iSCSI authentication, the prime modulus N MUST be at 
  5598.      least 768 bits.
  5599.  
  5600.      Upon receiving N and g from the Target, the Initiator MUST verify that 
  5601.      they satisfy the above requirements (and otherwise, abort the connec-
  5602.      tion). This verification MAY start by trying to match N and g with a 
  5603.      well-known group that satisfies the above requirements. 
  5604.      Well-known SRP groups are provided in [SEC-IPS]. 
  5605.  
  5606.      Compliant iSCSI initiators and targets MUST at least implement the SRP 
  5607.      authentication method [RFC2945] (see Chapter 10).
  5608.  
  5609.  
  5610. Julian Satran               Expires August  2002                         108
  5611.  
  5612.  
  5613.  
  5614.  
  5615.  
  5616.                                      iSCSI                       17-April-02
  5617.  
  5618.  
  5619.  
  5620. 7.3  IPsec 
  5621.  
  5622.      The IPsec mechanism is used by iSCSI for packet protection (crypto-
  5623.      graphic integrity, authentication, and confidentiality) at the IP 
  5624.      level between the iSCSI communicating end points. The following sec-
  5625.      tions describe the IPsec protocols that must be implemented for data 
  5626.      integrity and authentication, confidentiality, and key management.
  5627.  
  5628.      Detailed considerations and recommendations for using IPsec for iSCSI 
  5629.      are provided in [SEC-IPS].  
  5630.  
  5631. 7.3.1  Data Integrity and Authentication
  5632.  
  5633.      Data authentication and integrity is provided by a keyed Message 
  5634.      Authentication Code in every sent packet. This code protects against 
  5635.      message insertion, deletion, and modification.  Protection against 
  5636.      message replay is realized by using a sequence counter. 
  5637.  
  5638.      An iSCSI compliant initiator or target MUST provide data integrity and 
  5639.      authentication by implementing IPsec [RFC2401] with ESP in tunnel 
  5640.      mode [RFC2406] and MAY provide data integrity and authentication by 
  5641.      implementing IPsec with ESP in transport mode. The IPsec implementa-
  5642.      tion MUST fulfill the following iSCSI specific requirements:
  5643.  
  5644.        - HMAC-SHA1 MUST be implemented [RFC2404].
  5645.        - AES CBC MAC with XCBC extensions SHOULD be implemented 
  5646.          [AESCBC].
  5647.  
  5648.      The ESP anti-replay service MUST also be implemented. 
  5649.  
  5650.      At the high speeds iSCSI is expected to operate, a single IPsec SA 
  5651.      could rapidly cycle through the 32-bit IPsec sequence number space.
  5652.      In view of this, in the future it may be desirable for an iSCSI imple-
  5653.      mentation that operates at speeds of 1 Gbps or faster to implement the 
  5654.      IPsec sequence number extension [SEQ-EXT].
  5655.  
  5656. 7.3.2  Confidentiality
  5657.  
  5658.      Confidentiality is provided by encrypting the data in every packet. 
  5659.      When confidentiality is used it MUST be accompanied by data integrity 
  5660.      and authentication to provide comprehensive protection against eaves-
  5661.      dropping, message insertion, deletion, modification, and replaying.
  5662.  
  5663.  
  5664. Julian Satran               Expires August  2002                         109
  5665.  
  5666.  
  5667.  
  5668.  
  5669.  
  5670.                                     iSCSI                       17-April-02
  5671.  
  5672.  
  5673.      An iSCSI compliant initiator or target MUST provide confidentiality 
  5674.      by implementing IPsec [RFC2401] with ESP in tunnel mode [RFC2406] with 
  5675.      the following iSCSI specific requirements:
  5676.  
  5677.        - 3DES in CBC mode MUST be implemented [RFC2451].
  5678.        - AES in Counter mode SHOULD be implemented [AESCTR] (NOTE: This 
  5679.          is still subject to the IPsec WG's standardization plans). 
  5680.  
  5681.      If the IPsec implementation of an iSCSI initiator or target conforms 
  5682.      to the [RFC2401] definition of a host, then to comply with section 4.1 
  5683.      of [RFC2401] it MUST also implement ESP in transport mode (with the 
  5684.      same requirements above).  
  5685.  
  5686.      DES in CBC mode SHOULD NOT be used due to its inherent weakness.
  5687.      The NULL encryption algorithm MUST also be implemented.
  5688.  
  5689. 7.3.3  Policy, Security Associations and Key Management
  5690.  
  5691.      A compliant iSCSI implementation MUST meet the key management 
  5692.      requirements of the IPsec protocol suite. Authentication, security 
  5693.      association negotiation, and key management MUST be provided by 
  5694.      implementing IKE [RFC2409] using the IPsec DOI [RFC2407] with the fol-
  5695.      lowing iSCSI specific requirements:
  5696.  
  5697.        - Peer authentication using a pre-shared key MUST be supported.  
  5698.          Certificate-based peer authentication using digital signa-
  5699.          tures MAY be supported. Peer authentication using the public 
  5700.          key encryption methods outlined in IKE sections 5.2 and 5.3[7] 
  5701.          SHOULD NOT be used. 
  5702.  
  5703.        - When digital signatures are used to achieve authentication, an 
  5704.          IKE negotiator SHOULD use IKE Certificate Request Payload(s) 
  5705.          to specify the certificate authority. IKE negotiators SHOULD 
  5706.          check the pertinent Certificate Revocation List (CRL) before 
  5707.          accepting a PKI certificate for use in IKE authentication pro-
  5708.          cedures. 
  5709.  
  5710.        - Both IKE Main Mode and Aggressive Mode MUST be supported. IKE 
  5711.          main mode with pre-shared key authentication method SHOULD NOT 
  5712.          be used when either the initiator or the target uses dynami-
  5713.          cally assigned IP addresses. While pre-shared keys in many 
  5714.          cases offer good security, situations where dynamically 
  5715.          assigned addresses are used force the use of a group pre-
  5716.          shared key, which creates vulnerability to a man-in-the-middle 
  5717.          attack. 
  5718.  
  5719.  
  5720. Julian Satran               Expires August  2002                         110
  5721.  
  5722.  
  5723.  
  5724.  
  5725.  
  5726.                                    iSCSI                        17-April-02
  5727.  
  5728.        - In the IKE Phase 2 Quick Mode exchanges for creating the Phase 
  5729.          2 SA, the Identity Payload fields MUST be present. 
  5730.          ID_IPV4_ADDR, ID_IPV6_ADDR (if the protocol stack supports 
  5731.          IPv6) and ID_FQDN Identity payloads MUST be supported; 
  5732.          ID_USER_FQDN MAY be supported. The IP Subnet, IP Address 
  5733.          Range, ID_DER_ASN1_DN, ID_DER_ASN1_GN formats SHOULD NOT be 
  5734.          used. The ID_KEY_ID Identity Payload MUST NOT be used.
  5735.  
  5736.      Manual keying MUST NOT be used since it does not provide the necessary 
  5737.      re-keying support.
  5738.  
  5739.  
  5740.      When IPsec is used the receipt of an IKE Phase 2 delete message SHOULD 
  5741.      NOT be interpreted as a reason for tearing down the iSCSI TCP connec-
  5742.      tion. If additional traffic is sent on it, a new IKE Phase 2 SA will 
  5743.      be created to protect it. 
  5744.  
  5745.  
  5746.      The method used by the initiator to determine whether the target 
  5747.      should be connected using IPsec is regarded as an issue of IPsec pol-
  5748.      icy administration, and thus not defined in the iSCSI standard. How-
  5749.      ever, as iSCSI has an in-band discovery mechanism (discovery session 
  5750.      and SendTargets), the use or non-use of IPsec in any operational ses-
  5751.      sion is assumed to be identical to that of the discovery session.
  5752.  
  5753.      If an iSCSI target is discovered via a SendTargets request in a dis-
  5754.      covery session not using IPsec, the initiator should assume that it 
  5755.      does not need IPsec to establish a session to that target.  If an 
  5756.      iSCSI target is discovered using a discovery session that does use 
  5757.      IPsec, the initiator should use IPsec when establishing a session to 
  5758.      that target.
  5759.  
  5760.  
  5761.  
  5762.  
  5763.  
  5764. Julian Satran               Expires August  2002                        111
  5765.  
  5766.  
  5767.  
  5768.  
  5769.  
  5770.                                    iSCSI                     17-April-02
  5771.  
  5772. 8. Notes to Implementers
  5773.  
  5774.      This section notes some of the performance and reliability consider-
  5775.      ations of the iSCSI protocol.  This protocol was designed to allow 
  5776.      efficient silicon and software implementations. The iSCSI task tag 
  5777.      mechanism was designed to enable RDMA at the iSCSI level or lower.
  5778.  
  5779.      The guiding assumption made throughout the design of this protocol is 
  5780.      that targets are resource constrained relative to initiators. 
  5781.  
  5782.      Implementers are also advised to consider the implementation conse-
  5783.      quences of the iSCSI to SCSI mapping model as outlined in Section 
  5784.      2.4.3 Consequences of the Model. 
  5785.  
  5786. 8.1  Multiple Network Adapters
  5787.  
  5788.      The iSCSI protocol allows multiple connections, not all of which need 
  5789.      to go over the same network adapter. If multiple network connections 
  5790.      are to be utilized with hardware support, the iSCSI protocol command-
  5791.      data-status allegiance to one TCP connection ensures that there is no 
  5792.      need to replicate information across network adapters or otherwise 
  5793.      require them to cooperate.
  5794.  
  5795.      However, some task management commands may require some loose form of 
  5796.      cooperation or replication at least on the target.
  5797.  
  5798. 8.1.1  Conservative Reuse of ISIDs
  5799.  
  5800.      Historically, the SCSI model (and implementations and applications 
  5801.      based on that model) has assumed that SCSI ports are static, physical 
  5802.      entities. Recent extensions to the SCSI model have taken advantage of 
  5803.      persistent worldwide unique names for these ports. In iSCSI however, 
  5804.      the SCSI initiator ports are the endpoints of dynamically created ses-
  5805.      sions, so the presumption of "static and physical" does not apply. In 
  5806.      any case, the model clauses (particularly, Section 2.4.2 SCSI Archi-
  5807.      tecture Model) provide for persistent, reusable names for the iSCSI-
  5808.      type SCSI initiator ports even though there does not need to be any 
  5809.      physical entity bound to these names.
  5810.  
  5811.      To both minimize the disruption of legacy applications and to better 
  5812.      facilitate the SCSI features that rely on persistent names for SCSI 
  5813.      ports, iSCSI implementations should attempt to provide a stable pre-
  5814.      sentation of SCSI Initiator Ports (both to the upper OS-layers and to 
  5815.  
  5816.  
  5817. Julian Satran               Expires August  2002                       112
  5818.  
  5819.  
  5820.  
  5821.  
  5822.  
  5823.                                      iSCSI                     17-April-02
  5824.  
  5825.      the targets to which they connect). This can be achieved in an initi-
  5826.      ator implementation by conservatively reusing ISIDs. In other words, 
  5827.      the same ISID should be used in the Login process to multiple target 
  5828.      portal groups (of the same iSCSI Target or different iSCSI Targets). 
  5829.      The ISID RULE (Section 2.4.3 Consequences of the Model) only prohibits 
  5830.      reuse to the same target portal group. It does not "preclude" reuse to 
  5831.      other target portal groups. 
  5832.      The principle of conservative reuse "encourages" reuse to other tar-
  5833.      get portal groups.  When a SCSI target device sees the same (Initia-
  5834.      torName, ISID) pair in different sessions to different target portal 
  5835.      groups, it can identify the underlying SCSI Initiator Port on each 
  5836.      session as the same SCSI port. In effect, it can recognize multiple 
  5837.      paths from the same source.
  5838.  
  5839. 8.1.2  iSCSI Name, ISID and TPGT Use
  5840.  
  5841.      The designers of the iSCSI protocol envisioned there being 
  5842.      one iSCSI Initiator Node Name per operating system image on a machine.  
  5843.      This enables SAN resource configuration and authentication schemes 
  5844.      based on a system's identity.  It supports the notion that it should 
  5845.      be possible to assign access to storage resources based on "initiator 
  5846.      device" identity. 
  5847.            
  5848.      When there are multiple hardware or software components coordinated 
  5849.      as a single iSCSI Node, there must be some (logical) entity that rep-
  5850.      resents the iSCSI Node that makes the iSCSI Node Name available to all 
  5851.      components involved in session creation and login. Similarly, this 
  5852.      entity that represents the iSCSI Node must be able to coordinate ses-
  5853.      sion identifier resources (ISID for initiators) to enforce both the 
  5854.      ISID and TSIH RULES (see Section Section 2.4.3 Consequences of the 
  5855.      Model).
  5856.  
  5857.      For targets, because of the closed environment, implementation of 
  5858.      this entity should be straightforward. However, vendors of iSCSI 
  5859.      hardware (e.g., NICs or HBAs) intended for targets, should provide 
  5860.      mechanisms for configuration of the iSCSI Node Name across the portal 
  5861.      groups instantiated by multiple instances of these components within 
  5862.      a target. 
  5863.  
  5864.      However complex targets making use of multiple Target Portal Group 
  5865.      Tags may reconfigure them to achieve various quality goals.  The ini-
  5866.      tiators have two mechanisms at their disposal to discover and/or check 
  5867.      reconfiguring targets - the discovery session type and a key returned 
  5868.  
  5869.  
  5870. Julian Satran               Expires August  2002                        113
  5871.  
  5872.  
  5873.  
  5874.  
  5875.  
  5876.                                      iSCSI                       17-April-02
  5877.  
  5878.      by the target during login to confirm the TPGT.  An initiator should 
  5879.      attempt to "rediscover" the target configuration anytime a session is 
  5880.      terminated unexpectedly.
  5881.  
  5882.      For initiators, in the long term, it is expected that operating system 
  5883.      vendors will take on the role of this entity and provide standard APIs 
  5884.      that can inform components of their iSCSI Node Name and can configure 
  5885.      and/or coordinate ISID allocation, use and reuse.
  5886.       
  5887.      Recognizing that such initiator APIs are not available today, other 
  5888.      implementations of the role of this entity are possible.
  5889.      For example, a human may instantiate the (common) Node name as part of 
  5890.      the installation process of each iSCSI component involved in session 
  5891.      creation and login. This may be done either by pointing the component 
  5892.      to a vendor-specific location for this datum or to a system-wide loca-
  5893.      tion. The structure of the ISID namespace (see Section 9.12.5 ISID and 
  5894.      [NDT]) facilitates implementation of the ISID coordination by allow-
  5895.      ing each component vendor to independently (of other vendor's compo-
  5896.      nents) coordinate allocation and use and reuse its own partition of 
  5897.      the ISID namespace in a vendor-specific manner. Partitioning of the 
  5898.      ISID namespace within initiator portal groups managed by that vendor 
  5899.      allows each such initiator portal group to act independently of all 
  5900.      other portal groups when selecting an ISID for a login; this facili-
  5901.      tates enforcement of the ISID RULE (see Section 2.4.3 Consequences of 
  5902.      the Model) at the initiator.
  5903.  
  5904.      A vendor of iSCSI hardware (e.g., NICs or HBAs) intended for use in 
  5905.      the initiators must allow, in addition to a mechanism for configuring 
  5906.      the iSCSI Node Name, for a mechanism to configure and/or coordinate 
  5907.      ISIDs for all sessions managed by multiple instances of that hardware 
  5908.      within a given iSCSI Node.  Such configuration might be either perma-
  5909.      nently pre-assigned at the factory (in a necessarily globally unique 
  5910.      way), statically assigned (e.g., partitioned across all the NICs at 
  5911.      initialization in a locally unique way), or dynamically assigned 
  5912.      (e.g., on-line allocator, also in a locally unique way).  In the lat-
  5913.      ter two cases, the configuration may be via public APIs (perhaps 
  5914.      driven by an independent vendor's SW, such as the OS vendor) or via 
  5915.      private APIs driven by the vendor's own SW. 
  5916.  
  5917.  
  5918.  
  5919.  
  5920.  
  5921. Julian Satran               Expires August  2002                         114
  5922.  
  5923.  
  5924.  
  5925.  
  5926.  
  5927.                                    iSCSI                       17-April-02
  5928.  
  5929. 8.2  Autosense and Auto Contingent Allegiance (ACA)
  5930.  
  5931.      Autosense refers to the automatic return of sense data to the initia-
  5932.      tor in case a command did not complete successfully. iSCSI initiators 
  5933.      and targets MUST support autosense.
  5934.  
  5935.      ACA helps preserve ordered command execution in the presence of 
  5936.      errors.  As iSCSI can have many commands in-flight between initiator 
  5937.      and target, iSCSI initiators and targets SHOULD support ACA.
  5938.  
  5939. 8.3  iSCSI timeouts
  5940.  
  5941.      iSCSI recovery actions are often dependent on iSCSI timeouts being 
  5942.      recognized and acted upon before SCSI timeouts. Determining the right 
  5943.      timeouts to use for various iSCSI actions (command acknowledgements 
  5944.      expected, status acknowledgements etc.) is very much dependent on 
  5945.      infrastructure (hardware, links, TCP/IP stack, iSCSI driver). As a 
  5946.      guidance the implementer may use an average Nop-Out/Nop-In turnaround 
  5947.      delay multiplied by a "safety factor" (2-3) as a good estimate for the 
  5948.      basic delay of the iSCSI stack for a given connection.
  5949.  
  5950. 8.4  Command Retry and Cleaning Old Command Instances
  5951.  
  5952.      To avoid having old, retried command instances appear in a valid com-
  5953.      mand window after a command sequence number wrap around, the protocol 
  5954.      requires (see Section 2.2.2.1 Command Numbering and Acknowledging) 
  5955.      that on every connection on which a retry has been issued, a non-imme-
  5956.      diate command be issued and acknowledged within a 2**31-1 commands 
  5957.      interval from the CmdSN of the retried command. This requirement can 
  5958.      be fulfilled by an implementation in several ways.
  5959.  
  5960.      The simplest technique to use is to send a (non-retry) non-immediate 
  5961.      SCSI command (or a NOP if no SCSI command is available for a while) 
  5962.      after every command retry on the connection on which the retry was 
  5963.      attempted.  As errors are deemed rare events, this technique is prob-
  5964.      ably the most effective, as it does not involve additional checks at 
  5965.      the initiator when issuing commands.
  5966.  
  5967. 8.5  Synch and Steering Layer and Performance
  5968.  
  5969.      While a synch and steering layer is optional, an initiator/target that 
  5970.      does not have it working against a target/initiator that demands synch 
  5971.      and steering may experience performance degradation caused by packet 
  5972.  
  5973.  
  5974. Julian Satran               Expires August  2002                         115
  5975.  
  5976.  
  5977.  
  5978.  
  5979.  
  5980.                                    iSCSI                      17-April-02
  5981.  
  5982.      reordering and loss.  Providing a synch and steering mechanism is rec-
  5983.      ommended for all high-speed implementations.
  5984.  
  5985. 8.6  Considerations for State-dependent devices
  5986.  
  5987.      Sequential access devices operate on the principle that the position 
  5988.      of the device is based on the last command processed. As such, command 
  5989.      processing order and knowledge of whether or not the previous command 
  5990.      was processed is of the utmost importance to maintain data integrity. 
  5991.      As an example, inadvertent retries of SCSI commands when it is not 
  5992.      known if the previous SCSI command was processed is a potential data 
  5993.      integrity risk.  
  5994.  
  5995.      For a sequential access device, consider the scenario where a SCSI 
  5996.      SPACE command to backspace one filemark is issued and then re-issued 
  5997.      due to no status received for the command. If the first SPACE command 
  5998.      was actually processed, the re-issued SPACE command, if processed, 
  5999.      will cause the position to change. Thus, a subsequent write operation 
  6000.      will write data to the wrong position and any previous data at that 
  6001.      position will be overwritten.  
  6002.       
  6003.      For a medium changer device, consider the scenario where an EXCHANGE 
  6004.      MEDIUM command (the SOURCE ADDRESS and DESTINATION ADDRESS are the 
  6005.      same thus performing a swap) is issued and then re-issued due to no 
  6006.      status received for the command. If the first EXCHANGE MEDIUM command 
  6007.      was actually processed, the re-issued EXCHANGE MEDIUM command, if 
  6008.      processed, will perform the swap again. The net effect is no swap was 
  6009.      performed thus leaving a data integrity exposure.
  6010.  
  6011.      All commands that change the state of the device (as in SPACE commands 
  6012.      for sequential access devices, and EXCHANGE MEDIUM for medium changer 
  6013.      device), MUST be issued as non-immediate commands for deterministic 
  6014.      and in order delivery to iSCSI targets. 
  6015.  
  6016.      For many of those state changing commands the execution model also 
  6017.      assumes  that the command is executed exactly once.  For those com-
  6018.      mands a retry at SCSI level is not feasible or very difficult and 
  6019.      error recovery at iSCSI level is advisable.
  6020.  
  6021. 8.6.1  Determining the proper ErrorRecoveryLevel
  6022.  
  6023.  
  6024.  
  6025.  
  6026.  
  6027. Julian Satran               Expires August  2002                       116
  6028.  
  6029.  
  6030.  
  6031.  
  6032.  
  6033.                                   iSCSI                      17-April-02
  6034.  
  6035.      The implementation and usage of a specific ErrorRecoveryLevel should 
  6036.      be determined based on the deployment scenarios of a given iSCSI 
  6037.      implementation.  Generally, the following factors must be
  6038.      considered before deciding on the proper level of recovery:
  6039.  
  6040.         a)  Application resilience to I/O failures.
  6041.         b)  Required level of availability in the face of transport connec-
  6042.         tion failures. 
  6043.         c)  Probability of transport layer "checksum escape" frequency.  
  6044.         This in turn decides the iSCSI digest failure frequency, and thus 
  6045.         the criticality of iSCSI-level error recovery.  The details of 
  6046.         estimating this probability are outside the scope of this docu-
  6047.         ment.
  6048.  
  6049.      A consideration of the above factors for SCSI tape devices as an exam-
  6050.      ple suggests that implementations SHOULD use ErrorRecoveryLevel=1 
  6051.      when transport connection failure is not a concern, and ErrorRecov-
  6052.      eryLevel=2 when the connection failure is also of high likelihood dur-
  6053.      ing a backup/retrieval.
  6054.  
  6055.  
  6056.  
  6057.  
  6058.  
  6059. Julian Satran              Expires August  2002                       117
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.                                     iSCSI                     17-April-02
  6066.  
  6067. 9. iSCSI PDU Formats
  6068.  
  6069.      All multi-byte integers that are specified in formats defined in this 
  6070.      document are to be represented in network byte order (i.e., big 
  6071.      endian).  Any field that appears in this document assumes that the 
  6072.      most significant byte is the lowest numbered byte and the most signif-
  6073.      icant bit (within byte or field) is the lowest numbered bit unless 
  6074.      specified otherwise.
  6075.  
  6076.      Any compliant sender MUST set all bits not defined and all reserved 
  6077.      fields to zero unless specified otherwise.  Any compliant receiver 
  6078.      MUST ignore any bit not defined and all reserved fields unless speci-
  6079.      fied otherwise.
  6080.  
  6081.      Reserved fields are marked by the word "reserved", some abbreviation 
  6082.      of "reserved" or by "." for individual bits when no other form of 
  6083.      marking is technically feasible.
  6084.  
  6085. 9.1  iSCSI PDU Length and Padding
  6086.  
  6087.      iSCSI PDUs are padded to the closest integer number of four byte 
  6088.      words. The padding bytes SHOULD be 0. 
  6089.  
  6090. 9.2  PDU Template, Header, and Opcodes
  6091.  
  6092.      All iSCSI PDUs have one or more header segments and, optionally, a 
  6093.      data segment.  After the entire header segment group  a header-digest 
  6094.      may follow. The data segment MAY also be followed by a data-digest.  
  6095.  
  6096.      The Basic Header Segment (BHS) is the first segment in all of the 
  6097.      iSCSI PDUs.  The BHS is a fixed-length 48-byte header segment.  It may 
  6098.      be followed by Additional Header Segments (AHS), a Header-Digest, a 
  6099.      Data Segment, and/or a Data-Digest.
  6100.  
  6101.      The overall structure of an iSCSI  PDU is as follows:
  6102.  
  6103.  
  6104.  
  6105.  
  6106.  
  6107. Julian Satran                Expires August  2002                        118
  6108.  
  6109.  
  6110.  
  6111.  
  6112.  
  6113.                                    iSCSI                      17-April-02
  6114.  
  6115.      Byte /    0       |       1       |       2       |       3       |
  6116.         /              |               |               |               |
  6117.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6118.        +---------------+---------------+---------------+---------------+
  6119.       0/ Basic Header Segment (BHS)                                    /
  6120.       +/                                                               /
  6121.        +---------------+---------------+---------------+---------------+
  6122.      48/ Additional Header Segment (AHS)  (optional)                   /
  6123.       +/                                                               /
  6124.        +---------------+---------------+---------------+---------------+
  6125.      ----  
  6126.        +---------------+---------------+---------------+---------------+
  6127.       k/ Header-Digest (optional)                                      /
  6128.       +/                                                               /
  6129.        +---------------+---------------+---------------+---------------+
  6130.       l/ Data Segment(optional)                                        /
  6131.       +/                                                               /
  6132.        +---------------+---------------+---------------+---------------+
  6133.       m/ Data-Digest (optional)                                        /
  6134.       +/                                                               /
  6135.        +---------------+---------------+---------------+---------------+
  6136.  
  6137.      All PDU segments and digests are padded to the closest integer number 
  6138.      of four byte words - i.e., all PDU segments and the digests start at a 
  6139.      four byte word boundary and the padding ranges from 0 to 3 bytes. The 
  6140.      padding bytes SHOULD be sent as 0.
  6141.  
  6142.      iSCSI response PDUs do not have AH Segments.
  6143.  
  6144. 9.2.1  Basic Header Segment (BHS)
  6145.  
  6146.      The BHS is 48 bytes long.  The Opcode and DataSegmentLength fields 
  6147.      appear in all iSCSI PDUs. In addition, when used, the Initiator Task 
  6148.      Tag and Logical Unit Number always appear in the same location in the 
  6149.      header.  
  6150.  
  6151.      The format of the BHS is:
  6152.  
  6153.  
  6154.  
  6155.  
  6156.  
  6157. Julian Satran               Expires August  2002                       119
  6158.  
  6159.  
  6160.  
  6161.  
  6162.  
  6163.                                         iSCSI                   17-April-02
  6164.  
  6165.      Byte /    0       |       1       |       2       |       3       |
  6166.         /              |               |               |               |
  6167.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6168.        +---------------+---------------+---------------+---------------+
  6169.       0|.|I| Opcode    | Opcode-specific fields                        |
  6170.        +---------------+---------------+---------------+---------------+
  6171.       4|TotalAHSLength | DataSegmentLength                             |
  6172.        +---------------+---------------+---------------+---------------+
  6173.       8| LUN or Opcode-specific fields                                 |
  6174.        +                                                               +
  6175.      12|                                                               |
  6176.        +---------------+---------------+---------------+---------------+
  6177.      16| Initiator Task Tag                                            |
  6178.        +---------------+---------------+---------------+---------------+
  6179.      20/ Opcode-specific fields                                        /
  6180.       +/                                                               /
  6181.        +---------------+---------------+---------------+---------------+
  6182.      48
  6183.                      
  6184. 9.2.1.1  I
  6185.  
  6186.      For request PDUs, the I bit set to 1 is an immediate delivery marker.
  6187.       
  6188. 9.2.1.2  Opcode
  6189.  
  6190.      The Opcode indicates the type of iSCSI PDU the header encapsulates. 
  6191.  
  6192.      The Opcodes are divided into two categories: initiator opcodes and 
  6193.      target opcodes. Initiator opcodes are in PDUs sent by the initiators 
  6194.      (request PDUs). Target opcodes are in PDUs sent by the target 
  6195.      (response PDUs). 
  6196.  
  6197.      Initiators MUST NOT use target opcodes and targets MUST NOT use initi-
  6198.      ator opcodes.
  6199.  
  6200.      Initiator opcodes defined in this specification are:
  6201.  
  6202.  
  6203.            0x00 NOP-Out 
  6204.            0x01 SCSI Command (encapsulates a SCSI Command Descriptor Block)
  6205.            0x02 SCSI Task Management Function Request
  6206.            0x03 Login Request
  6207.            0x04 Text Request
  6208.            0x05 SCSI Data-out (for WRITE operations)
  6209.  
  6210.  
  6211. Julian Satran                    Expires August  2002                    120
  6212.  
  6213.  
  6214.  
  6215.  
  6216.  
  6217.                                      iSCSI                    17-April-02
  6218.  
  6219.        0x06 Logout Request
  6220.        0x10 SNACK Request
  6221.        0x1c-0x1e Vendor specific codes
  6222.  
  6223.      Target opcodes are:
  6224.  
  6225.  
  6226.        0x20 NOP-In 
  6227.        0x21 SCSI Response -contains SCSI status and possibly sense 
  6228.          information or other response information.
  6229.        0x22 SCSI Task Management Function Response
  6230.        0x23 Login Response
  6231.        0x24 Text Response
  6232.        0x25 SCSI Data-in -for READ operations.
  6233.        0x26 Logout Response
  6234.        0x31 Ready To Transfer (R2T) - sent by target when it is ready 
  6235.          to receive data.
  6236.        0x32 Asynchronous Message -sent by target to indicate certain 
  6237.          special conditions.
  6238.        0x3c-0x3e Vendor specific codes
  6239.        0x3f Reject
  6240.  
  6241.      All other opcodes are reserved.
  6242.  
  6243. 9.2.1.3  Opcode-specific Fields
  6244.  
  6245.      These fields have different meanings for different opcode types.
  6246.  
  6247. 9.2.1.4  TotalAHSLength
  6248.  
  6249.      Total length of all AHS header segments in four byte words including 
  6250.      padding, if any.
  6251.  
  6252.      The TotalAHSLength is used only in PDUs that have an AHS and MUST be 0 
  6253.      in all other PDUs. 
  6254.  
  6255. 9.2.1.5  DataSegmentLength
  6256.  
  6257.      This is the data segment payload length in bytes (excluding padding). 
  6258.      The DataSegmentLength MUST be 0 whenever the PDU has no data segment.
  6259.  
  6260. 9.2.1.6  LUN
  6261.  
  6262.      Some opcodes operate on a specific Logical Unit. The Logical Unit Num-
  6263.      ber (LUN) field identifies which Logical Unit.  If the opcode does not 
  6264.      relate to a Logical Unit, this field is either ignored or may be used 
  6265.      in an opcode specific way.  The LUN field is 64-bits and should be 
  6266.  
  6267. Julian Satran                 Expires August  2002                       121
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  
  6273.                                          iSCSI                17-April-02
  6274.  
  6275.      formatted in accordance with [SAM2] i.e., LUN[0] from [SAM2] is BHS 
  6276.      byte 8 and so on up to LUN[7] from [SAM2] that is BHS byte 15. 
  6277.  
  6278. 9.2.1.7  Initiator Task Tag 
  6279.  
  6280.      The initiator assigns a Task Tag to each iSCSI task it issues. While a 
  6281.      task exists, this tag MUST uniquely identify it session-wide. 
  6282.      SCSI may also use the initiator task tag as part of the SCSI task 
  6283.      identifier when the time span during which an iSCSI initiator task tag 
  6284.      must be unique extends over the time span during which a SCSI task tag 
  6285.      must be unique.  However, the iSCSI Initiator Task Tag has to exist 
  6286.      and be unique even for untagged SCSI commands.
  6287.  
  6288. 9.2.2  Additional Header Segment (AHS)
  6289.  
  6290.      The general format of an AHS is:
  6291.  
  6292.      Byte /    0       |       1       |       2       |       3       |
  6293.         /              |               |               |               |
  6294.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6295.        +---------------+---------------+---------------+---------------+
  6296.       0| AHSLength                     | AHSType       | AHS-Specific  |
  6297.        +---------------+---------------+---------------+---------------+
  6298.       4/ AHS-Specific                                                  /
  6299.       +/                                                               /
  6300.        +---------------+---------------+---------------+---------------+
  6301.       x
  6302.  
  6303. 9.2.2.1  AHSType 
  6304.  
  6305.      The AHSType field is coded as follows:
  6306.  
  6307.            bit 0-1 - Reserved 
  6308.  
  6309.            bit 2-7 - AHS code 
  6310.  
  6311.             0 - Reserved
  6312.             1 - Extended CDB
  6313.             2 - Expected Bidirectional Read Data Length
  6314.             3 - 59 Reserved
  6315.             60- 63 Non-iSCSI extensions
  6316.  
  6317.  
  6318.  
  6319.  
  6320.  
  6321. Julian Satran                     Expires August  2002                  122
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.                                     iSCSI                     17-April-02
  6328.  
  6329. 9.2.2.2  AHSLength 
  6330.  
  6331.      This field contains the effective length in bytes of the AHS excluding 
  6332.      AHSType and AHSLength (not including padding). The AHS is padded to 
  6333.      the smallest integer number of 4 byte words (i.e., from 0 up to 3 pad-
  6334.      ding bytes). 
  6335.  
  6336. 9.2.2.3  Extended CDB AHS
  6337.  
  6338.      The format of the Extended CDB AHS is:
  6339.  
  6340.      Byte /    0       |       1       |       2       |       3       |
  6341.         /              |               |               |               |
  6342.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6343.        +---------------+---------------+---------------+---------------+
  6344.       0| AHSLength (CDBLength-15)      | 0x01          | Reserved      |
  6345.        +---------------+---------------+---------------+---------------+
  6346.       4/ ExtendedCDB...+padding                                        /
  6347.       +/                                                               /
  6348.        +---------------+---------------+---------------+---------------+
  6349.       x
  6350.  
  6351.  
  6352. 9.2.2.4  Bidirectional Expected Read-Data Length AHS
  6353.  
  6354.      The format of the Bidirectional Read Expected Data Transfer Length AHS 
  6355.      is:
  6356.  
  6357.      Byte /    0       |       1       |       2       |       3       |
  6358.         /              |               |               |               |
  6359.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6360.        +---------------+---------------+---------------+---------------+
  6361.       0| AHSLength (0x0005)            | 0x02          | Reserved      |
  6362.        +---------------+---------------+---------------+---------------+
  6363.       4| Expected Read-Data Length                                     |
  6364.        +---------------+---------------+---------------+---------------+
  6365.       8
  6366.  
  6367. 9.2.3  Header Digest and Data Digest
  6368.  
  6369.      Optional header and data digests protect the integrity of the header 
  6370.      and data, respectively. The digests, if present, are located, respec-
  6371.      tively, after the header and PDU-specific data and cover both the 
  6372.      proper data as well as the padding bytes. 
  6373.  
  6374. Julian Satran                Expires August  2002                      123
  6375.  
  6376.  
  6377.  
  6378.  
  6379.  
  6380.                                    iSCSI                        17-April-02
  6381.  
  6382.  
  6383.      The digest types are negotiated during the login phase.
  6384.  
  6385.      The separation of the header and data digests is useful in iSCSI rout-
  6386.      ing applications, where only the header changes when a message is for-
  6387.      warded. In this case, only the header digest should be re-calculated.
  6388.  
  6389.      Digests are not included in data or header length fields.
  6390.  
  6391.      A zero-length Data Segment also implies a zero-length data-digest.
  6392.        
  6393. 9.2.4  Data Segment
  6394.  
  6395.      The (optional) Data Segment contains PDU associated data. Its payload 
  6396.      effective length is provided in the BHS field - DataSegmentLength. The 
  6397.      Data Segment is also padded to an integer number of 4 byte words.
  6398.  
  6399.  
  6400.  
  6401.  
  6402.  
  6403. Julian Satran               Expires August  2002                        124
  6404.  
  6405.  
  6406.  
  6407.  
  6408.  
  6409.                                   iSCSI                      17-April-02
  6410.  
  6411. 9.3  SCSI Command 
  6412.  
  6413.      The format of the SCSI Command PDU is:
  6414.  
  6415.      Byte /    0       |       1       |       2       |       3       |
  6416.         /              |               |               |               |
  6417.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6418.        +---------------+---------------+---------------+---------------+
  6419.       0|.|I| 0x01      |F|R|W|0 0|ATTR | Reserved                      |
  6420.        +---------------+---------------+---------------+---------------+
  6421.       4|TotalAHSLength | DataSegmentLength                             |
  6422.        +---------------+---------------+---------------+---------------+
  6423.       8| Logical Unit Number (LUN)                                     |
  6424.        +                                                               +
  6425.      12|                                                               |
  6426.        +---------------+---------------+---------------+---------------+
  6427.      16| Initiator Task Tag                                            |
  6428.        +---------------+---------------+---------------+---------------+
  6429.      20| Expected Data Transfer Length                                 |
  6430.        +---------------+---------------+---------------+---------------+
  6431.      24| CmdSN                                                         |
  6432.        +---------------+---------------+---------------+---------------+
  6433.      28| ExpStatSN                                                     |
  6434.        +---------------+---------------+---------------+---------------+
  6435.      32/ SCSI Command Descriptor Block (CDB)                           /
  6436.       +/                                                               /
  6437.        +---------------+---------------+---------------+---------------+
  6438.      48| AHS (if any), Header Digest (if any)                          |
  6439.        +---------------+---------------+---------------+---------------+
  6440.        / (DataSegment - Command Data + Data Digest (if any))(optional) / 
  6441.       +/                                                               /
  6442.        +---------------+---------------+---------------+---------------+
  6443.  
  6444.  
  6445. 9.3.1  Flags and Task Attributes (byte 1)
  6446.  
  6447.        The flags for a SCSI Command are:
  6448.  
  6449.        bit 0   (F) set to 1 when no unsolicited SCSI Data-Out PDUs fol-
  6450.          low this PDU.  For a write, if Expected Data Transfer Length 
  6451.          is larger than the DataSegmentLength the target may solicit 
  6452.          additional data through R2T.  
  6453.  
  6454.        bit 1   (R) set to 1 when the command is expected to input data.
  6455.          
  6456.  
  6457. Julian Satran              Expires August  2002                      125
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.                                     iSCSI                     17-April-02
  6464.  
  6465.        bit 2   (W) set to 1 when the command is expected to output 
  6466.          data.
  6467.  
  6468.        bit 3-4 Reserved 
  6469.  
  6470.        bit 5-7 contains Task Attributes. 
  6471.  
  6472.      Task Attributes (ATTR) have one of the following integer values (see 
  6473.      [SAM2] for details):
  6474.  
  6475.        0 - Untagged
  6476.        1 - Simple
  6477.        2 - Ordered
  6478.        3 - Head of Queue
  6479.        4 - ACA
  6480.        5-7 - Reserved
  6481.  
  6482.      Setting both the W and the F bit to 0 is an error.
  6483.      The R and W MAY both be 1 when the corresponding Expected Data Trans-
  6484.      fer Lengths are 0, but they  CANNOT both be 0 when the corresponding 
  6485.      Expected Data Transfer Lengths are not 0.
  6486.  
  6487.  
  6488. 9.3.2  CmdSN - Command Sequence Number
  6489.  
  6490.      Enables ordered delivery across multiple connections in a single ses-
  6491.      sion.
  6492.  
  6493. 9.3.3  ExpStatSN  
  6494.  
  6495.      Command responses up to ExpStatSN-1 (mod 2**32) have been received 
  6496.      (acknowledges status) on the connection.  
  6497.  
  6498. 9.3.4  Expected Data Transfer Length
  6499.  
  6500.      For unidirectional operations, the Expected Data Transfer Length 
  6501.      field contains the number of bytes of data involved in this SCSI oper-
  6502.      ation.  For a unidirectional write operation (W flag set to 1 and R 
  6503.      flag set to 0), the initiator uses this field to specify the number of 
  6504.      bytes of data it expects to transfer for this operation.  For a unidi-
  6505.      rectional read operation (W flag set to 0 and R flag set to 1), the 
  6506.      initiator uses this field to specify the number of bytes of data it 
  6507.      expects the target to transfer to the initiator.  It corresponds to 
  6508.      the SAM2 byte count.   
  6509.  
  6510.  
  6511.  
  6512. Julian Satran                Expires August  2002                      126
  6513.  
  6514.  
  6515.  
  6516.  
  6517.  
  6518.                                      iSCSI                    17-April-02
  6519.  
  6520.      For bidirectional operations (both R and W flags are set to 1), this 
  6521.      field contains the number of data bytes involved in the write trans-
  6522.      fer. For bidirectional operations, an additional header segment MUST 
  6523.      be present in the header sequence that indicates the Bidirectional 
  6524.      Read Expected Data Transfer Length.  The Expected Data Transfer Length 
  6525.      field and the Bidirectional Read Expected Data Transfer Length field 
  6526.      correspond to the SAM2 byte count
  6527.  
  6528.      If the Expected Data Transfer Length for a write and the length of the 
  6529.      immediate data part that follows the command (if any) are the same, 
  6530.      then no more data PDUs are expected to follow.  In this case, the F 
  6531.      bit MUST be set to 1.
  6532.  
  6533.      If the Expected Data Transfer Length is higher than the FirstBurstSize 
  6534.      (the negotiated maximum amount of unsolicited data the target will 
  6535.      accept), the initiator sends the maximum size of unsolicited data.  
  6536.  
  6537.      Upon completion of a data transfer, the target informs the initiator 
  6538.      (through residual counts) of how many bytes were actually processed 
  6539.      (sent and/or received) by the target.  
  6540.  
  6541. 9.3.5  CDB - SCSI Command Descriptor Block
  6542.  
  6543.      There are 16 bytes in the CDB field to accommodate the commonly used 
  6544.      CDBs.  Whenever the CDB is larger than 16 bytes, an Extended CDB AHS 
  6545.      MUST be used to contain the CDB spillover.
  6546.  
  6547. 9.3.6  Data Segment - Command Data
  6548.  
  6549.      Some SCSI commands require additional parameter data to accompany the 
  6550.      SCSI command. This data may be placed beyond the boundary of the iSCSI 
  6551.      header in a data segment.  Alternatively, user data (for example, from 
  6552.      a WRITE operation) can be placed in the same PDU (both cases are 
  6553.      referred to as immediate data). These data are governed by the general 
  6554.      rules for solicited vs. unsolicited data.
  6555.  
  6556.  
  6557.  
  6558.  
  6559.  
  6560. Julian Satran                 Expires August  2002                     127
  6561.  
  6562.  
  6563.  
  6564.  
  6565.  
  6566.                                    iSCSI                     17-April-02
  6567.  
  6568. 9.4  SCSI Response 
  6569.  
  6570.      The format of the SCSI Response PDU is:
  6571.  
  6572.      Byte /    0       |       1       |       2       |       3       |
  6573.         /              |               |               |               |
  6574.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6575.        +---------------+---------------+---------------+---------------+
  6576.       0|.|.| 0x21      |. . .|o|u|O|U|.| Response      | Status        |
  6577.        +---------------+---------------+---------------+---------------+
  6578.       4|TotalAHSLength | DataSegmentLength                             |
  6579.        +---------------+---------------+---------------+---------------+
  6580.       8| Reserved                                                      |
  6581.        +                                                               +
  6582.      12|                                                               |
  6583.        +---------------+---------------+---------------+---------------+
  6584.      16| Initiator Task Tag                                            |
  6585.        +---------------+---------------+---------------+---------------+
  6586.      20| Reserved                                                      |
  6587.        +---------------+---------------+---------------+---------------+
  6588.      24| StatSN                                                        |
  6589.        +---------------+---------------+---------------+---------------+
  6590.      28| ExpCmdSN                                                      |
  6591.        +---------------+---------------+---------------+---------------+
  6592.      32| MaxCmdSN                                                      |
  6593.        +---------------+---------------+---------------+---------------+
  6594.      36| ExpDataSN or Reserved                                         |
  6595.        +---------------+---------------+---------------+---------------+
  6596.      40| Bidirectional Read Residual Count                             |
  6597.        +---------------+---------------+---------------+---------------+
  6598.      44| Residual Count                                                |
  6599.        +---------------+---------------+---------------+---------------+
  6600.      48| Digests if any...                                             |
  6601.        +---------------+---------------+---------------+---------------+
  6602.        / Data Segment (Optional)                                       /
  6603.       +/                                                               /
  6604.        +---------------+---------------+---------------+---------------+
  6605.  
  6606. 9.4.1  Flags (byte 1)
  6607.  
  6608.        bit 0-2 Reserved 
  6609.  
  6610.        bit 3 - (o) set for Bidirectional Read Residual Overflow. In 
  6611.          this case, the b Bidirectional Read Residual Count indicates 
  6612.  
  6613. Julian Satran               Expires August  2002                        128
  6614.  
  6615.  
  6616.  
  6617.  
  6618.  
  6619.                                      iSCSI                     17-April-02
  6620.  
  6621.          the number of bytes that were not transferred to the initiator 
  6622.          because the initiator's Expected Bidirectional Read Data 
  6623.          Transfer Length was not sufficient.
  6624.  
  6625.        bit 4 - (u) set for Bidirectional Read Residual Underflow. In 
  6626.          this case, the Bidirectional Read Residual Count indicates the 
  6627.          number of bytes that were not transferred to the initiator out 
  6628.          of the number of bytes expected to be transferred.
  6629.  
  6630.        bit 5 - (O) set for Residual Overflow. In this case, the Resid-
  6631.          ual Count indicates the number of bytes that were not trans-
  6632.          ferred because the initiator's Expected Data Transfer length 
  6633.          was not sufficient. For a bidirectional operation, the Resid-
  6634.          ual Count contains the residual for the write operation.
  6635.  
  6636.        bit 6 - (U) set for Residual Underflow. In this case, the Resid-
  6637.          ual Count indicates the number of bytes that were not trans-
  6638.          ferred out of the number of bytes that expected to be 
  6639.          transferred. For a bidirectional operation, the Residual Count 
  6640.          contains the residual for the write operation.
  6641.  
  6642.        bit 7 - (0) Reserved
  6643.  
  6644.      Bits O and U and bits o and u are mutually exclusive. 
  6645.      For a response other than "Command Completed at Target" bit 3-6 MUST 
  6646.      be 0.
  6647.  
  6648. 9.4.2  Status
  6649.  
  6650.      The Status field is used to report the SCSI status of the command (as 
  6651.      specified in [SAM2]) and is valid only if the Response Code is Command 
  6652.      Completed at target. 
  6653.  
  6654.      Some of the status codes defined in [SAM2] are:
  6655.  
  6656.        0x00 GOOD
  6657.        0x02 CHECK CONDITION
  6658.        0x08 BUSY
  6659.        0x18 RESERVATION CONFLICT
  6660.        0x28 TASK SET FULL
  6661.        0x30 ACA ACTIVE
  6662.        0x40 TASK ABORTED
  6663.  
  6664.      See [SAM2] for the complete list and definitions. 
  6665.  
  6666.      If a SCSI device error is detected while data from the initiator is 
  6667.      still expected (the command PDU did not contain all the data and the 
  6668.  
  6669.  
  6670. Julian Satran                 Expires August  2002                     129
  6671.  
  6672.  
  6673.  
  6674.  
  6675.  
  6676.                                     iSCSI                     17-April-02
  6677.  
  6678.      target has not received a Data PDU with the final bit Set), the target 
  6679.      MUST wait until it receives a Data PDU with the F bit set in the last 
  6680.      expected sequence, before sending the Response PDU. 
  6681.  
  6682. 9.4.3  Response
  6683.  
  6684.      This field contains the iSCSI service response. 
  6685.  
  6686.      iSCSI service response codes defined in this specification are:
  6687.  
  6688.        0x00 - Command Completed at Target
  6689.        0x01 - Target Failure
  6690.        0x80-0xff - Vendor specific
  6691.  
  6692.      The Response is used to report a Service Response. The exact mapping 
  6693.      of the iSCSI response codes to SAM service response symbols is outside 
  6694.      the scope of this document.
  6695.  
  6696.      Certain iSCSI conditions result in the command being terminated at the 
  6697.      target (response Command Completed at Target) with a SCSI Check Condi-
  6698.      tion Status as outlined in the next table:
  6699.  
  6700.      +--------------------------+----------+---------------------------+
  6701.      | Reason                   |Sense     | Additional Sense Code &   |
  6702.      |                          |Key       | Qualifier                 |
  6703.      +--------------------------+----------+---------------------------+
  6704.      | Unexpected unsolicited   |Aborted   | ASC = 0x0c ASCQ = 0x0c    |
  6705.      | data                     |Command-0B| Write Error               |
  6706.      +--------------------------+----------+---------------------------+
  6707.      | Not enough unsolicited   |Aborted   | ASC = 0x0c ASCQ = 0x0d    |
  6708.      | data                     |Command-0B| Write Error               |
  6709.      +--------------------------+----------+---------------------------+
  6710.      | Protocol Service CRC     |Aborted   | ASC = 0x47 ASCQ = 0x05    |
  6711.      | error                    |Command-0B| CRC Error Detected        |
  6712.      +--------------------------+----------+---------------------------+
  6713.      | SNACK rejected           |Aborted   | ASC = 0x11 ASCQ = 0x13    |
  6714.      |                          |Command-0B| Read Error                |
  6715.      +--------------------------+----------+---------------------------+
  6716.  
  6717.      The target reports the "Not enough unsolicited data" condition only if 
  6718.      it does not support output (write) operations in which the total data 
  6719.      length is higher than FirstBurstSize, but the initiator sent less than 
  6720.      FirstBurstSize amount of unsolicited data, and out-of-order R2Ts can-
  6721.      not be used.
  6722.  
  6723. Julian Satran               Expires August  2002                        130
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.                                    iSCSI                      17-April-02
  6730.  
  6731.  
  6732. 9.4.4  Residual Count 
  6733.  
  6734.      The Residual Count field is only valid in the case where either the U 
  6735.      bit or the O bit is set. If neither bit is set, the Residual Count 
  6736.      field SHOULD be zero. If the O bit is set, the Residual Count indi-
  6737.      cates the number of bytes that were not transferred because the initi-
  6738.      ator's Expected Data Transfer Length was not sufficient. If the U bit 
  6739.      is set, the Residual Count indicates the number of bytes that were not 
  6740.      transferred out of the number of bytes expected to be transferred.
  6741.  
  6742. 9.4.5  Bidirectional Read Residual Count 
  6743.  
  6744.      The Bidirectional Read Residual Count field is only valid in the case 
  6745.      where either the u bit or the o bit is set. If neither bit is set, the 
  6746.      Bidirectional Read Residual Count field SHOULD be zero. If the o bit 
  6747.      is set, the Bidirectional Read Residual Count indicates the number of 
  6748.      bytes that were not transferred to the initiator because the initia-
  6749.      tor's Expected Bidirectional Read Transfer Length was not sufficient. 
  6750.      If the u bit is set, the Bidirectional Read Residual Count indicates 
  6751.      the number of bytes that were not transferred to the initiator out of 
  6752.      the number of bytes expected to be transferred.
  6753.  
  6754. 9.4.6  Data Segment - Sense and Response Data Segment
  6755.  
  6756.      iSCSI targets MUST support and enable autosense.  If Status is CHECK 
  6757.      CONDITION (0x02), then the Data Segment contains sense data for the 
  6758.      failed command. 
  6759.  
  6760.      For some iSCSI responses, the response data segment MAY contain some 
  6761.      response related information, (e.g., for a target failure, it may con-
  6762.      tain a vendor specific detailed description of the failure).
  6763.  
  6764.      If the DataSegmentLength is not 0, the format of the Data Segment is 
  6765.      as follows:
  6766.  
  6767.  
  6768.  
  6769.  
  6770.  
  6771. Julian Satran               Expires August  2002                       131
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.                                      iSCSI                     17-April-02
  6778.  
  6779.      Byte /    0       |       1       |       2       |       3       |
  6780.         /              |               |               |               |
  6781.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6782.        +---------------+---------------+---------------+---------------+
  6783.       0|SenseLength                    | Sense Data                    |
  6784.        +---------------+---------------+---------------+---------------+
  6785.       x/ Sense Data                                                    /
  6786.        +---------------+---------------+---------------+---------------+
  6787.       y/ Response Data                                                 /
  6788.        /                                                               /
  6789.        +---------------+---------------+---------------+---------------+
  6790.       z|
  6791.  
  6792. 9.4.6.1  SenseLength  
  6793.  
  6794.      Length of Sense Data.
  6795.  
  6796. 9.4.7  ExpDataSN
  6797.  
  6798.      The number of Data-In (read) PDUs the target has sent for the command.
  6799.  
  6800.      This field is reserved if the response code is not Command Completed 
  6801.      at Target or the command is a write command.
  6802.  
  6803. 9.4.8  StatSN - Status Sequence Number
  6804.  
  6805.      StatSN is a Sequence Number that the target iSCSI layer generates per 
  6806.      connection and that in turn, enables the initiator to acknowledge sta-
  6807.      tus reception. StatSN is incremented by 1 for every response/status 
  6808.      sent on a connection except for responses sent as a result of a retry 
  6809.      or SNACK.  In the case of responses sent due to a retransmission 
  6810.      request, the StatSN MUST be the same as the first time the PDU was 
  6811.      sent unless the connection has since been restarted. 
  6812.  
  6813. 9.4.9  ExpCmdSN - Next Expected CmdSN from this Initiator
  6814.  
  6815.      ExpCmdSN is a Sequence Number that the target iSCSI returns to the 
  6816.      initiator to acknowledge command reception. It is used to update a 
  6817.      local register with the same name. An ExpCmdSN equal to MaxCmdSN+1 
  6818.      indicates that the target cannot accept new commands. 
  6819.  
  6820.  
  6821.  
  6822.  
  6823.  
  6824. Julian Satran                 Expires August  2002                     132
  6825.  
  6826.  
  6827.  
  6828.  
  6829.  
  6830.                                    iSCSI                      17-April-02
  6831.  
  6832. 9.4.10  MaxCmdSN - Maximum CmdSN from this Initiator
  6833.  
  6834.      MaxCmdSN is a Sequence Number that the target iSCSI returns to the 
  6835.      initiator to indicate the maximum CmdSN the initiator can send. It is 
  6836.      used to update a local register with the same name. If MaxCmdSN is 
  6837.      equal to ExpCmdSN-1, this indicates to the initiator that the target 
  6838.      cannot receive any additional commands.  When MaxCmdSN changes at the 
  6839.      target while the target has no pending PDUs to convey this information 
  6840.      to the initiator, it MUST generate a NOP-IN to carry the new MaxCmdSN.
  6841.  
  6842.  
  6843.  
  6844.  
  6845.  
  6846. Julian Satran               Expires August  2002                       133
  6847.  
  6848.  
  6849.  
  6850.  
  6851.  
  6852.                                         iSCSI                        17-April-02
  6853.  
  6854. 9.5  Task Management Function Request
  6855.  
  6856.      Byte /    0       |       1       |       2       |       3       |
  6857.         /              |               |               |               |
  6858.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  6859.        +---------------+---------------+---------------+---------------+
  6860.       0|.|I| 0x02      |1| Function    | Reserved                      |
  6861.        +---------------+---------------+---------------+---------------+
  6862.       4|TotalAHSLength | DataSegmentLength                             |
  6863.        +---------------+---------------+---------------+---------------+
  6864.       8| Logical Unit Number (LUN) or Reserved                         |
  6865.        +                                                               +
  6866.      12|                                                               |
  6867.        +---------------+---------------+---------------+---------------+
  6868.      16| Initiator Task Tag                                            |
  6869.        +---------------+---------------+---------------+---------------+
  6870.      20| Referenced Task Tag or 0xffffffff                             |
  6871.        +---------------+---------------+---------------+---------------+
  6872.      24| CmdSN                                                         |
  6873.        +---------------+---------------+---------------+---------------+
  6874.      28| ExpStatSN                                                     |
  6875.        +---------------+---------------+---------------+---------------+
  6876.      32| RefCmdSN or Reserved                                          |
  6877.        +---------------+---------------+---------------+---------------+
  6878.      36| ExpDataSN or Reserved                                         |
  6879.        +---------------+---------------+---------------+---------------+
  6880.      40/ Reserved                                                      /
  6881.       +/                                                               /
  6882.        +---------------+---------------+---------------+---------------+
  6883.      48
  6884.  
  6885. 9.5.1  Function
  6886.  
  6887.      The Task Management functions provide an initiator with a way to 
  6888.      explicitly control the execution of one or more Tasks (SCSI and iSCSI 
  6889.      tasks). The Task Management functions are listed below. For a more 
  6890.      detailed description of SCSI task management, see [SAM2].
  6891.  
  6892.            1    ABORT TASK - aborts the task identified by the Referenced       
  6893.              Task Tag field.
  6894.  
  6895.            2    ABORT TASK SET - aborts all Tasks issued via this session 
  6896.              on the logical unit.
  6897.  
  6898.  
  6899. Julian Satran                   Expires August  2002                          134
  6900.  
  6901.  
  6902.  
  6903.  
  6904.  
  6905.                                    iSCSI                       17-April-02
  6906.  
  6907.        3    CLEAR ACA - clears the Auto Contingent Allegiance condi-
  6908.          tion.
  6909.  
  6910.        4    CLEAR TASK SET - aborts all Tasks for the Logical Unit.
  6911.  
  6912.        5    LOGICAL UNIT RESET
  6913.  
  6914.        6    TARGET WARM RESET
  6915.  
  6916.        7    TARGET COLD RESET
  6917.  
  6918.        8    TASK REASSIGN - reassigns connection allegiance for the 
  6919.          task identified by the Initiator Task Tag field to this con-
  6920.          nection, thus resuming the iSCSI exchanges for the task.
  6921.  
  6922.      For all these functions, the Task Management Function Response MUST be 
  6923.      returned as detailed in Section 9.6 Task Management Function 
  6924.      Response. All these functions apply to the referenced tasks regard-
  6925.      less of whether they are proper SCSI tasks or tagged iSCSI operations.  
  6926.      Task management requests must act on all the commands having a CmdSN 
  6927.      lower than the task management CmdSN. If the task management request 
  6928.      is marked for immediate delivery it must be considered immediately for 
  6929.      execution but the operations involved (all or part of them) may be 
  6930.      postponed to allow the target to receive all relevant tasks. According 
  6931.      to [SAM2] for all the tasks covered by the task management response 
  6932.      (i.e., with CmdSN not higher than the task management command CmdSN), 
  6933.      additional responses MUST NOT be delivered to the SCSI layer after the 
  6934.      task management response. The iSCSI initiator MAY deliver to the SCSI 
  6935.      layer all responses received before the task management response 
  6936.      (i.e., it is a matter of implementation if the SCSI responses - 
  6937.      received before the task management response but after the task man-
  6938.      agement request was issued - are delivered to the SCSI layer by the 
  6939.      iSCSI layer in the initiator). The iSCSI target MUST ensure that no 
  6940.      responses for the tasks covered by a task management function are 
  6941.      delivered to the iSCSI initiator after the task management response. 
  6942.  
  6943.      For ABORT TASK SET and CLEAR TASK SET, the issuing initiator MUST con-
  6944.      tinue to respond to all valid target transfer tags (received via R2T, 
  6945.      Text Response, NOP-In, or SCSI Data-in PDUs) related to the affected 
  6946.      task set, even after issuing the task management request.  The issuing 
  6947.      initiator SHOULD however terminate (i.e. by setting the F-bit to 1) 
  6948.      these response sequences as quickly as possible, and it is recommended 
  6949.      to terminate all responses with no data.  The target on its part, MUST 
  6950.      wait for responses on all affected target transfer tags before acting 
  6951.      on either of these two task management requests.  In case entire/part 
  6952.  
  6953. Julian Satran               Expires August  2002                         135
  6954.  
  6955.  
  6956.  
  6957.  
  6958.  
  6959.                                      iSCSI                    17-April-02
  6960.  
  6961.      of the response sequence is not received (due to digest errors) for a 
  6962.      valid TTT, the target MAY treat it as a case of within-command error 
  6963.      recovery class (section 6.12.1) if it is supporting ErrorRecovery-
  6964.      Level >= 1, or alternatively may drop the connection to complete the 
  6965.      requested task set function.
  6966.  
  6967.      If the connection is still active (it is not undergoing an implicit or 
  6968.      explicit logout), ABORT TASK MUST be issued on the same connection to 
  6969.      which the task to be aborted is allegiant at the time the Task Manage-
  6970.      ment Request is issued. If the connection is implicitly or explicitly 
  6971.      logged out (i.e., no other request will be issued on the failing con-
  6972.      nection and no other response will be received on the failing connec-
  6973.      tion), then an ABORT TASK function request may be issued on another 
  6974.      connection. This Task Management request will then establish a new 
  6975.      allegiance for the command to be aborted as well as abort it (i.e., 
  6976.      the task to be aborted will not have to be retried or reassigned, and 
  6977.      its status, if issued but not acknowledged, will be reissued followed 
  6978.      by the task management response). 
  6979.  
  6980.      For the LOGICAL UNIT RESET function, the target MUST behave as dic-
  6981.      tated by the Logical Unit Reset function in [SAM2]. 
  6982.  
  6983.      The TARGET RESET function (WARM and COLD) implementation is OPTIONAL 
  6984.      and when implemented, should act as described below. Target Reset MAY 
  6985.      also be subject to SCSI access controls for the requesting initiator. 
  6986.      When authorization fails at the target, the appropriate response as 
  6987.      described in Section 9.6 Task Management Function Response must be 
  6988.      returned by the target.
  6989.  
  6990.      For the TARGET WARM RESET and TARGET COLD RESET functions, the target 
  6991.      cancels all pending operations. Both functions are equivalent to the 
  6992.      Target Reset function specified by [SAM2]. They can affect many other 
  6993.      initiators.
  6994.       
  6995.      In addition, for the TARGET COLD RESET, the target MUST then terminate 
  6996.      all of its TCP connections to all initiators (all sessions are termi-
  6997.      nated). 
  6998.       
  6999.      For the TASK REASSIGN function, the target should reassign the connec-
  7000.      tion allegiance to this new connection (and thus resume iSCSI 
  7001.      exchanges for the task). TASK REASSIGN MUST be received by the target 
  7002.      ONLY after the connection on which the command was previously execut-
  7003.  
  7004.  
  7005. Julian Satran               Expires August  2002                       136
  7006.  
  7007.  
  7008.  
  7009.  
  7010.  
  7011.                                    iSCSI                       17-April-02
  7012.  
  7013.      ing has been successfully logged-out. For additional usage semantics 
  7014.      see Section 6.1 Retry and Reassign in Recovery.
  7015.  
  7016.  
  7017.      TASK REASSIGN MUST be issued as an immediate command.
  7018.  
  7019.  
  7020. 9.5.2  LUN
  7021.  
  7022.      This field is required for functions that address a specific LU (ABORT 
  7023.      TASK, CLEAR TASK SET, ABORT TASK SET, CLEAR ACA, LOGICAL UNIT RESET) 
  7024.      and is reserved in all others.
  7025.  
  7026. 9.5.3  Referenced Task Tag 
  7027.  
  7028.      The Initiator Task Tag of the task to be aborted for the ABORT TASK  
  7029.      function or reassigned for the TASK REASSIGN function.
  7030.      For all the other functions this field MUST be set to the reserved 
  7031.      value 0xffffffff. 
  7032.  
  7033. 9.5.4  RefCmdSN
  7034.  
  7035.      For the ABORT TASK function, initiators MUST always set this to the 
  7036.      CmdSN of the task identified by the Initiator Task Tag field. Targets 
  7037.      must use this field as described in section 9.6.1 when the task 
  7038.      identified by the ITT field is not with the target.
  7039.  
  7040.      Otherwise this field is reserved.
  7041.  
  7042. 9.5.5  ExpDataSN
  7043.  
  7044.      If the function is TASK REASSIGN, which establishes a new connection 
  7045.      allegiance for a previously issued Read or Bidirectional command, 
  7046.      this field will contain the next consecutive input DataSN number 
  7047.      expected by the initiator (no gaps) for the referenced command in a 
  7048.      previous execution. The initiator MUST discard any discontiguous data 
  7049.      PDUs from the previous execution and the target MUST retransmit all 
  7050.      data previously transmitted in Data-in PDUs (if any) starting with 
  7051.      ExpDataSN.  The number of retransmitted PDUs, may or may not be the 
  7052.      same as the original transmission, depending on if there was a change 
  7053.      in MaxRecvPDULength in the reassignment.
  7054.  
  7055.      Otherwise, this field is reserved.
  7056.  
  7057.  
  7058. Julian Satran               Expires August  2002                         137
  7059.  
  7060.  
  7061.  
  7062.  
  7063.  
  7064.                         iSCSI            17-April-02
  7065.  
  7066.  
  7067.  
  7068.  
  7069.  
  7070. Julian Satran    Expires August  2002            138
  7071.  
  7072.  
  7073.  
  7074.  
  7075.  
  7076.                                   iSCSI                      17-April-02
  7077.  
  7078. 9.6  Task Management Function Response
  7079.  
  7080.  
  7081.      Byte /    0       |       1       |       2       |       3       |
  7082.         /              |               |               |               |
  7083.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7084.        +---------------+---------------+---------------+---------------+
  7085.       0|.|.| 0x22      |1| Reserved    | Response      | Reserved      |
  7086.        +---------------+---------------+---------------+---------------+
  7087.       4|TotalAHSLength | DataSegmentLength                             |
  7088.        +---------------------------------------------------------------+
  7089.       8/ Reserved                                                      /
  7090.        /                                                               /
  7091.        +---------------+---------------+---------------+---------------+
  7092.      16| Initiator Task Tag                                            |
  7093.        +---------------+---------------+---------------+---------------+
  7094.      20| Reserved                                                      |
  7095.        +---------------+---------------+---------------+---------------+
  7096.      24| StatSN                                                        |
  7097.        +---------------+---------------+---------------+---------------+
  7098.      28| ExpCmdSN                                                      |
  7099.        +---------------+---------------+---------------+---------------+
  7100.      32| MaxCmdSN                                                      |
  7101.        +---------------+---------------+---------------+---------------+
  7102.      36/ Reserved                                                      /
  7103.       +/                                                               /
  7104.        +---------------+---------------+---------------+---------------+
  7105.      48| Digest (if any)                                               |
  7106.        +---------------------------------------------------------------+
  7107.  
  7108.      For the functions ABORT TASK, ABORT TASK SET, CLEAR ACA, CLEAR TASK 
  7109.      SET, LOGICAL UNIT RESET, and TARGET WARM RESET, the target performs 
  7110.      the requested Task Management function and sends a Task Management 
  7111.      Response back to the initiator. 
  7112.  
  7113. 9.6.1  Response
  7114.  
  7115.      The target provides a Response, which may take on the following val-
  7116.      ues:
  7117.  
  7118.         a)    0 - Function Complete
  7119.         b)    1 - Task does not exist
  7120.         c)    2 - LUN does not exist.
  7121.         d)    3 - Task still allegiant.
  7122.  
  7123. Julian Satran              Expires August  2002                      139
  7124.  
  7125.  
  7126.  
  7127.  
  7128.  
  7129.                                      iSCSI                    17-April-02
  7130.  
  7131.         e)    4 - Task failover not supported.
  7132.         f)    5 - Task management function not supported.
  7133.         g)    6 - Function authorization failed.
  7134.         h)  255 - Function Rejected.
  7135.  
  7136.      All other values are reserved.
  7137.  
  7138.      For a discussion on usage of response codes 3 and 4, see Section 6.1.2 
  7139.      Allegiance Reassignment.
  7140.  
  7141.      For the TARGET COLD RESET and TARGET WARM RESET functions, the target 
  7142.      cancels all pending operations.  For the TARGET COLD RESET function, 
  7143.      the target MUST then close all of its TCP connections to all initia-
  7144.      tors (terminates all sessions).
  7145.  
  7146.      The mapping of the response code into a SCSI service response code, if 
  7147.      needed, is outside the scope of this document. 
  7148.  
  7149.      The response to ABORT TASK SET and CLEAR TASK SET MUST be issued by 
  7150.      the target only after all the commands affected have been received by 
  7151.      the target, the corresponding task management functions have been 
  7152.      executed by the SCSI target and the delivery of all responses deliv-
  7153.      ered until the task management function completion have been con-
  7154.      firmed (acknowledged through ExpStatSN) by the initiator on all 
  7155.      connections of this session.  For the exact timeline of events, refer 
  7156.      Section 9.6.2 Task Management actions on task sets.
  7157.  
  7158.      For the ABORT TASK function,
  7159.  
  7160.         a)  if the ITT identifies a valid task leading to a successful ter-
  7161.         mination, targets must return the "Function complete" response.
  7162.         b)  if the ITT does not identify an existing task but if the CmdSN 
  7163.         indicated by the RefCmdSN field in the task management function 
  7164.         request is within the valid CmdSN window (between MaxCmdSN and 
  7165.         ExpCmdSN), targets must consider the CmdSN received and return the 
  7166.         "Function complete" response.
  7167.         c)  if the ITT does not identify an existing task and if the CmdSN 
  7168.         indicated by the RefCmdSN field in the task management function 
  7169.         request is outside the valid CmdSN window, targets must return the 
  7170.         "Task does not exist" response.
  7171.  
  7172.  
  7173.  
  7174.  
  7175. Julian Satran               Expires August  2002                         140
  7176.  
  7177.  
  7178.  
  7179.  
  7180.  
  7181.                                     iSCSI                       17-April-02
  7182.  
  7183. 9.6.2  Task Management actions on task sets
  7184.  
  7185.      The execution of ABORT TASK SET and CLEAR TASK SET task management 
  7186.      function requests consists of the following sequence of events in the 
  7187.      specified order on each of the entities.
  7188.  
  7189.      The initiator:
  7190.  
  7191.            a)  issues ABORT TASK SET/CLEAR TASK SET request.
  7192.            b)  continues to respond to each target transfer tag received 
  7193.                for the affected task set.
  7194.            c)  receives any responses for the tasks in the affected task 
  7195.                set (may process them as usual since they are guaranteed to 
  7196.                be valid).
  7197.            d)  receives the task set management response, thus concluding 
  7198.                all the tasks in the affected task set.
  7199.  
  7200.      The target:
  7201.  
  7202.            a)  receives the ABORT TASK SET/CLEAR TASK SET request.
  7203.            b)  waits for all target transfer tags to be responded and also 
  7204.                for all affected tasks in the task set to be received.
  7205.            c)  propagates the command up to and receives the response from 
  7206.                the target SCSI layer.
  7207.            d)  takes note of last-sent StatSN on each of the connections in 
  7208.                the session, and waits for acknowledgement of each StatSN 
  7209.                (may solicit for acknowledgement by way of a NOP-In).
  7210.            e)  sends the task set management response.
  7211.  
  7212.  
  7213.  
  7214.  
  7215.  
  7216. Julian Satran                Expires August  2002                        141
  7217.  
  7218.  
  7219.  
  7220.  
  7221.  
  7222.                                   iSCSI                      17-April-02
  7223.  
  7224. 9.7  SCSI Data-out & SCSI Data-in
  7225.  
  7226.      The SCSI Data-out PDU for WRITE operations has the following format:
  7227.  
  7228.  
  7229.      Byte /    0       |       1       |       2       |       3       |
  7230.         /              |               |               |               |
  7231.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7232.        +---------------+---------------+---------------+---------------+
  7233.       0|.|.| 0x05      |F| Reserved                                    |
  7234.        +---------------+---------------+---------------+---------------+
  7235.       4|TotalAHSLength | DataSegmentLength                             |
  7236.        +---------------+---------------+---------------+---------------+
  7237.       8| LUN or Reserved                                               |
  7238.        +                                                               +
  7239.      12|                                                               |
  7240.        +---------------+---------------+---------------+---------------+
  7241.      16| Initiator Task Tag                                            |
  7242.        +---------------+---------------+---------------+---------------+
  7243.      20| Target Transfer Tag or 0xffffffff                             |
  7244.        +---------------+---------------+---------------+---------------+
  7245.      24| Reserved                                                      |
  7246.        +---------------+---------------+---------------+---------------+
  7247.      28| ExpStatSN                                                     |
  7248.        +---------------+---------------+---------------+---------------+
  7249.      32| Reserved                                                      |
  7250.        +---------------+---------------+---------------+---------------+
  7251.      36| DataSN                                                        |
  7252.        +---------------+---------------+---------------+---------------+
  7253.      40| Buffer Offset                                                 |
  7254.        +---------------+---------------+---------------+---------------+
  7255.      44| Reserved                                                      |
  7256.        +---------------+---------------+---------------+---------------+
  7257.      48| Digests if any...                                             |
  7258.        +---------------+---------------+---------------+---------------+
  7259.        / DataSegment                                                   /
  7260.       +/                                                               /
  7261.        +---------------+---------------+---------------+---------------+
  7262.  
  7263.      The SCSI Data-in PDU for READ operations has the following format:
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269. Julian Satran              Expires August  2002                      142
  7270.  
  7271.  
  7272.  
  7273.  
  7274.  
  7275.                                    iSCSI                      17-April-02
  7276.  
  7277.      Byte /    0       |       1       |       2       |       3       |
  7278.         /              |               |               |               |
  7279.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7280.        +---------------+---------------+---------------+---------------+
  7281.       0|.|.| 0x25      |F|A|0 0 0|O|U|S| Reserved      |Status or Rsvd |
  7282.        +---------------+---------------+---------------+---------------+
  7283.       4|TotalAHSLength | DataSegmentLength                             |
  7284.        +---------------+---------------+---------------+---------------+
  7285.       8| LUN or Reserved                                               |
  7286.        +                                                               +
  7287.      12|                                                               |
  7288.        +---------------+---------------+---------------+---------------+
  7289.      16| Initiator Task Tag                                            |
  7290.        +---------------+---------------+---------------+---------------+
  7291.      20| Target Transfer Tag or 0xffffffff                             |
  7292.        +---------------+---------------+---------------+---------------+
  7293.      24| StatSN or Reserved                                            |
  7294.        +---------------+---------------+---------------+---------------+
  7295.      28| ExpCmdSN                                                      |
  7296.        +---------------+---------------+---------------+---------------+
  7297.      32| MaxCmdSN                                                      |
  7298.        +---------------+---------------+---------------+---------------+
  7299.      36| DataSN                                                        |
  7300.        +---------------+---------------+---------------+---------------+
  7301.      40| Buffer Offset                                                 |
  7302.        +---------------+---------------+---------------+---------------+
  7303.      44| Residual Count                                                |
  7304.        +---------------+---------------+---------------+---------------+
  7305.      48| Header Digest (if any)                                        |
  7306.        +---------------+---------------+---------------+---------------+
  7307.        / DataSegment (and digest if any)                               /
  7308.       +/                                                               /
  7309.        +---------------+---------------+---------------+---------------+
  7310.  
  7311.  
  7312.      Status can accompany the last Data-in PDU if the command did not end 
  7313.      with an exception (i.e., the status is "good status" - GOOD, CONDITION 
  7314.      MET or INTERMEDIATE CONDITION MET).  The presence of status (and of a 
  7315.      residual count) is signaled though the S flag bit.  Although targets 
  7316.      MAY choose to send even non-exception status in separate responses, 
  7317.      initiators MUST support non-exception status in Data-In PDUs.
  7318.  
  7319.  
  7320.  
  7321. Julian Satran               Expires August  2002                       143
  7322.  
  7323.  
  7324.  
  7325.  
  7326.  
  7327.                                    iSCSI                      17-April-02
  7328.  
  7329. 9.7.1  F (Final) Bit
  7330.  
  7331.      For outgoing data, this bit is 1 for the last PDU of unsolicited data 
  7332.      or the last PDU of a sequence that answers an R2T.
  7333.  
  7334.      For incoming data, this bit is 1 for the last input (read) data PDU of 
  7335.      a sequence.  Input can be split into several sequences, each having 
  7336.      its own F bit. Splitting the data stream into sequences does not 
  7337.      affect DataSN counting on Data-In PDUs. It MAY be used as a "change 
  7338.      direction" indication for Bidirectional operations that need such a 
  7339.      change.  
  7340.  
  7341.      DataSegmentLength MUST not exceed MaxRecvPDULength for the direction 
  7342.      it is sent and the total of all the DataSegmentLength of all PDUs in a 
  7343.      sequence MUST not exceed MaxBurstSize (or FirstBurstSize for unsolic-
  7344.      ited data).  However the number of individual PDUs in a sequence (or 
  7345.      in total) may be higher than the MaxBurstSize (or FirstBurstSize) to 
  7346.      MaxRecvPDULength ratio (as PDUs may be limited in size by the sender 
  7347.      capabilities).  Using DataSegmentLength of 0 may increase beyond what 
  7348.      is reasonable the number of PDUs and should therefore be avoided.
  7349.  
  7350.      For Bidirectional operations, the F bit is 1 for both the end of the 
  7351.      input sequences as well as the end of the output sequences. 
  7352.  
  7353. 9.7.2  A (Acknowledge) bit
  7354.  
  7355.      For sessions with ErrorRecoveryLevel 1 or higher, the target sets this 
  7356.      bit to 1 to indicate that it requests a positive acknowledgement from 
  7357.      the initiator for the data received.  The target should use the A bit 
  7358.      moderately; it MAY set the A bit to 1 only once every MaxBurstSize 
  7359.      bytes or on the last Data-In PDU that concludes the entire requested 
  7360.      read data transfer for the task from the target's perspective, and 
  7361.      MUST NOT do so more frequently than this. 
  7362.  
  7363.      On receiving a Data-In PDU with the A bit set to 1, if there are no 
  7364.      holes in the read data until that Data-In PDU, the initiator MUST 
  7365.      issue a SNACK of type DataACK except when it is able to acknowledge 
  7366.      the status for the task immediately via ExpStatSN on other outbound 
  7367.      PDUs if the status for the task is also received; in this later case 
  7368.      (acknowledgement through ExpStatSN) sending a SNACK of type DataACK 
  7369.      in response to the A bit is not mandatory but if it is done it must 
  7370.      not be sent after the status acknowledgement through ExpStatSN.  If 
  7371.      the initiator has detected holes in the read data until that Data-In 
  7372.      PDU, it MUST postpone issuing the SNACK of type DataACK until the 
  7373.  
  7374. Julian Satran               Expires August  2002                       144
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.                                    iSCSI                      17-April-02
  7381.  
  7382.      holes are filled. An initiator also MUST NOT acknowledge the status 
  7383.      for the task before those holes are filled.  A status acknowledgement 
  7384.      for a task that generated the Data-In PDUs is considered by the target 
  7385.      as an implicit acknowledgement of the Data-In PDUs if such an acknowl-
  7386.      edgement was requested by the target.
  7387.  
  7388. 9.7.3  Target Transfer Tag
  7389.  
  7390.      On outgoing data, the Target Transfer Tag is provided to the target if 
  7391.      the transfer is honoring an R2T. In this case, the Target Transfer Tag 
  7392.      field is a replica of the Target Transfer Tag provided with the R2T.
  7393.  
  7394.      On incoming data, the Target Transfer Tag MUST be provided by the tar-
  7395.      get if the A bit is set to 1. The Target Transfer Tag and LUN are cop-
  7396.      ied by the initiator in the SNACK of  type DataACK that it issues as a 
  7397.      result of receiving a SCSI Data-in PDU with the A bit set to 1.
  7398.  
  7399.      The Target Transfer Tag values are not specified by this protocol 
  7400.      except that the value 0xffffffff is reserved and means that the Target 
  7401.      Transfer Tag is not supplied.  If the Target Transfer Tag is provided, 
  7402.      then the LUN field MUST hold a valid value and be consistent with 
  7403.      whatever was specified with the command; otherwise, the LUN field is 
  7404.      reserved.
  7405.  
  7406. 9.7.4  StatSN 
  7407.  
  7408.      This field MUST ONLY be set if the S bit is set to 1.
  7409.  
  7410. 9.7.5  DataSN 
  7411.  
  7412.      For input (read) data PDUs, the DataSN is the data PDU number (start-
  7413.      ing with 0) within the data transfer for the command identified by the 
  7414.      Initiator Task Tag.
  7415.  
  7416.      For output (write) data PDUs, the DataSN is the data PDU number 
  7417.      (starting with 0) within the current output sequence. The current out-
  7418.      put sequence is either identified by the Initiator Task Tag (for unso-
  7419.      licited data) or is a data sequence generated for one R2T (for data 
  7420.      solicited through R2T). 
  7421.  
  7422.      Any input or output data sequence MUST contain less than 2**32 num-
  7423.      bered PDUs.
  7424.  
  7425.  
  7426.  
  7427. Julian Satran               Expires August  2002                         145
  7428.  
  7429.  
  7430.  
  7431.  
  7432.  
  7433.                                      iSCSI                    17-April-02
  7434.  
  7435. 9.7.6  Buffer Offset
  7436.  
  7437.      The Buffer Offset field contains the offset of this PDU payload data 
  7438.      within the complete data transfer. The sum of the buffer offset and 
  7439.      length should not exceed the expected transfer length for the command.
  7440.  
  7441.      The order of data PDUs within a sequence is determined by DataPDUInOr-
  7442.      der. When set to Yes, it means that PDUs have to be in increasing 
  7443.      Buffer Offset order and overlays are forbidden.
  7444.  
  7445.      The ordering between sequences is determined by DataSequenceInOrder. 
  7446.      When set to Yes, it means that sequences have to be in increasing 
  7447.      Buffer Offset order and overlays are forbidden. 
  7448.  
  7449. 9.7.7  DataSegmentLength 
  7450.  
  7451.      This is the data payload length of a SCSI Data-In or SCSI Data-Out 
  7452.      PDU. The sending of 0 length data segments should be avoided, but ini-
  7453.      tiators and targets MUST be able to properly receive 0 length data 
  7454.      segments. 
  7455.  
  7456.      The Data Segments of Data-in and Data-out PDUs SHOULD be filled to the 
  7457.      integer number of 4 byte words (real payload) unless the F bit is set 
  7458.      to 1.
  7459.  
  7460. 9.7.8  Flags (byte 1)
  7461.  
  7462.      The last SCSI Data packet sent from a target to an initiator for a 
  7463.      SCSI command that completed successfully (with a status of GOOD, CON-
  7464.      DITION MET, INTERMEDIATE or INTERMEDIATE CONDITION MET) may also 
  7465.      optionally contain the Status for the data transfer.  In this case, 
  7466.      Sense Data cannot be sent together with the Command Status.  If the 
  7467.      command is completed with an error, then the response and sense data 
  7468.      MUST be sent in a SCSI Response PDU (i.e., MUST NOT be sent in a SCSI 
  7469.      Data packet). For Bidirectional commands, the status MUST be sent in a 
  7470.      SCSI Response PDU.
  7471.  
  7472.        bit 2-3 - Reserved 
  7473.  
  7474.        bit 5-6 - used the same as in a SCSI Response.
  7475.  
  7476.        bit 7 S (status)- set to indicate that the Command Status field 
  7477.          contains status. If this bit is set to 1 the F bit MUST also 
  7478.          be set to 1.
  7479.  
  7480.  
  7481. Julian Satran                 Expires August  2002                     146
  7482.  
  7483.  
  7484.  
  7485.  
  7486.  
  7487.                                    iSCSI                      17-April-02
  7488.  
  7489.  
  7490.      The fields StatSN, Status and Residual Count have meaningful content 
  7491.      only if the S bit is set to 1 and they values are as define in Section 
  7492.      9.4 SCSI Response.
  7493.  
  7494.  
  7495.  
  7496.  
  7497.  
  7498. Julian Satran               Expires August  2002                       147
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504.                                    iSCSI                      17-April-02
  7505.  
  7506. 9.8  Ready To Transfer (R2T)
  7507.  
  7508.      Byte /    0       |       1       |       2       |       3       |
  7509.         /              |               |               |               |
  7510.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7511.        +---------------+---------------+---------------+---------------+
  7512.       0|.|.| 0x31      |1| Reserved                                    |
  7513.        +---------------+---------------+---------------+---------------+
  7514.       4|TotalAHSLength | DataSegmentLength                             |
  7515.        +---------------+---------------+---------------+---------------+
  7516.       8| LUN                                            |
  7517.        +                                                               +
  7518.      12|                                                               |
  7519.        +---------------+---------------+---------------+---------------+
  7520.      16| Initiator Task Tag                                            |
  7521.        +---------------+---------------+---------------+---------------+
  7522.      20| Target Transfer Tag                                           |
  7523.        +---------------+---------------+---------------+---------------+
  7524.      24| StatSN                                                        |
  7525.        +---------------+---------------+---------------+---------------+
  7526.      28| ExpCmdSN                                                      |
  7527.        +---------------+---------------+---------------+---------------+
  7528.      32| MaxCmdSN                                                      |
  7529.        +---------------+---------------+---------------+---------------+
  7530.      36| R2TSN                                                         |
  7531.        +---------------+---------------+---------------+---------------+
  7532.      40| Buffer Offset                                                 |
  7533.        +---------------+---------------+---------------+---------------+
  7534.      44| Desired Data Transfer Length                                  |
  7535.        +---------------------------------------------------------------+
  7536.      48| Digest (if any)                                               |
  7537.        +---------------------------------------------------------------+
  7538.  
  7539.  
  7540.      When an initiator has submitted a SCSI Command with data that passes 
  7541.      from the initiator to the target (WRITE), the target may specify which 
  7542.      blocks of data it is ready to receive. The target may request that the 
  7543.      data blocks be delivered in whichever order is convenient for the tar-
  7544.      get at that particular instant. This information is passed from the 
  7545.      target to the initiator in the Ready To Transfer (R2T) PDU.  
  7546.  
  7547.  
  7548.  
  7549.  
  7550.  
  7551. Julian Satran               Expires August  2002                       148
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.                                     iSCSI                     17-April-02
  7558.  
  7559.      In order to allow write operations without an explicit initial R2T, 
  7560.      the initiator and target MUST have negotiated the key InitialR2T to No 
  7561.      during Login.
  7562.  
  7563.      An R2T MAY be answered with one or more SCSI Data-out PDUs with a 
  7564.      matching Target Transfer Tag. If an R2T is answered with a single 
  7565.      Data-out PDU, the Buffer Offset in the Data PDU MUST be the same as 
  7566.      the one specified by the R2T. The data length of the Data PDU MUST be 
  7567.      the same as the Desired Data Transfer Length specified in the R2T. If 
  7568.      the R2T is answered with a sequence of Data PDUs, the Buffer Offset 
  7569.      and Length MUST be within the range of those specified by R2T, and the 
  7570.      last PDU MUST have the F bit set to 1. If the last PDU (marked with 
  7571.      the F bit) is received before the Desired Data Transfer Length is 
  7572.      transferred, a target MAY choose to Reject that PDU with "Protocol 
  7573.      error" reason code.  DataPDUInOrder governs the Data-Out PDU order-
  7574.      ing. If DataPDUInOrder is set to Yes, the Buffer Offsets and Lengths 
  7575.      for consecutive PDUs MUST form a continuous non-overlapping range and 
  7576.      the PDUs MUST be sent in increasing offset order.
  7577.  
  7578.      The target may send several R2T PDUs (up to a negotiated number).  It, 
  7579.      therefore, can have a number of pending data transfers.  Within a con-
  7580.      nection, outstanding R2Ts MUST be fulfilled by the initiator in the 
  7581.      order in which they were received.
  7582.  
  7583.      DataSequenceInOrder governs the buffer offset ordering in consecutive 
  7584.      R2Ts. If DataSequenceInOrder is Yes, then consecutive R2Ts SHOULD 
  7585.      refer to continuous non-overlapping ranges.  
  7586.  
  7587. 9.8.1  R2TSN 
  7588.  
  7589.      R2TSN is the R2T PDU number (starting with 0) within the command iden-
  7590.      tified by the Initiator Task Tag.
  7591.  
  7592.      The number of R2Ts in a command MUST be less than 2**32-1. 
  7593.  
  7594. 9.8.2  StatSN
  7595.  
  7596.      The StatSN field will contain the next StatSN. The StatSN for this 
  7597.      connection is not advanced.
  7598.  
  7599. 9.8.3  Desired Data Transfer Length and Buffer Offset
  7600.  
  7601.      The target specifies how many bytes it wants the initiator to send 
  7602.      because of this R2T PDU.  The target may request the data from the 
  7603.  
  7604. Julian Satran               Expires August  2002                       149
  7605.  
  7606.  
  7607.  
  7608.  
  7609.  
  7610.                                    iSCSI                         17-April-02
  7611.  
  7612.      initiator in several chunks, not necessarily in the original order of 
  7613.      the data.  The target, therefore, also specifies a Buffer Offset that 
  7614.      indicates the point at which the data transfer should begin, relative 
  7615.      to the beginning of the total data transfer. The Desired Data Transfer 
  7616.      Length SHOULD not be 0 and MUST not exceed MaxBurstSize.
  7617.  
  7618. 9.8.4  Target Transfer Tag
  7619.  
  7620.      The target assigns its own tag to each R2T request that it sends to 
  7621.      the initiator. This tag can be used by the target to easily identify 
  7622.      the data it receives.  The Target Transfer Tag and LUN are copied in 
  7623.      the outgoing data PDUs and are used by the target only. There is no 
  7624.      protocol rule about the Target Transfer Tag except that the value 
  7625.      0xffffffff is reserved and MUST never be sent by a target in an    
  7626.      R2T.   
  7627.  
  7628.  
  7629.  
  7630.  
  7631.  
  7632. Julian Satran               Expires August  2002                         150
  7633.  
  7634.  
  7635.  
  7636.  
  7637.  
  7638.                                      iSCSI                   17-April-02
  7639.  
  7640. 9.9  Asynchronous Message
  7641.  
  7642.      An Asynchronous Message may be sent from the target to the initiator 
  7643.      without corresponding to a particular command. The target specifies 
  7644.      the reason for the event and sense data.
  7645.  
  7646.      Byte /    0       |       1       |       2       |       3       |
  7647.         /              |               |               |               |
  7648.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7649.        +---------------+---------------+---------------+---------------+
  7650.       0|.|.| 0x32      |1| Reserved                                    |
  7651.        +---------------+---------------+---------------+---------------+
  7652.       4|TotalAHSLength | DataSegmentLength                             |
  7653.        +---------------+---------------+---------------+---------------+
  7654.       8| LUN                                                           |
  7655.        +                                                               +
  7656.      12|                                                               |
  7657.        +---------------+---------------+---------------+---------------+
  7658.      16| 0xffffffff                                                    |
  7659.        +---------------+---------------+---------------+---------------+
  7660.      20| Reserved                             |
  7661.        +---------------+---------------+---------------+---------------+
  7662.      24| StatSN                                                        |
  7663.        +---------------+---------------+---------------+---------------+
  7664.      28| ExpCmdSN                                                      |
  7665.        +---------------+---------------+---------------+---------------+
  7666.      32| MaxCmdSN                                                      |
  7667.        +---------------+---------------+---------------+---------------+
  7668.      36| AsyncEvent    | AsyncVCode    | Parameter1 or Reserved        |
  7669.        +---------------+---------------+---------------+---------------+
  7670.      40| Parameter2 or Reserved        | Parameter3 or Reserved        |
  7671.        +---------------+---------------+---------------+---------------+
  7672.      44| Reserved                                                      |
  7673.        +---------------+---------------+---------------+---------------+
  7674.      48| Digests if any...                                             |
  7675.        +---------------+---------------+---------------+---------------+
  7676.        / DataSegment - Sense Data and iSCSI Event Data                  /
  7677.       +/                                                               /
  7678.        +---------------+---------------+---------------+---------------+
  7679.  
  7680.  
  7681.      Some Asynchronous Messages are strictly related to iSCSI while others 
  7682.      are related to SCSI [SAM2]. 
  7683.  
  7684.  
  7685. Julian Satran                Expires August  2002                     151
  7686.  
  7687.  
  7688.  
  7689.  
  7690.  
  7691.                                      iSCSI                   17-April-02
  7692.  
  7693.  
  7694.      StatSN counts this PDU as an acknowledgeable event (StatSN is 
  7695.      advanced), which allows for initiator and target state synchroniza-
  7696.      tion.
  7697.  
  7698. 9.9.1  AsyncEvent
  7699.  
  7700.      The codes used for iSCSI Asynchronous Messages (Events) are:
  7701.  
  7702.        0 - a SCSI Asynchronous Event is reported in the sense data. 
  7703.          Sense Data that accompanies the report, in the data segment, 
  7704.          identifies the condition. The sending of a SCSI Event (Asyn-
  7705.          chronous Event Notification in SCSI terminology) is controlled 
  7706.          by a SCSI Control Mode Page bit. 
  7707.           
  7708.        1 - target requests Logout. This Async Message MUST be sent on 
  7709.          the same connection as the one requesting to be logged out.  
  7710.          The initiator MUST honor this request by issuing a Logout as 
  7711.          early as possible, but no later than Parameter3 seconds.   
  7712.          Initiator MUST send a Logout with a reason code of "Close the
  7713.         connection" (if not the only connection) OR "Close the session" 
  7714.          to close all the connections (if using multiple connections). 
  7715.          Once this message is received, the initiator SHOULD NOT issue 
  7716.          new iSCSI commands.  The target MAY reject any new I/O 
  7717.          requests that it receives after this Message with the reason 
  7718.          code "Waiting for Logout".  If the initiator does not Logout 
  7719.          in Parameter3 seconds, the target should send an Async PDU 
  7720.          with iSCSI event code "Dropped the connection" if possible, or 
  7721.          simply terminate the transport connection. Parameter1 and 
  7722.          Parameter2 are reserved.
  7723.  
  7724.        2 - target indicates it will drop the connection. 
  7725.          The Parameter1 field indicates the CID of the connection going 
  7726.          to be dropped. 
  7727.          The Parameter2 field (Time2Wait) indicates, in seconds, the 
  7728.          minimum time to wait before attempting to reconnect or reas-
  7729.          sign. 
  7730.          The Parameter3 field (Time2Retain) indicates the maximum time 
  7731.          allowed to reassign commands after the initial wait (in 
  7732.          Parameter2). 
  7733.          If the initiator does not attempt to reconnect and/or reassign 
  7734.          the outstanding commands within the time specified by 
  7735.          Parameter3, or if Parameter3 is 0, the target will terminate 
  7736.          all outstanding commands on this connection; no other 
  7737.          responses should be expected from the target for the outstand-
  7738.          ing commands on this connection in this case. 
  7739.          A value of 0 for Parameter2 indicates that reconnect can be 
  7740.          attempted immediately.
  7741.  
  7742.  
  7743. Julian Satran               Expires August  2002                        152
  7744.  
  7745.  
  7746.  
  7747.  
  7748.  
  7749.                                       iSCSI                   17-April-02
  7750.  
  7751.        3 - target indicates it will drop all the connections of this 
  7752.          session. 
  7753.          Parameter1 field is reserved. 
  7754.          The Parameter2 field (Time2Wait) indicates, in seconds, the 
  7755.          minimum time to wait before attempting to reconnect. 
  7756.          The Parameter3 field (Time2Retain) indicates the maximum time 
  7757.          allowed to reassign commands after the initial wait (in 
  7758.          Parameter2). 
  7759.          If the initiator does not attempt to reconnect and/or reassign 
  7760.          the outstanding commands within the time specified by 
  7761.          Parameter3, or if Parameter3 is 0, the session is terminated. 
  7762.          In this case, the target will terminate all outstanding com-
  7763.          mands in this session; no other responses should be expected 
  7764.          from the target for the outstanding commands in this session.  
  7765.          A value of 0 for Parameter2 indicates that reconnect can be 
  7766.          attempted immediately.
  7767.  
  7768.        255 - vendor specific iSCSI Event. The AsyncVCode details the 
  7769.          vendor code, and data MAY accompany the report.
  7770.  
  7771.      All other event codes are reserved.
  7772.  
  7773. 9.9.2  AsyncVCode
  7774.  
  7775.      AsyncVCode is a vendor specific detail code that is valid only if the 
  7776.      AsyncEvent field indicates a vendor specific event. Otherwise, it is 
  7777.      reserved.
  7778.  
  7779. 9.9.3  Sense Data and iSCSI Event Data 
  7780.  
  7781.      For a SCSI Event, this data accompanies the report in the data segment 
  7782.      and identifies the condition.
  7783.  
  7784.      For an iSCSI Event, additional vendor-unique data MAY accompany the 
  7785.      Async event.  Initiators MAY ignore the data when not understood while 
  7786.      processing the rest of the PDU.
  7787.  
  7788.      If the DataSegmentLength is not 0, the format of the Data Segment is 
  7789.      as follows:
  7790.  
  7791.  
  7792.  
  7793.  
  7794.  
  7795. Julian Satran               Expires August  2002                       153
  7796.  
  7797.  
  7798.  
  7799.  
  7800.  
  7801.                                      iSCSI                   17-April-02
  7802.  
  7803.      Byte /    0       |       1       |       2       |       3       |
  7804.         /              |               |               |               |
  7805.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7806.        +---------------+---------------+---------------+---------------+
  7807.       0|SenseLength                    | Sense Data                    |
  7808.        +---------------+---------------+---------------+---------------+
  7809.       x/ Sense Data                                                    /
  7810.        +---------------+---------------+---------------+---------------+
  7811.       y/ iSCSI Event Data                                                 /
  7812.        /                                                               /
  7813.        +---------------+---------------+---------------+---------------+
  7814.       z|
  7815.  
  7816. 9.9.3.1  SenseLength  
  7817.  
  7818.      Length of Sense Data.
  7819.  
  7820.  
  7821.  
  7822.  
  7823.  
  7824. Julian Satran                 Expires August  2002                    154
  7825.  
  7826.  
  7827.  
  7828.  
  7829.  
  7830.                                    iSCSI                      17-April-02
  7831.  
  7832. 9.10  Text Request
  7833.  
  7834.      The Text Request is provided to allow for the exchange of information 
  7835.      and for future extensions. It permits the initiator to inform a target 
  7836.      of its capabilities or to request some special operations.
  7837.  
  7838.      An initiator MUST have only one outstanding Text Request on a connec-
  7839.      tion at any given time.
  7840.  
  7841.      Byte /    0       |       1       |       2       |       3       |
  7842.         /              |               |               |               |
  7843.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7844.        +---------------+---------------+---------------+---------------+
  7845.       0|.|I| 0x04      |F| Reserved                                    |
  7846.        +---------------+---------------+---------------+---------------+
  7847.       4|TotalAHSLength | DataSegmentLength                             |
  7848.        +---------------+---------------+---------------+---------------+
  7849.       8| LUN or Reserved                                               |
  7850.        +                                                               +
  7851.      12|                                                               |
  7852.        +---------------+---------------+---------------+---------------+
  7853.      16| Initiator Task Tag                                            |
  7854.        +---------------+---------------+---------------+---------------+
  7855.      20| Target Transfer Tag or 0xffffffff                             |
  7856.        +---------------+---------------+---------------+---------------+
  7857.      24| CmdSN                                                         |
  7858.        +---------------+---------------+---------------+---------------+
  7859.      28| ExpStatSN                                                     |
  7860.        +---------------+---------------+---------------+---------------+
  7861.      32/ Reserved                                                      /
  7862.       +/                                                               /
  7863.        +---------------+---------------+---------------+---------------+
  7864.      48| Digests if any                                                |
  7865.        +---------------+---------------+---------------+---------------+
  7866.        / DataSegment (Text)                                            /
  7867.       +/                                                               /
  7868.        +---------------+---------------+---------------+---------------+
  7869.  
  7870.  
  7871. 9.10.1  F (Final) Bit
  7872.  
  7873.      When set to 1,  indicates that this is the last or only text request 
  7874.      in a sequence of commands; otherwise, it indicates that more commands 
  7875.      will follow.
  7876.  
  7877. Julian Satran               Expires August  2002                       155
  7878.  
  7879.  
  7880.  
  7881.  
  7882.  
  7883.                                    iSCSI                         17-April-02
  7884.  
  7885.  
  7886. 9.10.2  Initiator Task Tag
  7887.  
  7888.      The initiator assigned identifier for this Text Request.
  7889.      If the command is sent as part of a sequence of text requests and 
  7890.      responses, the Initiator Task Tag MUST be the same for all the 
  7891.      requests within the sequence (similar to linked SCSI commands).
  7892.  
  7893. 9.10.3  Target Transfer Tag
  7894.  
  7895.      When the Target Transfer Tag is set to the reserved value 0xffffffff, 
  7896.      it tells the target that this is a new request and the target should 
  7897.      reset any internal state associated with the Initiator Task Tag.
  7898.  
  7899.      The target sets the Target Transfer Tag in a text response to a value 
  7900.      other than the reserved value 0xffffffff whenever it indicates that it 
  7901.      has more data to send or more operations to perform that are associ-
  7902.      ated with the specified Initiator Task Tag. It MUST do so whenever it 
  7903.      sets the F bit to 0 in the response. By copying the Target Transfer 
  7904.      Tag from the response to the next Text Request, the initiator tells 
  7905.      the target to continue the operation for the specific Initiator Task 
  7906.      Tag. The initiator MUST ignore the Target Transfer Tag in the Text 
  7907.      Response when the F bit is set to 1.
  7908.  
  7909.      This mechanism allows the initiator and target to transfer a large 
  7910.      amount of textual data over a sequence of text-command/text-response 
  7911.      exchanges or to perform extended negotiation sequences.  
  7912.  
  7913.      If the Target Transfer Tag is not 0xffffffff the LUN field must be the 
  7914.      one sent by the target in the Text Response.
  7915.  
  7916.      A target MAY reset its internal state if an exchange is stalled by the 
  7917.      initiator for a long time or if it is running out of resources.
  7918.  
  7919.      Long text responses are handled as in the following example:
  7920.  
  7921.        I->T Text SendTargets=all (F=1,TTT=0xffffffff)
  7922.        T->I Text <part 1> (F=0,TTT=0x12345678) 
  7923.        I->T Text <empty> (F=1, TTT=0x12345678)
  7924.        T->I Text <part 2> (F=0, TTT=0x12345678) 
  7925.        I->T Text <empty> (F=1, TTT=0x12345678)
  7926.        ...
  7927.        T->I Text <part n> (F=1, TTT=0xffffffff) 
  7928.  
  7929.  
  7930.  
  7931. Julian Satran               Expires August  2002                         156
  7932.  
  7933.  
  7934.  
  7935.  
  7936.  
  7937.                                    iSCSI                      17-April-02
  7938.  
  7939. 9.10.4  Text
  7940.  
  7941.      The data lengths of a text request MUST NOT exceed the iSCSI target 
  7942.      MaxRecvPDULength (a per connection and per direction negotiated 
  7943.      parameter).  The text format is specified in Section 4.2 Text Mode 
  7944.      Negotiation.
  7945.  
  7946.      Chapter 10 and Chapter 11 list some basic Text key=value pairs, some 
  7947.      of which can be used in Login Request/Response and some in Text 
  7948.      Request/Response. 
  7949.  
  7950.      A key=value pair can span Text request or response boundaries (i.e., a 
  7951.      key=value pair can start in one PDU and continue on the next).
  7952.  
  7953.      The target responds by sending its response back to the initiator. The 
  7954.      response text format is similar to the request text format. 
  7955.  
  7956.      As text for text requests and responses can span several PDUs (e.g., 
  7957.      if the PDU length does not allow the whole text to be contained in a 
  7958.      single PDU), the text response MAY refer to key=value pairs presented 
  7959.      in an earlier text request and the text in the request may refer to 
  7960.      earlier responses. 
  7961.  
  7962.      Text operations are usually meant for parameter setting/negotiations, 
  7963.      but can also be used to perform some long lasting operations.
  7964.  
  7965.      Text operations that take a long time should be placed in their own 
  7966.      Text request.  
  7967.  
  7968.  
  7969.  
  7970.  
  7971.  
  7972. Julian Satran               Expires August  2002                         157
  7973.  
  7974.  
  7975.  
  7976.  
  7977.  
  7978.                                    iSCSI                      17-April-02
  7979.  
  7980. 9.11  Text Response
  7981.  
  7982.      The Text Response PDU contains the target's responses to the initia-
  7983.      tor's Text request. The format of the Text field matches that of the 
  7984.      Text request.
  7985.  
  7986.      Byte /    0       |       1       |       2       |       3       |
  7987.         /              |               |               |               |
  7988.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  7989.        +---------------+---------------+---------------+---------------+
  7990.       0|.|.| 0x24      |F| Reserved                                    |
  7991.        +---------------+---------------+---------------+---------------+
  7992.       4|TotalAHSLength | DataSegmentLength                             |
  7993.        +---------------+---------------+---------------+---------------+
  7994.       8| LUN or Reserved                                               |
  7995.        +                                                               +
  7996.      12|                                                               |
  7997.        +---------------+---------------+---------------+---------------+
  7998.      16| Initiator Task Tag                                            |
  7999.        +---------------+---------------+---------------+---------------+
  8000.      20| Target Transfer Tag or 0xffffffff                             |
  8001.        +---------------+---------------+---------------+---------------+
  8002.      24| StatSN                                                        |
  8003.        +---------------+---------------+---------------+---------------+
  8004.      28| ExpCmdSN                                                      |
  8005.        +---------------+---------------+---------------+---------------+
  8006.      32| MaxCmdSN                                                      |
  8007.        +---------------+---------------+---------------+---------------+
  8008.      36/ Reserved                                                      /
  8009.       +/                                                               /
  8010.        +---------------+---------------+---------------+---------------+
  8011.      48| Digests if any...                                             |
  8012.        +---------------+---------------+---------------+---------------+
  8013.        / DataSegment (Text)                                            /
  8014.       +/                                                               /
  8015.        +---------------+---------------+---------------+---------------+
  8016.  
  8017. 9.11.1  F (Final) Bit
  8018.  
  8019.      When set to 1, in response to a text request with the Final bit set to 
  8020.      1, the F bit indicates that the target has finished the whole opera-
  8021.      tion.  Otherwise, if set to 0 in response to a text request with the 
  8022.      Final Bit set to 1, it indicates that the target has more work to do 
  8023.      (invites a follow-on text request).  A text response with the F bit 
  8024.  
  8025. Julian Satran               Expires August  2002                       158
  8026.  
  8027.  
  8028.  
  8029.  
  8030.  
  8031.                                    iSCSI                        17-April-02
  8032.  
  8033.      set to 1 in response to a text request with the F bit set to 0 is a 
  8034.      protocol error. 
  8035.  
  8036.      A text response with the F bit set to 1 MUST NOT contain key=value 
  8037.      pairs that may require additional answers from the initiator.
  8038.  
  8039.      A text response with the F bit set to 1 MUST have a Target Transfer 
  8040.      Tag field set to the reserved value of 0xffffffff.
  8041.  
  8042.      A text response with the F bit set to 0 MUST have a Target Transfer 
  8043.      Tag field set to a value other than the reserved 0xffffffff.
  8044.  
  8045. 9.11.2  Initiator Task Tag
  8046.  
  8047.      The Initiator Task Tag matches the tag used in the initial Text 
  8048.      request.
  8049.  
  8050. 9.11.3  Target Transfer Tag
  8051.  
  8052.      When a target has more work to do (e.g., cannot transfer all the 
  8053.      remaining text data in a single Text response or has to continue the 
  8054.      negotiation) and has enough resources to proceed, it MUST set the Tar-
  8055.      get Transfer Tag to a value other than the reserved value of 
  8056.      0xffffffff.  Otherwise the Target Transfer Tag MUST be set to 
  8057.      0xffffffff.
  8058.  
  8059.      When the Target Transfer Tag is not 0xffffffff the LUN field may be 
  8060.      significant.
  8061.  
  8062.      The initiator MUST copy the Target Transfer Tag and LUN in its next 
  8063.      request to indicate that it wants the rest of the data.
  8064.  
  8065.      If the target receives a Text Request with the Target Transfer Tag set 
  8066.      to the reserved value of 0xffffffff, it discards its internal informa-
  8067.      tion (resets state) associated with the given Initiator Task Tag.  
  8068.  
  8069.      When a target cannot finish the operation in a single text response, 
  8070.      and does not have enough resources to continue it rejects the Text 
  8071.      request with the appropriate Reject code. A target may reset its 
  8072.      internal state associated with an Initiator Task Tag, state expressed 
  8073.      through the Target Transfer Tag if the initiator fails to continue the 
  8074.      exchange for some time. The target may reject subsequent Text requests 
  8075.      with the Target Transfer Tag set to the "stale" value.
  8076.  
  8077.  
  8078. Julian Satran               Expires August  2002                         159
  8079.  
  8080.  
  8081.  
  8082.  
  8083.  
  8084.                                      iSCSI                   17-April-02
  8085.  
  8086. 9.11.4  Text Response Data
  8087.  
  8088.      The data lengths of a text response MUST NOT exceed the iSCSI initia-
  8089.      tor MaxRecvPDULength (a per connection and per direction negotiated 
  8090.      parameter).  The text format is specified in Section 4.2 Text Mode 
  8091.      Negotiation.
  8092.  
  8093.      Chapter 10 and Chapter 11 list some basic Text key=value pairs, some 
  8094.      of which can be used in Login Request/Response and some in Text 
  8095.      Request/Response. 
  8096.  
  8097.      As text for text requests and responses can span several PDUs (e.g., 
  8098.      if the PDU length does not allow the whole text to be contained in a 
  8099.      single PDU) the text response MAY refer to key=value pairs presented 
  8100.      in an earlier text request. 
  8101.  
  8102.      Although the initiator is the requesting party and controls the 
  8103.      request-response initiation and termination, the target can offer 
  8104.      key=value pairs of its own as part of a sequence and not only in 
  8105.      response to the initiator.  
  8106.  
  8107.  
  8108.  
  8109.  
  8110.  
  8111. Julian Satran              Expires August  2002                          160
  8112.  
  8113.  
  8114.  
  8115.  
  8116.  
  8117.                                     iSCSI                     17-April-02
  8118.  
  8119. 9.12  Login Request
  8120.  
  8121.      After establishing a TCP connection between an initiator and a target, 
  8122.      the initiator MUST start a Login phase to gain further access to the 
  8123.      target's resources. 
  8124.  
  8125.      The Login Phase (see Chapter 4) consists of a sequence of Login 
  8126.      requests and responses that carry the same Initiator Task Tag.
  8127.  
  8128.      Login requests are always considered as immediate.
  8129.  
  8130.      Byte /    0       |       1       |       2       |       3       |
  8131.         /              |               |               |               |
  8132.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8133.        +---------------+---------------+---------------+---------------+
  8134.       0|.|.| 0x03      |T|0|0 0|CSG|NSG| Version-max   | Version-min   |
  8135.        +---------------+---------------+---------------+---------------+
  8136.       4|TotalAHSLength | DataSegmentLength                             |
  8137.        +---------------+---------------+---------------+---------------+
  8138.       8| ISID                                                          |
  8139.        +                               +---------------+---------------+
  8140.      12|                               |TSIH                           |
  8141.        +---------------+---------------+---------------+---------------+
  8142.      16| Initiator Task Tag                                            |
  8143.        +---------------+---------------+---------------+---------------+
  8144.      20| CID                           | Reserved                      |
  8145.        +---------------+---------------+---------------+---------------+
  8146.      24| CmdSN                                                         |
  8147.        +---------------+---------------+---------------+---------------+
  8148.      28| ExpStatSN   or   Reserved                                     |
  8149.        +---------------+---------------+---------------+---------------+
  8150.      32| Reserved                                                      |
  8151.        +---------------+---------------+---------------+---------------+
  8152.      36| Reserved                                                      |
  8153.        +---------------+---------------+---------------+---------------+
  8154.      40/ Reserved                                                      /
  8155.       +/                                                               /
  8156.        +---------------+---------------+---------------+---------------+
  8157.      48/ DataSegment - Login Parameters in Text request Format         /
  8158.       +/                                                               /
  8159.        +---------------+---------------+---------------+---------------+
  8160.  
  8161.  
  8162.  
  8163.  
  8164. Julian Satran                Expires August  2002                        161
  8165.  
  8166.  
  8167.  
  8168.  
  8169.  
  8170.                                     iSCSI                    17-April-02
  8171.  
  8172. 9.12.1  T (Transit) Bit
  8173.  
  8174.      If set to 1, indicates that the initiator is ready to transit to the 
  8175.      next stage.
  8176.  
  8177.      If the T bit is set to 1 and NSG is FullFeaturePhase, then this also 
  8178.      indicates that the initiator is ready for the Final Login Response 
  8179.      (see Chapter 4). 
  8180.  
  8181. 9.12.2  CSG and NSG
  8182.  
  8183.      Through these fields, Current Stage (CSG) and Next Stage (NSG), the 
  8184.      Login negotiation commands and responses are associated with a spe-
  8185.      cific stage in the session (SecurityNegotiation, LoginOperationalNe-
  8186.      gotiation, FullFeaturePhase) and may indicate the next stage they 
  8187.      want to move to (see Chapter 4). 
  8188.      The next stage value is valid only when the T bit is 1; otherwise, it 
  8189.      is reserved. 
  8190.  
  8191.      The stage codes are:
  8192.  
  8193.        - 0 - SecurityNegotiation
  8194.        - 1 - LoginOperationalNegotiation
  8195.        - 3 - FullFeaturePhase
  8196.         
  8197. 9.12.3  Version-max
  8198.  
  8199.      Maximum Version number supported.
  8200.  
  8201.      All Login requests within the Login phase MUST carry the same Version-
  8202.      max.
  8203.  
  8204.      The target MUST use the value presented with the first login request.
  8205.  
  8206. 9.12.4  Version-min
  8207.  
  8208.      Minimum Version supported. The version number of the current draft is 
  8209.      0x00.
  8210.  
  8211.      All Login requests within the Login phase MUST carry the same Version-
  8212.      min. The target MUST use the value presented with the first login 
  8213.      request.
  8214.  
  8215.  
  8216.  
  8217.  
  8218. Julian Satran                Expires August  2002                     162
  8219.  
  8220.  
  8221.  
  8222.  
  8223.  
  8224.                                         iSCSI                 17-April-02
  8225.  
  8226. 9.12.5  ISID
  8227.  
  8228.      This is an initiator-defined component of the session identifier and 
  8229.      is structured as follows (see [NDT] and Section 8.1.1 Conservative 
  8230.      Reuse of ISIDs for details):
  8231.       
  8232.  
  8233.      Byte /    0       |       1       |       2       |       3       |
  8234.         /              |               |               |               |
  8235.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8236.        +---------------+---------------+---------------+---------------+
  8237.       0| T |    A      |               B               |      C        |
  8238.        +---------------+---------------+---------------+---------------+
  8239.       4|               D               |
  8240.        +---------------+---------------+
  8241.         
  8242.      The T field identifies the format and usage of A, B, C & D as indi-
  8243.      cated bellow:
  8244.  
  8245.           T
  8246.                 
  8247.           00b     OUI-format 
  8248.                   A&B are a 22 bit OUI 
  8249.                   (the I/G & U/L omitted)
  8250.                   C&D 24 bit qualifier
  8251.           01b     EN - format (IANA Enterprise Number)
  8252.                   A - reserved
  8253.                   B&C EN (IANA Enterprise Number)
  8254.                   D - Qualifier  
  8255.           10b     "Random"
  8256.                   A - reserved
  8257.                   B&C Random
  8258.                   D - Qualifier
  8259.           11b     A,B,C&D Reserved   
  8260.  
  8261.      For the T field values 00b and 01b a combination of A and B (for 00b) 
  8262.      or B and C (for 01b) identifies the vendor or organization whose com-
  8263.      ponent (software or hardware) generates this ISID.  A vendor or orga-
  8264.      nization with one or more OUIs, or one or more Enterprise Numbers, 
  8265.      MUST use at least one of these numbers and select the appropriate 
  8266.      value for the T field when its components generate ISIDs.  An OUI or 
  8267.      EN MUST be set in the corresponding fields in network byte order (byte 
  8268.      big-endian).
  8269.  
  8270.  
  8271.  
  8272.  
  8273. Julian Satran                    Expires August  2002                  163
  8274.  
  8275.  
  8276.  
  8277.  
  8278.  
  8279.                                    iSCSI                        17-April-02
  8280.  
  8281.      If the T field is 10b, B and C are set to a random  24bit unsigned 
  8282.      integer value in network byte order (byte big-endian).  See [NDT] for 
  8283.      how this affects the principle of "conservative reuse".
  8284.  
  8285.      The Qualifier field is a 16 or 24 bit unsigned integer value that pro-
  8286.      vides a range of possible values for the ISID within the selected 
  8287.      namespace. It may be set to any value, within the constraints speci-
  8288.      fied in the iSCSI protocol (see Section 2.4.3 Consequences of the 
  8289.      Model and Section 8.1.1 Conservative Reuse of ISIDs).
  8290.  
  8291.      The T field of 11 is reserved.
  8292.  
  8293.      If the ISID is derived from something assigned to a hardware adapter 
  8294.      or interface by a vendor, as a preset default value, it MUST be con-
  8295.      figurable to a value assigned according to the SCSI port behavior 
  8296.      desired by the system in which it is installed (see Section 8.1.1 Con-
  8297.      servative Reuse of ISIDs and Section 8.1.2 iSCSI Name, ISID and TPGT 
  8298.      Use) and the resultant ISID MUST also be persistent over power cycles, 
  8299.      reboot, card swap etc..
  8300.  
  8301. 9.12.6  TSIH
  8302.  
  8303.      TSIH must be set in the first Login Request.  The reserved value 0 
  8304.      MUST be used on the first connection for a new session.  Otherwise the 
  8305.      TSIH sent by the target at the conclusion of successful login of the 
  8306.      first connection for this session MUST be used.  The TSIH identifies 
  8307.      to the target, the associated existing session for this new connec-
  8308.      tion.  
  8309.  
  8310.      All Login requests within the Login phase MUST carry the same TSIH. 
  8311.  
  8312.      The target MUST use the value presented with the first login request. 
  8313.  
  8314.  
  8315. 9.12.7  Connection ID - CID
  8316.  
  8317.      A unique ID for this connection within the session.
  8318.  
  8319.      All Login requests within the Login phase MUST carry the same CID.
  8320.  
  8321.      The target MUST use the value presented with the first login request.
  8322.  
  8323.  
  8324.  
  8325.  
  8326. Julian Satran               Expires August  2002                        164
  8327.  
  8328.  
  8329.  
  8330.  
  8331.  
  8332.                                     iSCSI                     17-April-02
  8333.  
  8334.      A Login request with a non-zero TSIH and a CID equal to that of an 
  8335.      existing connection implies a logout of the connection followed by a 
  8336.      Login (see Section 4.3.4 Connection reinstatement).
  8337.  
  8338. 9.12.8  CmdSN
  8339.  
  8340.      CmdSN is either the initial command sequence number of a session (for 
  8341.      the first Login request of a session - the "leading" login) or the 
  8342.      command sequence number in the command stream (e.g., if the leading 
  8343.      login carries the CmdSN 123 all other Login requests carry the CmdSN 
  8344.      123 and the first non-immediate command also carries the CmdSN 123). 
  8345.  
  8346.      The target MUST use the value presented with the first login request.
  8347.  
  8348. 9.12.9  ExpStatSN
  8349.  
  8350.      This is ExpStatSN for the old connection.
  8351.  
  8352.      This field is valid only if the Login request restarts a connection 
  8353.      (see Section 4.3.4 Connection reinstatement). 
  8354.  
  8355. 9.12.10  Login Parameters
  8356.  
  8357.      The initiator MAY provide some basic parameters in order to enable the 
  8358.      target to determine if the initiator may use the target's resources 
  8359.      and the initial text parameters for the security exchange.  
  8360.      All the rules specified in Section 9.10.4 Text for text requests/
  8361.      responses also hold for login requests/responses.   Keys and their 
  8362.      explanations are listed in Chapter 10 (security negotiation keys) and 
  8363.      Chapter 11 (operational parameter negotiation keys). All keys in 
  8364.      Chapter 11, except for the X- extension format, MUST be supported by 
  8365.      iSCSI initiators and targets. Keys in Chapter 10, only need to be sup-
  8366.      ported when the function to which they refer is mandatory to imple-
  8367.      ment.
  8368.  
  8369.  
  8370.  
  8371.  
  8372.  
  8373. Julian Satran                Expires August  2002                      165
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.                                   iSCSI                      17-April-02
  8380.  
  8381. 9.13  Login Response
  8382.  
  8383.      The Login Response indicates the progress and/or end of the login 
  8384.      phase.  
  8385.  
  8386.      Byte /    0       |       1       |       2       |       3       |
  8387.         /              |               |               |               |
  8388.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8389.        +---------------+---------------+---------------+---------------+
  8390.       0|.|.| 0x23      |T|0 0 0|CSG|NSG| Version-max   | Version-active|
  8391.        +---------------+---------------+---------------+---------------+
  8392.       4|TotalAHSLength | DataSegmentLength                             |
  8393.        +---------------+---------------+---------------+---------------+
  8394.       8| ISID                                                          |
  8395.        +                               +---------------+---------------+
  8396.      12|                               |TSIH                           |
  8397.        +---------------+---------------+---------------+---------------+
  8398.      16| Initiator Task Tag                                            |
  8399.        +---------------+---------------+---------------+---------------+
  8400.      20| Reserved                                                      |
  8401.        +---------------+---------------+---------------+---------------+
  8402.      24| StatSN                                                        |
  8403.        +---------------+---------------+---------------+---------------+
  8404.      28| ExpCmdSN                                                      |
  8405.        +---------------+---------------+---------------+---------------+
  8406.      32| MaxCmdSN                                                      |
  8407.        +---------------+---------------+---------------+---------------+
  8408.      36| Status-Class  | Status-Detail | Reserved                      |
  8409.        +---------------+---------------+---------------+---------------+
  8410.      40/ Reserved                                                      /
  8411.       +/                                                               /
  8412.        +---------------+---------------+---------------+---------------+
  8413.      48/ DataSegment - Login Parameters in Text request Format         /
  8414.       +/                                                               /
  8415.        +---------------+---------------+---------------+---------------+
  8416.  
  8417. 9.13.1  Version-max
  8418.  
  8419.      This is the highest version number supported by the target.
  8420.  
  8421.      All Login responses within the Login phase MUST carry the same Ver-
  8422.      sion-max.
  8423.  
  8424.  
  8425.  
  8426. Julian Satran              Expires August  2002                      166
  8427.  
  8428.  
  8429.  
  8430.  
  8431.  
  8432.                                    iSCSI                      17-April-02
  8433.  
  8434.      The initiator MUST use the value presented as a response to the first 
  8435.      login request.
  8436.  
  8437. 9.13.2  Version-active
  8438.  
  8439.      Indicates the highest version supported by the target and initiator. 
  8440.      If the target does not support a version within the range specified by 
  8441.      the initiator, the target rejects the login and this field indicates 
  8442.      the lowest version supported by the target.
  8443.  
  8444.      All Login responses within the Login phase MUST carry the same Ver-
  8445.      sion-active.
  8446.  
  8447.      The initiator MUST use the value presented as a response to the first 
  8448.      login request.
  8449.  
  8450. 9.13.3  TSIH
  8451.  
  8452.      The TSIH is the target assigned session identifying handle and its 
  8453.      internal format and content are not defined by this protocol except 
  8454.      for the value 0 that is reserved and used by the initiator to indicate 
  8455.      a new session.  For a new session  TSIH MUST be  set by the target in 
  8456.      the final response andd MUST be 0 otherwise. For an existing session 
  8457.      all Login Responses MUST carry the same TSIH as the Login Request. 
  8458.  
  8459. 9.13.4  StatSN
  8460.  
  8461.      For the first Login Response (the response to the first Login 
  8462.      Request), this is the starting status Sequence Number for the connec-
  8463.      tion. The next response of any kind, including the next login 
  8464.      response, if any, in the same login phase, will carry this number + 1. 
  8465.      This field is valid only if the Status-Class is 0.
  8466.  
  8467. 9.13.5  Status-Class and Status-Detail
  8468.  
  8469.      The Status returned in a Login Response indicates the execution status 
  8470.      of the login phase. The status includes:
  8471.  
  8472.        Status-Class 
  8473.        Status-Detail
  8474.  
  8475.      0 Status-Class indicates success. 
  8476.  
  8477.  
  8478.  
  8479.  
  8480. Julian Satran               Expires August  2002                       167
  8481.  
  8482.  
  8483.  
  8484.  
  8485.  
  8486.                                      iSCSI                         17-April-02
  8487.  
  8488.      A non-zero Status-Class indicates an exception. In this case, Status-
  8489.      Class is sufficient for a simple initiator to use when handling 
  8490.      errors, without having to look at the Status-Detail.  The Status-
  8491.      Detail allows finer-grained error recovery for more sophisticated 
  8492.      initiators, as well as better information for error logging.
  8493.  
  8494.      The status classes are as follows:
  8495.  
  8496.        0 - Success - indicates that the iSCSI target successfully 
  8497.             received, understood, and accepted the request. The numbering 
  8498.             fields (StatSN, ExpCmdSN, MaxCmdSN) are valid only if Status-
  8499.             Class is 0.
  8500.         
  8501.        1 - Redirection - indicates that the initiator must take further 
  8502.             action to complete the request. This is usually due to the 
  8503.             target moving to a different address. All of the redirection 
  8504.             status class responses MUST return one or more text key param-
  8505.             eters of the type "TargetAddress", which indicates the tar-
  8506.             get's new address.
  8507.  
  8508.        2 - Initiator Error (not a format error) - indicates that the 
  8509.             initiator most likely caused the error. This MAY be due to a 
  8510.             request for a resource for which the initiator does not have 
  8511.             permission.  The request should not be tried again.
  8512.  
  8513.        3 - Target Error - indicates that the target sees no errors in 
  8514.             the initiator's login request, but is currently incapable of 
  8515.             fulfilling the request.  The initiator may re-try the same 
  8516.             login request later.
  8517.  
  8518.      The table below shows all of the currently allocated status codes.  
  8519.      The codes are in hexadecimal; the first byte is the status class and 
  8520.      the second byte is the status detail.  
  8521.  
  8522.  
  8523.  
  8524.  
  8525.  
  8526. Julian Satran                Expires August  2002                          168
  8527.  
  8528.  
  8529.  
  8530.  
  8531.  
  8532.                                       iSCSI                      17-April-02
  8533.  
  8534.      -----------------------------------------------------------------
  8535.      Status        | Code | Description
  8536.                    |(hex) |
  8537.      -----------------------------------------------------------------
  8538.      Success       | 0000 | Login is proceeding OK (*1).
  8539.      -----------------------------------------------------------------
  8540.      Target Moved  | 0101 | The requested iSCSI Target Name (ITN)       
  8541.      Temporarily   |      |  has temporarily moved
  8542.                    |      |  to the address provided.
  8543.      -----------------------------------------------------------------
  8544.      Target Moved  | 0102 | The requested ITN has permanently moved
  8545.      Permanently   |      |  to the address provided.
  8546.      -----------------------------------------------------------------
  8547.      Initiator     | 0200 | Miscellaneous iSCSI initiator 
  8548.      Error         |      | errors.
  8549.      ----------------------------------------------------------------
  8550.      Authentication| 0201 | The initiator could not be
  8551.      Failure       |      | successfully authenticated.
  8552.      -----------------------------------------------------------------
  8553.      Authorization | 0202 | The initiator is not allowed access
  8554.      Failure       |      | to the given target.
  8555.      -----------------------------------------------------------------
  8556.      Not Found     | 0203 | The requested ITN does not
  8557.                    |      | exist at this address.
  8558.      -----------------------------------------------------------------
  8559.      Target Removed| 0204 | The requested ITN has been removed and
  8560.                    |      |no forwarding address is provided.
  8561.      -----------------------------------------------------------------
  8562.      Unsupported   | 0205 | The requested iSCSI version range is 
  8563.      Version       |      | not supported by the target. 
  8564.      -----------------------------------------------------------------
  8565.      Too many      | 0206 | Too many connections on this SSID 
  8566.      connections   |      | 
  8567.      -----------------------------------------------------------------
  8568.      Missing       | 0207 | Missing parameters (e.g., iSCSI 
  8569.      parameter     |      | Initiator and/or Target Name).
  8570.      -----------------------------------------------------------------
  8571.      Can't include | 0208 | Target does not support session  
  8572.      in session    |      | spanning to this connection (address)
  8573.      -----------------------------------------------------------------
  8574.      Session type  | 0209 | Target does not support this type of  
  8575.      Not supported |      | of session or not from this Initiator.
  8576.      -----------------------------------------------------------------
  8577.  
  8578. Julian Satran                  Expires August  2002                      169
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.                                      iSCSI                       17-April-02
  8585.  
  8586.      Session does  | 020a | Attempt to add a connection
  8587.      not exist     |      | to an inexistent session
  8588.      -----------------------------------------------------------------
  8589.      Invalid during| 020b | Invalid Request type during Login
  8590.      login         |      | 
  8591.      -----------------------------------------------------------------
  8592.      Target Error  | 0300 | Target hardware or software error.
  8593.      -----------------------------------------------------------------
  8594.      Service       | 0301 | The iSCSI service or target is not
  8595.      Unavailable   |      | currently operational. 
  8596.      -----------------------------------------------------------------
  8597.      Out of        | 0302 | The target has insufficient session, 
  8598.      Resources     |      | connection, or other resources.
  8599.      -----------------------------------------------------------------
  8600.  
  8601.      (*1)If the response T bit is 1 and the NSG is FullFeaturePhase in both 
  8602.      the request and the response the login phase is finished and the ini-
  8603.      tiator may proceed to issue SCSI commands. 
  8604.       
  8605.      If the Status Class is not 0, the initiator and target MUST close the 
  8606.      TCP connection. 
  8607.  
  8608.      If the target wishes to reject the login request for more than one 
  8609.      reason, it should return the primary reason for the rejection.
  8610.  
  8611. 9.13.6  T (Transit) bit
  8612.  
  8613.      The T bit is set to 1 as an indicator of the end of the stage. If the 
  8614.      T bit is set to 1 and NSG is FullFeaturePhase, then this is also the 
  8615.      Final Login Response (see Chapter 4). A T bit of 0 indicates a "par-
  8616.      tial" response, which means "more negotiation needed".
  8617.  
  8618.      A login response with a T bit set to 1 MUST NOT contain key=value 
  8619.      pairs that may require additional answers from the initiator within 
  8620.      the same stage.
  8621.  
  8622.      If the status class is 0, the T bit MUST NOT be set to 1 if the T bit 
  8623.      in the request was set to 0.
  8624.  
  8625.  
  8626.  
  8627.  
  8628.  
  8629. Julian Satran               Expires August  2002                         170
  8630.  
  8631.  
  8632.  
  8633.  
  8634.  
  8635.                                    iSCSI                      17-April-02
  8636.  
  8637. 9.14  Logout Request
  8638.  
  8639.      The Logout request is used to perform a controlled closing of a con-
  8640.      nection.
  8641.  
  8642.      An initiator MAY use a logout command to remove a connection from a 
  8643.      session or to close an entire session.
  8644.  
  8645.      After sending the Logout PDU, an initiator MUST NOT send any new iSCSI 
  8646.      commands on the closing connection. If the Logout is intended to close 
  8647.      the session, new iSCSI commands MUST NOT be sent on any of the connec-
  8648.      tions participating in the session.
  8649.  
  8650.      When receiving a Logout request with the reason code of "close the 
  8651.      connection" or "close the session", the target MUST abort all pending 
  8652.      commands, whether acknowledged or not, on that connection or session 
  8653.      respectively. When receiving a Logout request with the reason code 
  8654.      "remove connection for recovery", the target MUST discard all 
  8655.      requests not yet acknowledged that were issued on the specified con-
  8656.      nection and suspend all data/status/R2T transfers on behalf of pend-
  8657.      ing commands on the specified connection.  The target then issues the 
  8658.      Logout response and half-closes the TCP connection (sends FIN).  After 
  8659.      receiving the Logout response and attempting to receive the FIN (if 
  8660.      still possible), the initiator MUST completely close the logging-out 
  8661.      connection. For the terminated commands, no additional responses 
  8662.      should be expected.
  8663.  
  8664.      A Logout for a CID may be performed on a different transport connec-
  8665.      tion when the TCP connection for the CID has already been terminated.  
  8666.      In such a case, only a logical "closing" of the iSCSI connection for 
  8667.      the CID is implied with a Logout. 
  8668.  
  8669.      All commands that were not terminated or not completed (with status) 
  8670.      and acknowledged when the connection is closed completely can be reas-
  8671.      signed to a new connection if the target supports connection recovery.
  8672.  
  8673.      If an initiator intends to start recovery for a failing connection, it 
  8674.      MUST use either the Logout command to "clean-up" the target end of a 
  8675.      failing connection and enable recovery to start, or use the restart 
  8676.      option of the Login command for the same effect.  In sessions with a 
  8677.      single connection, this may imply the opening of a second connection 
  8678.      with the sole purpose of cleaning-up the first. In this case, the 
  8679.      restart option of the Login should be used.
  8680.  
  8681.  
  8682. Julian Satran               Expires August  2002                       171
  8683.  
  8684.  
  8685.  
  8686.  
  8687.  
  8688.                                     iSCSI                    17-April-02
  8689.  
  8690.  
  8691.      Sending a logout request with the reason code of "close the connec-
  8692.      tion" or "remove the connection for recovery" may result in the dis-
  8693.      carding of some unacknowledged commands. Those holes in command 
  8694.      sequence numbers will have to be handled by appropriate recovery (see 
  8695.      Chapter 6) unless the session is also closed. 
  8696.  
  8697.  
  8698.      Byte /    0       |       1       |       2       |       3       |
  8699.         /              |               |               |               |
  8700.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8701.        +---------------+---------------+---------------+---------------+
  8702.       0|.|I| 0x06      |1| Reserved                                    |
  8703.        +---------------+---------------+---------------+---------------+
  8704.       4|TotalAHSLength | DataSegmentLength                             |
  8705.        +---------------------------------------------------------------+
  8706.       8/ Reserved                                                      /
  8707.       +/                                                               /
  8708.        +---------------+---------------+---------------+---------------+
  8709.      16| Initiator Task Tag                                            |
  8710.        +---------------+---------------+---------------+---------------+
  8711.      20| CID or Reserved               | Reserved      |Reason Code    |
  8712.        +---------------+---------------+---------------+---------------+
  8713.      24| CmdSN                                                         |
  8714.        +---------------+---------------+---------------+---------------+
  8715.      28| ExpStatSN                                                     |
  8716.        +---------------+---------------+---------------+---------------+
  8717.      32/ Reserved                                                      /
  8718.       +/                                                               /
  8719.        +---------------+---------------+---------------+---------------+
  8720.      48| Digest (if any)                                               |
  8721.        +---------------------------------------------------------------+
  8722.  
  8723. 9.14.1  CID
  8724.  
  8725.      This is the connection ID of the connection to be closed (including 
  8726.      closing the TCP stream). This field is valid only if the reason code 
  8727.      is not "close the session".
  8728.  
  8729. 9.14.2  ExpStatSN
  8730.  
  8731.      This is the last ExpStatSN value for the connection to be closed.
  8732.  
  8733.  
  8734.  
  8735. Julian Satran              Expires August  2002                          172
  8736.  
  8737.  
  8738.  
  8739.  
  8740.  
  8741.                                         iSCSI                  17-April-02
  8742.  
  8743. 9.14.3  Reason Code
  8744.  
  8745.      Indicates the reason for Logout:
  8746.  
  8747.        0 - closes the session. All commands associated with the session 
  8748.             (if any) are terminated.
  8749.  
  8750.        1 - closes the connection. All commands associated with connec-
  8751.             tion (if any) are terminated. 
  8752.         
  8753.        2 - removes the connection for recovery. Connection is closed 
  8754.             and all commands associated with it, if any, are to be pre-
  8755.             pared for a new allegiance.
  8756.  
  8757.  
  8758. 9.14.4  Implicit termination of tasks
  8759.  
  8760.      A target implicitly terminates the active tasks in three cases due to 
  8761.      iSCSI protocol:
  8762.  
  8763.         a)  When a connection is implicitly or explicitly logged out with 
  8764.         the Reason code of "Closes the connection" and there are active 
  8765.         tasks allegiant to that connection.
  8766.  
  8767.         b)  When a connection fails and eventually the connection state 
  8768.         times out (state transition M1 in Section 5.2.2 State Transition 
  8769.         Descriptions for Initiators and Targets) and there are active 
  8770.         tasks allegiant to that connection.
  8771.  
  8772.         c)  When a successful recovery Logout is performed while there are 
  8773.         active tasks allegiant to that connection, and those tasks eventu-
  8774.         ally time out after the Time2Wait and Time2Retain periods without 
  8775.         allegiance reassignment.
  8776.  
  8777.      If the tasks terminated in any of the above cases are SCSI tasks, they 
  8778.      MUST be internally terminated with CHECK CONDITION status with a sense 
  8779.      key of unit attention and ASC/ASCQ values of 0x6E/0x00 (COMMAND TO 
  8780.      LOGICAL UNIT FAILED).  Note that this status is meaningful only for 
  8781.      appropriately handling the internal SCSI state aspects such as queued 
  8782.      commands since this status is never communicated back as a terminating 
  8783.      status to the initiator. 
  8784.  
  8785.  
  8786.  
  8787.  
  8788.  
  8789. Julian Satran                Expires August  2002                          173
  8790.  
  8791.  
  8792.  
  8793.  
  8794.  
  8795.                                    iSCSI                      17-April-02
  8796.  
  8797. 9.15  Logout Response
  8798.  
  8799.      The logout response is used by the target to indicate if the cleanup 
  8800.      operation for the connection(s) has completed.
  8801.  
  8802.      After Logout, the TCP connection referred by the CID MUST be closed at 
  8803.      both ends (or all connections must be closed if the logout reason was 
  8804.      session close).
  8805.  
  8806.      Byte /    0       |       1       |       2       |       3       |
  8807.         /              |               |               |               |
  8808.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8809.        +---------------+---------------+---------------+---------------+
  8810.       0|.|.| 0x26      |1| Reserved    | Response      | Reserved      |
  8811.        +---------------+---------------+---------------+---------------+
  8812.       4|TotalAHSLength | DataSegmentLength                             |
  8813.        +---------------------------------------------------------------+
  8814.       8/ Reserved                                                      /
  8815.       +/                                                               /
  8816.        +---------------+---------------+---------------+---------------+
  8817.      16| Initiator Task Tag                                            |
  8818.        +---------------+---------------+---------------+---------------+
  8819.      20| Reserved                                                      |
  8820.        +---------------+---------------+---------------+---------------+
  8821.      24| StatSN                                                        |
  8822.        +---------------+---------------+---------------+---------------+
  8823.      28| ExpCmdSN                                                      |
  8824.        +---------------+---------------+---------------+---------------+
  8825.      32| MaxCmdSN                                                      |
  8826.        +---------------+---------------+---------------+---------------+
  8827.      36| Reserved                                                      |
  8828.        +---------------------------------------------------------------+
  8829.      40| Time2Wait                     | Time2Retain                   |
  8830.        +---------------+---------------+---------------+---------------+
  8831.      44| Reserved                                                      |
  8832.        +---------------+---------------+---------------+---------------+
  8833.      48| Digest (if any)                                               |
  8834.        +---------------------------------------------------------------+
  8835.  
  8836. 9.15.1  Response
  8837.  
  8838.      Logout response:
  8839.  
  8840.        0 - connection or session closed successfully.
  8841.  
  8842. Julian Satran               Expires August  2002                       174
  8843.  
  8844.  
  8845.  
  8846.  
  8847.  
  8848.                                     iSCSI                       17-April-02
  8849.  
  8850.  
  8851.        1 - CID not found.
  8852.  
  8853.        2 - connection recovery not supported (if Logout reason code was 
  8854.          recovery and target does not support it- as indicated by the 
  8855.          ErrorRecoveryLevel.
  8856.  
  8857.        3 - cleanup failed for various reasons.
  8858.  
  8859. 9.15.2  Time2Wait
  8860.  
  8861.      If the Logout response code is 0 and if the operational ErrorRecovery-
  8862.      Level is 2, this is the minimum amount of time, in seconds, to wait 
  8863.      before attempting task reassignment.  If the Logout response code is 0 
  8864.      and if the operational ErrorRecoveryLevel is less than 2, this field 
  8865.      is to be ignored.
  8866.  
  8867.      This field is invalid if the Logout response code is 1.
  8868.  
  8869.      If the Logout response code is 2 or 3, this field specifies the mini-
  8870.      mum time to wait before attempting a new implicit or explicit logout.
  8871.  
  8872.      If Time2Wait is 0, the reassignment or a new Logout may be attempted 
  8873.      immediately.
  8874.  
  8875. 9.15.3  Time2Retain
  8876.  
  8877.      If the Logout response code is 0 and if the operational ErrorRecovery-
  8878.      Level is 2, this is the maximum amount of time, in seconds, after the 
  8879.      initial wait (Time2Wait), the target waits for the allegiance reas-
  8880.      signment for any active task after which the task state is discarded.  
  8881.      If the Logout response code is 0 and if the operational ErrorRecovery-
  8882.      Level is less than 2, this field is to be ignored.
  8883.  
  8884.      This field is invalid if the Logout response code is 1.
  8885.  
  8886.      If the Logout response code is 2 or 3, this field specifies the maxi-
  8887.      mum amount of time, in seconds, after the initial wait (Time2Wait),the 
  8888.      target waits for a new implicit or explicit logout.
  8889.  
  8890.      If it is the last connection of a session, the whole session state is 
  8891.      discarded after Time2Retain.  
  8892.  
  8893.  
  8894.  
  8895.  
  8896. Julian Satran                Expires August  2002                       175
  8897.  
  8898.  
  8899.  
  8900.  
  8901.  
  8902.                                   iSCSI                      17-April-02
  8903.  
  8904.      If Time2Retain is 0, the target had already discarded the connection 
  8905.      (and possibly the session) state along with the task states.  No reas-
  8906.      signment or Logout is required in this case.
  8907.  
  8908.  
  8909.  
  8910.  
  8911.  
  8912. Julian Satran              Expires August  2002                       176
  8913.  
  8914.  
  8915.  
  8916.  
  8917.  
  8918.                                   iSCSI                      17-April-02
  8919.  
  8920. 9.16   SNACK Request
  8921.  
  8922.      Byte /    0       |       1       |       2       |       3       |
  8923.         /              |               |               |               |
  8924.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  8925.        +---------------+---------------+---------------+---------------+
  8926.       0|.|.| 0x10      |1|Rsrvd| Type  | Reserved                      |
  8927.        +---------------+---------------+---------------+---------------+
  8928.       4|TotalAHSLength | DataSegmentLength                             |
  8929.        +---------------+---------------+---------------+---------------+
  8930.       8| LUN or Reserved                                               |
  8931.        +                                                               +
  8932.      12|                                                               |
  8933.        +---------------+---------------+---------------+---------------+
  8934.      16| Initiator Task Tag or 0xffffffff                              |
  8935.        +---------------+---------------+---------------+---------------+
  8936.      20| Target Transfer Tag or 0xffffffff                             |
  8937.        +---------------+---------------+---------------+---------------+
  8938.      24| Reserved                                                      |
  8939.        +---------------+---------------+---------------+---------------+
  8940.      28| ExpStatSN                                                     |
  8941.        +---------------+---------------+---------------+---------------+
  8942.      32/ Reserved                                                      /
  8943.       +/                                                               /
  8944.        +---------------+---------------+---------------+---------------+
  8945.      40| BegRun                                                        |
  8946.        +---------------------------------------------------------------+
  8947.      44| RunLength                                                     |
  8948.        +---------------------------------------------------------------+
  8949.      48| Digest (if any)                                               |
  8950.        +---------------------------------------------------------------+
  8951.  
  8952.      Support for SNACK is mandatory only if the supported ErrorRecovery-
  8953.      Level of the implementation is greater than zero.
  8954.  
  8955.      The SNACK request is used to request the retransmission of numbered-
  8956.      responses, data, or R2T PDUs from the target.  The SNACK request indi-
  8957.      cates the missed numbered-response or data "run" to the target, where 
  8958.      the run starts with the first missed StatSN, DataSN, or R2TSN and 
  8959.      indicates also the number of missed Status, Data, or R2T PDUs (0 has 
  8960.      the special meaning of "all after the initial").
  8961.  
  8962.  
  8963.  
  8964.  
  8965. Julian Satran              Expires August  2002                       177
  8966.  
  8967.  
  8968.  
  8969.  
  8970.  
  8971.                                      iSCSI                    17-April-02
  8972.  
  8973.      The numbered-response(s) or R2T(s), requested by a SNACK, MUST be 
  8974.      delivered as exact replicas of the ones the initiator missed and MUST 
  8975.      include all its flags. However, the fields ExpCmdSN, MaxCmdSN and Exp-
  8976.      DataSN MUST carry the current values.
  8977.  
  8978.      The numbered Data-In PDUs, requested by a SNACK with a RunLength dif-
  8979.      ferent from 0, have to be delivered as exact replicas of the ones the 
  8980.      initiator missed and MUST include all its flags. However, the fields 
  8981.      ExpCmdSN and MaxCmdSN MUST carry the current values.  Data-In PDUs 
  8982.      requested with RunLength 0 (meaning all PDUs after this number) may be 
  8983.      different from the ones originally sent, in order to reflect changes 
  8984.      in MaxRecvPDULength. 
  8985.  
  8986.      Any SNACK that requests a numbered-response, Data, or R2T that was not 
  8987.      sent by the target MUST be rejected with a reason code of "Protocol 
  8988.      error".
  8989.  
  8990. 9.16.1  Type
  8991.  
  8992.      This field encodes the SNACK function as follows:
  8993.  
  8994.        0-Data/R2T SNACK - requesting retransmission of a Data-In or R2T 
  8995.          PDU.
  8996.  
  8997.        1-Status SNACK - requesting retransmission of a numbered 
  8998.          response.
  8999.  
  9000.        2-DataACK - positively acknowledges Data-In PDUs. 
  9001.  
  9002.      All other values are reserved.
  9003.  
  9004.      Data/R2T SNACK for a command MUST precede status acknowledgement for 
  9005.      the given command.
  9006.  
  9007.      For Status SNACK and DataACK, the Initiator Task Tag MUST be set to 
  9008.      the reserved value 0xffffffff. In all other cases, the Initiator Task 
  9009.      Tag field MUST be set to the Initiator Task Tag of the referenced com-
  9010.      mand.
  9011.  
  9012.      For DataACK, the Target Transfer Tag has to contain a copy of the Tar-
  9013.      get Transfer Tag and LUN provided with the SCSI Data-In PDU with the A 
  9014.      bit set to 1. In all other cases, the Target Transfer Tag field MUST 
  9015.      be set to the reserved value of 0xffffffff.
  9016.  
  9017.  
  9018.  
  9019. Julian Satran                 Expires August  2002                     178
  9020.  
  9021.  
  9022.  
  9023.  
  9024.  
  9025.                                       iSCSI                   17-April-02
  9026.  
  9027.      An iSCSI target that does not support recovery within connection MAY 
  9028.      discard the status SNACK. If the target supports recovery within con-
  9029.      nection, it MAY discard the SNACK after which it MUST issue an Asyn-
  9030.      chronous Message PDU with an iSCSI event that indicates "Request 
  9031.      Logout".
  9032.  
  9033.      If an initiator operates at ErrorRecoveryLevel 1 or higher, it MUST 
  9034.      issue a SNACK of type DataACK after receiving a Data-In PDU with the A 
  9035.      bit set to 1.  However, if the initiator has detected holes in the 
  9036.      input sequence, it MUST postpone issuing the SNACK of type DataACK 
  9037.      until the holes are filled. An initiator MAY ignore the A bit if it 
  9038.      deems that the bit is being set aggressively by the target (i.e.,      
  9039.      before the MaxBurstSize limit is reached).
  9040.  
  9041.      The DataACK is used to free resources at the target and not to request 
  9042.      or imply data retransmission.
  9043.  
  9044. 9.16.2  BegRun
  9045.  
  9046.      The first missed DataSN, R2TSN, or StatSN or the next expected DataSN 
  9047.      for a DataACK type SNACK request.
  9048.  
  9049. 9.16.3  RunLength
  9050.  
  9051.      The number of sequential missed DataSN, R2TSN or StatSN. 
  9052.  
  9053.      RunLength of "0" signals that all Data-In, R2T or Response PDUs carry-
  9054.      ing the numbers equal to or greater to BegRun have to be resent.
  9055.  
  9056.      The RunLength MUST also be 0 for a DataACK SNACK.
  9057.  
  9058.      The first data SNACK, issued after initiator's MaxRecvPDULength 
  9059.      decreased, for a command issued on the same connection before the 
  9060.      change in MaxRecvPDULength, MUST use RunLength "0" to request 
  9061.      retransmission of any number of PDUs (including one).  The number of 
  9062.      retransmitted PDUs in this case, may or may not be the same as the 
  9063.      original transmission, depending on whether loss was before or after 
  9064.      the MaxRecvPDULength was changed at the target.
  9065.  
  9066.  
  9067.  
  9068.  
  9069.  
  9070. Julian Satran               Expires August  2002                         179
  9071.  
  9072.  
  9073.  
  9074.  
  9075.  
  9076.                                     iSCSI                    17-April-02
  9077.  
  9078. 9.17  Reject
  9079.  
  9080.      Byte /    0       |       1       |       2       |       3       |
  9081.         /              |               |               |               |
  9082.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  9083.        +---------------+---------------+---------------+---------------+
  9084.       0|.|.| 0x3f      |1| Reserved    | Reason        | Reserved      |
  9085.        +---------------+---------------+---------------+---------------+
  9086.       4|TotalAHSLength | DataSegmentLength                             |
  9087.        +---------------+---------------+---------------+---------------+
  9088.       8/ Reserved                                                      /
  9089.       +/                                                               /
  9090.        +---------------+---------------+---------------+---------------+
  9091.      16| 0xffffffff                                                    |
  9092.        +---------------+---------------+---------------+---------------+
  9093.      20| Reserved                                                      |
  9094.        +---------------+---------------+---------------+---------------+
  9095.      24| StatSN                                                        |
  9096.        +---------------+---------------+---------------+---------------+
  9097.      28| ExpCmdSN                                                      |
  9098.        +---------------+---------------+---------------+---------------+
  9099.      32| MaxCmdSN                                                      |
  9100.        +---------------+---------------+---------------+---------------+
  9101.      36| DataSN or Reserved                                            |
  9102.        +---------------+---------------+---------------+---------------+
  9103.      40| Reserved                                                      |
  9104.        +---------------+---------------+---------------+---------------+
  9105.      44| Reserved                                                      |
  9106.        +---------------+---------------+---------------+---------------+
  9107.      48| Digest (if any)                                               |
  9108.        +---------------+---------------+---------------+---------------+
  9109.      xx/ Complete Header of Bad PDU                                    /
  9110.       +/                                                               /
  9111.        +---------------+---------------+---------------+---------------+
  9112.      yy/Vendor specific data (if any)                                  /
  9113.        /                                                               /
  9114.        +---------------+---------------+---------------+---------------+
  9115.      zz| Digest (if any)                                               |
  9116.        +---------------+---------------+---------------+---------------+
  9117.  
  9118.      Reject is used to indicate an iSCSI error condition (protocol, unsup-
  9119.      ported option etc.).
  9120.  
  9121.  
  9122.  
  9123. Julian Satran                Expires August  2002                    180
  9124.  
  9125.  
  9126.  
  9127.  
  9128.  
  9129.                                   iSCSI                        17-April-02
  9130.  
  9131. 9.17.1  Reason
  9132.  
  9133.      The reject Reason is coded as follows:
  9134.  
  9135.      +------+-----------------------------------------+------------------+
  9136.      | Code | Explanation                             | Can the original |
  9137.      | (hex)|                                         | PDU be re-sent?  |
  9138.      +------+-----------------------------------------+------------------+
  9139.      | 0x01 | Reserved                                | no               |
  9140.      |      |                                         |                  |
  9141.      | 0x02 | Data (payload) Digest Error             | yes  (Note 1)    |
  9142.      |      |                                         |                  |
  9143.      | 0x03 | Data-SNACK Reject                       | yes              |
  9144.      |      |                                         |                  |
  9145.      | 0x04 | Protocol Error (e.g., SNACK request for | no               |
  9146.      |      | a status that was already acknowledged  |                  |
  9147.      |      |                                         |                  |
  9148.      | 0x05 | Command not supported in this session   | no               |
  9149.      |      | type                                    |                  |
  9150.      |      |                                         |                  |
  9151.      | 0x06 | Immediate Command Reject - too many     | yes              |
  9152.      |      | immediate commands                      |                  |
  9153.      |      |                                         |                  |
  9154.      | 0x07 | Task in progress                        | no               |
  9155.      |      |                                         |                  |
  9156.      | 0x08 | Invalid Data ACK                        | no               |
  9157.      |      |                                         |                  |
  9158.      | 0x09 | Invalid PDU field                       | no   (Note 2)    |
  9159.      |      |                                         |                  |
  9160.      | 0x0a | Long Operation Reject - Can't generate  | yes              |
  9161.      |      | Target Transfer Tag - out of resources  |                  |
  9162.      |      |                                         |                  |
  9163.      | 0x0b | Negotiation Reset                       | no               |
  9164.      |      |                                         |                  |
  9165.      | 0x0c | Waiting for Logout                      | no               |
  9166.      +------+-----------------------------------------+------------------+
  9167.  
  9168.      Note 1: For iSCSI Data-Out PDU retransmission is done only if the tar-
  9169.      get requests retransmission with a recovery R2T. However, if this is 
  9170.      the data digest error on immediate data, the initiator may choose to 
  9171.      retransmit the whole PDU including the immediate data.
  9172.  
  9173.  
  9174.  
  9175.  
  9176. Julian Satran              Expires August  2002                        181
  9177.  
  9178.  
  9179.  
  9180.  
  9181.  
  9182.                                    iSCSI                      17-April-02
  9183.  
  9184.      Note 2: A target should use this reason code for all invalid values of 
  9185.      PDU fields that are meant to describe a task or a data transfer.  Some 
  9186.      examples are invalid TTT/ITT, buffer offset, LUN qualifying a TTT.  
  9187.  
  9188.      All other values for Reason are reserved.
  9189.  
  9190.      In all the cases in which a pre-instantiated SCSI task is terminated 
  9191.      because of the reject, the target must issue a proper SCSI command 
  9192.      response with CHECK CONDITION as described in Section 9.4.3 Response. 
  9193.      In those cases in which a status for the SCSI task was already sent 
  9194.      before the reject no additional status is required. If the error is 
  9195.      detected while data from the initiator is still expected (the command 
  9196.      PDU did not contain all the data and the target has not received a 
  9197.      Data-out PDU with the Final bit 1), the target MUST wait until it 
  9198.      receives the Data-out PDU with the F bit set to 1 before sending the 
  9199.      Response PDU. 
  9200.  
  9201.      For additional usage semantics of Reject PDU, see Section 6.2 Usage Of 
  9202.      Reject PDU in Recovery.
  9203.  
  9204. 9.17.2  DataSN
  9205.  
  9206.      This field is valid only if the Reason code is "Protocol error" and 
  9207.      the SNACK was a Data/R2T SNACK.  The DataSN/R2TSN is the last valid 
  9208.      sequence number that the target sent for the task.
  9209.  
  9210. 9.17.3  StatSN, ExpCmdSN and MaxCmdSN
  9211.  
  9212.      Those fields carry their usual values and are not related to the 
  9213.      rejected command
  9214.  
  9215. 9.17.4  Complete Header of Bad PDU
  9216.  
  9217.      The target returns the header (not including digest) of the PDU in 
  9218.      error as the data of the response.
  9219.  
  9220.  
  9221.  
  9222.  
  9223.  
  9224. Julian Satran               Expires August  2002                       182
  9225.  
  9226.  
  9227.  
  9228.  
  9229.  
  9230.                                    iSCSI                       17-April-02
  9231.  
  9232. 9.18  NOP-Out
  9233.  
  9234.      Byte /    0       |       1       |       2       |       3       |
  9235.         /              |               |               |               |
  9236.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  9237.        +---------------+---------------+---------------+---------------+
  9238.       0|.|I| 0x00      |1| Reserved                                    |
  9239.        +---------------+---------------+---------------+---------------+
  9240.       4|TotalAHSLength | DataSegmentLength                             |
  9241.        +---------------+---------------+---------------+---------------+
  9242.       8| LUN or Reserved                                               |
  9243.        +                                                               +
  9244.      12|                                                               |
  9245.        +---------------+---------------+---------------+---------------+
  9246.      16| Initiator Task Tag or 0xffffffff                              |
  9247.        +---------------+---------------+---------------+---------------+
  9248.      20| Target Transfer Tag or 0xffffffff                             |
  9249.        +---------------+---------------+---------------+---------------+
  9250.      24| CmdSN                                                         |
  9251.        +---------------+---------------+---------------+---------------+
  9252.      28| ExpStatSN                                                     |
  9253.        +---------------+---------------+---------------+---------------+
  9254.      32/ Reserved                                                      /
  9255.       +/                                                               /
  9256.        +---------------+---------------+---------------+---------------+
  9257.      48| Digests if any...                                             |
  9258.        +---------------+---------------+---------------+---------------+
  9259.        / DataSegment - Ping Data (optional)                            /
  9260.       +/                                                               /
  9261.        +---------------+---------------+---------------+---------------+
  9262.  
  9263.      A NOP-Out may be used by an initiator as a "ping command" to verify 
  9264.      that a connection/session is still active and all its components are    
  9265.      operational.  The NOP-In response is the "ping echo".
  9266.  
  9267.      A NOP-Out is also sent by an initiator in response to a NOP-In.
  9268.  
  9269.      A NOP-Out may also be used to confirm a changed ExpStatSN if another 
  9270.      PDU will not be available for a long time.
  9271.  
  9272.      When used as a ping command, the Initiator Task Tag MUST be set to a 
  9273.      valid value (not the reserved 0xffffffff).
  9274.  
  9275.  
  9276.  
  9277. Julian Satran               Expires August  2002                        183
  9278.  
  9279.  
  9280.  
  9281.  
  9282.  
  9283.                                    iSCSI                      17-April-02
  9284.  
  9285.      Upon receipt of a NOP-In with the Target Transfer Tag set to a valid 
  9286.      value (not the reserved 0xffffffff), the initiator MUST respond with a 
  9287.      NOP-Out. In this case, the NOP-Out Target Transfer Tag MUST contain a 
  9288.      copy of the NOP-In Target Transfer Tag.
  9289.  
  9290.      When a target receives the NOP-Out with a valid Initiator Task Tag, it 
  9291.      MUST respond with a Nop-In Response (see NOP-In).
  9292.  
  9293. 9.18.1  Initiator Task Tag
  9294.  
  9295.      An initiator assigned identifier for the operation.
  9296.  
  9297.      The NOP-Out must have the Initiator Task Tag set to a valid value only 
  9298.      if a response in the form of NOP-In is requested.
  9299.  
  9300.      If the Initiator Task Tag contains 0xffffffff, the CmdSN field con-
  9301.      tains the next CmdSN. However, CmdSN is not advanced and the I bit 
  9302.      must be set to 1.
  9303.  
  9304. 9.18.2  Target Transfer Tag
  9305.  
  9306.      A target assigned identifier for the operation.
  9307.  
  9308.      The NOP-Out MUST have the Target Transfer Tag set only if it is issued 
  9309.      in response to a NOP-In with a valid Target Transfer Tag. In this 
  9310.      case, it copies the Target Transfer Tag from the NOP-In PDU.
  9311.  
  9312.      When the Target Transfer Tag is set, the LUN field MUST also be copied 
  9313.      from the NOP-In. 
  9314.  
  9315. 9.18.3  Ping Data
  9316.  
  9317.      Ping data is reflected in the NOP-In Response. The length of the 
  9318.      reflected data is limited to MaxRecvPDULength. The length of ping data 
  9319.      is indicated by the Data Segment Length.  0 is a valid value for the 
  9320.      Data Segment Length and indicates the absence of ping data. 
  9321.  
  9322.  
  9323.  
  9324.  
  9325.  
  9326. Julian Satran               Expires August  2002                       184
  9327.  
  9328.  
  9329.  
  9330.  
  9331.  
  9332.                                     iSCSI                     17-April-02
  9333.  
  9334. 9.19  NOP-In
  9335.  
  9336.      Byte /    0       |       1       |       2       |       3       |
  9337.         /              |               |               |               |
  9338.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  9339.        +---------------+---------------+---------------+---------------+
  9340.       0|.|.| 0x20      |1| Reserved                                    |
  9341.        +---------------+---------------+---------------+---------------+
  9342.       4|TotalAHSLength | DataSegmentLength                             |
  9343.        +---------------+---------------+---------------+---------------+
  9344.       8| LUN or Reserved                                               |
  9345.        +                                                               +
  9346.      12|                                                               |
  9347.        +---------------+---------------+---------------+---------------+
  9348.      16| Initiator Task Tag or 0xffffffff                              |
  9349.        +---------------+---------------+---------------+---------------+
  9350.      20| Target Transfer Tag or 0xffffffff                             |
  9351.        +---------------+---------------+---------------+---------------+
  9352.      24| StatSN                                                        |
  9353.        +---------------+---------------+---------------+---------------+
  9354.      28| ExpCmdSN                                                      |
  9355.        +---------------+---------------+---------------+---------------+
  9356.      32| MaxCmdSN                                                      |
  9357.        +---------------+---------------+---------------+---------------+
  9358.      36/ Reserved                                                      /
  9359.       +/                                                               /
  9360.        +---------------+---------------+---------------+---------------+
  9361.      48| Digests if any...                                             |
  9362.        +---------------+---------------+---------------+---------------+
  9363.        / DataSegment - Return Ping Data                                /
  9364.       +/                                                               /
  9365.        +---------------+---------------+---------------+---------------+
  9366.  
  9367.  
  9368.      NOP-In is either sent by a target as a response to a NOP-Out, as a 
  9369.      "ping" to an initiator or as a means to carry a changed ExpCmdSN and/
  9370.      or MaxCmdSN if another PDU will not be available for a long time (as 
  9371.      determined by the target). 
  9372.  
  9373.      When a target receives the NOP-Out with a valid Initiator Task Tag 
  9374.      (not the reserved value 0xffffffff), it MUST respond with a NOP-In 
  9375.      with the same Initiator Task Tag that was provided in the NOP-Out Com-
  9376.      mand. It MUST also duplicate up to the first MaxRecvPDULength bytes of 
  9377.  
  9378.  
  9379. Julian Satran               Expires August  2002                       185
  9380.  
  9381.  
  9382.  
  9383.  
  9384.  
  9385.                                       iSCSI                   17-April-02
  9386.  
  9387.      the initiator provided Ping Data.  For such a response, the Target 
  9388.      Transfer Tag MUST be 0xffffffff.
  9389.  
  9390.      When a target send a NOP-In as a "ping" (the Initiator Task Tag is 
  9391.      0xffffffff) it MUST NOT send any data in the data segment (DataSeg-
  9392.      mentLength MUST be 0).
  9393.  
  9394. 9.19.1  Target Transfer Tag
  9395.  
  9396.      A target assigned identifier for the operation. 
  9397.  
  9398.      If the target is responding to a NOP-Out, this is set to the reserved 
  9399.      value 0xffffffff.
  9400.  
  9401.      If the target is sending a NOP-In as a Ping (intending to receive a 
  9402.      corresponding NOP-Out), this field is set to a valid value (not the 
  9403.      reserved 0xffffffff).
  9404.  
  9405.      If the target is initiating a NOP-In without wanting to receive a cor-
  9406.      responding NOP-Out, this field MUST hold the reserved value of 
  9407.      0xffffffff.
  9408.  
  9409.      Whenever the NOP-In is sent as a "ping" to an initiator (not as a 
  9410.      response to a NOP-Out), the StatSN field will contain the next StatSN. 
  9411.      However, StatSN for this connection is not advanced.
  9412.  
  9413. 9.19.2  LUN
  9414.  
  9415.      A LUN MUST be set to a correct value when the Target Transfer Tag is 
  9416.      valid (not the reserved value 0xffffffff).
  9417.  
  9418.  
  9419.  
  9420.  
  9421.  
  9422. Julian Satran                  Expires August  2002                     186
  9423.  
  9424.  
  9425.  
  9426.  
  9427.  
  9428.                                       iSCSI                   17-April-02
  9429.  
  9430. 10. iSCSI Security Keys and Values
  9431.  
  9432.      Only the following keys can be used during the SecurityNegotiation 
  9433.      stage of the Login Phase:
  9434.  
  9435.        SessionType
  9436.        InitiatorName
  9437.        TargetName
  9438.        InitiatorAlias
  9439.        TargetAlias
  9440.        AuthMethod and all keys listed under AuthMethod along with all 
  9441.          of their associated keys.
  9442.  
  9443.      SessionType, InitiatorName, TargetName, InitiatorAlias and Tar-
  9444.      getAlias are described in Chapter 11 as they can be used also in the 
  9445.      OperationalNegotiation stage. 
  9446.  
  9447.      All security keys have connection-wide applicability.
  9448.  
  9449. 10.1  AuthMethod
  9450.  
  9451.      Use: During Login - Security Negotiation
  9452.      Senders: Initiator and Target
  9453.      Scope: connection
  9454.  
  9455.      AuthMethod = <list-of-options>
  9456.  
  9457.      The  main item of security negotiation is the authentication method 
  9458.      (AuthMethod).
  9459.  
  9460.      The authentication methods that can be used (appear in the list-of-
  9461.      options) are either those listed in the following table or are vendor-
  9462.      unique methods:
  9463.  
  9464.  
  9465.  
  9466.  
  9467.  
  9468. Julian Satran              Expires August  2002                         187
  9469.  
  9470.  
  9471.  
  9472.  
  9473.  
  9474.                                       iSCSI                  17-April-02
  9475.  
  9476.      +------------------------------------------------------------+
  9477.      | Name          | Description                                |
  9478.      +------------------------------------------------------------+
  9479.      | KRB5          | Kerberos V5                                | 
  9480.      +------------------------------------------------------------+
  9481.      | SPKM1         | Simple Public-Key GSS-API Mechanism        | 
  9482.      +------------------------------------------------------------+
  9483.      | SPKM2         | Simple Public-Key GSS-API Mechanism        | 
  9484.      +------------------------------------------------------------+
  9485.      | SRP           | Secure Remote Password                     |
  9486.      +------------------------------------------------------------+
  9487.      | CHAP          | Challenge Handshake Authentication Protocol|
  9488.      +------------------------------------------------------------+
  9489.      | None          | No authentication                          |
  9490.      +------------------------------------------------------------+
  9491.  
  9492.      KRB5 is defined in [RFC1510].
  9493.      SPKM1 and SPKM2 are defined in [RFC2025].
  9494.      SRP is defined in [RFC2945] and CHAP is defined in [RFC1994]. 
  9495.  
  9496.      The AuthMethod selection is followed by an "authentication exchange" 
  9497.      specific to the authentication method selected.
  9498.  
  9499.      The authentication exchange authenticates the initiator to the tar-
  9500.      get, and optionally, the target to the initiator.  Authentication is 
  9501.      not mandatory to use but must be supported by the target and initia-
  9502.      tor.
  9503.  
  9504.      The initiator and target MUST implement SRP.
  9505.  
  9506. 10.2  Kerberos
  9507.  
  9508.      For KRB5 (Kerberos V5) [RFC1510], the initiator MUST use:
  9509.  
  9510.          KRB_AP_REQ=<KRB_AP_REQ>
  9511.  
  9512.      where KRB_AP_REQ is the client message as defined in [RFC1510].
  9513.  
  9514.      If the initiator authentication fails, the target MUST answer with a 
  9515.      Login reject with "Authentication Failure" status. Otherwise, if the 
  9516.      initiator has selected the mutual authentication option (by setting 
  9517.      MUTUAL-REQUIRED in the ap-options field of the KRB_AP_REQ), the tar-
  9518.      get MUST reply with:
  9519.  
  9520.  
  9521. Julian Satran                Expires August  2002                       188
  9522.  
  9523.  
  9524.  
  9525.  
  9526.  
  9527.                                     iSCSI                      17-April-02
  9528.  
  9529.  
  9530.          KRB_AP_REP=<KRB_AP_REP>
  9531.  
  9532.      where KRB_AP_REP is the server's response message as defined in 
  9533.      [RFC1510].
  9534.  
  9535.      If mutual authentication was selected and target authentication 
  9536.      fails, the initiator MUST close the connection.
  9537.  
  9538.      KRB_AP_REQ and KRB_AP_REP are large binary items and their binary 
  9539.      length (not the length of the character string that represents them in 
  9540.      encoded form) MUST not exceed 65536 bytes.
  9541.  
  9542. 10.3  Simple Public-Key Mechanism (SPKM)
  9543.  
  9544.  
  9545.      For SPKM1 and SPKM2 [RFC2025], the initiator MUST use:
  9546.  
  9547.          SPKM_REQ=<SPKM-REQ>
  9548.  
  9549.      where SPKM-REQ is the first initiator token as defined in [RFC2025].
  9550.  
  9551.      [RFC2025] defines situations where each side may send an error token
  9552.      that may cause the peer to re-generate and resend its last token. This 
  9553.      scheme is followed in iSCSI, and the error token syntax is:
  9554.  
  9555.          SPKM_ERROR=<SPKM-ERROR>
  9556.  
  9557.      However, SPKM-DEL tokens that are defined by [RFC2025] for fatal 
  9558.      errors will not be used by iSCSI. If the target needs to send a SPKM-
  9559.      DEL token, it will, instead, send a Login "login reject" message with 
  9560.      the "Authentication Failure" status and terminate the connection. If 
  9561.      the initiator needs to send a SPKM-DEL token, it will  close the con-
  9562.      nection.
  9563.  
  9564.      In the following sections, we assume that no SPKM-ERROR tokens are 
  9565.      required.
  9566.  
  9567.      If the initiator authentication fails, the target MUST return an 
  9568.      error. Otherwise, if the AuthMethod is SPKM1 or if the initiator has 
  9569.      selected the mutual authentication option (by setting mutual-state 
  9570.      bit in the options field of the REQ-TOKEN in the SPKM-REQ), the target 
  9571.      MUST reply with:
  9572.  
  9573.  
  9574. Julian Satran               Expires August  2002                         189
  9575.  
  9576.  
  9577.  
  9578.  
  9579.  
  9580.                                       iSCSI                     17-April-02
  9581.  
  9582.  
  9583.          SPKM_REP_TI=<SPKM-REP-TI>
  9584.  
  9585.      where SPKM-REP-TI is the target token as defined in [RFC2025].
  9586.  
  9587.      If mutual authentication was selected and target authentication 
  9588.      fails, the initiator MUST close the connection. Otherwise, if the 
  9589.      AuthMethod is SPKM1, the initiator MUST continue with: 
  9590.  
  9591.          SPKM_REP_IT=<SPKM-REP-IT>
  9592.  
  9593.      where SPKM-REP-IT is the second initiator token as defined in 
  9594.      [RFC2025]. If the initiator authentication fails, the target MUST 
  9595.      answer with a Login reject with "Authentication Failure" status.
  9596.  
  9597.      All the SPKM-* tokens are large binary items and their binary length 
  9598.      (not the length of the character string that represents them in 
  9599.      encoded form) MUST not exceed 65536 bytes.
  9600.  
  9601. 10.4  Secure Remote Password (SRP)
  9602.  
  9603.  
  9604.      For SRP [RFC2945], the initiator MUST use:
  9605.  
  9606.         SRP_U=<user> TargetAuth=Yes   /* or TargetAuth=No */
  9607.  
  9608.      The target MUST answer with a Login reject with the "Authorization 
  9609.      Failure" status or reply with:
  9610.  
  9611.         SRP_N=<N> SRP_g=<g> SRP_s=<s>
  9612.  
  9613.      The initiator MUST either close the connection or continue with:
  9614.  
  9615.         SRP_A=<A>
  9616.  
  9617.      The target MUST answer with a Login reject with the "Authentication 
  9618.      Failure" status or reply with:
  9619.  
  9620.         SRP_B=<B>
  9621.  
  9622.      The initiator MUST close the connection or continue with:
  9623.  
  9624.         SRP_M=<M>
  9625.  
  9626.  
  9627. Julian Satran              Expires August  2002                          190
  9628.  
  9629.  
  9630.  
  9631.  
  9632.  
  9633.                                     iSCSI                    17-April-02
  9634.  
  9635.  
  9636.      If the initiator authentication fails, the target MUST answer with a 
  9637.      Login reject with "Authentication Failure" status. Otherwise, if the 
  9638.      initiator sent TargetAuth=Yes in the first message (requiring target 
  9639.      authentication), the target MUST reply with:
  9640.  
  9641.        SRP_HM=<H(A | M | K)>
  9642.  
  9643.      If the target authentication fails, the initiator MUST close the con-
  9644.      nection.
  9645.  
  9646.      Where U, N, g, s, A, B, M, and H(A | M | K) are defined in [RFC2945] 
  9647.      (using the SHA1 hash function, i.e., SRP-SHA1), U is a text string, 
  9648.      N,g,s,A,B,M, and H(A | M | K) are binary items. The length of 
  9649.      N,g,s,A,B,M in binary form (not the length of the character string 
  9650.      that represents them in encoded form) MUST not exceed 1024 bytes. Fur-
  9651.      ther restrictions on allowed N,g values are specified in Section 7.2 
  9652.      In-band Initiator-Target Authentication.
  9653.  
  9654. 10.5  Challenge Handshake Authentication Protocol (CHAP)
  9655.  
  9656.      For CHAP [RFC1994], the initiator MUST use:
  9657.  
  9658.         CHAP_A=<A1,A2...>
  9659.  
  9660.      Where A1,A2... are proposed algorithms, in order of preference.
  9661.  
  9662.      The target MUST answer with a Login reject with the "Authentication 
  9663.      Failure" status or reply with:
  9664.  
  9665.         CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
  9666.  
  9667.      Where A is one of A1,A2... that were proposed by the initiator.
  9668.  
  9669.      The initiator MUST continue with:
  9670.  
  9671.         CHAP_N=<N> CHAP_R=<R> 
  9672.  
  9673.      or, if it requires target authentication, with:
  9674.  
  9675.         CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C>
  9676.  
  9677.  
  9678.  
  9679.  
  9680. Julian Satran                Expires August  2002                       191
  9681.  
  9682.  
  9683.  
  9684.  
  9685.  
  9686.                                   iSCSI                      17-April-02
  9687.  
  9688.      If the initiator authentication fails, the target MUST answer with a 
  9689.      Login reject with "Authentication Failure" status. Otherwise, if the 
  9690.      initiator required target authentication, the target MUST reply with 
  9691.  
  9692.         CHAP_N=<N> CHAP_R=<R>
  9693.  
  9694.      If target authentication fails, the initiator MUST close the connec-
  9695.      tion.
  9696.  
  9697.      Where N, (A,A1,A2), I, C, and R are (correspondingly) the Name, Algo-
  9698.      rithm, Identifier, Challenge, and Response as defined in [RFC1994], N 
  9699.      is a text string, A,A1,A2, and I are numbers, and C and R are binary 
  9700.      items and their binary length (not the length of the character string 
  9701.      that represents them in encoded form) MUST not exceed 1024 bytes.
  9702.       
  9703.      For the Algorithm, as stated in [RFC1994], one value is required
  9704.      to be implemented:
  9705.  
  9706.        5       (CHAP with MD5)
  9707.  
  9708.      To guarantee interoperability, initiators SHOULD always offer it as 
  9709.      one of the proposed algorithms.
  9710.  
  9711.  
  9712.  
  9713.  
  9714.  
  9715. Julian Satran              Expires August  2002                          192
  9716.  
  9717.  
  9718.  
  9719.  
  9720.  
  9721.                                       iSCSI                  17-April-02
  9722.  
  9723. 11. Login/Text Operational Keys
  9724.  
  9725.      Some session specific parameters MUST only be carried on the leading 
  9726.      connection and cannot be changed after the leading connection login 
  9727.      (e.g., MaxConnections, the maximum number of connections).  This 
  9728.      holds for a single connection session with regard to connection 
  9729.      restart. The keys that fall into this category have the use LO (Lead-
  9730.      ing Only). 
  9731.  
  9732.      Keys that can be used only during login have the use IO (initialize 
  9733.      only) while those that can be used in both the login phase and full 
  9734.      feature phase have the use ALL.
  9735.  
  9736.      Keys that can only be used during full feature phase use FFPO (full 
  9737.      feature phase only). 
  9738.  
  9739.      Keys marked as "declarative" may appear also in the SecurityNegotia-
  9740.      tion stage while all other keys described in this chapter are opera-
  9741.      tional keys.
  9742.  
  9743.      Key scope is indicated as session-wide (SW) or connection-only (CO).
  9744.  
  9745. 11.1  HeaderDigest and DataDigest
  9746.  
  9747.      Use: IO
  9748.      Senders: Initiator and Target
  9749.      Scope: CO
  9750.  
  9751.      HeaderDigest = <list-of-options>
  9752.      DataDigest = <list-of-options>
  9753.  
  9754.      Digests enable the checking of end-to-end non-cryptographic data 
  9755.      integrity beyond the integrity checks provided by the link layers and 
  9756.      the covering of the whole communication path including all elements 
  9757.      that may change the network level PDUs such as routers, switches, and 
  9758.      proxies. 
  9759.  
  9760.      The following table lists cyclic integrity checksums that can be nego-
  9761.      tiated for the digests and that MUST be implemented by every iSCSI 
  9762.      initiator and target.  These digest options only have error detection 
  9763.      significance.
  9764.  
  9765.      +---------------------------------------------+
  9766.  
  9767.  
  9768. Julian Satran                 Expires August  2002                       193
  9769.  
  9770.  
  9771.  
  9772.  
  9773.  
  9774.                                     iSCSI                    17-April-02
  9775.  
  9776.      | Name          | Description     | Generator |
  9777.      +---------------------------------------------+
  9778.      | CRC32C        | 32 bit CRC      |0x11edc6f41|
  9779.      +---------------------------------------------+
  9780.      | None          | no digest                   |
  9781.      +---------------------------------------------+
  9782.  
  9783.      The generator polynomial for this digest is given in hex-nota-
  9784.      tion(e.g., 0x3b stands for 0011 1011 and the polynomial is 
  9785.      x**5+X**4+x**3+x+1).
  9786.  
  9787.      When the Initiator and Target agree on a digest, this digest MUST be 
  9788.      used for every PDU in Full Feature Phase.
  9789.  
  9790.      Padding bytes, when present, in a segment covered by a CRC, should be 
  9791.      set to 0 and are included in the CRC. The CRC should be calculated as 
  9792.      follows:
  9793.  
  9794.        - Data bits are assumed to form a serial bit stream in the num-
  9795.          bering order that appears in the draft and starts with byte 0 
  9796.          bit 7 to 0 continues with byte 1 bit 7 etc. (Big Endian on 
  9797.          bytes / Little Endian on bits). This bit-stream has no rela-
  9798.          tion to the physical bit stream and is used to associate the 
  9799.          data bits with specific coefficients of a binary polynomial.
  9800.  
  9801.        - The first 32 bits of the bit-stream are complemented.
  9802.  
  9803.        - The n bits of the bit-stream are considered coefficients of a 
  9804.          polynomial M(x) of order n-1, with bit 0 of byte 0 being x^(n-
  9805.          1).
  9806.  
  9807.        - The polynomial is multiplied by x^32 then divided by G(x). The 
  9808.          generator polynomial produces a remainder R(x) of degree <= 
  9809.          31.
  9810.  
  9811.        - The coefficients of R(x) are considered a 32 bit sequence.
  9812.  
  9813.        - The bit sequence is complemented and the result is the CRC.
  9814.  
  9815.        - The CRC bits appear after the message bits with x^31 first 
  9816.          followed by x^30 etc. (when examples are provided, the value 
  9817.          to be specified in the examples follows the same rules of 
  9818.          ordering as the rest of this document).
  9819.  
  9820.        - A receiver of a "good" segment (data or header) including the 
  9821.          CRC built using the generator 0x11edc6f41 will get the value 
  9822.  
  9823.  
  9824. Julian Satran                Expires August  2002                       194
  9825.  
  9826.  
  9827.  
  9828.  
  9829.  
  9830.                                       iSCSI                  17-April-02
  9831.  
  9832.          0x1c2d19ed as its CRC (this is a polynomial value and not a 
  9833.          word as outlined in this draft).
  9834.  
  9835.      Proprietary algorithms MAY also be negotiated for digests. Whenever a 
  9836.      proprietary algorithm is negotiated, "None" or "CRC32C" should be 
  9837.      listed as an option in order to guarantee interoperability.
  9838.  
  9839. 11.2  MaxConnections
  9840.  
  9841.      Use: LO
  9842.      Senders: Initiator and Target
  9843.      Scope: SW
  9844.  
  9845.      MaxConnections=<integer-from-1-to-65535>  
  9846.  
  9847.      Default is 1.
  9848.  
  9849.      Initiator and target negotiate the maximum number of connections 
  9850.      requested/acceptable.  The lower of the two numbers is selected.
  9851.  
  9852. 11.3  SendTargets
  9853.  
  9854.      Use: FFPO
  9855.      Senders: Initiator
  9856.      Scope: SW
  9857.  
  9858.      For a complete description, see Appendix D. - SendTargets Operation -.
  9859.  
  9860. 11.4  TargetName
  9861.  
  9862.      Use: IO by initiator ALL by target, Declarative
  9863.      Senders: Initiator and Target
  9864.      Scope: SW
  9865.  
  9866.      TargetName=<iSCSI-Name>
  9867.  
  9868.      Examples:
  9869.  
  9870.        TargetName=iqn.1993-11.com.disk-vendor.diskarrays.sn.45678
  9871.        TargetName=eui.020000023B040506
  9872.  
  9873.      The initiator of the TCP connection MUST provide this key to the 
  9874.      remote endpoint in the first login request if the initiator is not 
  9875.  
  9876.  
  9877.  
  9878. Julian Satran              Expires August  2002                          195
  9879.  
  9880.  
  9881.  
  9882.  
  9883.  
  9884.                                       iSCSI                      17-April-02
  9885.  
  9886.      establishing a discovery session. The iSCSI Target Name specifies the 
  9887.      worldwide unique name of the target.  
  9888.      The TargetName key may also be returned by the "SendTargets" text 
  9889.      request (which is its only use when issued by a target).
  9890.  
  9891. 11.5  InitiatorName 
  9892.  
  9893.      Use: IO, Declarative
  9894.      Senders: Initiator
  9895.      Scope: SW
  9896.  
  9897.      InitiatorName=<iSCSI-Name>
  9898.  
  9899.      Examples:
  9900.  
  9901.        InitiatorName=iqn.1992-04.com.os-vendor.plan9.cdrom.12345
  9902.        InitiatorName=iqn.2001-02.com.ssp.users.customer235.host90
  9903.        InitiatorName=iSCSI
  9904.  
  9905.      The initiator of the TCP connection MUST provide this key to the 
  9906.      remote endpoint at the first Login of the login phase for every con-
  9907.      nection. The Initiator key enables the initiator to identify itself to 
  9908.      the remote endpoint. 
  9909.  
  9910. 11.6  TargetAlias 
  9911.  
  9912.      Use: ALL, Declarative
  9913.      Senders: Target
  9914.      Scope: SW
  9915.  
  9916.      TargetAlias=<UTF-8 string>
  9917.  
  9918.      Examples:
  9919.  
  9920.        TargetAlias=Bob-s Disk
  9921.        TargetAlias=Database Server 1 Log Disk
  9922.        TargetAlias=Web Server 3 Disk 20
  9923.  
  9924.      If a target has been configured with a human-readable name or descrip-
  9925.      tion, this name MUST be communicated to the initiator during a Login 
  9926.      Response PDU.  This string is not used as an identifier, but can be 
  9927.      displayed by the initiator's user interface in a list of targets to 
  9928.      which it is connected.
  9929.  
  9930.  
  9931.  
  9932. Julian Satran                  Expires August  2002                      196
  9933.  
  9934.  
  9935.  
  9936.  
  9937.  
  9938.                                       iSCSI                      17-April-02
  9939.  
  9940. 11.7  InitiatorAlias
  9941.  
  9942.      Use: ALL, Declarative
  9943.      Senders: Initiator
  9944.      Scope: SW
  9945.  
  9946.      InitiatorAlias=<UTF-8 string>
  9947.  
  9948.      Examples:
  9949.  
  9950.        InitiatorAlias=Web Server 4
  9951.        InitiatorAlias=spyalley.nsa.gov
  9952.        InitiatorAlias=Exchange Server
  9953.  
  9954.      If an initiator has been configured with a human-readable name or 
  9955.      description, it may be communicated to the target during a Login 
  9956.      Request PDU.  If not, the host name can be used instead.
  9957.      This string is not used as an identifier, but can be displayed by the 
  9958.      target's user interface in a list of initiators to which it is con-
  9959.      nected.
  9960.  
  9961.      This key SHOULD be sent by an initiator within the Login phase, if 
  9962.      available.
  9963.  
  9964. 11.8  TargetAddress
  9965.  
  9966.      Use: ALL, Declarative
  9967.      Senders: Target
  9968.      Scope: SW
  9969.  
  9970.      TargetAddress=domainname[:port][,portal-group-tag]
  9971.  
  9972.      If the TCP port is not specified, it is assumed to be the IANA-
  9973.      assigned default port for iSCSI (3260).
  9974.  
  9975.      If the TargetAddress is returned as the result of a redirect status in 
  9976.      a login response, the comma and portal group tag are omitted.
  9977.  
  9978.      If the TargetAddress is returned within a SendTargets response, the 
  9979.      portal group tag is required.
  9980.  
  9981.      Examples:
  9982.  
  9983.        TargetAddress=10.0.0.1:5003,1
  9984.  
  9985. Julian Satran                 Expires August  2002                       197
  9986.  
  9987.  
  9988.  
  9989.  
  9990.  
  9991.                                       iSCSI                  17-April-02
  9992.  
  9993.        TargetAddress=[1080:0:0:0:8:800:200C:417A],65
  9994.        TargetAddress=[1080::8:800:200C:417A]:5003,1
  9995.        TargetAddress=computingcenter.acme.com,23
  9996.  
  9997.      The TargetAddress key is further described in Appendix D. - SendTar-
  9998.      gets Operation -.
  9999.  
  10000. 11.9  TargetPortalGroupTag
  10001.  
  10002.      Use: IO by target, Declarative 
  10003.      Senders: Target 
  10004.      Scope: SW
  10005.  
  10006.      TargetPortalGroupTag=<integer-from-0-to-65535>
  10007.  
  10008.      Examples:
  10009.      TargetPortalGroupTag=1
  10010.  
  10011.      Target portal group tag is a 16-bit integer that uniquely identifies a
  10012.      portal group within an iSCSI target node.  This key carries the value 
  10013.      of the tag of the portal group that is servicing the Login request.  
  10014.      The iSCSI target returns this key to the initiator in the first Login 
  10015.      Response PDU.  
  10016.  
  10017.      For the complete usage expectations of this key see Section 4.3 Login 
  10018.      Phase.
  10019.  
  10020.  
  10021. 11.10  InitialR2T
  10022.  
  10023.      Use: LO
  10024.      Senders: Initiator and Target
  10025.      Scope: SW
  10026.  
  10027.      InitialR2T=<Yes|No> 
  10028.  
  10029.      Examples:
  10030.  
  10031.        I->InitialR2T=No
  10032.        T->InitialR2T=No
  10033.  
  10034.      Default is Yes.
  10035.      Result function is OR.
  10036.  
  10037.  
  10038.  
  10039. Julian Satran                  Expires August  2002                   198
  10040.  
  10041.  
  10042.  
  10043.  
  10044.  
  10045.                                       iSCSI                     17-April-02
  10046.  
  10047.      The InitialR2T key is used to turn off the default use of R2T, thus 
  10048.      allowing an initiator to start sending data to a target as if it has 
  10049.      received an initial R2T with Buffer Offset=0 and Desired Data Transfer 
  10050.      Length=min((FirstBurstSize - Received Immediate Data
  10051.      Length), Expected Data Transfer Length).  The default action is that 
  10052.      R2T is required, unless both the initiator and the target send this 
  10053.      key-pair attribute specifying InitialR2T=No.     Only the first outgo-
  10054.      ing data burst (immediate data and/or separate PDUs) can be sent unso-
  10055.      licited (i.e., not requiring an explicit R2T).
  10056.  
  10057. 11.11  BidiInitialR2T
  10058.  
  10059.      Use: LO
  10060.      Senders: Initiator and Target
  10061.      Scope: SW
  10062.  
  10063.      BidiInitialR2T=<Yes|No> 
  10064.  
  10065.      Examples:
  10066.  
  10067.        I->BidiInitialR2T=No
  10068.        T->BidiInitialR2T=No
  10069.  
  10070.      Default is Yes.
  10071.      Result function is OR.
  10072.  
  10073.      The BidiInitialR2T key is used to turn off the default use of BiDiR2T, 
  10074.      thus allowing an initiator to send data to a target without the target 
  10075.      having sent an R2T to the initiator for the output data (write part) 
  10076.      of a Bidirectional command (having both the R and the W bits set).  
  10077.      The default action is that R2T is required, unless both the initiator 
  10078.      and the target send this key-pair attribute specifying 
  10079.      BidiInitialR2T=No.  Only the first outgoing data burst (immediate 
  10080.      data and/or separate PDUs) can be sent unsolicited by an R2T.
  10081.  
  10082. 11.12  ImmediateData
  10083.  
  10084.      Use: LO
  10085.      Senders: Initiator and Target
  10086.      Scope: SW
  10087.  
  10088.      ImmediateData=<Yes|No> 
  10089.  
  10090.      Default is Yes.
  10091.  
  10092. Julian Satran                  Expires August  2002                     199
  10093.  
  10094.  
  10095.  
  10096.  
  10097.  
  10098.                                       iSCSI                   17-April-02
  10099.  
  10100.      Result function is AND.
  10101.  
  10102.      The initiator and target negotiate support for immediate data. To turn 
  10103.      immediate data off, the initiator or target must state its desire to 
  10104.      do so.  ImmediateData can be turned on if both the initiator and tar-
  10105.      get have ImmediateData=Yes.
  10106.  
  10107.      If ImmediateData is set to Yes and InitialR2T is set to Yes (default), 
  10108.      then only immediate data are accepted in the first burst.
  10109.  
  10110.      If ImmediateData is set to No and InitialR2T is set to Yes, then the 
  10111.      initiator MUST NOT send unsolicited data and the target MUST reject 
  10112.      them with the corresponding response code. 
  10113.  
  10114.      If ImmediateData is set to No and InitialR2T is set to No, then the 
  10115.      initiator MUST NOT send unsolicited immediate data, but MAY send one 
  10116.      unsolicited burst of Data-OUT PDUs.
  10117.  
  10118.      If ImmediateData is set to Yes and InitialR2T is set to No, then the 
  10119.      initiator MAY send unsolicited immediate data and/or one unsolicited 
  10120.      burst of Data-OUT PDUs. 
  10121.  
  10122.      The following table is a summary of unsolicited data options:
  10123.  
  10124.  
  10125.      +----------+-------------+---------------------------------------+
  10126.      |InitialR2T|ImmediateData| Result (up to FirstBurstSize)         |
  10127.      +----------+-------------+---------------------------------------+
  10128.      |  No      |    No       | Unsolicited data in data PDUs only.   |
  10129.      +----------+-------------+---------------------------------------+
  10130.      |  No      |    Yes      | Immediate & separate unsolicited data.|
  10131.      +----------+-------------+---------------------------------------+
  10132.      |  Yes     |    No       | Unsolicited data disallowed.          |
  10133.      +----------+-------------+---------------------------------------+
  10134.      |  Yes     |    Yes      | Immediate unsolicited data only.      |
  10135.      +----------+-------------+---------------------------------------+  
  10136.  
  10137.  
  10138. 11.13  MaxRecvPDULength
  10139.  
  10140.      Use: ALL
  10141.      Senders: Initiator and Target
  10142.      Scope: CO
  10143.  
  10144.  
  10145. Julian Satran               Expires August  2002                       200
  10146.  
  10147.  
  10148.  
  10149.  
  10150.  
  10151.                                       iSCSI                   17-April-02
  10152.  
  10153.  
  10154.      MaxRecvPDULength=<integer-512-to-(2**24-1)> 
  10155.  
  10156.      Default is 8192 bytes.
  10157.  
  10158.      This is a connection specific parameter.
  10159.      The initiator or target declares the maximum data segment length in 
  10160.      bytes they can receive in an iSCSI PDU.
  10161.  
  10162.      For a target the value limiting the size of the receive PDUs is the 
  10163.      lower of the declared MaxRecvPDULength and the negotiated MaxBurst-
  10164.      Size for solicited data or FirstBurstSize for unsolicited data.  The 
  10165.      transmitter is required to send PDUs with a data segment not exceeding 
  10166.      MaxRecvPDULength.   
  10167.  
  10168. 11.14  MaxBurstSize
  10169.  
  10170.      Use: LO
  10171.      Senders: Initiator and Target
  10172.      Scope: SW
  10173.  
  10174.      MaxBurstSize=<integer-512-to-(2**24-1)> 
  10175.  
  10176.      Default is 262144 (256 Kbytes).
  10177.  
  10178.      The initiator and target negotiate maximum SCSI data payload in bytes 
  10179.      in an Data-In or a solicited Data-Out iSCSI sequence. A sequence of 
  10180.      Data-In or Data-Out PDUs ending with a Data-In or Data-Out PDU with 
  10181.      the F bit set to one. 
  10182.  
  10183.      The minimum of the two numbers is selected. 
  10184.  
  10185. 11.15  FirstBurstSize
  10186.  
  10187.      Use: LO
  10188.      Senders: Initiator and Target
  10189.      Scope: SW
  10190.  
  10191.      FirstBurstSize=<integer-512-to-(2**24-1)>  
  10192.  
  10193.      Default is 65536 (64 Kbytes).
  10194.  
  10195.      The initiator and target negotiate the maximum amount in bytes of 
  10196.      unsolicited data an iSCSI initiator may send to the target, during the 
  10197.  
  10198. Julian Satran                  Expires August  2002                    201
  10199.  
  10200.  
  10201.  
  10202.  
  10203.  
  10204.                                       iSCSI                   17-April-02
  10205.  
  10206.      execution of a single SCSI command. This covers the immediate data (if 
  10207.      any) and the sequence of unsolicited Data-Out PDUs (if any) that fol-
  10208.      low the command.
  10209.  
  10210.      The minimum of the two numbers is selected. 
  10211.  
  10212.      FirstBurstSize MUST NOT exceed MaxBurstSize.
  10213.  
  10214. 11.16  DefaultTime2Wait
  10215.  
  10216.      Use: LO
  10217.      Senders: Initiator and Target
  10218.      Scope: SW
  10219.  
  10220.      DefaultTime2Wait=<integer-0-to-3600>
  10221.  
  10222.      Default is 2.
  10223.  
  10224.      The initiator and target negotiate the minimum time, in seconds, to 
  10225.      wait before attempting an explicit/implicit logout or active task 
  10226.      reassignment after an unexpected connection termination or a connec-
  10227.      tion reset. 
  10228.       
  10229.      The higher of the two values is selected.
  10230.  
  10231.      A value of 0 indicates that logout or active task reassignment can be 
  10232.      attempted immediately. 
  10233.  
  10234. 11.17  DefaultTime2Retain
  10235.  
  10236.      Use: LO
  10237.      Senders: Initiator and Target
  10238.      Scope: SW
  10239.  
  10240.      DefaultTime2Retain=<integer-0-to-3600>
  10241.  
  10242.      Default is 20.
  10243.  
  10244.      The initiator and target negotiate the maximum time, in seconds after 
  10245.      an initial wait (Time2Wait), before which an active task reassignment 
  10246.      is still possible after an unexpected connection termination or a con-
  10247.      nection reset. 
  10248.       
  10249.  
  10250.  
  10251. Julian Satran                Expires August  2002                      202
  10252.  
  10253.  
  10254.  
  10255.  
  10256.  
  10257.                                       iSCSI                     17-April-02
  10258.  
  10259.      This value is also the session state timeout if the connection in 
  10260.      question is the last LOGGED_IN connection in the session.
  10261.  
  10262.      The lesser of the two values is selected.
  10263.  
  10264.      A value of 0 indicates that connection/task state is immediately dis-
  10265.      carded by the target. 
  10266.  
  10267. 11.18  MaxOutstandingR2T
  10268.  
  10269.      Use: LO
  10270.      Senders: Initiator and Target
  10271.      Scope: SW
  10272.  
  10273.      MaxOutstandingR2T=<integer-from-1-to-65535>
  10274.  
  10275.      Default is 1.
  10276.  
  10277.      Initiator and target negotiate the maximum number of outstanding R2Ts 
  10278.      per task, excluding any implied initial R2T that might be part of that 
  10279.      task.  An R2T is considered outstanding until the last data PDU (with 
  10280.      the F bit set to 1) is transferred, or a sequence reception timeout 
  10281.      (section 6.12.1) is encountered for that data sequence.
  10282.  
  10283. 11.19  DataPDUInOrder
  10284.  
  10285.      Use: LO
  10286.      Senders: Initiator and Target
  10287.      Scope: SW
  10288.  
  10289.      DataPDUInOrder=<Yes|No>
  10290.  
  10291.      Default is Yes. 
  10292.      Result function is OR.
  10293.  
  10294.      No is used by iSCSI to indicate that the data PDUs within sequences 
  10295.      can be in any order. Yes is used to indicate that data PDUs within 
  10296.      sequences have to be at continuously increasing addresses and over-
  10297.      lays are forbidden.
  10298.  
  10299. 11.20  DataSequenceInOrder
  10300.  
  10301.      Use: LO
  10302.      Senders: Initiator and Target
  10303.  
  10304. Julian Satran                  Expires August  2002                     203
  10305.  
  10306.  
  10307.  
  10308.  
  10309.  
  10310.                                       iSCSI                   17-April-02
  10311.  
  10312.      Scope: SW
  10313.  
  10314.      DataSequenceInOrder=<Yes|No>
  10315.  
  10316.      Default is Yes. 
  10317.      Result function is OR.
  10318.  
  10319.      A Data Sequence is a sequence of Data-In or Data-Out PDUs ending with 
  10320.      a Data-In or Data-Out PDU with the F bit set to one. A Data-out 
  10321.      sequence is sent either unsolicited or in response to an R2T. 
  10322.      Sequences cover an offset-range.
  10323.  
  10324.      If DataSequenceInOrder is set to No, Data PDU sequences may be trans-
  10325.      ferred in any order. 
  10326.  
  10327.      If DataSequenceInOrder is set to Yes, Data Sequences MUST be trans-
  10328.      ferred using continuously non-decreasing sequence offsets (R2T buffer 
  10329.      offset for writes, or the smallest SCSI Data-In buffer offset within a 
  10330.      read data sequence).  
  10331.  
  10332.      If ErrorRecoveryLevel is not 0 and if DataSequenceInOrder is set to 
  10333.      Yes, a target may retry at most the last R2T, and an initiator may at 
  10334.      most request retransmission for the last read data sequence.  
  10335.      MaxOustandingR2T MUST be set to 1 in this case.
  10336.  
  10337. 11.21  ErrorRecoveryLevel 
  10338.  
  10339.      Use: LO
  10340.      Senders: Initiator and Target
  10341.      Scope: SW
  10342.  
  10343.      ErrorRecoveryLevel=<0 to 2>
  10344.  
  10345.      Default is 0.
  10346.  
  10347.      The initiator and target negotiate the recovery level supported.
  10348.      The minimum of the two values is selected.
  10349.  
  10350.      Recovery levels represent a combination of recovery capabilities.
  10351.      Each recovery level includes all the capabilities of the lower recov-
  10352.      ery levels and adds some new ones to them.
  10353.  
  10354.  
  10355.  
  10356.  
  10357. Julian Satran                  Expires August  2002                      204
  10358.  
  10359.  
  10360.  
  10361.  
  10362.  
  10363.                                       iSCSI                  17-April-02
  10364.  
  10365.      In the description of recovery mechanisms, certain recovery classes 
  10366.      are specified.  Section 6.13 Error Recovery Hierarchy describes the 
  10367.      mapping between the classes and the levels.
  10368.  
  10369. 11.22  SessionType 
  10370.  
  10371.      Use: LO, Declarative
  10372.      Senders: Initiator
  10373.      Scope: SW
  10374.  
  10375.      SessionType= <Discovery|Normal>
  10376.  
  10377.      Default is Normal.
  10378.  
  10379.      The Initiator indicates the type of session it wants to create.  The 
  10380.      target can either accept it or reject it.
  10381.  
  10382.      A discovery session indicates to the Target that the only purpose of 
  10383.      this Session is discovery.  The only requests a target accepts  in 
  10384.      this type of session are a text request with a SendTargets key and a 
  10385.      logout request with reason "close the session".
  10386.  
  10387.      The discovery session implies MaxConnections = 1 and overrides both 
  10388.      the default and an explicit setting.
  10389.  
  10390. 11.23  The Vendor Specific Key Format
  10391.  
  10392.      Use: ALL
  10393.      Senders: Initiator and Target
  10394.      Scope: specific key dependent
  10395.  
  10396.      X-reversed.vendor.dns_name.do_something=
  10397.  
  10398.      Keys with this format are used for vendor-specific purposes. These 
  10399.      keys always start with X-.
  10400.  
  10401.      To identify the vendor, we suggest you use the reversed DNS-name as a 
  10402.      prefix to the key-proper.
  10403.  
  10404.  
  10405.  
  10406.  
  10407.  
  10408. Julian Satran                Expires August  2002                     205
  10409.  
  10410.  
  10411.  
  10412.  
  10413.  
  10414.                                   iSCSI                     17-April-02
  10415.  
  10416. 12. IANA Considerations
  10417.  
  10418.  
  10419.      The temporary (user) well-known port number for iSCSI connections 
  10420.      assigned by IANA is 3260.
  10421.  
  10422.  
  10423.  
  10424.  
  10425.  
  10426. Julian Satran              Expires August  2002                      206
  10427.  
  10428.  
  10429.  
  10430.  
  10431.  
  10432.                                     iSCSI                       17-April-02
  10433.  
  10434. References and Bibliography
  10435.  
  10436.      Normative References
  10437.  
  10438.        [AC] A Detailed Proposal for Access Control, Jim Hafner, T10/99-
  10439.          245
  10440.        [AESCBC] Frankel, S., Kelly, S., Glenn, R., "The AES Cipher 
  10441.          Algorithm and Its Use with IPsec", Internet draft  (work in 
  10442.          progress), draft-ietf-ipsec-ciph-aes-cbc-03.txt, November 
  10443.          2001.
  10444.        [AESCTR] Walker, J., Moskowitz, R., "The AES128 CTR Mode of 
  10445.          Operation and Its Use with IPsec", Internet draft (work in 
  10446.          progress), draft-moskowitz-aes128-ctr-00.txt, September 2001.
  10447.        [CAM] ANSI X3.232-199X, Common Access Method-3. 
  10448.        [EUI] "Guidelines for 64-bit Global Identifier (EUI-64)", 
  10449.          http://standards.ieee.org/regauth/oui/tutorials/EUI64.html
  10450.        [OUI] "IEEE OUI and Company_Id Assignments", http://stan-
  10451.          dards.ieee.org/regauth/oui/index.shtml
  10452.        [RFC790] J. Postel, ASSIGNED NUMBERS, September 1981.
  10453.        [RFC791] INTERNET PROTOCOL, DARPA INTERNET PROGRAM PROTOCOL 
  10454.          SPECIFICATION, September 1981.
  10455.        [RFC793] TRANSMISSION CONTROL PROTOCOL, DARPA INTERNET PROGRAM 
  10456.          PROTOCOL SPECIFICATION, September 1981.
  10457.        [RFC1035] P. Mockapetris, DOMAIN NAMES - IMPLEMENTATION AND 
  10458.          SPECIFICATION, November 1987.
  10459.        [RFC1122] Requirements for Internet Hosts-Communication Layer 
  10460.          RFC1122, R. Braden (editor).
  10461.        [RFC1510] J. Kohl, C. Neuman, "The Kerberos Network Authentica-
  10462.          tion Service (V5)", September 1993.
  10463.        [RFC1737] K. Sollins, L. Masinter "Functional Requirements for 
  10464.          Uniform Resource Names". 
  10465.        [RFC1766] H. Alvestrand, "Tags for the Identification of Lan-
  10466.          guages", March 1995.
  10467.        [RFC1964] J. Linn, "The Kerberos Version 5 GSS-API Mechanism", 
  10468.          June 1996.
  10469.        [RFC1982] Elz, R., Bush, R., "Serial Number Arithmetic", RFC 
  10470.          1982, August 1996. 
  10471.        [RFC1994] "W. Simpson, PPP Challenge Handshake Authentication 
  10472.          Protocol (CHAP)", RFC 1994, August 1996.
  10473.        [RFC2025] C. Adams, "The Simple Public-Key GSS-API Mechanism 
  10474.          (SPKM)", October 1996.
  10475.        [RFC2026] Bradner, S., "The Internet Standards Process -- Revi-
  10476.          sion 3", RFC 2026, October 1996.
  10477.        [RFC2044] Yergeau, F., "UTF-8, a Transformation Format of Uni-
  10478.          code and ISO 10646", October 1996.
  10479.        [RFC2045] N. Borenstein, N. Freed, "MIME (Multipurpose Internet 
  10480.          Mail Extensions) Part One: Mechanisms for Specifying and 
  10481.          Describing the Format of Internet Message Bodies", November 
  10482.          1996.
  10483.  
  10484.  
  10485. Julian Satran                Expires August  2002                       207
  10486.  
  10487.  
  10488.  
  10489.  
  10490.  
  10491.                                      iSCSI                      17-April-02
  10492.  
  10493.        [RFC2119] Bradner, S. "Key Words for use in RFCs to Indicate 
  10494.          Requirement Levels", BCP 14, RFC 2119, March 1997. 
  10495.        [RFC2234] D. Crocker, P. Overell Augmented BNF for Syntax Spec-
  10496.          ifications: ABNF.
  10497.        [RFC2246] T. Dierks, C. Allen, " The TLS Protocol Version 1.0.
  10498.        [RFC2373] Hinden, R. and S. Deering, "IP Version 6 Addressing 
  10499.          Architecture", RFC 2373, July 1998.
  10500.        [RFC2396] T. Berners-Lee, R. Fielding, L. Masinter "Uniform 
  10501.          Resource Identifiers".
  10502.        [RFC2434] T. Narten, and H. Avestrand, "Guidelines for Writing 
  10503.          an IANA Considerations Section in RFCs.", RFC2434, October 
  10504.          1998.
  10505.        [RFC2401] S. Kent, R. Atkinson, "Security Architecture for the 
  10506.          Internet Protocol", RFC 2401, November 1998.
  10507.         [RFC2404] C. Madson, R. Glenn, "The Use of HMAC-SHA-1-96 within ESP 
  10508.         and AH", RFC 2404, November 1998.
  10509.         [RFC2406] S. Kent, R. Atkinson, "IP Encapsulating Security Payload 
  10510.         (ESP)", RFC 2406, November 1998.
  10511.         [RFC2407] D. Piper, "The Internet IP Security Domain of Interpre-
  10512.         tation of ISAKMP", RFC 2407, November 1998.
  10513.        [RFC2409] D. Harkins, D. Carrel, "The Internet Key Exchange 
  10514.          (IKE)", RFC 2409, November 1998.
  10515.         [RFC2451] R. Pereira, R. Adams " The ESP CBC-Mode Cipher Algo-
  10516.         rithms".
  10517.        [RFC2732] R. Hinden, B. Carpenter, L. Masinter, "Format for Lit-
  10518.          eral IPv6 Addresses in URL's", RFC 2732, December 1999.
  10519.        [RFC2945], Wu, T., "The SRP Authentication and Key Exchange Sys-
  10520.          tem", September 2000. 
  10521.        [SAM] ANSI X3.270-1998, SCSI-3 Architecture Model (SAM).
  10522.        [SAM2] T10/1157D, SCSI Architecture Model - 2 (SAM-2).
  10523.        [SBC] NCITS.306-1998, SCSI-3 Block Commands (SBC).
  10524.        [SEQ-EXT] Kent, S., "IP Encapsulating Security Payload (ESP)", 
  10525.          Internet draft (work in progress), draft-ietf-ipsec-esp-v3-
  10526.          01.txt, November 2002.
  10527.        [SEC-IPS] B. Aboba & team "Securing Block Storage Protocols over 
  10528.          IP", Internet draft (work in progress), draft-ietf-ips-secu-
  10529.          rity-09.txt, February 2002.             
  10530.        [SPC3]T10/1416-D, SCSI-3 Primary Commands (SPC).
  10531.        [STPREP] P. Hoffman, M. Blanchet, "Preparation of Internation-
  10532.          alized Strings", draft-hoffman-stringprep-00.txt, September, 
  10533.          2001.
  10534.        [STPREP-iSCSI] M. Bakke, "String Profile for iSCSI Names", 
  10535.          draft-ietf-ips-iscsi-string-prep-00.txt, November 2001. 
  10536.        [UNICODE] Unicode Standard Annex #15, "Unicode Normalization 
  10537.          Forms", http://www.unicode.org/unicode/reports/15
  10538.  
  10539.      Informative References:
  10540.  
  10541.  
  10542. Julian Satran                 Expires August  2002                      208
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.                                    iSCSI                    17-April-02
  10549.  
  10550.  
  10551.      [BOOT] P. Sarkar & team draft-ietf-ips-iscsi-boot-03.txt (work 
  10552.        in progress)
  10553.      [COBS] S. Cheshire and M. Baker, Consistent Overhead Byte Stuff-
  10554.        ing, IEEE Transactions on Networking, April 1999.
  10555.      [Castagnoli93] G. Castagnoli, S. Braeuer and M. Herrman "Optimi-
  10556.        zation of Cyclic Redundancy-Check Codes with 24 and 32 Parity 
  10557.        Bits", IEEE Transact. on Communications, Vol. 41, No. 6, June 
  10558.        1993.
  10559.      [CRC] ISO 3309, High-Level Data Link Control (CRC 32). 
  10560.      [NDT] M. Bakke & team, draft-ietf-ips-iscsi-name-disc-05.txt 
  10561.        (work in progress)
  10562.      [Schneier] B. Schneier, "Applied Cryptography: Protocols, Algo-
  10563.        rithms, and Source Code in C", 2nd edition, John Wiley & Sons, 
  10564.        New York, NY, 1996.
  10565.  
  10566.  
  10567. Authors' Addresses
  10568.  
  10569.      Julian Satran
  10570.      IBM, Haifa Research Lab
  10571.      Haifa University Campus - Mount Carmel
  10572.      Haifa 31905, Israel
  10573.      Phone +972.4.829.6264
  10574.      E-mail: Julian_Satran@vnet.ibm.com 
  10575.  
  10576.      Kalman Meth
  10577.      Haifa University Campus - Mount Carmel
  10578.      MATAM - Advanced Technology Center
  10579.      Haifa 31905, Israel
  10580.      Phone +972.4.829.6341
  10581.      E-mail: meth@il.ibm.com
  10582.  
  10583.       Ofer Biran
  10584.      IBM, Haifa Research Lab
  10585.      Haifa University Campus - Mount Carmel
  10586.      Haifa 31905, Israel
  10587.      Phone +972.4.829.6253
  10588.      E-mail: biran@il.ibm.com
  10589.  
  10590.      Daniel F. Smith
  10591.      IBM Almaden Research Center
  10592.      650 Harry Road
  10593.      San Jose, CA 95120-6099, USA
  10594.      Phone: +1.408.927.2072
  10595.      E-mail: dfsmith@almaden.ibm.com
  10596.  
  10597.      Jim Hafner
  10598.      IBM Almaden Research Center
  10599.      650 Harry Road
  10600.  
  10601. Julian Satran               Expires August  2002                      209
  10602.  
  10603.  
  10604.  
  10605.  
  10606.  
  10607.                                    iSCSI            17-April-02
  10608.  
  10609.      San Jose, CA 95120
  10610.      Phone: +1.408.927.1892
  10611.      E-mail: hafner@almaden.ibm.com
  10612.  
  10613.      Costa Sapuntzakis
  10614.      Cisco Systems, Inc.
  10615.      170 W. Tasman Drive
  10616.      San Jose, CA 95134, USA
  10617.      Phone: +1.408.525.5497
  10618.      E-mail: csapuntz@cisco.com
  10619.  
  10620.      Mark Bakke
  10621.      Cisco Systems, Inc.
  10622.      6450 Wedgwood Road
  10623.      Maple Grove, MN
  10624.      USA 55311
  10625.      Phone: +1.763.398.1000
  10626.      E-Mail: mbakke@cisco.com
  10627.  
  10628.      Randy Haagens
  10629.      Hewlett-Packard Company
  10630.      8000 Foothills Blvd.
  10631.      Roseville, CA 95747-5668, USA
  10632.      Phone: +1.916.785.4578
  10633.      E-mail: Randy_Haagens@hp.com
  10634.  
  10635.      Matt Wakeley (current address)
  10636.      Sierra Logic, Inc.
  10637.      Phone: +1.916.772.1234 ext 116
  10638.      E-mail: matt_wakeley@sierralogic.com
  10639.  
  10640.      Efri Zeidner
  10641.      SANgate Systems, Inc. 
  10642.      41 Hameyasdim Street 
  10643.      P.O.B. 1486 
  10644.      Even-Yehuda, Israel 40500 
  10645.      Phone: +972.9.891.9555
  10646.      E-mail: efri@sangate.com
  10647.  
  10648.      Paul von Stamwitz (current address)
  10649.      TrueSAN Networks, Inc.
  10650.      Phone: +1.408.869.4219
  10651.      E-mail: pvonstamwitz@truesan.com
  10652.  
  10653.      Luciano Dalle Ore
  10654.      Quantum Corp.
  10655.      Phone: +1.408.232.6524
  10656.      E-mail: ldalleore@snapserver.com
  10657.  
  10658.      Mallikarjun Chadalapaka
  10659.  
  10660. Julian Satran               Expires August  2002            210
  10661.  
  10662.  
  10663.  
  10664.  
  10665.  
  10666.                                    iSCSI           17-April-02
  10667.  
  10668.        Hewlett-Packard Company
  10669.        8000 Foothills Blvd.
  10670.        Roseville, CA 95747-5668, USA
  10671.        Phone: +1.916.785.5621 
  10672.        E-mail: cbm@rose.hp.com 
  10673.             
  10674.          
  10675.  
  10676.      Comments may be sent to Julian Satran
  10677.  
  10678.  
  10679.  
  10680.  
  10681.  
  10682. Julian Satran              Expires August  2002            211
  10683.  
  10684.  
  10685.  
  10686.  
  10687.  
  10688.                                      iSCSI                    17-April-02
  10689.  
  10690. Appendix A. Sync and Steering with Fixed Interval Markers
  10691.  
  10692.      This appendix presents a simple scheme for synchronization (PDU 
  10693.      boundary retrieval). It uses markers that include synchronization 
  10694.      information placed at fixed intervals in the TCP stream.
  10695.  
  10696.      A Marker consists of:
  10697.  
  10698.      Byte /    0       |       1       |       2       |       3       |
  10699.          /             |               |               |               |
  10700.        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  10701.        +---------------+---------------+---------------+---------------+
  10702.       0| Next-iSCSI-PDU-start pointer - copy #1                        |
  10703.        +---------------+---------------+---------------+---------------+
  10704.       4| Next-iSCSI-PDU-start pointer - copy #2                        |
  10705.        +---------------+---------------+---------------+---------------+
  10706.  
  10707.      The Marker scheme uses payload byte stream counting that includes 
  10708.      every byte placed by iSCSI in the TCP stream except for the markers 
  10709.      themselves. It also excludes any bytes that TCP counts but are not 
  10710.      originated by iSCSI.
  10711.       
  10712.      The Marker indicates the offset to the next iSCSI PDU header. The 
  10713.      Marker is eight bytes in length and contains two 32-bit offset fields 
  10714.      that indicate how many bytes to skip in the TCP stream in order to 
  10715.      find the next iSCSI PDU header. The marker uses two copies of the 
  10716.      pointer so that a marker that spans a TCP packet boundary should leave 
  10717.      at least one valid copy in one of the packets.
  10718.  
  10719.      The inserted value is independent of the marker interval.
  10720.  
  10721.      The use of markers is negotiable. The initiator and target MAY indi-
  10722.      cate their readiness to receive and/or send markers during login sep-
  10723.      arately for each connection. The default is No. 
  10724.  
  10725. A.1  Markers At Fixed Intervals
  10726.  
  10727.      A marker is inserted at fixed intervals in the TCP byte stream. During 
  10728.      login, each end of the iSCSI session specifies the interval at which 
  10729.      it is willing to receive the marker, or it disables the marker alto-
  10730.      gether. If a receiver indicates that it desires a marker, the sender 
  10731.      MAY agree (during negotiation) and provide the marker at the desired 
  10732.      interval. However, in certain environments, a sender not providing 
  10733.  
  10734.  
  10735. Julian Satran                 Expires August  2002                       212
  10736.  
  10737.  
  10738.  
  10739.  
  10740.  
  10741.                                       iSCSI                   17-April-02
  10742.  
  10743.      markers to a receiver wanting markers may suffer an appreciable per-
  10744.      formance degradation. 
  10745.  
  10746.      The marker interval and the initial marker-less interval are counted 
  10747.      in terms of the bytes placed in the TCP stream data by iSCSI. 
  10748.  
  10749.      When reduced to iSCSI terms, markers MUST indicate the offset to a 4-
  10750.      byte word boundary in the stream. The least significant two bits of 
  10751.      each marker word are reserved and are considered 0 for offset computa-
  10752.      tion.
  10753.  
  10754.      Padding iSCSI PDU payloads to 4-byte word boundaries simplifies 
  10755.      marker manipulation.
  10756.  
  10757. A.2  Initial Marker-less Interval
  10758.  
  10759.      To enable the connection setup including the login phase negotiation, 
  10760.      marking (if any) is started only at the first marker interval after 
  10761.      the end of the login phase. However, in order to enable the marker 
  10762.      inclusion and exclusion mechanism to work without knowledge of the 
  10763.      length of the login phase, the first marker will be placed in the TCP 
  10764.      stream as if the Marker-less interval had included markers.
  10765.  
  10766.      Thus all markers appear in the stream at locations conforming to the 
  10767.      formula: [(MI + 8) * n - 8] where MI = Marker Interval, n = integer 
  10768.      number.
  10769.  
  10770.      As an example if the marker interval is 512 bytes and the login ended 
  10771.      at byte 1003 (first iSCSI placed byte is 0) the first marker will be 
  10772.      inserted after byte 1031 in the stream. 
  10773.  
  10774. A.3  Negotiation
  10775.  
  10776.      The following operational key=value pairs are used to negotiate the 
  10777.      fixed interval markers. The direction (output or input) is relative to 
  10778.      the initiator.
  10779.  
  10780. A.3.1   OFMarker, IFMarker
  10781.  
  10782.      Use: IO
  10783.      Senders: Initiator and Target
  10784.      Scope: CO
  10785.  
  10786.      OFMarker=<Yes|No>
  10787.  
  10788. Julian Satran                  Expires August  2002                      213
  10789.  
  10790.  
  10791.  
  10792.  
  10793.  
  10794.                                       iSCSI                   17-April-02
  10795.  
  10796.      IFMarker=<Yes|No>
  10797.  
  10798.      Default is No. 
  10799.  
  10800.      Result function is AND.
  10801.  
  10802.      OFMarker is used to turn on or off the initiator to target markers on 
  10803.      the connection.  IFMarker is used to turn on or off the target to ini-
  10804.      tiator markers on the connection.
  10805.  
  10806.      Examples:
  10807.  
  10808.        I->OFMarker=Yes,IFMarker=Yes
  10809.        T->OFMarker=Yes,IFMarker=Yes
  10810.  
  10811.      Results in the Marker being used in both directions while
  10812.  
  10813.        I->OFMarker=Yes,IFMarker=Yes
  10814.        T->OFMarker=Yes,IFMarker=No
  10815.  
  10816.      Results in Marker being used from the initiator to the target, but not 
  10817.      from the target to initiator.
  10818.  
  10819. A.3.2   OFMarkInt, IFMarkInt
  10820.  
  10821.      Use: IO
  10822.      Senders: Initiator and Target
  10823.      Scope: CO
  10824.  
  10825.      Offering:
  10826.  
  10827.      OFMarkInt=<integer-from-1-to-65535>[~<integer-from-1-to-65535>] 
  10828.      IFMarkInt=<integer-from-1-to-65535>[~<integer-from-1-to-65535>]
  10829.  
  10830.      Responding:
  10831.  
  10832.      OFMarkInt=<integer-from-1-to-65535>|Reject
  10833.      IFMarkInt=<integer-from-1-to-65535>|Reject
  10834.  
  10835.      OFMarkInt is used to set the interval for the initiator to target 
  10836.      markers on the connection.  IFMarkInt is used to set the interval for 
  10837.      the target to initiator markers on the connection.
  10838.  
  10839.  
  10840.  
  10841. Julian Satran               Expires August  2002                         214
  10842.  
  10843.  
  10844.  
  10845.  
  10846.  
  10847.                                     iSCSI                    17-April-02
  10848.  
  10849.      For the offering the initiator or target indicates the minimum to max-
  10850.      imum interval (in 4-byte words) it wants the markers for one or both 
  10851.      directions. In case it only wants a specific value, only a single 
  10852.      value has to be specified. The responder selects a value within the 
  10853.      minimum and maximum offered or the only value offered or indicates 
  10854.      through the xFMarker key=value its inability to set and/or receive 
  10855.      markers. When the interval is unacceptable the responder answers with 
  10856.      "Reject".  Reject is resetting the marker function in the specified 
  10857.      direction (Output or Input) to No.
  10858.  
  10859.      The interval is measured from the end of a marker to the beginning of 
  10860.      the next marker. For example, a value of 1024 means 1024 words (4096 
  10861.      bytes of iSCSI payload between markers). 
  10862.  
  10863.      The default is 2048.
  10864.  
  10865.  
  10866.  
  10867.  
  10868.  
  10869. Julian Satran                Expires August  2002                     215
  10870.  
  10871.  
  10872.  
  10873.  
  10874.  
  10875.                                   iSCSI                     17-April-02
  10876.  
  10877. Appendix B. Examples
  10878.  
  10879. B.1  Read Operation Example
  10880.  
  10881.      +------------------+-----------------------+----------------------+
  10882.      |Initiator Function|    PDU Type           |  Target Function     |
  10883.      +------------------+-----------------------+----------------------+
  10884.      |  Command request |SCSI Command (READ)>>> |                      |
  10885.      |  (read)          |                       |                      |
  10886.      +------------------+-----------------------+----------------------+
  10887.      |                  |                       | Prepare Data Transfer|
  10888.      +------------------+-----------------------+----------------------+
  10889.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          |
  10890.      +------------------+-----------------------+----------------------+
  10891.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          |
  10892.      +------------------+-----------------------+----------------------+
  10893.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          |
  10894.      +------------------+-----------------------+----------------------+
  10895.      |                  |   <<< SCSI Response   |Send Status and Sense |
  10896.      +------------------+-----------------------+----------------------+
  10897.      | Command Complete |                       |                      |
  10898.      +------------------+-----------------------+----------------------+
  10899.  
  10900.  
  10901.  
  10902.  
  10903.  
  10904. Julian Satran              Expires August  2002                      216
  10905.  
  10906.  
  10907.  
  10908.  
  10909.  
  10910.                                   iSCSI                      17-April-02
  10911.  
  10912. B.2  Write Operation Example
  10913.  
  10914.      +------------------+-----------------------+---------------------+
  10915.      |Initiator Function|    PDU Type           |  Target Function    |
  10916.      +------------------+-----------------------+---------------------+
  10917.      |  Command request |SCSI Command (WRITE)>>>| Receive command     |
  10918.      |  (write)         |                       | and queue it        |
  10919.      +------------------+-----------------------+---------------------+
  10920.      |                  |                       | Process old commands|
  10921.      +------------------+-----------------------+---------------------+
  10922.      |                  |                       | Ready to process    |
  10923.      |                  |   <<< R2T             | WRITE command       |
  10924.      +------------------+-----------------------+---------------------+
  10925.      |   Send Data      |   SCSI Data-out >>>   |   Receive Data      |
  10926.      +------------------+-----------------------+---------------------+
  10927.      |                  |   <<< R2T             | Ready for data      |
  10928.      +------------------+-----------------------+---------------------+
  10929.      |                  |   <<< R2T             | Ready for data      |
  10930.      +------------------+-----------------------+---------------------+
  10931.      |   Send Data      |   SCSI Data-out >>>   |   Receive Data      |
  10932.      +------------------+-----------------------+---------------------+
  10933.      |   Send Data      |   SCSI Data-out >>>   |   Receive Data      |
  10934.      +------------------+-----------------------+---------------------+
  10935.      |                  |   <<< SCSI Response   |Send Status and Sense|
  10936.      +------------------+-----------------------+---------------------+
  10937.      | Command Complete |                       |                     |
  10938.      +------------------+-----------------------+---------------------+
  10939.  
  10940. B.3  R2TSN/DataSN use Examples
  10941.  
  10942.      Output (write) data DataSN/R2TSN Example
  10943.  
  10944.  
  10945.  
  10946.  
  10947.  
  10948. Julian Satran              Expires August  2002                      217
  10949.  
  10950.  
  10951.  
  10952.  
  10953.  
  10954.                                   iSCSI                      17-April-02
  10955.  
  10956.      +------------------+-----------------------+----------------------+ 
  10957.      |Initiator Function|    PDU Type & Content |  Target Function     | 
  10958.      +------------------+-----------------------+----------------------+ 
  10959.      |  Command request |SCSI Command (WRITE)>>>| Receive command      | 
  10960.      |  (write)         |                       | and queue it         | 
  10961.      +------------------+-----------------------+----------------------+ 
  10962.      |                  |                       | Process old commands | 
  10963.      +------------------+-----------------------+----------------------+ 
  10964.      |                  |   <<< R2T             | Ready for data       | 
  10965.      |                  |   R2TSN = 0           |                      | 
  10966.      +------------------+-----------------------+----------------------+ 
  10967.      |                  |   <<< R2T             | Ready for more data  | 
  10968.      |                  |   R2TSN = 1           |                      |
  10969.      +------------------+-----------------------+----------------------+ 
  10970.      |  Send Data       |   SCSI Data-out >>>   |   Receive Data       | 
  10971.      |  for R2TSN 0     |   DataSN = 0, F=0     |                      |
  10972.      +------------------+-----------------------+----------------------+ 
  10973.      |  Send Data       |   SCSI Data-out >>>   |   Receive Data       | 
  10974.      |  for R2TSN 0     |   DataSN = 1, F=1     |                      |
  10975.      +------------------+-----------------------+----------------------+ 
  10976.      |  Send Data       |   SCSI Data >>>       |   Receive Data       | 
  10977.      |  for R2TSN 1     |   DataSN = 0, F=1     |                      |
  10978.      +------------------+-----------------------+----------------------+ 
  10979.      |                  |   <<< SCSI Response   |Send Status and Sense | 
  10980.      |                  |   ExpDataSN = 0       |                      |
  10981.      +------------------+-----------------------+----------------------+ 
  10982.      | Command Complete |                       |                      | 
  10983.      +------------------+-----------------------+----------------------+ 
  10984.  
  10985.  
  10986.  
  10987.       Input (read) data DataSN Example
  10988.  
  10989.  
  10990.  
  10991.  
  10992.  
  10993. Julian Satran              Expires August  2002                      218
  10994.  
  10995.  
  10996.  
  10997.  
  10998.  
  10999.                                       iSCSI                  17-April-02
  11000.  
  11001.      +------------------+-----------------------+----------------------+ 
  11002.      |Initiator Function|    PDU Type           |  Target Function     | 
  11003.      +------------------+-----------------------+----------------------+ 
  11004.      |  Command request |SCSI Command (READ)>>> |                      | 
  11005.      |  (read)          |                       |                      | 
  11006.      +------------------+-----------------------+----------------------+ 
  11007.      |                  |                       | Prepare Data Transfer| 
  11008.      +------------------+-----------------------+----------------------+ 
  11009.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          | 
  11010.      |                  |   DataSN = 0, F=0     |                      |
  11011.      +------------------+-----------------------+----------------------+ 
  11012.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          | 
  11013.      |                  |   DataSN = 1, F=0     |                      |
  11014.      +------------------+-----------------------+----------------------+ 
  11015.      |   Receive Data   |   <<< SCSI Data-in    |   Send Data          | 
  11016.      |                  |   DataSN = 2, F=1     |                      |
  11017.      +------------------+-----------------------+----------------------+ 
  11018.      |                  |   <<< SCSI Response   |Send Status and Sense | 
  11019.      |                  |   ExpDataSN = 3       |                      |
  11020.      +------------------+-----------------------+----------------------+ 
  11021.      | Command Complete |                       |                      | 
  11022.      +------------------+-----------------------+----------------------+ 
  11023.  
  11024.  
  11025.       Bidirectional DataSN Example
  11026.  
  11027.  
  11028.  
  11029.  
  11030.  
  11031. Julian Satran              Expires August  2002                      219
  11032.  
  11033.  
  11034.  
  11035.  
  11036.  
  11037.                                   iSCSI                      17-April-02
  11038.  
  11039.      +------------------+-----------------------+----------------------+ 
  11040.      |Initiator Function|    PDU Type           |  Target Function     | 
  11041.      +------------------+-----------------------+----------------------+ 
  11042.      |  Command request |SCSI Command >>>       |                      | 
  11043.      |  (Read-Write)    |  Read-Write           |                      | 
  11044.      +------------------+-----------------------+----------------------+ 
  11045.      |                  |                       | Process old commands | 
  11046.      +------------------+-----------------------+----------------------+ 
  11047.      |                  |   <<< R2T             | Ready to process     | 
  11048.      |                  |   R2TSN = 0           | WRITE command        | 
  11049.      +------------------+-----------------------+----------------------+ 
  11050.      | * Receive Data   |   <<< SCSI Data-in    |   Send Data          | 
  11051.      |                  |   DataSN = 0, F=0     |                      |
  11052.      +------------------+-----------------------+----------------------+ 
  11053.      | * Receive Data   |   <<< SCSI Data-in    |   Send Data          | 
  11054.      |                  |   DataSN = 1, F=1     |                      |
  11055.      +------------------+-----------------------+----------------------+ 
  11056.      |  * Send Data     |   SCSI Data-out >>>   |   Receive Data       | 
  11057.      |  for R2TSN 0     |   DataSN = 0, F=1     |                      |
  11058.      +------------------+-----------------------+----------------------+ 
  11059.      |                  |   <<< SCSI Response   |Send Status and Sense | 
  11060.      |                  |   ExpDataSN = 2       |                      |
  11061.      +------------------+-----------------------+----------------------+ 
  11062.      | Command Complete |                       |                      | 
  11063.      +------------------+-----------------------+----------------------+ 
  11064.  
  11065.      *) Send data and Receive Data may be transferred simultaneously as in 
  11066.      an atomic Read-Old-Write-New or sequential as in an atomic Read-
  11067.      Update-Write (in the alter case the R2T may follow the received data).
  11068.  
  11069.      Unsolicited and immediate output (write) data with DataSN Example
  11070.  
  11071.  
  11072.  
  11073.  
  11074.  
  11075. Julian Satran              Expires August  2002                          220
  11076.  
  11077.  
  11078.  
  11079.  
  11080.  
  11081.                                    iSCSI                     17-April-02
  11082.  
  11083.      +------------------+-----------------------+----------------------+ 
  11084.      |Initiator Function|    PDU Type & Content |  Target Function     | 
  11085.      +------------------+-----------------------+----------------------+ 
  11086.      |  Command request |SCSI Command (WRITE)>>>| Receive command      | 
  11087.      |  (write)         |F=0                    | and data             | 
  11088.      |+ immediate data  |                       | and queue it         | 
  11089.      +------------------+-----------------------+----------------------+ 
  11090.      | Send Unsolicited |   SCSI Write Data >>> | Receive more Data    | 
  11091.      |  Data            |   DataSN = 0, F=1     |                      |
  11092.      +------------------+-----------------------+----------------------+ 
  11093.      |                  |                       | Process old commands | 
  11094.      +------------------+-----------------------+----------------------+ 
  11095.      |                  |   <<< R2T             | Ready for more data  | 
  11096.      |                  |   R2TSN = 0           |                      | 
  11097.      +------------------+-----------------------+----------------------+ 
  11098.      |  Send Data       |   SCSI Write Data >>> |   Receive Data       | 
  11099.      |  for R2TSN 0     |   DataSN = 0, F=1     |                      |
  11100.      +------------------+-----------------------+----------------------+ 
  11101.      |                  |   <<< SCSI Response   |Send Status and Sense | 
  11102.      |                  |                       |                      |
  11103.      +------------------+-----------------------+----------------------+ 
  11104.      | Command Complete |                       |                      | 
  11105.      +------------------+-----------------------+----------------------+
  11106.  
  11107. B.4  CRC Examples
  11108.  
  11109.      N.B. all Values are Hexadecimal
  11110.  
  11111.      32 bytes of zeroes:
  11112.  
  11113.        Byte:        0  1  2  3
  11114.  
  11115.           0:       00 00 00 00
  11116.         ...
  11117.          28:       00 00 00 00
  11118.  
  11119.         CRC:       aa 36 91 8a
  11120.  
  11121.      32 bytes of ones:
  11122.  
  11123.        Byte:        0  1  2  3
  11124.  
  11125.           0:       ff ff ff ff
  11126.  
  11127.  
  11128. Julian Satran               Expires August  2002                     221
  11129.  
  11130.  
  11131.  
  11132.  
  11133.  
  11134.                                   iSCSI            17-April-02
  11135.  
  11136.         ...
  11137.          28:       ff ff ff ff
  11138.  
  11139.         CRC:       43 ab a8 62
  11140.  
  11141.      32 bytes of incrementing 00..1f:
  11142.  
  11143.        Byte:        0  1  2  3
  11144.  
  11145.           0:       00 01 02 03
  11146.         ...
  11147.          28:       1c 1d 1e 1f
  11148.  
  11149.         CRC:       4e 79 dd 46
  11150.  
  11151.      32 bytes of decrementing 1f..00:
  11152.  
  11153.        Byte:        0  1  2  3
  11154.  
  11155.           0:       1f 1e 1d 1c
  11156.         ...
  11157.          28:       03 02 01 00
  11158.  
  11159.         CRC:       5c db 3f 11
  11160.  
  11161.  
  11162.  
  11163.  
  11164.  
  11165. Julian Satran              Expires August  2002            222
  11166.  
  11167.  
  11168.  
  11169.  
  11170.  
  11171.                                      iSCSI                       17-April-02
  11172.  
  11173. Appendix C. Login Phase Examples
  11174.  
  11175.      In the first example, the initiator and target authenticate each other 
  11176.      via Kerberos:
  11177.  
  11178.        I-> Login (CSG,NSG=0,1 T=1)
  11179.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11180.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11181.            AuthMethod=KRB5,SRP,None 
  11182.  
  11183.        T-> Login (CSG,NSG=0,0 T=0)
  11184.            AuthMethod=KRB5
  11185.  
  11186.  
  11187.        I-> Login (CSG,NSG=0,1 T=1)
  11188.            KRB_AP_REQ=<krb_ap_req>
  11189.  
  11190.        (krb_ap_req contains the Kerberos V5 ticket and authenticator 
  11191.             with MUTUAL-REQUIRED set in the ap-options field)
  11192.  
  11193.        If the authentication is successful, the target proceeds with:
  11194.  
  11195.        T-> Login (CSG,NSG=0,1 T=1)
  11196.            KRB_AP_REP=<krb_ap_rep> 
  11197.  
  11198.        (krb_ap_rep is the Kerberos V5 mutual authentication reply) 
  11199.         
  11200.        If the authentication is successful, the initiator may proceed 
  11201.             with:
  11202.  
  11203.        I-> Login (CSG,NSG=1,0 T=0) FirstBurstSize=0
  11204.        T-> Login (CSG,NSG=1,0 T=0) FirstBurstSize=8192 MaxBurst-
  11205.             Size=8192
  11206.        I-> Login (CSG,NSG=1,0 T=0) MaxBurstSize=8192
  11207.            ... more iSCSI Operational Parameters
  11208.  
  11209.        T-> Login (CSG,NSG=1,0 T=0)
  11210.            ... more iSCSI Operational Parameters 
  11211.  
  11212.        And at the end:
  11213.  
  11214.        I-> Login (CSG,NSG=1,3 T=1)
  11215.            optional iSCSI parameters
  11216.  
  11217.        T-> Login (CSG,NSG=1,3 T=1) "login accept" 
  11218.  
  11219.        If the initiator's authentication by the target is not success-
  11220.             ful, the target responds with:
  11221.  
  11222.  
  11223. Julian Satran                 Expires August  2002                       223
  11224.  
  11225.  
  11226.  
  11227.  
  11228.  
  11229.                                      iSCSI                      17-April-02
  11230.  
  11231.        T-> Login "login reject"
  11232.  
  11233.        instead of the Login KRB_AP_REP message, and terminates the con-
  11234.          nection.
  11235.  
  11236.        If the target's authentication by the initiator is not success-
  11237.          ful, the initiator terminates the connection (without respond-
  11238.          ing to the Login KRB_AP_REP message).
  11239.  
  11240.      In the next example only the initiator is authenticated by the target 
  11241.      via Kerberos:
  11242.  
  11243.        I-> Login (CSG,NSG=0,1 T=1)
  11244.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11245.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88  
  11246.            AuthMethod=SRP,KRB5,None 
  11247.  
  11248.        T-> Login-PR (CSG,NSG=0,0 T=0)
  11249.            AuthMethod=KRB5 
  11250.  
  11251.        I-> Login (CSG,NSG=0,1 T=1)
  11252.            KRB_AP_REQ=krb_ap_req 
  11253.  
  11254.        (MUTUAL-REQUIRED not set in the ap-options field of krb_ap_req)
  11255.  
  11256.        If the authentication is successful, the target proceeds with:
  11257.  
  11258.        T-> Login (CSG,NSG=0,1 T=1)
  11259.  
  11260.        I-> Login (CSG,NSG=1,0 T=0)
  11261.            ... iSCSI parameters
  11262.  
  11263.        T-> Login (CSG,NSG=1,0 T=0)
  11264.            ... iSCSI parameters
  11265.  
  11266.        . . .
  11267.  
  11268.        T-> Login (CSG,NSG=1,3 T=1)"login accept"
  11269.  
  11270.  
  11271.      In the next example, the initiator and target authenticate each other 
  11272.      via SPKM1:
  11273.  
  11274.        I-> Login (CSG,NSG=0,1 T=1)
  11275.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11276.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88
  11277.            AuthMethod=SPKM1,KRB5,None 
  11278.  
  11279.        T-> Login (CSG,NSG=0,0 T=0)
  11280.  
  11281. Julian Satran              Expires August  2002                         224
  11282.  
  11283.  
  11284.  
  11285.  
  11286.  
  11287.                                      iSCSI                     17-April-02
  11288.  
  11289.            AuthMethod=SPKM1
  11290.  
  11291.        I-> Login (CSG,NSG=0,0 T=0)
  11292.            SPKM_REQ=<spkm-req>
  11293.  
  11294.        (spkm-req is the SPKM-REQ token with the mutual-state bit in the 
  11295.             options field of the REQ-TOKEN set)
  11296.  
  11297.        T-> Login (CSG,NSG=0,0 T=0)
  11298.            SPKM_REP_TI=<spkm-rep-ti> 
  11299.  
  11300.        If the authentication is successful, the initiator proceeds:
  11301.  
  11302.        I-> Login (CSG,NSG=0,1 T=1)
  11303.            SPKM_REP_IT=<spkm-rep-it>
  11304.         
  11305.        If the authentication is successful, the target proceeds with:
  11306.  
  11307.        T-> Login (CSG,NSG=0,1 T=1)
  11308.  
  11309.        The initiator may proceed:
  11310.  
  11311.        I-> Login  (CSG,NSG=1,0 T=0) ... iSCSI parameters
  11312.        T-> Login  (CSG,NSG=1,0 T=0) ... iSCSI parameters
  11313.  
  11314.        And at the end:
  11315.  
  11316.        I-> Login  (CSG,NSG=1,3 T=1)
  11317.            optional iSCSI parameters 
  11318.  
  11319.        T-> Login (CSG,NSG=1,3 T=1) "login accept"
  11320.  
  11321.  
  11322.        If the target's authentication by the initiator is not success-
  11323.             ful, the initiator terminates the connection (without respond-
  11324.             ing to the Login SPKM_REP_TI message).
  11325.  
  11326.        If the initiator's authentication by the target is not success-
  11327.             ful, the target responds with:
  11328.  
  11329.        T-> Login "login reject"
  11330.  
  11331.        instead of the Login "proceed and change stage" message, and 
  11332.             terminates the connection.
  11333.  
  11334.  
  11335.      In the next example, the initiator and target authenticate each other 
  11336.      via SPKM2:
  11337.  
  11338.  
  11339.  
  11340. Julian Satran                Expires August  2002                       225
  11341.  
  11342.  
  11343.  
  11344.  
  11345.  
  11346.                                      iSCSI                     17-April-02
  11347.  
  11348.        I-> Login (CSG,NSG=0,0 T=0)
  11349.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11350.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88
  11351.                  AuthMethod=SPKM1,SPKM2 
  11352.  
  11353.        T-> Login-PR (CSG,NSG=0,0 T=0)
  11354.            AuthMethod=SPKM2
  11355.  
  11356.        I-> Login (CSG,NSG=0,1 T=1)
  11357.            SPKM_REQ=<spkm-req>
  11358.  
  11359.        (spkm-req is the SPKM-REQ token with the mutual-state bit in the 
  11360.             options field of the REQ-TOKEN not set)
  11361.  
  11362.        If the authentication is successful, the target proceeds with:
  11363.  
  11364.        T-> Login (CSG,NSG=0,1 T=1) 
  11365.  
  11366.        The initiator may proceed:
  11367.  
  11368.        I-> Login (CSG,NSG=1,0 T=0)
  11369.            ... iSCSI parameters
  11370.  
  11371.        T-> Login (CSG,NSG=1,0 T=0)
  11372.            ... iSCSI parameters
  11373.  
  11374.        And at the end:
  11375.  
  11376.        I-> Login  (CSG,NSG=1,3 T=1)
  11377.            optional iSCSI parameters
  11378.  
  11379.        T-> Login (CSG,NSG=1,3 T=1) "login accept"
  11380.  
  11381.  
  11382.      In the next example, the initiator and target authenticate each other 
  11383.      via SRP:
  11384.  
  11385.        I-> Login (CSG,NSG=0,1 T=1)
  11386.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11387.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11388.            AuthMethod=KRB5,SRP,None
  11389.         
  11390.        T-> Login-PR  (CSG,NSG=0,0 T=0)
  11391.            AuthMethod=SRP
  11392.  
  11393.        I-> Login (CSG,NSG=0,0 T=0)
  11394.            SRP_U=<user>
  11395.            TargetAuth=Yes
  11396.  
  11397.  
  11398. Julian Satran                Expires August  2002                      226
  11399.  
  11400.  
  11401.  
  11402.  
  11403.  
  11404.                                     iSCSI                      17-April-02
  11405.  
  11406.        T-> Login (CSG,NSG=0,0 T=0)
  11407.            SRP_N=<N>
  11408.            SRP_g=<g>
  11409.            SRP_s=<s>
  11410.  
  11411.        I-> Login (CSG,NSG=0,0 T=0)
  11412.            SRP_A=<A>
  11413.  
  11414.        T-> Login (CSG,NSG=0,0 T=0)
  11415.            SRP_B=<B>
  11416.  
  11417.        I-> Login (CSG,NSG=0,1 T=1)
  11418.            SRP_M=<M>
  11419.  
  11420.        If the initiator authentication is successful, the target pro-
  11421.          ceeds:
  11422.  
  11423.        T-> Login (CSG,NSG=0,1 T=1)
  11424.            SRP_HM=<H(A | M | K)>
  11425.  
  11426.         Where N, g, s, A, B, M, and H(A | M | K) are defined in [RFC2945].
  11427.  
  11428.        If the target authentication is not successful, the initiator 
  11429.          terminates the connection; otherwise, it proceeds.
  11430.  
  11431.        I-> Login (CSG,NSG=1,0 T=0)
  11432.            ... iSCSI parameters
  11433.  
  11434.        T-> Login (CSG,NSG=1,0 T=0)
  11435.            ... iSCSI parameters
  11436.  
  11437.        And at the end:
  11438.  
  11439.        I-> Login (CSG,NSG=1,3 T=1)
  11440.            optional iSCSI parameters 
  11441.  
  11442.        T-> Login  (CSG,NSG=1,3 T=1) "login accept"
  11443.  
  11444.        If the initiator authentication is not successful, the target 
  11445.          responds with:
  11446.  
  11447.        T-> Login "login reject"
  11448.  
  11449.        Instead of the T-> Login SRP_HM=<H(A | M | K)>  message and ter-
  11450.          minates the connection.
  11451.  
  11452.      In the next example, only the initiator is authenticated by the target 
  11453.      via SRP:
  11454.  
  11455.  
  11456.  
  11457. Julian Satran               Expires August  2002                       227
  11458.  
  11459.  
  11460.  
  11461.  
  11462.  
  11463.                                     iSCSI                      17-April-02
  11464.  
  11465.        I-> Login (CSG,NSG=0,1 T=1)
  11466.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11467.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11468.            AuthMethod=KRB5,SRP,None 
  11469.  
  11470.        T-> Login-PR (CSG,NSG=0,0 T=0)
  11471.            AuthMethod=SRP
  11472.  
  11473.        I-> Login (CSG,NSG=0,0 T=0)
  11474.            SRP_U=<user>
  11475.            TargetAuth=No
  11476.  
  11477.         T-> Login (CSG,NSG=0,0 T=0)
  11478.             SRP_N=<N> 
  11479.             SRP_g=<g>
  11480.             SRP_s=<s>
  11481.  
  11482.        I-> Login (CSG,NSG=0,0 T=0) 
  11483.            SRP_A=<A>
  11484.  
  11485.        T-> Login (CSG,NSG=0,0 T=0) 
  11486.            SRP_B=<B>
  11487.  
  11488.        I-> Login (CSG,NSG=0,1 T=1) 
  11489.            SRP_M=<M>
  11490.         
  11491.        If the initiator authentication is successful, the target pro-
  11492.             ceeds:
  11493.  
  11494.        T-> Login (CSG,NSG=0,1 T=1)
  11495.  
  11496.        I-> Login (CSG,NSG=1,0 T=0) 
  11497.            ... iSCSI parameters
  11498.  
  11499.        T-> Login (CSG,NSG=1,0 T=0)
  11500.            ... iSCSI parameters
  11501.  
  11502.        And at the end:
  11503.  
  11504.        I-> Login (CSG,NSG=1,3 T=1)
  11505.            optional iSCSI parameters
  11506.  
  11507.        T-> Login (CSG,NSG=1,3 T=1) "login accept"
  11508.  
  11509.  
  11510.      In the next example the initiator and target authenticate each other 
  11511.      via CHAP:
  11512.  
  11513.        I-> Login (CSG,NSG=0,0 T=0) 
  11514.  
  11515. Julian Satran                Expires August  2002                      228
  11516.  
  11517.  
  11518.  
  11519.  
  11520.  
  11521.                                      iSCSI                     17-April-02
  11522.  
  11523.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11524.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11525.            AuthMethod=KRB5,CHAP,None 
  11526.  
  11527.        T-> Login-PR (CSG,NSG=0,0 T=0)
  11528.            AuthMethod=CHAP
  11529.  
  11530.        I-> Login (CSG,NSG=0,0 T=0)
  11531.            CHAP_A=<A1,A2>
  11532.  
  11533.         T-> Login (CSG,NSG=0,0 T=0) 
  11534.             CHAP_A=<A1> 
  11535.             CHAP_I=<I> 
  11536.             CHAP_C=<C>
  11537.  
  11538.        I-> Login (CSG,NSG=0,1 T=1)
  11539.            CHAP_N=<N> 
  11540.            CHAP_R=<R> 
  11541.            CHAP_I=<I> 
  11542.            CHAP_C=<C> 
  11543.  
  11544.        If the initiator authentication is successful, the target pro-
  11545.          ceeds:
  11546.  
  11547.        T-> Login (CSG,NSG=0,1 T=1) 
  11548.            CHAP_N=<N> 
  11549.            CHAP_R=<R>
  11550.  
  11551.        If the target authentication is not successful, the initiator 
  11552.          aborts the connection; otherwise, it proceeds.
  11553.  
  11554.        I-> Login (CSG,NSG=1,0 T=0) 
  11555.            ... iSCSI parameters
  11556.        T-> Login (CSG,NSG=1,0 T=0) 
  11557.            ... iSCSI parameters
  11558.  
  11559.        And at the end:
  11560.  
  11561.        I-> Login (CSG,NSG=1,3 T=1) 
  11562.            optional iSCSI parameters
  11563.  
  11564.        T-> Login (CSG,NSG=1,3 T=1) "login accept" 
  11565.  
  11566.        If the initiator authentication is not successful, the target 
  11567.          responds with:
  11568.  
  11569.        T-> Login "login reject"
  11570.  
  11571.  
  11572.  
  11573. Julian Satran                 Expires August  2002                     229
  11574.  
  11575.  
  11576.  
  11577.  
  11578.  
  11579.                                      iSCSI                     17-April-02
  11580.  
  11581.        Instead of the Login CHAP_R=<response> "proceed and change 
  11582.          stage"
  11583.        message and terminates the connection.
  11584.  
  11585.  
  11586.      In the next example, only the initiator is authenticated by the target 
  11587.      via CHAP:
  11588.  
  11589.        I-> Login (CSG,NSG=0,1 T=0) 
  11590.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11591.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11592.            AuthMethod=KRB5,CHAP,None 
  11593.  
  11594.        T-> Login-PR (CSG,NSG=0,0 T=0)
  11595.            AuthMethod=CHAP
  11596.  
  11597.        I-> Login (CSG,NSG=0,0 T=0) 
  11598.            CHAP_A=<A1,A2>
  11599.  
  11600.         T-> Login (CSG,NSG=0,0 T=0) 
  11601.             CHAP_A=<A1> 
  11602.             CHAP_I=<I> 
  11603.             CHAP_C=<C>
  11604.  
  11605.        I-> Login (CSG,NSG=0,1 T=1) 
  11606.            CHAP_N=<N> 
  11607.            CHAP_R=<R> 
  11608.  
  11609.        If the initiator authentication is successful, the target pro-
  11610.          ceeds:
  11611.  
  11612.        T-> Login (CSG,NSG=0,1 T=1)
  11613.  
  11614.        I-> Login (CSG,NSG=1,0 T=0) 
  11615.            ... iSCSI parameters
  11616.  
  11617.        T-> Login (CSG,NSG=1,0 T=0) 
  11618.            ... iSCSI parameters
  11619.  
  11620.        And at the end:
  11621.  
  11622.        I-> Login (CSG,NSG=1,3 T=1) 
  11623.            optional iSCSI parameters
  11624.  
  11625.        T-> Login (CSG,NSG=1,3 T=1) "login accept" 
  11626.  
  11627.  
  11628.  
  11629.  
  11630. Julian Satran                 Expires August  2002                     230
  11631.  
  11632.  
  11633.  
  11634.  
  11635.  
  11636.                                      iSCSI                      17-April-02
  11637.  
  11638.      In the next example, the initiator does not offer any security param-
  11639.      eters. It therefore, may offer iSCSI parameters on the Login PDU with 
  11640.      the T bit set to 1, and the target may respond with a final Login 
  11641.      Response PDU immediately:
  11642.  
  11643.        I-> Login (CSG,NSG=1,3 T=1) 
  11644.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11645.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88  
  11646.            ... iSCSI parameters
  11647.  
  11648.        T-> Login (CSG,NSG=1,3 T=1) "login accept"     
  11649.            ... ISCSI parameters
  11650.  
  11651.        In the next example, the initiator does offer security parame-
  11652.          ters on the Login PDU, but the target does not choose any 
  11653.          (i.e., chooses the "None" values):
  11654.  
  11655.        I-> Login (CSG,NSG=0,1 T=1) 
  11656.            InitiatorName=iqn.1999-07.com.os.hostid.77
  11657.            TargetName=iqn.1999-07.com.acme.diskarray.sn.88 
  11658.            AuthMethod:KRB5,SRP,None
  11659.  
  11660.        T-> Login-PR (CSG,NSG=0,1 T=1) 
  11661.            AuthMethod=None
  11662.  
  11663.        I-> Login (CSG,NSG=1,0 T=0) 
  11664.            ... iSCSI parameters
  11665.  
  11666.        T-> Login (CSG,NSG=1,0 T=0) 
  11667.            ... iSCSI parameters
  11668.  
  11669.        And at the end:
  11670.  
  11671.        I-> Login (CSG,NSG=1,3 T=1) 
  11672.            optional iSCSI parameters
  11673.  
  11674.        T-> Login (CSG,NSG=1,3 T=1) "login accept" 
  11675.  
  11676.  
  11677.  
  11678.  
  11679.  
  11680. Julian Satran                 Expires August  2002                      231
  11681.  
  11682.  
  11683.  
  11684.  
  11685.  
  11686.                                       iSCSI                        17-April-02
  11687.  
  11688. Appendix D. SendTargets Operation
  11689.  
  11690.      To reduce the amount of configuration required on an initiator, iSCSI 
  11691.      provides the SendTargets text request.  The initiator uses the Send-
  11692.      Targets request to get a list of targets to which it may have access, 
  11693.      as well as the list of addresses (IP address and TCP port) on which 
  11694.      these targets may be accessed.
  11695.  
  11696.      To make use of SendTargets, an initiator must first establish one of         
  11697.      two types of sessions.  If the initiator establishes the session using 
  11698.      the key "SessionType=Discovery", the session is a discovery session, 
  11699.      and a target name does not need to be specified.  Otherwise, the ses-
  11700.      sion is a normal, operational session.  The SendTargets command MUST 
  11701.      only be sent during the full feature phase of a normal or discovery 
  11702.      session.
  11703.  
  11704.      A system that contains targets MUST support discovery sessions on each 
  11705.      of its IP addresses, and MUST support the SendTargets command on the 
  11706.      discovery session.  A target MUST support the SendTargets command on 
  11707.      operational sessions; these will only return address information 
  11708.      about the target to which the session is connected, and do not return 
  11709.      information about other targets.
  11710.  
  11711.      An initiator MAY make use of the SendTargets as it sees fit.
  11712.  
  11713.      A SendTargets command consists of a single Text request PDU.
  11714.      This PDU contains exactly one text key and value.  The text key MUST 
  11715.      be SendTargets.  The expected response depends upon the value, as well 
  11716.      as whether the session is a discovery or operational session.
  11717.  
  11718.      The value must be one of:
  11719.  
  11720.         All
  11721.  
  11722.         The initiator is requesting that information on all relevant 
  11723.           targets known to the implementation be returned.  This value 
  11724.           MUST be supported on a discovery session, and MUST NOT be sup-
  11725.           ported on an operational session.
  11726.  
  11727.         <iSCSI-target-name>
  11728.  
  11729.         If an iSCSI target name is specified, the session should respond 
  11730.           with addresses for only the named target, if possible.  This 
  11731.           value MUST be supported on discovery sessions.  A discovery 
  11732.  
  11733.  
  11734. Julian Satran                  Expires August  2002                         232
  11735.  
  11736.  
  11737.  
  11738.  
  11739.  
  11740.                                    iSCSI                         17-April-02
  11741.  
  11742.          session MUST be capable of returning addresses for those tar-
  11743.          gets that would have been returned had value=all been desig-
  11744.          nated.
  11745.  
  11746.        <nothing>
  11747.  
  11748.        The session should respond only with addresses for the target to  
  11749.          which the session is logged in.  This MUST be supported on 
  11750.          operational sessions, and MUST NOT return targets other than 
  11751.          the one to which the session is logged in.
  11752.  
  11753.      The response to this command is a text response that contains a list 
  11754.      of zero or more targets and, optionally, their addresses.  Each target 
  11755.      is returned as a target record.  A target record begins with the Tar-
  11756.      getName text key, followed by a list of TargetAddress text keys, and 
  11757.      bounded by the end of the text response or the next TargetName key, 
  11758.      which begins a new record.  No text keys other than TargetName and 
  11759.      TargetAddress are permitted within a SendTargets response.
  11760.  
  11761.      For the format of the TargetName, see Section 11.4 TargetName. 
  11762.  
  11763.      A discovery session MAY respond to a SendTargets request with its com-
  11764.      plete list of targets, or with a list of targets that is based on the 
  11765.      name of the initiator logged in to the session.
  11766.  
  11767.      A SendTargets response MUST NOT not contain target names if there are 
  11768.      no targets for the requesting initiator to access.
  11769.  
  11770.      Each target record returned includes zero or more TargetAddress 
  11771.      fields.
  11772.  
  11773.      A SendTargets response MUST NOT contain iSCSI default target names.
  11774.  
  11775.      Each target record starts with one text key of the form:
  11776.  
  11777.        TargetName=<target-name-goes-here>
  11778.  
  11779.      Followed by zero or more address keys of the form:
  11780.  
  11781.        TargetAddress=<hostname-or-ipaddress>[:<tcp-port>],<portal-
  11782.          group-tag>
  11783.  
  11784.      The hostname-or-ipaddress and tcp port are as specified in the  Sec-
  11785.      tion 2.2.6 iSCSI Names.
  11786.  
  11787.  
  11788. Julian Satran               Expires August  2002                         233
  11789.  
  11790.  
  11791.  
  11792.  
  11793.  
  11794.                                       iSCSI                    17-April-02
  11795.  
  11796.      Each TargetAddress belongs to a portal group, identified by its 
  11797.      numeric, decimal portal group tag.  The iSCSI target name, together 
  11798.      with this tag, constitutes the SCSI port identifier; the tag need be 
  11799.      unique only within a given target name's list of addresses.
  11800.  
  11801.      Multiple-connection sessions can span iSCSI addresses that belong to 
  11802.      the same portal group.
  11803.  
  11804.      Multiple-connection sessions cannot span iSCSI addresses that belong 
  11805.      to different portal groups.
  11806.  
  11807.      If a SendTargets response reports an iSCSI address for a target, it 
  11808.      SHOULD also report all other addresses in its portal group in the same 
  11809.      response.
  11810.  
  11811.      A SendTargets text response can be longer than a single Text Response
  11812.      PDU, and makes use of the long text responses as specified.
  11813.  
  11814.      After obtaining a list of targets from the discovery target session, 
  11815.      an iSCSI initiator may initiate new sessions to log in to the discov-
  11816.      ered targets for full operation.  The initiator MAY keep the session 
  11817.      to a default target open, and MAY send subsequently SendTargets com-
  11818.      mands to discover new targets.
  11819.  
  11820.      Examples:
  11821.  
  11822.  
  11823.      This example is the SendTargets response from a single target that has 
  11824.      no other interface ports.
  11825.  
  11826.      Initiator sends text request that contains:
  11827.  
  11828.        SendTargets=All
  11829.  
  11830.      Target sends a text response that contains:
  11831.  
  11832.        TargetName=iqn.1993-11.com.acme.diskarray.sn.8675309
  11833.  
  11834.      All the target  had to return in the simple case was the target name.  
  11835.      It is assumed by the initiator that the IP address and TCP port for 
  11836.      this target are the same as used on the current connection to the 
  11837.      default iSCSI target.
  11838.  
  11839.  
  11840.  
  11841. Julian Satran                  Expires August  2002                      234
  11842.  
  11843.  
  11844.  
  11845.  
  11846.  
  11847.                                    iSCSI                       17-April-02
  11848.  
  11849.      The next example has two internal iSCSI targets, each accessible via 
  11850.      two different ports with different IP addresses.  The following is the 
  11851.      text response:
  11852.  
  11853.        TargetName=iqn.1993-11.com.acme.diskarray.sn.8675309
  11854.        TargetAddress=10.1.0.45:3000,1
  11855.        TargetAddress=10.1.1.45:3000,2
  11856.        TargetName=iqn.1993-11.com.acme.diskarray.sn.1234567
  11857.        TargetAddress=10.1.0.45:3000,1
  11858.        TargetAddress=10.1.1.45:3000,2
  11859.  
  11860.      Both targets share both addresses; the multiple addresses are likely 
  11861.      used to provide multi-path support.  The initiator may connect to 
  11862.      either target name on either address.  Each of the addresses has its 
  11863.      own portal group tag; they do not support spanning multiple-connec-
  11864.      tion sessions with each other.  Keep in mind also that the portal 
  11865.      group tags for the two named targets are independent of one another; 
  11866.      portal group "1" on the first target is not necessarily the same as 
  11867.      portal group "1" on the second.
  11868.  
  11869.      In the above example, a DNS host name could have been returned instead 
  11870.      of an IP address, and that an IPv6 addresses (5 to 16 dotted-decimal 
  11871.      numbers) could have also been returned.
  11872.  
  11873.      The next text response shows a target that supports spanning sessions 
  11874.      across multiple addresses, which indicates the use of the portal group 
  11875.      tags:
  11876.  
  11877.        TargetName=iqn.1993-11.com.acme.diskarray.sn.8675309
  11878.        TargetAddress=10.1.0.45:3000,1
  11879.        TargetAddress=10.1.1.46:3000,1
  11880.        TargetAddress=10.1.0.47:3000,2
  11881.        TargetAddress=10.1.1.48:3000,2
  11882.        TargetAddress=10.1.1.49:3000,3
  11883.  
  11884.      In this example, any of the target addresses can be used to reach the 
  11885.      same target.  A single-connection session can be established to any of 
  11886.      these TCP addresses.  A multiple-connection session could span 
  11887.      addresses .45 and .46 or .47 and .48, but cannot span any other combi-
  11888.      nation.  A TargetAddress with its own tag (.49), cannot be combined 
  11889.      with any other address within the same session.
  11890.  
  11891.      This SendTargets response does not indicate whether .49 supports mul-
  11892.      tiple connections per session; it communicated via the MaxConnections 
  11893.      text key upon login to the target.
  11894.  
  11895. Julian Satran               Expires August  2002                        235
  11896.  
  11897.  
  11898.  
  11899.  
  11900.  
  11901.                                       iSCSI                      17-April-02
  11902.  
  11903. Appendix E. Algorithmic Presentation of Error Recovery Classes
  11904.  
  11905.      This appendix illustrates the error recovery classes using a pseudo-
  11906.      programming-language.  The procedure names are chosen to be obvious to 
  11907.      most implementers. Each of the recovery classes described has initia-
  11908.      tor procedures as well as target procedures.   These algorithms focus 
  11909.      on outlining the mechanics of error recovery classes, and ignore all 
  11910.      other aspects/cases. Examples of this approach are:
  11911.  
  11912.            - Handling for only certain Opcode types is shown.
  11913.  
  11914.            - Only certain reason codes (for example, Recovery in Logout 
  11915.             command) are outlined.
  11916.  
  11917.            - Resultant cases, such as recovery of Synchronization on a 
  11918.             header digest error are considered out-of-scope in these algo-
  11919.             rithms.  In this particular example a header digest error may 
  11920.             lead to connection recovery if some type of sync and steering 
  11921.             layer is not implemented.
  11922.  
  11923.      These algorithms strive to convey the iSCSI error recovery concepts in 
  11924.      the simplest terms, and are not designed to be optimal.
  11925.  
  11926. E.1  General Data Structure and Procedure Description
  11927.  
  11928.      This section defines the procedures and data structures that are com-
  11929.      monly used by all the error recovery algorithms. The structures may 
  11930.      not be the exhaustive representations of what is required for a typi-
  11931.      cal implementation.
  11932.  
  11933.      Data structure definitions -
  11934.      struct TransferContext {
  11935.              int TargetTransferTag;
  11936.              int ExpectedDataSN;
  11937.      };
  11938.  
  11939.      struct TCB {              /* task control block */
  11940.              Boolean SoFarInOrder;
  11941.              int ExpectedDataSN; /* used for both R2Ts, and Data */
  11942.              int MissingDataSNList[MaxMissingDPDU];
  11943.              Boolean FbitReceived;
  11944.              Boolean StatusXferd;
  11945.              Boolean CurrentlyAllegiant;
  11946.              int ActiveR2Ts;
  11947.  
  11948.  
  11949. Julian Satran                 Expires August  2002                          236
  11950.  
  11951.  
  11952.  
  11953.  
  11954.  
  11955.                                       iSCSI                    17-April-02
  11956.  
  11957.              int Response;
  11958.              char *Reason;
  11959.              struct TransferContext 
  11960.                          TransferContextList[MaxOutStandingR2T];
  11961.              int InitiatorTaskTag;
  11962.              int CmdSN;
  11963.      };
  11964.  
  11965.      struct Connection {
  11966.              struct Session SessionReference;
  11967.              Boolean SoFarInOrder;
  11968.              int CID;
  11969.              int State;
  11970.              int ExpectedStatSN;
  11971.              int MissingStatSNList[MaxMissingSPDU];
  11972.              Boolean PerformConnectionCleanup;
  11973.      };
  11974.  
  11975.      struct Session {
  11976.              int NumConnections;
  11977.              int CmdSN;
  11978.              int Maxconnections;
  11979.              int ErrorRecoveryLevel;
  11980.              struct iSCSIEndpoint OtherEndInfo;
  11981.              struct Connection ConnectionList[MaxSupportedConns];
  11982.      };
  11983.  
  11984.      Procedure descriptions -
  11985.      Receive-a-In-PDU(transport connection, inbound PDU);
  11986.      check-basic-validity(inbound PDU);
  11987.      Start-Timer(timeout handler, argument, timeout value);
  11988.      Build-And-Send-Reject(transport connection, bad PDU, reason code);
  11989.  
  11990. E.2  Within-command Error Recovery Algorithms
  11991.  
  11992. E.2.1   Procedure Descriptions
  11993.  
  11994.      Recover-Data-if-Possible(last required DataSN, task control block);
  11995.      Build-And-Send-DSnack(task control block);
  11996.      Build-And-Send-Abort(task control block);
  11997.      SCSI-Task-Completion(task control block);
  11998.      Build-And-Send-a-Data-Burst(transport connection, R2T PDU, 
  11999.                                                    task control block);
  12000.      Build-And-Send-R2T(transport connection, description of data, 
  12001.  
  12002. Julian Satran                 Expires August  2002                     237
  12003.  
  12004.  
  12005.  
  12006.  
  12007.  
  12008.                                      iSCSI                      17-April-02
  12009.  
  12010.                                                   task control block);
  12011.      Build-And-Send-Status(transport connection, task control block);
  12012.      Transfer-Context-Timeout-Handler(transfer context);
  12013.  
  12014.      Implementation-specific tunables -
  12015.      InitiatorDataSNACKEnabled, TargetDataSNACKSupported, 
  12016.      TargetRecoveryR2TEnabled.
  12017.  
  12018.      Notes:
  12019.  
  12020.           - Some procedures used in this section, including: Recover-Sta-
  12021.            tus-if-Possible, Handle-Status-SNACK-request, Evaluate-a-
  12022.            StatSN are defined in Within-connection recovery algorithms.
  12023.  
  12024.           - The Response processing pseudo-code, shown in the target algo-
  12025.            rithms, applies to all solicited PDUs that carry StatSN - SCSI 
  12026.            Response, Text Response etc.
  12027.  
  12028. E.2.2   Initiator Algorithms
  12029.  
  12030.      Recover-Data-if-Possible(LastRequiredDataSN, TCB)
  12031.      {
  12032.          if (InitiatorDataSNACKEnabled) {
  12033.               if (# of missing PDUs is trackable) {
  12034.                     Note the missing DataSNs in TCB.
  12035.                     Build-And-Send-DSnack(TCB);
  12036.               } else {
  12037.                   TCB.Reason = "Protocol service CRC error";
  12038.                   }
  12039.          } else {
  12040.                TCB.Reason = "Protocol service CRC error";
  12041.          }
  12042.          if (TCB.Reason = "Protocol service CRC error") {
  12043.                Clear the missing PDU list in the TCB.
  12044.                if (TCB.StatusXferd is not TRUE)
  12045.                   Build-And-Send-Abort(TCB);
  12046.          }
  12047.      }
  12048.  
  12049.      Receive-a-In-PDU(Connection, CurrentPDU)
  12050.      {
  12051.         check-basic-validity(CurrentPDU);
  12052.         if (Header-Digest-Bad) discard, return;
  12053.         Retrieve TCB for CurrentPDU.InitiatorTaskTag.
  12054.  
  12055.  
  12056. Julian Satran                Expires August  2002                        238
  12057.  
  12058.  
  12059.  
  12060.  
  12061.  
  12062.                                       iSCSI                      17-April-02
  12063.  
  12064.         if ((CurrentPDU.type = Data)
  12065.                     or (CurrentPDU.type = R2T)) {
  12066.            if (Data-Digest-Bad) {
  12067.                send-data-SNACK = TRUE;
  12068.              LastRequiredDataSN = CurrentPDU.DataSN;
  12069.              } else { 
  12070.                  if (TCB.SoFarInOrder = TRUE) {
  12071.                      if (current DataSN is expected) {
  12072.                           Increment TCB.ExpectedDataSN.
  12073.                      } else {
  12074.                          TCB.SoFarInOrder = FALSE;
  12075.                          send-data-SNACK = TRUE;
  12076.                          }
  12077.                  } else {
  12078.                        if (current DataSN was considered missing) {
  12079.                             remove current DataSN from missing PDU list.
  12080.                        } else if (current DataSN is higher than expected) {
  12081.                              send-data-SNACK = TRUE;
  12082.                          } else {
  12083.                                discard, return;
  12084.                          }
  12085.                          Adjust TCB.ExpectedDataSN if appropriate.
  12086.                  }
  12087.                  LastRequiredDataSN = CurrentPDU.DataSN - 1;
  12088.              }
  12089.              if (send-data-SNACK is TRUE and 
  12090.                      task is not already considered failed) {
  12091.                  Recover-Data-if-Possible(LastRequiredDataSN, TCB);
  12092.            }
  12093.              if (missing data PDU list is empty) {
  12094.                 TCB.SoFarInOrder = TRUE;
  12095.              }
  12096.            if (CurrentPDU.type = R2T) {
  12097.               Increment ActiveR2Ts for this task.
  12098.               Build-And-Send-A-Data-Burst(Connection, CurrentPDU, TCB);
  12099.            }
  12100.         } else if (CurrentPDU.type = Response) {
  12101.            if (Data-Digest-Bad) {
  12102.                 send-status-SNACK = TRUE;
  12103.              } else { 
  12104.               TCB.StatusXferd = TRUE;
  12105.               Store the status information in TCB.
  12106.               if (ExpDataSN does not match) {
  12107.  
  12108. Julian Satran                  Expires August  2002                         239
  12109.  
  12110.  
  12111.  
  12112.  
  12113.  
  12114.                                      iSCSI                         17-April-02
  12115.  
  12116.                    TCB.SoFarInOrder = FALSE;
  12117.                    Recover-Data-if-Possible(current DataSN, TCB);
  12118.               }
  12119.                  if (missing data PDU list is empty) {
  12120.                       TCB.SoFarInOrder = TRUE;
  12121.                  }
  12122.               send-status-SNACK = Evaluate-a-StatSN(Connection,
  12123.                                            CurrentPDU.StatSN);
  12124.            }
  12125.            if (send-status-SNACK is TRUE)
  12126.               Recover-Status-if-Possible(Connection, CurrentPDU);
  12127.         } else { /* REST UNRELATED TO WITHIN-COMMAND-RECOVERY, NOT SHOWN */
  12128.         }
  12129.         if ((TCB.SoFarInOrder is TRUE) and 
  12130.                              (TCB.StatusXferd is TRUE)) { 
  12131.            SCSI-Task-Completion(TCB);
  12132.         }
  12133.      }
  12134.  
  12135. E.2.3   Target Algorithms
  12136.  
  12137.      Receive-a-In-PDU(Connection, CurrentPDU)
  12138.      {
  12139.        check-basic-validity(CurrentPDU);
  12140.        if (Header-Digest-Bad) discard, return;
  12141.        Retrieve TCB for CurrentPDU.InitiatorTaskTag.
  12142.        if (CurrentPDU.type = Data) { 
  12143.            Retrieve TContext from CurrentPDU.TargetTransferTag;
  12144.            if (Data-Digest-Bad) {
  12145.                  Build-And-Send-Reject(Connection, CurrentPDU, 
  12146.                                    Payload-Digest-Error);
  12147.               Note the missing data PDUs in MissingDataRange[].
  12148.                  send-recovery-R2T = TRUE;
  12149.               } else { 
  12150.               if (current DataSN is not expected) {
  12151.                   Note the missing data PDUs in MissingDataRange[].
  12152.                      send-recovery-R2T = TRUE;
  12153.                  }
  12154.               if (CurrentPDU.Fbit = TRUE) {
  12155.                   if (current PDU is solicited) {
  12156.                          Decrement TCB.ActiveR2Ts.
  12157.                   }
  12158.                   if ((current PDU is unsolicited and 
  12159.  
  12160.  
  12161. Julian Satran                 Expires August  2002                         240
  12162.  
  12163.  
  12164.  
  12165.  
  12166.  
  12167.                                       iSCSI                      17-April-02
  12168.  
  12169.                          data received is less than I/O size and 
  12170.                            data received is less than FirstBurstSize)
  12171.                       or {current PDU is solicited and the size of
  12172.                            this burst is less than expected)) {
  12173.                       send-recovery-R2T = TRUE;
  12174.                       Note the missing data in MissingDataRange[].
  12175.                   }
  12176.                 }
  12177.              }
  12178.              Increment TContext.ExpectedDataSN.
  12179.            if (send-recovery-R2T is TRUE  and
  12180.                      task is not already considered failed) {
  12181.               if (TargetRecoveryR2TEnabled is TRUE) {
  12182.                   Increment TCB.ActiveR2Ts.
  12183.                   Build-And-Send-R2T(Connection, MissingDataRange, TCB);
  12184.               } else {
  12185.                    if (current PDU is the last unsolicited)
  12186.                        TCB.Reason = "Not enough unsolicited data";
  12187.                    else
  12188.                        TCB.Reason = "Protocol service CRC error";
  12189.               }
  12190.            }
  12191.            if (TCB.ActiveR2Ts = 0) {
  12192.               Build-And-Send-Status(Connection, TCB);
  12193.            }
  12194.        } else if (CurrentPDU.type = SNACK) {
  12195.            snack-failure = FALSE;
  12196.            if (this is data retransmission request) {
  12197.               if (TargetDataSNACKSupported) {
  12198.                    if (the request is satisfiable) {
  12199.                          Build-And-Send-A-Data-Burst(CurrentPDU, TCB);
  12200.                    } else {
  12201.                          snack-failure = TRUE;
  12202.                    }
  12203.               } else {
  12204.                    snack-failure = TRUE;
  12205.               }
  12206.               if (snack-failure is TRUE) {
  12207.                    Build-And-Send-Reject(Connection, CurrentPDU, 
  12208.                                                        Data-SNACK-Reject);
  12209.                    if (TCB.StatusXferd is not TRUE) {
  12210.                         TCB.Reason = "SNACK Rejected";
  12211.                         Build-And-Send-Status(Connection, TCB);
  12212.  
  12213. Julian Satran                  Expires August  2002                      241
  12214.  
  12215.  
  12216.  
  12217.  
  12218.  
  12219.                                     iSCSI                        17-April-02
  12220.  
  12221.                    }
  12222.               }
  12223.            } else {
  12224.                Handle-Status-SNACK-request(Connection, CurrentPDU);
  12225.            }
  12226.        } else { /* REST UNRELATED TO WITHIN-COMMAND-RECOVERY, NOT SHOWN */
  12227.        }
  12228.      }
  12229.  
  12230.      Transfer-Context-Timeout-Handler(TContext)
  12231.      {
  12232.        Retrieve TCB and Connection from TContext.
  12233.        Decrement TCB.ActiveR2Ts.
  12234.        if (TargetRecoveryR2TEnabled is TRUE and
  12235.                      task is not already considered failed) {
  12236.            Note the missing data PDUs in MissingDataRange[].
  12237.            Build-And-Send-R2T(Connection, MissingDataRange, TCB);
  12238.        } else {
  12239.            TCB.Reason = "Protocol service CRC error";
  12240.            if (TCB.ActiveR2Ts = 0) {
  12241.               Build-And-Send-Status(Connection, TCB);
  12242.            }
  12243.        }
  12244.      }
  12245.  
  12246. E.3  Within-connection Recovery Algorithms
  12247.  
  12248. E.3.1   Procedure Descriptions
  12249.  
  12250.      Procedure descriptions:
  12251.      Recover-Status-if-Possible(transport connection, 
  12252.                                          currently received PDU);
  12253.      Evaluate-a-StatSN(transport connection, current StatSN);
  12254.      Retransmit-Command-if-Possible(transport connection, CmdSN);
  12255.      Build-And-Send-SSnack(transport connection);
  12256.      Build-And-Send-Command(transport connection, task control block);
  12257.      Command-Acknowledge-Timeout-Handler(task control block);
  12258.      Status-Expect-Timeout-Handler(transport connection);
  12259.      Build-And-Send-Nop-Out(transport connection);
  12260.      Handle-Status-SNACK-request(transport connection, status SNACK PDU);
  12261.      Retransmit-Status-Burst(status SNACK, task control block);
  12262.      Is-Acknowledged(beginning StatSN, run size);
  12263.  
  12264.      Implementation-specific tunables:
  12265.  
  12266. Julian Satran              Expires August  2002                          242
  12267.  
  12268.  
  12269.  
  12270.  
  12271.  
  12272.                                       iSCSI                        17-April-02
  12273.  
  12274.      InitiatorCommandRetryEnabled, InitiatorStatusExpectNopEnabled, Initi-
  12275.      atorProactiveSNACKEnabled, InitiatorStatusSNACKEnabled, TargetSta-
  12276.      tusSNACKSupported.
  12277.  
  12278.      Notes:
  12279.            - The initiator algorithms only deal with unsolicited Nop-In 
  12280.             PDUs for generating status SNACKs.  Solicited Nop-In PDU has 
  12281.             an assigned StatSN, which, when out-of-order, could trigger 
  12282.             the out-of-order StatSN handling in Within-command algo-
  12283.             rithms, again leading to Recover-Status-if-Possible.
  12284.  
  12285.            - The pseudo-code shown may result in the retransmission of 
  12286.             unacknowledged commands in more cases than necessary.  This 
  12287.             will not however affect the correctness of the operation since 
  12288.             the target is required to discard the duplicate CmdSNs.
  12289.  
  12290.            - The procedure Build-And-Send-Async is defined in the Connec-
  12291.             tion recovery algorithms.
  12292.  
  12293.            - The procedure Status-Expect-Timeout-Handler describes how 
  12294.             initiators may proactively attempt to retrieve the Status if 
  12295.             they so choose. This procedure is assumed to be triggered much 
  12296.             before the standard ULP timeout.
  12297.  
  12298. E.3.2   Initiator Algorithms
  12299.  
  12300.      Recover-Status-if-Possible(Connection, CurrentPDU)
  12301.      {
  12302.          if ((Connection.state = LOGGED_IN) and 
  12303.                       connection is not already considered failed) {
  12304.             if (InitiatorStatusSNACKEnabled) {
  12305.                if (# of missing PDUs is trackable) {
  12306.                      Note the missing StatSNs in Connection;
  12307.                  Build-And-Send-SSnack(Connection);
  12308.                    } else {
  12309.                     Connection.PerformConnectionCleanup = TRUE;
  12310.                }
  12311.             } else {
  12312.                    Connection.PerformConnectionCleanup = TRUE;
  12313.             }
  12314.             if (Connection.PerformConnectionCleanup is TRUE) {
  12315.                Start-Timer(Connection-Cleanup-Handler, Connection, 0);
  12316.                 }
  12317.          }
  12318.      }
  12319.  
  12320.  
  12321. Julian Satran                  Expires August  2002                         243
  12322.  
  12323.  
  12324.  
  12325.  
  12326.  
  12327.                                         iSCSI                        17-April-02
  12328.  
  12329.      Retransmit-Command-if-Possible(Connection, CmdSN)
  12330.      {
  12331.          if (InitiatorCommandRetryEnabled) {
  12332.             Retrieve the InitiatorTaskTag, and thus TCB for the CmdSN.
  12333.             Build-And-Send-Command(Connection, TCB);
  12334.          }
  12335.      }
  12336.  
  12337.      Evaluate-a-StatSN(Connection, StatSN)
  12338.      {
  12339.          send-status-SNACK = FALSE;
  12340.          if (Connection.SoFarInOrder is TRUE) {
  12341.             if (current StatSN is the expected) {
  12342.                  Increment Connection.ExpectedStatSN.
  12343.             } else {
  12344.                      Connection.SoFarInOrder = FALSE;
  12345.                      send-status-SNACK = TRUE;
  12346.                 }
  12347.          } else {
  12348.             if (current StatSN was considered missing) {
  12349.                  remove current StatSN from the missing list.
  12350.             } else {
  12351.                      if (current StatSN is higher than expected){
  12352.                          send-status-SNACK = TRUE;
  12353.                      } else {
  12354.                      discard, return;
  12355.                  }
  12356.             }
  12357.             Adjust Connection.ExpectedStatSN if appropriate.
  12358.             if (missing StatSN list is empty) {
  12359.                  Connection.SoFarInOrder = TRUE;
  12360.                 }
  12361.          }
  12362.          return send-status-SNACK;
  12363.      }
  12364.  
  12365.      Receive-a-In-PDU(Connection, CurrentPDU)
  12366.      {
  12367.          check-basic-validity(CurrentPDU);
  12368.          if (Header-Digest-Bad) discard, return;
  12369.          Retrieve TCB for CurrentPDU.InitiatorTaskTag.
  12370.          if (CurrentPDU.type = Nop-In) { 
  12371.                if (the PDU is unsolicited) { 
  12372.  
  12373. Julian Satran                    Expires August  2002                        244
  12374.  
  12375.  
  12376.  
  12377.  
  12378.  
  12379.                                      iSCSI                       17-April-02
  12380.  
  12381.                      if (current StatSN is not expected) {
  12382.                         Recover-Status-if-Possible(Connection, CurrentPDU);
  12383.                      }
  12384.                      if (current ExpCmdSN is not Session.CmdSN) {
  12385.                          Retransmit-Command-if-Possible(Connection, 
  12386.                                         CurrentPDU.ExpCmdSN);
  12387.                      }
  12388.                }
  12389.          } else if (CurrentPDU.type = Reject) {
  12390.                if (it is a data digest error on immediate data) {
  12391.                      Retransmit-Command-if-Possible(Connection, 
  12392.                                         CurrentPDU.BadPDUHeader.CmdSN);
  12393.                }
  12394.          } else if (CurrentPDU.type = Response) {
  12395.               send-status-SNACK = Evaluate-a-StatSN(Connection,
  12396.                                              CurrentPDU.StatSN);
  12397.               if (send-status-SNACK is TRUE)
  12398.                   Recover-Status-if-Possible(Connection, CurrentPDU);
  12399.          } else { /* REST UNRELATED TO WITHIN-CONNECTION-RECOVERY,
  12400.                    * NOT SHOWN */
  12401.          }
  12402.      }
  12403.  
  12404.      Command-Acknowledge-Timeout-Handler(TCB)
  12405.      {
  12406.          Retrieve the Connection for TCB.
  12407.          Retransmit-Command-if-Possible(Connection, TCB.CmdSN);
  12408.      }
  12409.  
  12410.      Status-Expect-Timeout-Handler(Connection)
  12411.      {
  12412.          if (InitiatorStatusExpectNopEnabled) {
  12413.              Build-And-Send-Nop-Out(Connection);
  12414.          } else if (InitiatorProactiveSNACKEnabled){
  12415.              if ((Connection.state = LOGGED_IN) and 
  12416.                     connection is not already considered failed) {
  12417.                   Build-And-Send-SSnack(Connection);
  12418.              }
  12419.          }
  12420.      }
  12421.  
  12422.  
  12423.  
  12424.  
  12425. Julian Satran                Expires August  2002                        245
  12426.  
  12427.  
  12428.  
  12429.  
  12430.  
  12431.                                     iSCSI                        17-April-02
  12432.  
  12433. E.3.3   Target Algorithms
  12434.  
  12435.      Handle-Status-SNACK-request(Connection, CurrentPDU)
  12436.      {
  12437.          if (TargetStatusSNACKSupported) {
  12438.             if (request for an acknowledged run) {
  12439.                 Build-And-Send-Reject(Connection, CurrentPDU, 
  12440.                                                   Protocol-Error);
  12441.             } else if (request for an untransmitted run) {
  12442.                 discard, return;
  12443.             } else {
  12444.                 Retransmit-Status-Burst(CurrentPDU, TCB);
  12445.             }
  12446.          } else {
  12447.             Build-And-Send-Async(Connection, DroppedConnection,
  12448.                                     DefaultTime2Wait, DefaultTime2Retain);
  12449.          }
  12450.      }
  12451.  
  12452. E.4  Connection Recovery Algorithms
  12453.  
  12454. E.4.1   Procedure Descriptions
  12455.  
  12456.      Build-And-Send-Async(transport connection, reason code, 
  12457.                                         minimum time, maximum time);
  12458.      Pick-A-Logged-In-Connection(session);
  12459.      Build-And-Send-Logout(transport connection, logout connection
  12460.                        identifier, reason code);
  12461.      PerformImplicitLogout(transport connection, logout connection
  12462.                        identifier, target information);
  12463.      PerformLogin(transport connection, target information);
  12464.      CreateNewTransportConnection(target information);
  12465.      Build-And-Send-Command(transport connection, task control block);
  12466.      Connection-Cleanup-Handler(transport connection);
  12467.      Connection-Resource-Timeout-Handler(transport connection);
  12468.      Quiesce-And-Prepare-for-New-Allegiance(session, task control block);
  12469.      Build-And-Send-Logout-Response(transport connection, 
  12470.                               CID of connection in recovery, reason code);
  12471.      Build-And-Send-TaskMgmt-Response(transport connection,
  12472.                             task mgmt command PDU, response code);
  12473.      Establish-New-Allegiance(task control block, transport connection);
  12474.      Schedule-Command-To-Continue(task control block);
  12475.  
  12476.      Notes:
  12477.  
  12478. Julian Satran                Expires August  2002                        246
  12479.  
  12480.  
  12481.  
  12482.  
  12483.  
  12484.                                       iSCSI                      17-April-02
  12485.  
  12486.           - Transport exception conditions, such as unexpected connection 
  12487.            termination, connection reset, and hung connection while the 
  12488.            connection is in the full-feature phase, are all assumed to be 
  12489.            asynchronously signaled to the iSCSI layer using the 
  12490.            Transport_Exception_Handler procedure.
  12491.  
  12492. E.4.2   Initiator Algorithms
  12493.  
  12494.  
  12495.      Receive-a-In-PDU(Connection, CurrentPDU)
  12496.      {
  12497.          check-basic-validity(CurrentPDU);
  12498.          if (Header-Digest-Bad) discard, return;
  12499.          Retrieve TCB from CurrentPDU.InitiatorTaskTag.
  12500.          if (CurrentPDU.type = Async) { 
  12501.              if (CurrentPDU.AsyncEvent = ConnectionDropped) {
  12502.                 Retrieve the AffectedConnection for CurrentPDU.Parameter1.
  12503.                AffectedConnection.State = CLEANUP_WAIT;
  12504.              } else if (CurrentPDU.AsyncEvent = LogoutRequest)) {
  12505.                 Retrieve the AffectedConnection for CurrentPDU.Parameter1.
  12506.                AffectedConnection.State = LOGOUT_REQUESTED;
  12507.                AffectedConnection.PerformConnectionCleanup = TRUE;
  12508.                Start-Timer(Connection-Cleanup-Handler, 
  12509.                              AffectedConnection, CurrentPDU.Parameter2);
  12510.              } else if (CurrentPDU.AsyncEvent = SessionDropped)) {
  12511.                for (each Connection) {
  12512.                    Connection.state = CLEANUP_WAIT;
  12513.                }
  12514.                Session.state = FAILED;
  12515.                Start-Timer(Session-Continuation-Handler, 
  12516.                              Session, CurrentPDU.Parameter2);
  12517.              }
  12518.  
  12519.          } else if (CurrentPDU.type = LogoutResponse) {
  12520.              Retrieve the CleanupConnection for CurrentPDU.CID.
  12521.              if (CurrentPDU.Response = failure) {
  12522.                 CleanupConnection.State = CLEANUP_WAIT;
  12523.              } else {
  12524.                  CleanupConnection.State = FREE;
  12525.              }
  12526.          } else if (CurrentPDU.type = LoginResponse) {
  12527.               if (this is a response to an implicit Logout) {
  12528.                  Retrieve the CleanupConnection.
  12529.                  if (successful) {
  12530.  
  12531. Julian Satran                Expires August  2002                        247
  12532.  
  12533.  
  12534.  
  12535.  
  12536.  
  12537.                                       iSCSI                      17-April-02
  12538.  
  12539.                      CleanupConnection.State = FREE;
  12540.                      Connection.State = LOGGED_IN;
  12541.                  } else {
  12542.                       CleanupConnection.State = CLEANUP_WAIT;
  12543.                       DestroyTransportConnection(Connection);
  12544.                  }
  12545.               }
  12546.          } else { /* REST UNRELATED TO CONNECTION-RECOVERY, 
  12547.                    * NOT SHOWN */
  12548.          }
  12549.          if (CleanupConnection.State = FREE) {
  12550.             for (each command that was active on CleanupConnection) {
  12551.             /* Establish new connection allegiance */
  12552.                  NewConnection = Pick-A-Logged-In-Connection(Session);
  12553.                  Build-And-Send-Command(NewConnection, TCB);
  12554.              }
  12555.          }
  12556.      }
  12557.  
  12558.      Connection-Cleanup-Handler(Connection)
  12559.      {
  12560.          Retrieve Session from Connection.
  12561.          Start-Timer(Connection-Resource-Timeout-Handler, 
  12562.                    Connection, DefaultTime2Retain);
  12563.          if (Connection can still exchange iSCSI PDUs) {
  12564.              NewConnection = Connection;
  12565.          } else {
  12566.              if (there are other logged-in connections) {
  12567.                   NewConnection = Pick-A-Logged-In-Connection(Session);
  12568.              } else {
  12569.                   NewConnection = 
  12570.                        CreateTransportConnection(Session.OtherEndInfo);
  12571.                   Initiate an implicit Logout on NewConnection for
  12572.                                                     Connection.CID.
  12573.                   return;
  12574.              }
  12575.          }
  12576.          Build-And-Send-Logout(NewConnection, Connection.CID,
  12577.                                              RecoveryRemove); 
  12578.      }
  12579.  
  12580.      Transport_Exception_Handler(Connection)
  12581.      {
  12582.  
  12583. Julian Satran                Expires August  2002                        248
  12584.  
  12585.  
  12586.  
  12587.  
  12588.  
  12589.                                           iSCSI                  17-April-02
  12590.  
  12591.          Connection.PerformConnectionCleanup = TRUE;
  12592.          if (the event is an unexpected transport disconnect) {
  12593.              Connection.State = CLEANUP_WAIT;
  12594.              Start-Timer(Connection-Cleanup-Handler, Connection, 
  12595.                                                LogooutLoginMinTime);
  12596.  
  12597.          } else {
  12598.              Connection.State = FREE;
  12599.          }
  12600.      }
  12601.  
  12602. E.4.3   Target Algorithms
  12603.  
  12604.      Receive-a-In-PDU(Connection, CurrentPDU)
  12605.      {
  12606.          check-basic-validity(CurrentPDU);
  12607.          if (Header-Digest-Bad) discard, return;
  12608.          else if (Data-Digest-Bad) {
  12609.                Build-And-Send-Reject(Connection, CurrentPDU, 
  12610.                                            Payload-Digest-Error);
  12611.                discard, return;
  12612.          }
  12613.          Retrieve TCB and Session.
  12614.          if (CurrentPDU.type = Logout) { 
  12615.             if (CurrentPDU.ReasonCode = RecoveryRemove) {
  12616.                 Retrieve the CleanupConnection from CurrentPDU.CID).
  12617.                 for (each command active on CleanupConnection) {
  12618.                      Quiesce-And-Prepare-for-New-Allegiance(Session, TCB);
  12619.                      TCB.CurrentlyAllegiant = FALSE;
  12620.                 }
  12621.                 Cleanup-Connection-State(CleanupConnection);
  12622.                 if ((quiescing successful) and (cleanup successful)) {
  12623.                      Build-And-Send-Logout-Response(Connection, 
  12624.                                          CleanupConnection.CID, Success);
  12625.                 } else {
  12626.                      Build-And-Send-Logout-Response(Connection, 
  12627.                                          CleanupConnection.CID, Failure);
  12628.                 }
  12629.             }
  12630.          } else if (CurrentPDU.type = TaskManagement) { 
  12631.               if (CurrentPDU.function = "TaskReassign") {
  12632.                     if (Session.ErrorRecoveryLevel < 2) {
  12633.                        Build-And-Send-TaskMgmt-Response(Connection,
  12634.  
  12635.  
  12636. Julian Satran                      Expires August  2002                  249
  12637.  
  12638.  
  12639.  
  12640.  
  12641.  
  12642.                                      iSCSI                       17-April-02
  12643.  
  12644.                             CurrentPDU, "Task failover not supported");
  12645.                     } else if (task is not found) {
  12646.                        Build-And-Send-TaskMgmt-Response(Connection,
  12647.                             CurrentPDU, "Task not in task set");
  12648.                     } else if (task is currently allegiant) {
  12649.                        Build-And-Send-TaskMgmt-Response(Connection,
  12650.                                  CurrentPDU, "Task still allegiant");
  12651.                     } else {
  12652.                        Establish-New-Allegiance(TCB, Connection);
  12653.                        TCB.CurrentlyAllegiant = TRUE;
  12654.                        Schedule-Command-To-Continue(TCB);
  12655.                     } 
  12656.               } 
  12657.          } else { /* REST UNRELATED TO CONNECTION-RECOVERY, 
  12658.                    * NOT SHOWN */
  12659.          }
  12660.      }
  12661.  
  12662.      Transport_Exception_Handler(Connection)
  12663.      {
  12664.          Connection.PerformConnectionCleanup = TRUE;
  12665.          if (the event is an unexpected transport disconnect) {
  12666.              Connection.State = CLEANUP_WAIT;
  12667.               Start-Timer(Connection-Resource-Timeout-Handler, Connection, 
  12668.                                    (DefaultTime2Wait+DefaultTime2Retain));
  12669.              if (this Session has full-feature phase connections left) {
  12670.                  DifferentConnection = 
  12671.                     Pick-A-Logged-In-Connection(Session);
  12672.                   Build-And-Send-Async(DifferentConnection, 
  12673.                         DroppedConnection, DefaultTime2Wait, 
  12674.                           DefaultTime2Retain);
  12675.             }
  12676.          } else {
  12677.              Connection.State = FREE;
  12678.          }
  12679.      }
  12680.  
  12681.  
  12682.  
  12683.  
  12684.  
  12685. Julian Satran              Expires August  2002                          250
  12686.  
  12687.  
  12688.  
  12689.  
  12690.  
  12691.                                    iSCSI                      17-April-02
  12692.  
  12693. Appendix F. Clearing effects of various events on targets
  12694.  
  12695. F.1  Clearing effects on iSCSI objects
  12696.  
  12697.      The following tables describe the target behavior on receiving the 
  12698.      events specified in the rows of the table.  The second table is merely 
  12699.      an extension of the first table and defines clearing actions for more 
  12700.      objects on the same events.  The legend is:
  12701.  
  12702.        Y   = Yes (cleared/discarded/reset on the event specified in the 
  12703.          row).  Unless noted otherwise, the clearing action is applica-
  12704.          ble only for the issuing initiator port.
  12705.        N   = No  (not affected on the event specified in the row, i.e. 
  12706.          stays at previous value).
  12707.        NA  = Not Applicable, or Not Defined.
  12708.  
  12709.  
  12710.  
  12711.  
  12712.  
  12713. Julian Satran               Expires August  2002                       251
  12714.  
  12715.  
  12716.  
  12717.  
  12718.  
  12719.                                    iSCSI                      17-April-02
  12720.  
  12721.                            +-----+-----+-----+-----+-----+
  12722.                            |IT(1)|IC(2)|CT(5)|ST(6)|PP(7)|
  12723.      +---------------------+-----+-----+-----+-----+-----+
  12724.      |connection failure(8)|Y    |Y    |N    |N    |Y    |
  12725.      +---------------------+-----+-----+-----+-----+-----+
  12726.      |connection state     |NA   |NA   |Y    |N    |NA   |
  12727.      |timeout (9)          |     |     |     |     |     |
  12728.      +---------------------+-----+-----+-----+-----+-----+
  12729.      |session timeout/     |Y    |Y    |Y    |Y    |Y(14)|
  12730.      |closure/reinstatement|     |     |     |     |     |
  12731.      |(10)                 |     |     |     |     |     |
  12732.      +---------------------+-----+-----+-----+-----+-----+
  12733.      |session continuation |NA   |NA   |N(11)|N    |NA   |
  12734.      |(12)                 |     |     |     |     |     |
  12735.      +---------------------+-----+-----+-----+-----+-----+
  12736.      |successful connection|Y    |Y   |Y    |N    |Y(13)|
  12737.      |close logout         |     |     |     |     |     |
  12738.      +---------------------+-----+-----+-----+-----+-----+
  12739.      |session failure (18) |Y    |Y    |N    |N    |Y    |
  12740.      +---------------------+-----+-----+-----+-----+-----+
  12741.      |successful recovery  |Y    |Y    |N    |N    |Y(13)|
  12742.      |Logout               |     |     |     |     |     |
  12743.      +---------------------+-----+-----+-----+-----+-----+
  12744.      |failed Logout        |Y    |Y    |N    |N    |Y    |
  12745.      +---------------------+-----+-----+-----+-----+-----+
  12746.      |connection Login     |NA   |NA   |NA   |Y(15)|NA   |
  12747.      |(leading)            |     |     |     |     |     |
  12748.      +---------------------+-----+-----+-----+-----+-----+
  12749.      |connection Login     |NA   |NA   |N(11)|N    |Y    |
  12750.      |(non-leading)        |     |     |     |     |     |
  12751.      +---------------------+-----+-----+-----+-----+-----+
  12752.      |target cold reset(16)|Y    |Y    |Y    |Y    |Y    |
  12753.      +---------------------+-----+-----+-----+-----+-----+
  12754.      |target warm reset(16)|Y    |Y    |Y    |Y    |Y    |
  12755.      +---------------------+-----+-----+-----+-----+-----+
  12756.      |LU reset(19)         |Y    |Y    |Y    |Y    |Y    |
  12757.      +---------------------+-----+-----+-----+-----+-----+
  12758.      |powercycle(16)       |Y    |Y    |Y    |Y    |Y    |
  12759.      +---------------------+-----+-----+-----+-----+-----+
  12760.  
  12761.      1.Incomplete TTTs - Target Transfer Tags on which the target is still 
  12762.      expecting PDUs to be received. Examples include TTTs received via R2T, 
  12763.      NOP-IN etc.
  12764.  
  12765. Julian Satran               Expires August  2002                       252
  12766.  
  12767.  
  12768.  
  12769.  
  12770.  
  12771.                                       iSCSI                   17-April-02
  12772.  
  12773.  
  12774.      2.Immediate Commands - immediate commands but waiting for execution 
  12775.      on a target, for ex., Abort Task Set.
  12776.  
  12777.      5.Connection Tasks - tasks that are active on the iSCSI connection in 
  12778.      question.
  12779.  
  12780.      6.Session Tasks - tasks that are active on the entire iSCSI session, 
  12781.      so is a union of `connection tasks' on all participating connections.
  12782.  
  12783.      7.Partial PDUs (if any) - PDUs that are partially sent and waiting for 
  12784.      transport window credit to complete the transmission.
  12785.  
  12786.      8.Connection failure is a connection exception condition -one of 
  12787.      transport connection shutdown, transport connection reset, or trans-
  12788.      port connection timeout abruptly terminating the iSCSI full-feature 
  12789.      phase connection. A connection failure always takes the connection 
  12790.      state machine to the CLEANUP_WAIT state.
  12791.  
  12792.      9.Connection state timeout happens if a connection spends more time 
  12793.      than agreed upon during Login negotiation in the CLEANUP_WAIT state, 
  12794.      and this takes the connection to the FREE state (M1 transition in con-
  12795.      nection cleanup state diagram).
  12796.  
  12797.      10.These are defined in Section 4.3.5 Session reinstatement, closure 
  12798.      and timeout.
  12799.  
  12800.      11.This clearing effect is however "Y" only if it is a connection 
  12801.      reinstatement and the operational ErrorRecoveryLevel is less than 2.
  12802.  
  12803.      12.Session continuation is as defined in Section 4.3.6 Session con-
  12804.      tinuation and failure.
  12805.  
  12806.      13.This clearing effect is valid only if the connection is being 
  12807.      logged-out on a different connection and when the connection being 
  12808.      logged out on the target may have some partial PDUs pending to be 
  12809.      sent.  In all other cases, the effect is "NA".
  12810.  
  12811.      14.This clearing effect is valid only for a "close the session" logout 
  12812.      in a multi-connection session.  In all other cases, the effect is 
  12813.      "NA". 
  12814.  
  12815.  
  12816.  
  12817. Julian Satran                  Expires August  2002                    253
  12818.  
  12819.  
  12820.  
  12821.  
  12822.  
  12823.                                   iSCSI                      17-April-02
  12824.  
  12825.      15.Applicable only if this leading connection login is a session rein-
  12826.      statement. If that is not the case, this is "NA".
  12827.  
  12828.      16.This operation affects all logged-in initiators.
  12829.  
  12830.      18.Session failure is as defined in Section 4.3.6 Session continua-
  12831.      tion and failure.
  12832.  
  12833.      19.This operation affects all logged-in initiators and the clearing 
  12834.      effects are only applicable to the LU being reset.
  12835.  
  12836.  
  12837.  
  12838.  
  12839.  
  12840. Julian Satran              Expires August  2002                       254
  12841.  
  12842.  
  12843.  
  12844.  
  12845.  
  12846.                                   iSCSI                       17-April-02
  12847.  
  12848.                            +-----+-----+-----+-----+-----+
  12849.                            |DC(1)|DD(2)|SS(3)|CS(4)|DS(5)|
  12850.      +---------------------+-----+-----+-----+-----+-----+
  12851.      |connection failure   |N    |Y    |N    |N    |N    |
  12852.      +---------------------+-----+-----+-----+-----+-----+
  12853.      |connection state     |Y    |NA   |Y    |N    |NA   |
  12854.      |timeout              |     |     |     |     |     |
  12855.      +---------------------+-----+-----+-----+-----+-----+
  12856.      |session timeout/     |Y    |Y    |Y(7) |Y    |NA   |
  12857.      |closure/reinstatement|     |     |     |     |     |
  12858.      +---------------------+-----+-----+-----+-----+-----+
  12859.      |session continuation |N(11)|NA*12|NA   |N    |NA*13|
  12860.      +---------------------+-----+-----+-----+-----+-----+
  12861.      |successful connection|Y    |Y    |Y   |N    |NA   |
  12862.      |close Logout         |     |     |     |     |     |
  12863.      +---------------------+-----+-----+-----+-----+-----+
  12864.      |session failure      |N    |Y    |N    |N    |N    |
  12865.      +---------------------+-----+-----+-----+-----+-----+
  12866.      |successful recovery  |Y    |Y    |Y    |N    |N    |
  12867.      |Logout               |     |     |     |     |     |
  12868.      +---------------------+-----+-----+-----+-----+-----+
  12869.      |failed Logout        |N    |Y(9) |N    |N    |N    |
  12870.      +---------------------+-----+-----+-----+-----+-----+
  12871.      |connection Login     |NA   |NA   |N(8) |N(8) |NA   |
  12872.      |(leading             |     |     |     |     |     |
  12873.      +---------------------+-----+-----+-----+-----+-----+
  12874.      |connection Login     |N(11)|NA*12|N(8) |N    |NA*13|
  12875.      |(non-leading)        |     |     |     |     |     |
  12876.      +---------------------+-----+-----+-----+-----+-----+
  12877.      |target cold reset    |Y    |Y    |Y    |Y(10)|NA   |
  12878.      +---------------------+-----+-----+-----+-----+-----+
  12879.      |target warm reset    |Y    |Y    |N    |N    |NA   |
  12880.      +---------------------+-----+-----+-----+-----+-----+
  12881.      |LU reset             |N    |Y    |N    |N    |N    |
  12882.      +---------------------+-----+-----+-----+-----+-----+
  12883.      |powercycle           |Y    |Y    |Y    |Y(10)|NA   |
  12884.      +---------------------+-----+-----+-----+-----+-----+
  12885.  
  12886.      1.Discontiguous Commands - commands allegiant to the connection in 
  12887.      question and waiting to be reordered in the iSCSI layer. All "Y"s in 
  12888.      this column assume that the task causing the event (if indeed the 
  12889.      event is the result of a task) is issued as an immediate command, 
  12890.      since the discontiguities can be ahead of the task.
  12891.  
  12892. Julian Satran              Expires August  2002                       255
  12893.  
  12894.  
  12895.  
  12896.  
  12897.  
  12898.                                    iSCSI                      17-April-02
  12899.  
  12900.  
  12901.      2.Discontiguous Data - data PDUs received for the task in question and 
  12902.      waiting to be reordered due to prior discontiguities in DataSN.
  12903.  
  12904.      3.StatSN
  12905.  
  12906.      4.CmdSN
  12907.  
  12908.      5.DataSN
  12909.  
  12910.      7.It clears the StatSN on all the connections.
  12911.  
  12912.      8.This sequence number is instantiated on this event.
  12913.  
  12914.      9.A logout failure drives the connection state machine to the 
  12915.      CLEANUP_WAIT state, similar to the connection failure event. Hence, 
  12916.      it has a similar effect on this and several other protocol aspects.
  12917.  
  12918.      10.This is cleared by virtue of the fact that all sessions with all 
  12919.      initiators are terminated.
  12920.  
  12921.      11.This clearing effect is "Y" if it is a connection reinstatement.
  12922.  
  12923.      12.This clearing effect is "Y" only if it is a connection reinstate-
  12924.      ment and the operational ErrorRecoveryLevel is 2.
  12925.  
  12926.      13.This clearing effect is "N" only if it is a connection reinstate-
  12927.      ment and the operational ErrorRecoveryLevel is 2.
  12928.  
  12929. F.2  Clearing effects on SCSI objects
  12930.  
  12931.      The only iSCSI protocol action that can effect clearing actions on 
  12932.      SCSI objects is the "I_T nexus loss" notification (Section 4.3.5.1 
  12933.      Loss of Nexus notification).  The following table describes the clear-
  12934.      ing effects of this notification on a variety of SCSI attributes.  In 
  12935.      addition, SCSI standards documents ([SAM2] and [SPC3]) define addi-
  12936.      tional clearing actions that may take place for several SCSI objects 
  12937.      on SCSI events such as LU resets and power-on resets.
  12938.  
  12939.      Note that since iSCSI defines target cold reset as protocol-equiva-
  12940.      lent to a target powercycle, the iSCSI target cold reset must also be 
  12941.      considered as the power-on reset event in interpreting the actions 
  12942.      defined in the SCSI standards.
  12943.  
  12944.  
  12945. Julian Satran               Expires August  2002                        256
  12946.  
  12947.  
  12948.  
  12949.  
  12950.  
  12951.                                   iSCSI                      17-April-02
  12952.  
  12953.  
  12954.      When the iSCSI session is reconstructed (thus between the same SCSI 
  12955.      ports with the same nexus identifier) establishing the same I_T nexus 
  12956.      again, all SCSI objects that were not cleared on the previous session 
  12957.      termination (i.e with the "N" clearing effect in the following table) 
  12958.      such as persistent reservations are automatically associated to this 
  12959.      new session.
  12960.  
  12961.      All the SCSI objects not mentioned herein shall remain unaffected by 
  12962.      the "I_T nexus loss" notification.
  12963.  
  12964.  
  12965.  
  12966.  
  12967.  
  12968. Julian Satran              Expires August  2002                       257
  12969.  
  12970.  
  12971.  
  12972.  
  12973.  
  12974.                                   iSCSI               17-April-02
  12975.  
  12976.      +---------------------------------+---------+
  12977.      | SCSI object                     |Clearing |
  12978.      |                                 |effect   |
  12979.      +---------------------------------+---------+
  12980.      |Background operations            |   N     |
  12981.      |(e.g. FORMAT UNIT)               |         |
  12982.      +---------------------------------+---------+
  12983.      |Sense data                       |   Y     |
  12984.      +---------------------------------+---------+
  12985.      |SCSI Tasks                       |   Y     |
  12986.      +---------------------------------+---------+
  12987.      |existing CA or ACA               |   Y     |
  12988.      +---------------------------------+---------+
  12989.      |Regular reservations (1)         |   N     |
  12990.      +---------------------------------+---------+
  12991.      |Regular reservations - 3rd       |   N     |
  12992.      |party reservation                |         |
  12993.      +---------------------------------+---------+
  12994.      |Persistent reservations (2)      |   N     |
  12995.      +---------------------------------+---------+
  12996.      |Alias table associations         |   N     |
  12997.      +---------------------------------+---------+
  12998.      |Log pages                        |   Y (3) |
  12999.      |(only the TapeAlert page         |         |
  13000.      |in SSC-2)                        |         |
  13001.      +---------------------------------+---------+
  13002.      |Mode pages revert to             |   Y (4) |
  13003.      |saved/default                    |         |
  13004.      +---------------------------------+---------+
  13005.      |Prevention of medium removal     |   N     |
  13006.      +---------------------------------+---------+
  13007.      |EXTENDED COPY                    |   Y     |
  13008.      |COPY STATUS data                 |         |
  13009.      +---------------------------------+---------+
  13010.      |EXTENDED COPY                    |   Y     |
  13011.      |RECEIVE DATA data                |         |
  13012.      +---------------------------------+---------+
  13013.      |EXTENDED COPY                    |   Y     |
  13014.      |FAILED SEGMENT DETAILS data      |         |
  13015.      +---------------------------------+---------+
  13016.      |WRITE BUFFER download microcode  |   Y     |
  13017.      +---------------------------------+---------+
  13018.      |SEND DIAGNOSTIC invoked          |   N     |
  13019.  
  13020. Julian Satran              Expires August  2002               258
  13021.  
  13022.  
  13023.  
  13024.  
  13025.  
  13026.                                   iSCSI                      17-April-02
  13027.  
  13028.      |background self-test             |         |
  13029.      +---------------------------------+---------+
  13030.      |enabled Access Controls          |   N     |
  13031.      +---------------------------------+---------+
  13032.      |Access Controls enrollment state |   Y(5)  |
  13033.      +---------------------------------+---------+
  13034.      |XOR data                         |   N     |
  13035.      +---------------------------------+---------+
  13036.  
  13037.      1.Regular Reservations - these are the SCSI reservations managed by 
  13038.      the SCSI Reserve and Release commands.
  13039.  
  13040.      2.Persistent Reservations - the objects that are covered in this row 
  13041.      are registration information, and the persistent reservation informa-
  13042.      tion.  
  13043.  
  13044.      3. The unsaved and modified log pages are discarded for different 
  13045.      types of log pages as follows:
  13046.        - per initiator port pages: when the initiator port logs out
  13047.        - shared: when the last sharing initiator logs out
  13048.  
  13049.      4. The unsaved and modified mode pages are discarded for different 
  13050.      types of mode pages as follows:
  13051.        - per-I_T-nexus pages: when the I_T nexus logs out
  13052.        - per initiator port pages: when initiator port logs out from 
  13053.          all I_T nexuses in the target 
  13054.        - shared pages: when the last sharing initiator logs out
  13055.  
  13056.      5. AccessID enrollment state is forced to pending-enrolled state on 
  13057.      logout.
  13058.  
  13059.  
  13060.  
  13061.  
  13062.  
  13063. Julian Satran              Expires August  2002                        259
  13064.  
  13065.  
  13066.  
  13067.  
  13068.  
  13069.                                    iSCSI                      17-April-02
  13070.  
  13071. Full Copyright Statement
  13072.  
  13073.      "Copyright (C) The Internet Society (date). All Rights Reserved. This 
  13074.      document and translations of it may be copied and furnished to others, 
  13075.      and derivative works that comment on or otherwise explain it or assist 
  13076.      in its implementation may be prepared, copied, published and distrib-
  13077.      uted, in whole or in part, without restriction of any kind, provided 
  13078.      that the above copyright notice and this paragraph are included on all 
  13079.      such copies and derivative works. However, this document itself may 
  13080.      not be modified in any way, such as by removing the copyright notice 
  13081.      or references to the Internet Society or other Internet organiza-
  13082.      tions, except as needed for the purpose of developing Internet stan-
  13083.      dards in which case the procedures for copyrights defined in the 
  13084.      Internet Standards process must be followed, or as required to trans-
  13085.      late it into languages other than    English.
  13086.  
  13087.      The limited permissions granted above are perpetual and will not be    
  13088.      revoked by the Internet Society or its successors or assigns.
  13089.  
  13090.      This document and the information contained herein is provided on an 
  13091.      "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING 
  13092.      TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 
  13093.      BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN 
  13094.      WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF   MERCHANT-
  13095.      ABILITY OR FITNESS FOR A PARTICULAR PURPOSE."
  13096.  
  13097.  
  13098.  
  13099.  
  13100.  
  13101. Julian Satran               Expires August  2002                       260
  13102.  
  13103.  
  13104.  
  13105.  
  13106.  
  13107.