diff options
Diffstat (limited to 'Documentation/target/tcmu-design.txt')
-rw-r--r-- | Documentation/target/tcmu-design.txt | 43 |
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 | |||
138 | cmd_tail, the ring is empty -- no commands are currently waiting to be | 138 | cmd_tail, the ring is empty -- no commands are currently waiting to be |
139 | processed by userspace. | 139 | processed by userspace. |
140 | 140 | ||
141 | TCMU commands start with a common header containing "len_op", a 32-bit | 141 | TCMU commands are 8-byte aligned. They start with a common header |
142 | value that stores the length, as well as the opcode in the lowest | 142 | containing "len_op", a 32-bit value that stores the length, as well as |
143 | unused bits. Currently only two opcodes are defined, TCMU_OP_PAD and | 143 | the opcode in the lowest unused bits. It also contains cmd_id and |
144 | TCMU_OP_CMD. When userspace encounters a command with PAD opcode, it | 144 | flags fields for setting by the kernel (kflags) and userspace |
145 | should skip ahead by the bytes in "length". (The kernel inserts PAD | 145 | (uflags). |
146 | entries to ensure each CMD entry fits contigously into the circular | 146 | |
147 | buffer.) | 147 | Currently only two opcodes are defined, TCMU_OP_CMD and TCMU_OP_PAD. |
148 | 148 | ||
149 | When userspace handles a CMD, it finds the SCSI CDB (Command Data | 149 | When the opcode is CMD, the entry in the command ring is a struct |
150 | Block) via tcmu_cmd_entry.req.cdb_off. This is an offset from the | 150 | tcmu_cmd_entry. Userspace finds the SCSI CDB (Command Data Block) via |
151 | start of the overall shared memory region, not the entry. The data | 151 | tcmu_cmd_entry.req.cdb_off. This is an offset from the start of the |
152 | in/out buffers are accessible via tht req.iov[] array. Note that | 152 | overall shared memory region, not the entry. The data in/out buffers |
153 | each iov.iov_base is also an offset from the start of the region. | 153 | are accessible via tht req.iov[] array. iov_cnt contains the number of |
154 | 154 | entries in iov[] needed to describe either the Data-In or Data-Out | |
155 | TCMU currently does not support BIDI operations. | 155 | buffers. For bidirectional commands, iov_cnt specifies how many iovec |
156 | entries cover the Data-Out area, and iov_bidi_count specifies how many | ||
157 | iovec entries immediately after that in iov[] cover the Data-In | ||
158 | area. Just like other fields, iov.iov_base is an offset from the start | ||
159 | of the region. | ||
156 | 160 | ||
157 | When completing a command, userspace sets rsp.scsi_status, and | 161 | When completing a command, userspace sets rsp.scsi_status, and |
158 | rsp.sense_buffer if necessary. Userspace then increments | 162 | rsp.sense_buffer if necessary. Userspace then increments |
159 | mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the | 163 | mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the |
160 | kernel via the UIO method, a 4-byte write to the file descriptor. | 164 | kernel via the UIO method, a 4-byte write to the file descriptor. |
161 | 165 | ||
166 | When the opcode is PAD, userspace only updates cmd_tail as above -- | ||
167 | it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry | ||
168 | is contiguous within the command ring.) | ||
169 | |||
170 | More opcodes may be added in the future. If userspace encounters an | ||
171 | opcode it does not handle, it must set UNKNOWN_OP bit (bit 0) in | ||
172 | hdr.uflags, update cmd_tail, and proceed with processing additional | ||
173 | commands, if any. | ||
174 | |||
162 | The Data Area: | 175 | The Data Area: |
163 | 176 | ||
164 | This is shared-memory space after the command ring. The organization | 177 | This is shared-memory space after the command ring. The organization |