diff options
author | Sheng Yang <sheng@yasker.org> | 2016-02-29 19:02:15 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-11 00:49:09 -0500 |
commit | 32c76de3466ed2a875e36c140ac4e3800fdfab6e (patch) | |
tree | 1296fc2d9efffb9deb50de671be4f69d5af7dcde | |
parent | 0241fd39ce7bc9b82b7e57305cb0d6bb1364d45b (diff) |
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>
-rw-r--r-- | Documentation/target/tcmu-design.txt | 11 | ||||
-rw-r--r-- | drivers/target/target_core_user.c | 1 | ||||
-rw-r--r-- | include/uapi/linux/target_core_user.h | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/Documentation/target/tcmu-design.txt b/Documentation/target/tcmu-design.txt index bef81e42788f..4cebc1ebf99a 100644 --- a/Documentation/target/tcmu-design.txt +++ b/Documentation/target/tcmu-design.txt | |||
@@ -117,7 +117,9 @@ userspace (respectively) to put commands on the ring, and indicate | |||
117 | when the commands are completed. | 117 | when the commands are completed. |
118 | 118 | ||
119 | version - 1 (userspace should abort if otherwise) | 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 | cmdr_off - The offset of the start of the command ring from the start | 123 | cmdr_off - The offset of the start of the command ring from the start |
122 | of the memory region, to account for the mailbox size. | 124 | of the memory region, to account for the mailbox size. |
123 | cmdr_size - The size of the command ring. This does *not* need to be a | 125 | 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 | |||
162 | mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the | 164 | mailbox.cmd_tail by entry.hdr.length (mod cmdr_size) and signals the |
163 | kernel via the UIO method, a 4-byte write to the file descriptor. | 165 | kernel via the UIO method, a 4-byte write to the file descriptor. |
164 | 166 | ||
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 | |||
165 | When the opcode is PAD, userspace only updates cmd_tail as above -- | 174 | When the opcode is PAD, userspace only updates cmd_tail as above -- |
166 | it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry | 175 | it's a no-op. (The kernel inserts PAD entries to ensure each CMD entry |
167 | is contiguous within the command ring.) | 176 | is contiguous within the command ring.) |
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index fc4789c6067c..62bf4fe5704a 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
@@ -930,6 +930,7 @@ static int tcmu_configure_device(struct se_device *dev) | |||
930 | 930 | ||
931 | mb = udev->mb_addr; | 931 | mb = udev->mb_addr; |
932 | mb->version = TCMU_MAILBOX_VERSION; | 932 | mb->version = TCMU_MAILBOX_VERSION; |
933 | mb->flags = TCMU_MAILBOX_FLAG_CAP_OOOC; | ||
933 | mb->cmdr_off = CMDR_OFF; | 934 | mb->cmdr_off = CMDR_OFF; |
934 | mb->cmdr_size = udev->cmdr_size; | 935 | mb->cmdr_size = udev->cmdr_size; |
935 | 936 | ||
diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 95c6521d8a95..c506cddb8165 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | #define TCMU_MAILBOX_VERSION 2 | 42 | #define TCMU_MAILBOX_VERSION 2 |
43 | #define ALIGN_SIZE 64 /* Should be enough for most CPUs */ | 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 | struct tcmu_mailbox { | 46 | struct tcmu_mailbox { |
46 | __u16 version; | 47 | __u16 version; |