Subject: iSCSI: CmdSN with Text Command

From: "Eddy Quicksall" <[email-masked]>
Date: Wed, 16 May 2001 13:53:49 -0400

I am confused about the use of CmdSN with the Text command. The reason is as
follows:

Section 1.2.2.1 says

   iSCSI supports ordered command delivery within a session.  All
   commands (initiator-to-target) are numbered.

   Commands in transit from the initiator SCSI layer to the SCSI target
   layer are numbered by iSCSI; the number is carried by the iSCSI PDU
   as CmdSN (Command-Sequence-Number).

       - CmdSN - the current command Sequence Number advanced by 1 on
      each command shipped except for commands marked for immediate
      delivery.

	... The target iSCSI layer sets the ExpCmdSN to the largest
      non-immediate CmdSN that it is able to deliver to the target
      SCSI layer plus 1 (no holes in the CmdSN sequence).

It looks like the 1st and 3rd paragraphs are saying that the CmdSN of a Text
Command would be advanced.

But, the 2nd and 4th paragraphs hint that only the SCSI layers advance
CmdSN.

Can someone clear this up? i.e., is CmdSN advanced for Text Commands?

mailto:[email-masked]

---

From: [email-masked]
Date: Mon, 21 May 2001 18:28:32 +0300

Eddy,

There is no reason Txt commands should be excmpt from numbering.  The
quoted satements
only say that iSCSI does the numbering.  To avoid confusion I will however
suggest the following rephrasing:

1.1.1.1   Command Numbering and Acknowledging

   iSCSI supports ordered command delivery within a session.  All commands
   (initiator-to-target) are numbered.

   Any SCSI activity is related to a task (SAM-2). The task is identified
   by the Initiator Task Tag for the life of the task.

   Commands in transit from the initiator to the target layer are numbered
   by iSCSI; the number is carried by the iSCSI PDU as CmdSN
   (Command-Sequence-Number).  The numbering is session-wide.  All outgoing
   iSCSI PDUs that have a task association, except Data-Out, carry this
   number. CmdSNs are allocated by the initiator iSCSI within a 32-bit
   unsigned counter (modulo 2**32). Comparisons and arithmetic on CmdSN
   SHOULD use Serial Number Arithmetic as defined in [RFC1982] where
   SERIAL_BITS = 32.

   Commands meant for immediate delivery are marked as such through an
   immediate delivery flag. They carry the same CmdSN as that which would
   have been given to a non-immediate command but the CmdSN is not advanced
   for immediate commands.

   Not covered in this document are the means by which one may request
   immediate delivery for a command or by which iSCSI will decide by itself
   to mark a PDU for immediate delivery.

   If immediate delivery is used with task management commands, these
   commands may reach the SCSI target task management before the tasks they
   are supposed to act upon.  However, their CmdSN is a good reference for
   what commands the immediate command was supposed to act upon.

   During command delivery to the target, the allocated numbers are unique
   session wide.

   Except for the commands marked for immediate delivery the iSCSI target
   layer MUST deliver the commands for execution in the order specified by
   CmdSN. Commands marked for immediate delivery may be handed over by the
   iSCSI target layer for execution as soon as detected. iSCSI may avoid
   delivering some command for execution if so required by some prior SCSI
   or iSCSI action (e.g., clear task set Task Management request received
   before all the commands it was supposed to act on).

   The initiator and target are assumed to have three registers that define
   the numbering mechanism:

       - CmdSN - the current command Sequence Number advanced by 1 on each
      command shipped except for commands marked for immediate delivery.
       - ExpCmdSN - the next expected command by the target. The target
      acknowledges all commands up to but not including this number. The
      target iSCSI layer sets the ExpCmdSN to the largest non-immediate
      CmdSN that it is able to deliver for execution plus 1 (no holes in
      the CmdSN sequence).
       - MaxCmdSN - the maximum number to be shipped. The queuing capacity
      of the receiving iSCSI layer is MaxCmdSN - ExpCmdSN + 1.

   ExpCmdSN and MaxCmdSN are derived from target-to-initiator PDU fields.

   MaxCmdSN and ExpCmdSN fields are processed as follows:

      -if the PDU MaxCmdSN is less than the PDU ExpCmdSN (in Serial
      Arithmetic Sense and with a difference bounded by 2**31-1), they are
      both ignored
      -if the PDU MaxCmdSN is less than the local MaxCmdSN (in Serial
      Arithmetic Sense and with a difference bounded by 2**31-1), it is
      ignored; else it updates the local MaxCmdSN
      -if the PDU ExpCmdSN is less than the local ExpCmdSN (in Serial
      Arithmetic Sense and with a difference bounded by 2**31-1), it is
      ignored; else it updates the local ExpCmdSN

   This sequence is required as updates may arrive out of order because
   they travel on different TCP connections.

   The target MUST NOT transmit a MaxCmdSN that is more than 2**31 - 1
   above the last ExpCmdSN.  For non-immediate commands, the CmdSN field
   can take any value from ExpCmdSN to MaxCmdSN. For immediate commands,
   the CmdSN field can take any value from ExpCmdSN to MaxCmdSN+1. The
   target MUST silently ignore any command outside this range or duplicates
   within the range that have not been flagged with the retry bit (the X
   bit in the opcode).

   iSCSI initiators and targets MUST support the command numbering scheme.

Regards,
Julo

"Eddy Quicksall" <[email-masked]> on 16-05-2001 20:53:49

Please respond to "Eddy Quicksall" <[email-masked]>

To:   [email-masked]
cc:
Subject:  iSCSI: CmdSN with Text Command

I am confused about the use of CmdSN with the Text command. The reason is
as
follows:

Section 1.2.2.1 says

It looks like the 1st and 3rd paragraphs are saying that the CmdSN of a
Text
Command would be advanced.