aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 13:22:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 13:22:09 -0400
commitc6668726d2c2c581e6c417448c472c994d026f5f (patch)
treeccbc5a73b9dfe09a065cb5d8627aa2297e730ec0 /Documentation
parent06b45f2aa703837163496f5db6a53575665cc6b4 (diff)
parent68d4cef3bab3fb9bb0dbac690ba35a96cb5a16d9 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "Lots of activity in target land the last months. The highlights include: - Convert fabric drivers tree-wide to target_register_template() (hch + bart) - iser-target hardening fixes + v1.0 improvements (sagi) - Convert iscsi_thread_set usage to kthread.h + kill iscsi_target_tq.c (sagi + nab) - Add support for T10-PI WRITE_STRIP + READ_INSERT operation (mkp + sagi + nab) - DIF fixes for CONFIG_DEBUG_SG=y + UNMAP file emulation (akinobu + sagi + mkp) - Extended TCMU ABI v2 for future BIDI + DIF support (andy + ilias) - Fix COMPARE_AND_WRITE handling for NO_ALLLOC drivers (hch + nab) Thanks to everyone who contributed this round with new features, bug-reports, fixes, cleanups and improvements. Looking forward, it's currently shaping up to be a busy v4.2 as well" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (69 commits) target: Put TCMU under a new config option target: Version 2 of TCMU ABI target: fix tcm_mod_builder.py target/file: Fix UNMAP with DIF protection support target/file: Fix SG table for prot_buf initialization target/file: Fix BUG() when CONFIG_DEBUG_SG=y and DIF protection enabled target: Make core_tmr_abort_task() skip TMFs target/sbc: Update sbc_dif_generate pr_debug output target/sbc: Make internal DIF emulation honor ->prot_checks target/sbc: Return INVALID_CDB_FIELD if DIF + sess_prot_type disabled target: Ensure sess_prot_type is saved across session restart target/rd: Don't pass incomplete scatterlist entries to sbc_dif_verify_* target: Remove the unused flag SCF_ACK_KREF target: Fix two sparse warnings target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling target: simplify the target template registration API target: simplify target_xcopy_init_pt_lun target: remove the unused SCF_CMD_XCOPY_PASSTHROUGH flag target/rd: reduce code duplication in rd_execute_rw() tcm_loop: fixup tpgt string to integer conversion ...
Diffstat (limited to 'Documentation')
-rwxr-xr-xDocumentation/target/tcm_mod_builder.py79
-rw-r--r--Documentation/target/tcmu-design.txt43
2 files changed, 40 insertions, 82 deletions
diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index 2b47704f75cb..2ba71cea0172 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -237,8 +237,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
237 buf += "#include \"" + fabric_mod_name + "_base.h\"\n" 237 buf += "#include \"" + fabric_mod_name + "_base.h\"\n"
238 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" 238 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n"
239 239
240 buf += "/* Local pointer to allocated TCM configfs fabric module */\n" 240 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops;\n\n"
241 buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n"
242 241
243 buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n" 242 buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n"
244 buf += " struct se_portal_group *se_tpg,\n" 243 buf += " struct se_portal_group *se_tpg,\n"
@@ -309,8 +308,8 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
309 buf += " }\n" 308 buf += " }\n"
310 buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n" 309 buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n"
311 buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n" 310 buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n"
312 buf += " ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n" 311 buf += " ret = core_tpg_register(&" + fabric_mod_name + "_ops, wwn,\n"
313 buf += " &tpg->se_tpg, (void *)tpg,\n" 312 buf += " &tpg->se_tpg, tpg,\n"
314 buf += " TRANSPORT_TPG_TYPE_NORMAL);\n" 313 buf += " TRANSPORT_TPG_TYPE_NORMAL);\n"
315 buf += " if (ret < 0) {\n" 314 buf += " if (ret < 0) {\n"
316 buf += " kfree(tpg);\n" 315 buf += " kfree(tpg);\n"
@@ -370,7 +369,10 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
370 buf += " NULL,\n" 369 buf += " NULL,\n"
371 buf += "};\n\n" 370 buf += "};\n\n"
372 371
373 buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" 372 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n"
373 buf += " .module = THIS_MODULE,\n"
374 buf += " .name = " + fabric_mod_name + ",\n"
375 buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n"
374 buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n" 376 buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n"
375 buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n" 377 buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n"
376 buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n" 378 buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n"
@@ -413,75 +415,18 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
413 buf += " .fabric_drop_np = NULL,\n" 415 buf += " .fabric_drop_np = NULL,\n"
414 buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n" 416 buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n"
415 buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n" 417 buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n"
416 buf += "};\n\n" 418 buf += "\n"
417 419 buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
418 buf += "static int " + fabric_mod_name + "_register_configfs(void)\n"
419 buf += "{\n"
420 buf += " struct target_fabric_configfs *fabric;\n"
421 buf += " int ret;\n\n"
422 buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n"
423 buf += " \" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n"
424 buf += " utsname()->machine);\n"
425 buf += " /*\n"
426 buf += " * Register the top level struct config_item_type with TCM core\n"
427 buf += " */\n"
428 buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name + "\");\n"
429 buf += " if (IS_ERR(fabric)) {\n"
430 buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n"
431 buf += " return PTR_ERR(fabric);\n"
432 buf += " }\n"
433 buf += " /*\n"
434 buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n"
435 buf += " */\n"
436 buf += " fabric->tf_ops = " + fabric_mod_name + "_ops;\n"
437 buf += " /*\n"
438 buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n"
439 buf += " */\n"
440 buf += " fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
441 buf += " fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = NULL;\n"
442 buf += " fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;\n"
443 buf += " fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;\n"
444 buf += " fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;\n"
445 buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n"
446 buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n"
447 buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n"
448 buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n"
449 buf += " /*\n"
450 buf += " * Register the fabric for use within TCM\n"
451 buf += " */\n"
452 buf += " ret = target_fabric_configfs_register(fabric);\n"
453 buf += " if (ret < 0) {\n"
454 buf += " printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n"
455 buf += " \" for " + fabric_mod_name.upper() + "\\n\");\n"
456 buf += " return ret;\n"
457 buf += " }\n"
458 buf += " /*\n"
459 buf += " * Setup our local pointer to *fabric\n"
460 buf += " */\n"
461 buf += " " + fabric_mod_name + "_fabric_configfs = fabric;\n"
462 buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n"
463 buf += " return 0;\n"
464 buf += "};\n\n"
465 buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n"
466 buf += "{\n"
467 buf += " if (!" + fabric_mod_name + "_fabric_configfs)\n"
468 buf += " return;\n\n"
469 buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n"
470 buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n"
471 buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n"
472 buf += "};\n\n" 420 buf += "};\n\n"
473 421
474 buf += "static int __init " + fabric_mod_name + "_init(void)\n" 422 buf += "static int __init " + fabric_mod_name + "_init(void)\n"
475 buf += "{\n" 423 buf += "{\n"
476 buf += " int ret;\n\n" 424 buf += " return target_register_template(" + fabric_mod_name + "_ops);\n"
477 buf += " ret = " + fabric_mod_name + "_register_configfs();\n"
478 buf += " if (ret < 0)\n"
479 buf += " return ret;\n\n"
480 buf += " return 0;\n"
481 buf += "};\n\n" 425 buf += "};\n\n"
426
482 buf += "static void __exit " + fabric_mod_name + "_exit(void)\n" 427 buf += "static void __exit " + fabric_mod_name + "_exit(void)\n"
483 buf += "{\n" 428 buf += "{\n"
484 buf += " " + fabric_mod_name + "_deregister_configfs();\n" 429 buf += " target_unregister_template(" + fabric_mod_name + "_ops);\n"
485 buf += "};\n\n" 430 buf += "};\n\n"
486 431
487 buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" 432 buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
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