aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/target
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2015-04-14 20:30:04 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-04-20 01:40:26 -0400
commit0ad46af8a618fc38e0cdc3927cfa9f7b42cc9423 (patch)
tree92ff9184b1c24d7886403f6f2bbb25115022e16f /Documentation/target
parent65204c84d7666a78e965da0dd8696bdb007606dd (diff)
target: Version 2 of TCMU ABI
The initial version of TCMU (in 3.18) does not properly handle bidirectional SCSI commands -- those with both an in and out buffer. In looking to fix this it also became clear that TCMU's support for adding new types of entries (opcodes) to the command ring was broken. We need to fix this now, so that future issues can be handled properly by adding new opcodes. We make the most of this ABI break by enabling bidi cmd handling within TCMP_OP_CMD opcode. Add an iov_bidi_cnt field to tcmu_cmd_entry.req. This enables TCMU to describe bidi commands, but further kernel work is needed for full bidi support. Enlarge tcmu_cmd_entry_hdr by 32 bits by pulling in cmd_id and __pad1. Turn __pad1 into two 8 bit flags fields, for kernel-set and userspace-set flags, "kflags" and "uflags" respectively. Update version fields so userspace can tell the interface is changed. Update tcmu-design.txt with details of how new stuff works: - Specify an additional requirement for userspace to set UNKNOWN_OP (bit 0) in hdr.uflags for unknown/unhandled opcodes. - Define how Data-In and Data-Out fields are described in req.iov[] Changed in v2: - Change name of SKIPPED bit to UNKNOWN bit - PAD op does not set the bit any more - Change len_op helper functions to take just len_op, not the whole struct - Change version to 2 in missed spots, and use defines - Add 16 unused bytes to cmd_entry.req, in case additional SAM cmd parameters need to be included - Add iov_dif_cnt field to specify buffers used for DIF info in iov[] - Rearrange fields to naturally align cdb_off - Handle if userspace sets UNKNOWN_OP by indicating failure of the cmd - Wrap some overly long UPDATE_HEAD lines (Add missing req.iov_bidi_cnt + req.iov_dif_cnt zeroing - Ilias) Signed-off-by: Andy Grover <agrover@redhat.com> Reviewed-by: Ilias Tsitsimpis <iliastsi@arrikto.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'Documentation/target')
-rw-r--r--Documentation/target/tcmu-design.txt43
1 files changed, 28 insertions, 15 deletions
diff --git a/Documentation/target/tcmu-design.txt b/Documentation/target/tcmu-design.txt
index 5518465290bf..43e94ea6d2ca 100644
--- a/Documentation/target/tcmu-design.txt
+++ b/Documentation/target/tcmu-design.txt
@@ -138,27 +138,40 @@ signals the kernel via a 4-byte write(). When cmd_head equals
138cmd_tail, the ring is empty -- no commands are currently waiting to be 138cmd_tail, the ring is empty -- no commands are currently waiting to be
139processed by userspace. 139processed by userspace.
140 140
141TCMU commands start with a common header containing "len_op", a 32-bit 141TCMU commands are 8-byte aligned. They start with a common header
142value that stores the length, as well as the opcode in the lowest 142containing "len_op", a 32-bit value that stores the length, as well as
143unused bits. Currently only two opcodes are defined, TCMU_OP_PAD and 143the opcode in the lowest unused bits. It also contains cmd_id and
144TCMU_OP_CMD. When userspace encounters a command with PAD opcode, it 144flags fields for setting by the kernel (kflags) and userspace
145should skip ahead by the bytes in "length". (The kernel inserts PAD 145(uflags).
146entries to ensure each CMD entry fits contigously into the circular 146
147buffer.) 147Currently only two opcodes are defined, TCMU_OP_CMD and TCMU_OP_PAD.
148 148
149When userspace handles a CMD, it finds the SCSI CDB (Command Data 149When the opcode is CMD, the entry in the command ring is a struct
150Block) via tcmu_cmd_entry.req.cdb_off. This is an offset from the 150tcmu_cmd_entry. Userspace finds the SCSI CDB (Command Data Block) via
151start of the overall shared memory region, not the entry. The data 151tcmu_cmd_entry.req.cdb_off. This is an offset from the start of the
152in/out buffers are accessible via tht req.iov[] array. Note that 152overall shared memory region, not the entry. The data in/out buffers
153each iov.iov_base is also an offset from the start of the region. 153are accessible via tht req.iov[] array. iov_cnt contains the number of
154 154entries in iov[] needed to describe either the Data-In or Data-Out
155TCMU currently does not support BIDI operations. 155buffers. For bidirectional commands, iov_cnt specifies how many iovec
156entries cover the Data-Out area, and iov_bidi_count specifies how many
157iovec entries immediately after that in iov[] cover the Data-In
158area. Just like other fields, iov.iov_base is an offset from the start
159of the region.
156 160
157When completing a command, userspace sets rsp.scsi_status, and 161When completing a command, userspace sets rsp.scsi_status, and
158rsp.sense_buffer if necessary. Userspace then increments 162rsp.sense_buffer if necessary. Userspace then increments
159mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the 163mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the
160kernel via the UIO method, a 4-byte write to the file descriptor. 164kernel via the UIO method, a 4-byte write to the file descriptor.
161 165
166When the opcode is PAD, userspace only updates cmd_tail as above --
167it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry
168is contiguous within the command ring.)
169
170More opcodes may be added in the future. If userspace encounters an
171opcode it does not handle, it must set UNKNOWN_OP bit (bit 0) in
172hdr.uflags, update cmd_tail, and proceed with processing additional
173commands, if any.
174
162The Data Area: 175The Data Area:
163 176
164This is shared-memory space after the command ring. The organization 177This is shared-memory space after the command ring. The organization