Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sheng Yang and committed by
Nicholas Bellinger
32c76de3 0241fd39

+12 -1
+10 -1
Documentation/target/tcmu-design.txt
··· 117 117 when the commands are completed. 118 118 119 119 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. 121 123 cmdr_off - The offset of the start of the command ring from the start 122 124 of the memory region, to account for the mailbox size. 123 125 cmdr_size - The size of the command ring. This does *not* need to be a ··· 163 161 rsp.sense_buffer if necessary. Userspace then increments 164 162 mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the 165 163 kernel via the UIO method, a 4-byte write to the file descriptor. 164 + 165 + If TCMU_MAILBOX_FLAG_CAP_OOOC is set for mailbox->flags, kernel is 166 + capable of handling out-of-order completions. In this case, userspace can 167 + handle command in different order other than original. Since kernel would 168 + still process the commands in the same order it appeared in the command 169 + ring, userspace need to update the cmd->id when completing the 170 + command(a.k.a steal the original command's entry). 166 171 167 172 When the opcode is PAD, userspace only updates cmd_tail as above -- 168 173 it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry
+1
drivers/target/target_core_user.c
··· 930 930 931 931 mb = udev->mb_addr; 932 932 mb->version = TCMU_MAILBOX_VERSION; 933 + mb->flags = TCMU_MAILBOX_FLAG_CAP_OOOC; 933 934 mb->cmdr_off = CMDR_OFF; 934 935 mb->cmdr_size = udev->cmdr_size; 935 936
+1
include/uapi/linux/target_core_user.h
··· 41 41 42 42 #define TCMU_MAILBOX_VERSION 2 43 43 #define ALIGN_SIZE 64 /* Should be enough for most CPUs */ 44 + #define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0) /* Out-of-order completions */ 44 45 45 46 struct tcmu_mailbox { 46 47 __u16 version;