Skip to content

Commit 32c76de

Browse files
yaskerNicholas Bellinger
authored andcommitted
target/user: Report capability of handling out-of-order completions to userspace
TCMU_MAILBOX_FLAG_CAP_OOOC was introduced, and userspace can check the flag for out-of-order completion capability support. Also update the document on how to use the feature. Signed-off-by: Sheng Yang <sheng@yasker.org> Reviewed-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 0241fd3 commit 32c76de

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎Documentation/target/tcmu-design.txt‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ userspace (respectively) to put commands on the ring, and indicate
117117
when the commands are completed.
118118

119119
version - 1 (userspace should abort if otherwise)
120-
flags - none yet defined.
120+
flags:
121+
- TCMU_MAILBOX_FLAG_CAP_OOOC: indicates out-of-order completion is
122+
supported. See "The Command Ring" for details.
121123
cmdr_off - The offset of the start of the command ring from the start
122124
of the memory region, to account for the mailbox size.
123125
cmdr_size - The size of the command ring. This does *not* need to be a
@@ -162,6 +164,13 @@ rsp.sense_buffer if necessary. Userspace then increments
162164
mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the
163165
kernel via the UIO method, a 4-byte write to the file descriptor.
164166

167+
If TCMU_MAILBOX_FLAG_CAP_OOOC is set for mailbox->flags, kernel is
168+
capable of handling out-of-order completions. In this case, userspace can
169+
handle command in different order other than original. Since kernel would
170+
still process the commands in the same order it appeared in the command
171+
ring, userspace need to update the cmd->id when completing the
172+
command(a.k.a steal the original command's entry).
173+
165174
When the opcode is PAD, userspace only updates cmd_tail as above --
166175
it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry
167176
is contiguous within the command ring.)

‎drivers/target/target_core_user.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ static int tcmu_configure_device(struct se_device *dev)
930930

931931
mb = udev->mb_addr;
932932
mb->version = TCMU_MAILBOX_VERSION;
933+
mb->flags = TCMU_MAILBOX_FLAG_CAP_OOOC;
933934
mb->cmdr_off = CMDR_OFF;
934935
mb->cmdr_size = udev->cmdr_size;
935936

‎include/uapi/linux/target_core_user.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#define TCMU_MAILBOX_VERSION 2
4343
#define ALIGN_SIZE 64 /* Should be enough for most CPUs */
44+
#define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0) /* Out-of-order completions */
4445

4546
struct tcmu_mailbox {
4647
__u16 version;

0 commit comments

Comments
 (0)