aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-18 18:59:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-18 18:59:18 -0500
commit4ba3069fea9f0771dad3f4906b305ab50d5a1b30 (patch)
tree3f75f2c0a320a6f38538c5e63f46ef79b0b3f1d1
parent507a03c1cba0e32309223d23d19a1bfc0916c140 (diff)
parent895f3022523361e9b383cf48f51feb1f7d5e7e53 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (26 commits) target: Set additional sense length field in sense data target: Remove legacy device status check from transport_execute_tasks target: Remove __transport_execute_tasks() for each processing context target: Remove extra se_device->execute_task_lock access in fast path target: Drop se_device TCQ queue_depth usage from I/O path target: Fix possible NULL pointer with __transport_execute_tasks target: Remove TFO->check_release_cmd() fabric API caller tcm_fc: Convert ft_send_work to use target_submit_cmd target: Add target_submit_cmd() for process context fabric submission target: Make target_put_sess_cmd use target_release_cmd_kref target: Set response format in INQUIRY response target: tcm_mod_builder: small fixups Documentation/target: Fix tcm_mod_builder.py build breakage target: remove overagressive ____cacheline_aligned annoations tcm_loop: bump max_sectors target/configs: remove trailing newline from udev_path and alias iscsi-target: fix chap identifier simple_strtoul usage target: remove useless casts target: simplify target_check_cdb_and_preempt target: Move core_scsi3_check_cdb_abort_and_preempt ...
-rwxr-xr-xDocumentation/target/tcm_mod_builder.py60
-rw-r--r--drivers/target/iscsi/iscsi_target.c19
-rw-r--r--drivers/target/iscsi/iscsi_target_auth.c36
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c11
-rw-r--r--drivers/target/iscsi/iscsi_target_device.c3
-rw-r--r--drivers/target/iscsi/iscsi_target_erl0.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_erl1.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_erl2.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c23
-rw-r--r--drivers/target/iscsi/iscsi_target_nego.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_nodeattrib.c3
-rw-r--r--drivers/target/iscsi/iscsi_target_stat.c17
-rw-r--r--drivers/target/iscsi/iscsi_target_tmr.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_tpg.c6
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c8
-rw-r--r--drivers/target/loopback/tcm_loop.c33
-rw-r--r--drivers/target/loopback/tcm_loop.h11
-rw-r--r--drivers/target/target_core_alua.c7
-rw-r--r--drivers/target/target_core_cdb.c39
-rw-r--r--drivers/target/target_core_cdb.h14
-rw-r--r--drivers/target/target_core_configfs.c34
-rw-r--r--drivers/target/target_core_device.c15
-rw-r--r--drivers/target/target_core_fabric_configfs.c8
-rw-r--r--drivers/target/target_core_fabric_lib.c13
-rw-r--r--drivers/target/target_core_file.c15
-rw-r--r--drivers/target/target_core_hba.c7
-rw-r--r--drivers/target/target_core_hba.h7
-rw-r--r--drivers/target/target_core_iblock.c7
-rw-r--r--drivers/target/target_core_internal.h123
-rw-r--r--drivers/target/target_core_pr.c24
-rw-r--r--drivers/target/target_core_pr.h2
-rw-r--r--drivers/target/target_core_pscsi.c20
-rw-r--r--drivers/target/target_core_rd.c6
-rw-r--r--drivers/target/target_core_stat.c9
-rw-r--r--drivers/target/target_core_stat.h8
-rw-r--r--drivers/target/target_core_tmr.c36
-rw-r--r--drivers/target/target_core_tpg.c9
-rw-r--r--drivers/target/target_core_transport.c343
-rw-r--r--drivers/target/target_core_ua.c6
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c57
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c6
-rw-r--r--drivers/target/tcm_fc/tfc_io.c5
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c5
-rw-r--r--include/target/target_core_backend.h65
-rw-r--r--include/target/target_core_base.h169
-rw-r--r--include/target/target_core_device.h63
-rw-r--r--include/target/target_core_fabric.h (renamed from include/target/target_core_fabric_ops.h)94
-rw-r--r--include/target/target_core_fabric_lib.h28
-rw-r--r--include/target/target_core_tmr.h35
-rw-r--r--include/target/target_core_tpg.h35
-rw-r--r--include/target/target_core_transport.h287
51 files changed, 829 insertions, 1014 deletions
diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index 7ef9b843d529..6e21b8b52638 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -230,14 +230,9 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
230 buf += "#include <linux/ctype.h>\n" 230 buf += "#include <linux/ctype.h>\n"
231 buf += "#include <asm/unaligned.h>\n\n" 231 buf += "#include <asm/unaligned.h>\n\n"
232 buf += "#include <target/target_core_base.h>\n" 232 buf += "#include <target/target_core_base.h>\n"
233 buf += "#include <target/target_core_transport.h>\n" 233 buf += "#include <target/target_core_fabric.h>\n"
234 buf += "#include <target/target_core_fabric_ops.h>\n"
235 buf += "#include <target/target_core_fabric_configfs.h>\n" 234 buf += "#include <target/target_core_fabric_configfs.h>\n"
236 buf += "#include <target/target_core_fabric_lib.h>\n"
237 buf += "#include <target/target_core_device.h>\n"
238 buf += "#include <target/target_core_tpg.h>\n"
239 buf += "#include <target/target_core_configfs.h>\n" 235 buf += "#include <target/target_core_configfs.h>\n"
240 buf += "#include <target/target_core_base.h>\n"
241 buf += "#include <target/configfs_macros.h>\n\n" 236 buf += "#include <target/configfs_macros.h>\n\n"
242 buf += "#include \"" + fabric_mod_name + "_base.h\"\n" 237 buf += "#include \"" + fabric_mod_name + "_base.h\"\n"
243 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" 238 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n"
@@ -260,7 +255,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
260 buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" 255 buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
261 buf += " return ERR_PTR(-EINVAL); */\n" 256 buf += " return ERR_PTR(-EINVAL); */\n"
262 buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" 257 buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n"
263 buf += " if (!(se_nacl_new))\n" 258 buf += " if (!se_nacl_new)\n"
264 buf += " return ERR_PTR(-ENOMEM);\n" 259 buf += " return ERR_PTR(-ENOMEM);\n"
265 buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" 260 buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n"
266 buf += " nexus_depth = 1;\n" 261 buf += " nexus_depth = 1;\n"
@@ -308,7 +303,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
308 buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" 303 buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n"
309 buf += " return ERR_PTR(-EINVAL);\n\n" 304 buf += " return ERR_PTR(-EINVAL);\n\n"
310 buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" 305 buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n"
311 buf += " if (!(tpg)) {\n" 306 buf += " if (!tpg) {\n"
312 buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" 307 buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n"
313 buf += " return ERR_PTR(-ENOMEM);\n" 308 buf += " return ERR_PTR(-ENOMEM);\n"
314 buf += " }\n" 309 buf += " }\n"
@@ -344,7 +339,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
344 buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" 339 buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
345 buf += " return ERR_PTR(-EINVAL); */\n\n" 340 buf += " return ERR_PTR(-EINVAL); */\n\n"
346 buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" 341 buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n"
347 buf += " if (!(" + fabric_mod_port + ")) {\n" 342 buf += " if (!" + fabric_mod_port + ") {\n"
348 buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" 343 buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n"
349 buf += " return ERR_PTR(-ENOMEM);\n" 344 buf += " return ERR_PTR(-ENOMEM);\n"
350 buf += " }\n" 345 buf += " }\n"
@@ -352,7 +347,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
352 if proto_ident == "FC" or proto_ident == "SAS": 347 if proto_ident == "FC" or proto_ident == "SAS":
353 buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" 348 buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n"
354 349
355 buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n" 350 buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
356 buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" 351 buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n"
357 buf += "}\n\n" 352 buf += "}\n\n"
358 buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" 353 buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n"
@@ -391,8 +386,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
391 buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n" 386 buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n"
392 buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n" 387 buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n"
393 buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" 388 buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n"
394 buf += " .release_cmd_to_pool = " + fabric_mod_name + "_release_cmd,\n" 389 buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n"
395 buf += " .release_cmd_direct = " + fabric_mod_name + "_release_cmd,\n"
396 buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" 390 buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n"
397 buf += " .close_session = " + fabric_mod_name + "_close_session,\n" 391 buf += " .close_session = " + fabric_mod_name + "_close_session,\n"
398 buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n" 392 buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n"
@@ -405,14 +399,12 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
405 buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n" 399 buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n"
406 buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n" 400 buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n"
407 buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n" 401 buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n"
408 buf += " .new_cmd_failure = " + fabric_mod_name + "_new_cmd_failure,\n"
409 buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n" 402 buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n"
410 buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n" 403 buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n"
411 buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n" 404 buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n"
412 buf += " .get_fabric_sense_len = " + fabric_mod_name + "_get_fabric_sense_len,\n" 405 buf += " .get_fabric_sense_len = " + fabric_mod_name + "_get_fabric_sense_len,\n"
413 buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n" 406 buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n"
414 buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n" 407 buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n"
415 buf += " .pack_lun = " + fabric_mod_name + "_pack_lun,\n"
416 buf += " /*\n" 408 buf += " /*\n"
417 buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n" 409 buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n"
418 buf += " */\n" 410 buf += " */\n"
@@ -439,9 +431,9 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
439 buf += " * Register the top level struct config_item_type with TCM core\n" 431 buf += " * Register the top level struct config_item_type with TCM core\n"
440 buf += " */\n" 432 buf += " */\n"
441 buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" 433 buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n"
442 buf += " if (!(fabric)) {\n" 434 buf += " if (IS_ERR(fabric)) {\n"
443 buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" 435 buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n"
444 buf += " return -ENOMEM;\n" 436 buf += " return PTR_ERR(fabric);\n"
445 buf += " }\n" 437 buf += " }\n"
446 buf += " /*\n" 438 buf += " /*\n"
447 buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" 439 buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n"
@@ -475,9 +467,9 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
475 buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" 467 buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n"
476 buf += " return 0;\n" 468 buf += " return 0;\n"
477 buf += "};\n\n" 469 buf += "};\n\n"
478 buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n" 470 buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n"
479 buf += "{\n" 471 buf += "{\n"
480 buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n" 472 buf += " if (!" + fabric_mod_name + "_fabric_configfs)\n"
481 buf += " return;\n\n" 473 buf += " return;\n\n"
482 buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" 474 buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n"
483 buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" 475 buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n"
@@ -492,17 +484,15 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
492 buf += " return ret;\n\n" 484 buf += " return ret;\n\n"
493 buf += " return 0;\n" 485 buf += " return 0;\n"
494 buf += "};\n\n" 486 buf += "};\n\n"
495 buf += "static void " + fabric_mod_name + "_exit(void)\n" 487 buf += "static void __exit " + fabric_mod_name + "_exit(void)\n"
496 buf += "{\n" 488 buf += "{\n"
497 buf += " " + fabric_mod_name + "_deregister_configfs();\n" 489 buf += " " + fabric_mod_name + "_deregister_configfs();\n"
498 buf += "};\n\n" 490 buf += "};\n\n"
499 491
500 buf += "#ifdef MODULE\n"
501 buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" 492 buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
502 buf += "MODULE_LICENSE(\"GPL\");\n" 493 buf += "MODULE_LICENSE(\"GPL\");\n"
503 buf += "module_init(" + fabric_mod_name + "_init);\n" 494 buf += "module_init(" + fabric_mod_name + "_init);\n"
504 buf += "module_exit(" + fabric_mod_name + "_exit);\n" 495 buf += "module_exit(" + fabric_mod_name + "_exit);\n"
505 buf += "#endif\n"
506 496
507 ret = p.write(buf) 497 ret = p.write(buf)
508 if ret: 498 if ret:
@@ -514,7 +504,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
514 504
515def tcm_mod_scan_fabric_ops(tcm_dir): 505def tcm_mod_scan_fabric_ops(tcm_dir):
516 506
517 fabric_ops_api = tcm_dir + "include/target/target_core_fabric_ops.h" 507 fabric_ops_api = tcm_dir + "include/target/target_core_fabric.h"
518 508
519 print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api 509 print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api
520 process_fo = 0; 510 process_fo = 0;
@@ -579,11 +569,7 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
579 buf += "#include <scsi/scsi_cmnd.h>\n" 569 buf += "#include <scsi/scsi_cmnd.h>\n"
580 buf += "#include <scsi/libfc.h>\n\n" 570 buf += "#include <scsi/libfc.h>\n\n"
581 buf += "#include <target/target_core_base.h>\n" 571 buf += "#include <target/target_core_base.h>\n"
582 buf += "#include <target/target_core_transport.h>\n" 572 buf += "#include <target/target_core_fabric.h>\n"
583 buf += "#include <target/target_core_fabric_ops.h>\n"
584 buf += "#include <target/target_core_fabric_lib.h>\n"
585 buf += "#include <target/target_core_device.h>\n"
586 buf += "#include <target/target_core_tpg.h>\n"
587 buf += "#include <target/target_core_configfs.h>\n\n" 573 buf += "#include <target/target_core_configfs.h>\n\n"
588 buf += "#include \"" + fabric_mod_name + "_base.h\"\n" 574 buf += "#include \"" + fabric_mod_name + "_base.h\"\n"
589 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" 575 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n"
@@ -788,7 +774,7 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
788 buf += "{\n" 774 buf += "{\n"
789 buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" 775 buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n"
790 buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" 776 buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n"
791 buf += " if (!(nacl)) {\n" 777 buf += " if (!nacl) {\n"
792 buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n" 778 buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n"
793 buf += " return NULL;\n" 779 buf += " return NULL;\n"
794 buf += " }\n\n" 780 buf += " }\n\n"
@@ -815,7 +801,7 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
815 buf += "}\n\n" 801 buf += "}\n\n"
816 bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n" 802 bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n"
817 803
818 if re.search('release_cmd_to_pool', fo): 804 if re.search('\*release_cmd\)\(', fo):
819 buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n" 805 buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n"
820 buf += "{\n" 806 buf += "{\n"
821 buf += " return;\n" 807 buf += " return;\n"
@@ -899,13 +885,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
899 buf += "}\n\n" 885 buf += "}\n\n"
900 bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n" 886 bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n"
901 887
902 if re.search('new_cmd_failure\)\(', fo):
903 buf += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *se_cmd)\n"
904 buf += "{\n"
905 buf += " return;\n"
906 buf += "}\n\n"
907 bufi += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *);\n"
908
909 if re.search('queue_data_in\)\(', fo): 888 if re.search('queue_data_in\)\(', fo):
910 buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n" 889 buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n"
911 buf += "{\n" 890 buf += "{\n"
@@ -948,15 +927,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
948 buf += "}\n\n" 927 buf += "}\n\n"
949 bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n" 928 bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n"
950 929
951 if re.search('pack_lun\)\(', fo):
952 buf += "u64 " + fabric_mod_name + "_pack_lun(unsigned int lun)\n"
953 buf += "{\n"
954 buf += " WARN_ON(lun >= 256);\n"
955 buf += " /* Caller wants this byte-swapped */\n"
956 buf += " return cpu_to_le64((lun & 0xff) << 8);\n"
957 buf += "}\n\n"
958 bufi += "u64 " + fabric_mod_name + "_pack_lun(unsigned int);\n"
959
960 930
961 ret = p.write(buf) 931 ret = p.write(buf)
962 if ret: 932 if ret:
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 8599545cdf9e..ac44af165b27 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -27,8 +27,7 @@
27#include <scsi/scsi_device.h> 27#include <scsi/scsi_device.h>
28#include <scsi/iscsi_proto.h> 28#include <scsi/iscsi_proto.h>
29#include <target/target_core_base.h> 29#include <target/target_core_base.h>
30#include <target/target_core_tmr.h> 30#include <target/target_core_fabric.h>
31#include <target/target_core_transport.h>
32 31
33#include "iscsi_target_core.h" 32#include "iscsi_target_core.h"
34#include "iscsi_target_parameters.h" 33#include "iscsi_target_parameters.h"
@@ -284,8 +283,8 @@ static struct iscsi_np *iscsit_get_np(
284 sock_in6 = (struct sockaddr_in6 *)sockaddr; 283 sock_in6 = (struct sockaddr_in6 *)sockaddr;
285 sock_in6_e = (struct sockaddr_in6 *)&np->np_sockaddr; 284 sock_in6_e = (struct sockaddr_in6 *)&np->np_sockaddr;
286 285
287 if (!memcmp((void *)&sock_in6->sin6_addr.in6_u, 286 if (!memcmp(&sock_in6->sin6_addr.in6_u,
288 (void *)&sock_in6_e->sin6_addr.in6_u, 287 &sock_in6_e->sin6_addr.in6_u,
289 sizeof(struct in6_addr))) 288 sizeof(struct in6_addr)))
290 ip_match = 1; 289 ip_match = 1;
291 290
@@ -1225,7 +1224,7 @@ static void iscsit_do_crypto_hash_buf(
1225 1224
1226 crypto_hash_init(hash); 1225 crypto_hash_init(hash);
1227 1226
1228 sg_init_one(&sg, (u8 *)buf, payload_length); 1227 sg_init_one(&sg, buf, payload_length);
1229 crypto_hash_update(hash, &sg, payload_length); 1228 crypto_hash_update(hash, &sg, payload_length);
1230 1229
1231 if (padding) { 1230 if (padding) {
@@ -1603,7 +1602,7 @@ static int iscsit_handle_nop_out(
1603 /* 1602 /*
1604 * Attach ping data to struct iscsi_cmd->buf_ptr. 1603 * Attach ping data to struct iscsi_cmd->buf_ptr.
1605 */ 1604 */
1606 cmd->buf_ptr = (void *)ping_data; 1605 cmd->buf_ptr = ping_data;
1607 cmd->buf_ptr_size = payload_length; 1606 cmd->buf_ptr_size = payload_length;
1608 1607
1609 pr_debug("Got %u bytes of NOPOUT ping" 1608 pr_debug("Got %u bytes of NOPOUT ping"
@@ -3197,7 +3196,7 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3197 end_of_buf = 1; 3196 end_of_buf = 1;
3198 goto eob; 3197 goto eob;
3199 } 3198 }
3200 memcpy((void *)payload + payload_len, buf, len); 3199 memcpy(payload + payload_len, buf, len);
3201 payload_len += len; 3200 payload_len += len;
3202 3201
3203 spin_lock(&tiqn->tiqn_tpg_lock); 3202 spin_lock(&tiqn->tiqn_tpg_lock);
@@ -3229,7 +3228,7 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3229 end_of_buf = 1; 3228 end_of_buf = 1;
3230 goto eob; 3229 goto eob;
3231 } 3230 }
3232 memcpy((void *)payload + payload_len, buf, len); 3231 memcpy(payload + payload_len, buf, len);
3233 payload_len += len; 3232 payload_len += len;
3234 } 3233 }
3235 spin_unlock(&tpg->tpg_np_lock); 3234 spin_unlock(&tpg->tpg_np_lock);
@@ -3486,7 +3485,7 @@ int iscsi_target_tx_thread(void *arg)
3486 struct iscsi_conn *conn; 3485 struct iscsi_conn *conn;
3487 struct iscsi_queue_req *qr = NULL; 3486 struct iscsi_queue_req *qr = NULL;
3488 struct se_cmd *se_cmd; 3487 struct se_cmd *se_cmd;
3489 struct iscsi_thread_set *ts = (struct iscsi_thread_set *)arg; 3488 struct iscsi_thread_set *ts = arg;
3490 /* 3489 /*
3491 * Allow ourselves to be interrupted by SIGINT so that a 3490 * Allow ourselves to be interrupted by SIGINT so that a
3492 * connection recovery / failure event can be triggered externally. 3491 * connection recovery / failure event can be triggered externally.
@@ -3775,7 +3774,7 @@ int iscsi_target_rx_thread(void *arg)
3775 u8 buffer[ISCSI_HDR_LEN], opcode; 3774 u8 buffer[ISCSI_HDR_LEN], opcode;
3776 u32 checksum = 0, digest = 0; 3775 u32 checksum = 0, digest = 0;
3777 struct iscsi_conn *conn = NULL; 3776 struct iscsi_conn *conn = NULL;
3778 struct iscsi_thread_set *ts = (struct iscsi_thread_set *)arg; 3777 struct iscsi_thread_set *ts = arg;
3779 struct kvec iov; 3778 struct kvec iov;
3780 /* 3779 /*
3781 * Allow ourselves to be interrupted by SIGINT so that a 3780 * Allow ourselves to be interrupted by SIGINT so that a
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index 1cd6ce373b83..db0cf7c8adde 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -82,7 +82,7 @@ static void chap_gen_challenge(
82 unsigned int *c_len) 82 unsigned int *c_len)
83{ 83{
84 unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1]; 84 unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1];
85 struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; 85 struct iscsi_chap *chap = conn->auth_protocol;
86 86
87 memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1); 87 memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1);
88 88
@@ -120,7 +120,7 @@ static struct iscsi_chap *chap_server_open(
120 if (!conn->auth_protocol) 120 if (!conn->auth_protocol)
121 return NULL; 121 return NULL;
122 122
123 chap = (struct iscsi_chap *) conn->auth_protocol; 123 chap = conn->auth_protocol;
124 /* 124 /*
125 * We only support MD5 MDA presently. 125 * We only support MD5 MDA presently.
126 */ 126 */
@@ -165,14 +165,15 @@ static int chap_server_compute_md5(
165 unsigned int *nr_out_len) 165 unsigned int *nr_out_len)
166{ 166{
167 char *endptr; 167 char *endptr;
168 unsigned char id, digest[MD5_SIGNATURE_SIZE]; 168 unsigned long id;
169 unsigned char digest[MD5_SIGNATURE_SIZE];
169 unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; 170 unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2];
170 unsigned char identifier[10], *challenge = NULL; 171 unsigned char identifier[10], *challenge = NULL;
171 unsigned char *challenge_binhex = NULL; 172 unsigned char *challenge_binhex = NULL;
172 unsigned char client_digest[MD5_SIGNATURE_SIZE]; 173 unsigned char client_digest[MD5_SIGNATURE_SIZE];
173 unsigned char server_digest[MD5_SIGNATURE_SIZE]; 174 unsigned char server_digest[MD5_SIGNATURE_SIZE];
174 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; 175 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH];
175 struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; 176 struct iscsi_chap *chap = conn->auth_protocol;
176 struct crypto_hash *tfm; 177 struct crypto_hash *tfm;
177 struct hash_desc desc; 178 struct hash_desc desc;
178 struct scatterlist sg; 179 struct scatterlist sg;
@@ -246,7 +247,7 @@ static int chap_server_compute_md5(
246 goto out; 247 goto out;
247 } 248 }
248 249
249 sg_init_one(&sg, (void *)&chap->id, 1); 250 sg_init_one(&sg, &chap->id, 1);
250 ret = crypto_hash_update(&desc, &sg, 1); 251 ret = crypto_hash_update(&desc, &sg, 1);
251 if (ret < 0) { 252 if (ret < 0) {
252 pr_err("crypto_hash_update() failed for id\n"); 253 pr_err("crypto_hash_update() failed for id\n");
@@ -254,7 +255,7 @@ static int chap_server_compute_md5(
254 goto out; 255 goto out;
255 } 256 }
256 257
257 sg_init_one(&sg, (void *)&auth->password, strlen(auth->password)); 258 sg_init_one(&sg, &auth->password, strlen(auth->password));
258 ret = crypto_hash_update(&desc, &sg, strlen(auth->password)); 259 ret = crypto_hash_update(&desc, &sg, strlen(auth->password));
259 if (ret < 0) { 260 if (ret < 0) {
260 pr_err("crypto_hash_update() failed for password\n"); 261 pr_err("crypto_hash_update() failed for password\n");
@@ -262,7 +263,7 @@ static int chap_server_compute_md5(
262 goto out; 263 goto out;
263 } 264 }
264 265
265 sg_init_one(&sg, (void *)chap->challenge, CHAP_CHALLENGE_LENGTH); 266 sg_init_one(&sg, chap->challenge, CHAP_CHALLENGE_LENGTH);
266 ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH); 267 ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH);
267 if (ret < 0) { 268 if (ret < 0) {
268 pr_err("crypto_hash_update() failed for challenge\n"); 269 pr_err("crypto_hash_update() failed for challenge\n");
@@ -305,14 +306,17 @@ static int chap_server_compute_md5(
305 } 306 }
306 307
307 if (type == HEX) 308 if (type == HEX)
308 id = (unsigned char)simple_strtoul((char *)&identifier[2], 309 id = simple_strtoul(&identifier[2], &endptr, 0);
309 &endptr, 0);
310 else 310 else
311 id = (unsigned char)simple_strtoul(identifier, &endptr, 0); 311 id = simple_strtoul(identifier, &endptr, 0);
312 if (id > 255) {
313 pr_err("chap identifier: %lu greater than 255\n", id);
314 goto out;
315 }
312 /* 316 /*
313 * RFC 1994 says Identifier is no more than octet (8 bits). 317 * RFC 1994 says Identifier is no more than octet (8 bits).
314 */ 318 */
315 pr_debug("[server] Got CHAP_I=%d\n", id); 319 pr_debug("[server] Got CHAP_I=%lu\n", id);
316 /* 320 /*
317 * Get CHAP_C. 321 * Get CHAP_C.
318 */ 322 */
@@ -351,7 +355,7 @@ static int chap_server_compute_md5(
351 goto out; 355 goto out;
352 } 356 }
353 357
354 sg_init_one(&sg, (void *)&id, 1); 358 sg_init_one(&sg, &id, 1);
355 ret = crypto_hash_update(&desc, &sg, 1); 359 ret = crypto_hash_update(&desc, &sg, 1);
356 if (ret < 0) { 360 if (ret < 0) {
357 pr_err("crypto_hash_update() failed for id\n"); 361 pr_err("crypto_hash_update() failed for id\n");
@@ -359,7 +363,7 @@ static int chap_server_compute_md5(
359 goto out; 363 goto out;
360 } 364 }
361 365
362 sg_init_one(&sg, (void *)auth->password_mutual, 366 sg_init_one(&sg, auth->password_mutual,
363 strlen(auth->password_mutual)); 367 strlen(auth->password_mutual));
364 ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual)); 368 ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual));
365 if (ret < 0) { 369 if (ret < 0) {
@@ -371,7 +375,7 @@ static int chap_server_compute_md5(
371 /* 375 /*
372 * Convert received challenge to binary hex. 376 * Convert received challenge to binary hex.
373 */ 377 */
374 sg_init_one(&sg, (void *)challenge_binhex, challenge_len); 378 sg_init_one(&sg, challenge_binhex, challenge_len);
375 ret = crypto_hash_update(&desc, &sg, challenge_len); 379 ret = crypto_hash_update(&desc, &sg, challenge_len);
376 if (ret < 0) { 380 if (ret < 0) {
377 pr_err("crypto_hash_update() failed for ma challenge\n"); 381 pr_err("crypto_hash_update() failed for ma challenge\n");
@@ -414,7 +418,7 @@ static int chap_got_response(
414 char *nr_out_ptr, 418 char *nr_out_ptr,
415 unsigned int *nr_out_len) 419 unsigned int *nr_out_len)
416{ 420{
417 struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; 421 struct iscsi_chap *chap = conn->auth_protocol;
418 422
419 switch (chap->digest_type) { 423 switch (chap->digest_type) {
420 case CHAP_DIGEST_MD5: 424 case CHAP_DIGEST_MD5:
@@ -437,7 +441,7 @@ u32 chap_main_loop(
437 int *in_len, 441 int *in_len,
438 int *out_len) 442 int *out_len)
439{ 443{
440 struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; 444 struct iscsi_chap *chap = conn->auth_protocol;
441 445
442 if (!chap) { 446 if (!chap) {
443 chap = chap_server_open(conn, auth, in_text, out_text, out_len); 447 chap = chap_server_open(conn, auth, in_text, out_text, out_len);
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index db327845e46b..3468caab47a2 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -22,12 +22,8 @@
22#include <linux/configfs.h> 22#include <linux/configfs.h>
23#include <linux/export.h> 23#include <linux/export.h>
24#include <target/target_core_base.h> 24#include <target/target_core_base.h>
25#include <target/target_core_transport.h> 25#include <target/target_core_fabric.h>
26#include <target/target_core_fabric_ops.h>
27#include <target/target_core_fabric_configfs.h> 26#include <target/target_core_fabric_configfs.h>
28#include <target/target_core_fabric_lib.h>
29#include <target/target_core_device.h>
30#include <target/target_core_tpg.h>
31#include <target/target_core_configfs.h> 27#include <target/target_core_configfs.h>
32#include <target/configfs_macros.h> 28#include <target/configfs_macros.h>
33 29
@@ -56,8 +52,7 @@ struct iscsi_portal_group *lio_get_tpg_from_tpg_item(
56{ 52{
57 struct se_portal_group *se_tpg = container_of(to_config_group(item), 53 struct se_portal_group *se_tpg = container_of(to_config_group(item),
58 struct se_portal_group, tpg_group); 54 struct se_portal_group, tpg_group);
59 struct iscsi_portal_group *tpg = 55 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
60 (struct iscsi_portal_group *)se_tpg->se_tpg_fabric_ptr;
61 int ret; 56 int ret;
62 57
63 if (!tpg) { 58 if (!tpg) {
@@ -1225,7 +1220,7 @@ struct se_portal_group *lio_target_tiqn_addtpg(
1225 1220
1226 ret = core_tpg_register( 1221 ret = core_tpg_register(
1227 &lio_target_fabric_configfs->tf_ops, 1222 &lio_target_fabric_configfs->tf_ops,
1228 wwn, &tpg->tpg_se_tpg, (void *)tpg, 1223 wwn, &tpg->tpg_se_tpg, tpg,
1229 TRANSPORT_TPG_TYPE_NORMAL); 1224 TRANSPORT_TPG_TYPE_NORMAL);
1230 if (ret < 0) 1225 if (ret < 0)
1231 return NULL; 1226 return NULL;
diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c
index a19fa5eea88e..f63ea35bc4ae 100644
--- a/drivers/target/iscsi/iscsi_target_device.c
+++ b/drivers/target/iscsi/iscsi_target_device.c
@@ -21,8 +21,7 @@
21 21
22#include <scsi/scsi_device.h> 22#include <scsi/scsi_device.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_device.h> 24#include <target/target_core_fabric.h>
25#include <target/target_core_transport.h>
26 25
27#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
28#include "iscsi_target_device.h" 27#include "iscsi_target_device.h"
diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
index b7ffc3cd40cc..478451167b62 100644
--- a/drivers/target/iscsi/iscsi_target_erl0.c
+++ b/drivers/target/iscsi/iscsi_target_erl0.c
@@ -21,7 +21,7 @@
21 21
22#include <scsi/iscsi_proto.h> 22#include <scsi/iscsi_proto.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_transport.h> 24#include <target/target_core_fabric.h>
25 25
26#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
27#include "iscsi_target_seq_pdu_list.h" 27#include "iscsi_target_seq_pdu_list.h"
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
index 101b1beb3bca..255c0d67e898 100644
--- a/drivers/target/iscsi/iscsi_target_erl1.c
+++ b/drivers/target/iscsi/iscsi_target_erl1.c
@@ -21,7 +21,7 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <scsi/iscsi_proto.h> 22#include <scsi/iscsi_proto.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_transport.h> 24#include <target/target_core_fabric.h>
25 25
26#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
27#include "iscsi_target_seq_pdu_list.h" 27#include "iscsi_target_seq_pdu_list.h"
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c
index 0b8404c30125..1af1f21af21f 100644
--- a/drivers/target/iscsi/iscsi_target_erl2.c
+++ b/drivers/target/iscsi/iscsi_target_erl2.c
@@ -21,7 +21,7 @@
21 21
22#include <scsi/iscsi_proto.h> 22#include <scsi/iscsi_proto.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_transport.h> 24#include <target/target_core_fabric.h>
25 25
26#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
27#include "iscsi_target_datain_values.h" 27#include "iscsi_target_datain_values.h"
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index d734bdec24f9..373b0cc6abd8 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -23,7 +23,7 @@
23#include <linux/crypto.h> 23#include <linux/crypto.h>
24#include <scsi/iscsi_proto.h> 24#include <scsi/iscsi_proto.h>
25#include <target/target_core_base.h> 25#include <target/target_core_base.h>
26#include <target/target_core_transport.h> 26#include <target/target_core_fabric.h>
27 27
28#include "iscsi_target_core.h" 28#include "iscsi_target_core.h"
29#include "iscsi_target_tq.h" 29#include "iscsi_target_tq.h"
@@ -143,7 +143,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
143 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list, 143 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
144 sess_list) { 144 sess_list) {
145 145
146 sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr; 146 sess_p = se_sess->fabric_sess_ptr;
147 spin_lock(&sess_p->conn_lock); 147 spin_lock(&sess_p->conn_lock);
148 if (atomic_read(&sess_p->session_fall_back_to_erl0) || 148 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
149 atomic_read(&sess_p->session_logout) || 149 atomic_read(&sess_p->session_logout) ||
@@ -151,9 +151,9 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
151 spin_unlock(&sess_p->conn_lock); 151 spin_unlock(&sess_p->conn_lock);
152 continue; 152 continue;
153 } 153 }
154 if (!memcmp((void *)sess_p->isid, (void *)conn->sess->isid, 6) && 154 if (!memcmp(sess_p->isid, conn->sess->isid, 6) &&
155 (!strcmp((void *)sess_p->sess_ops->InitiatorName, 155 (!strcmp(sess_p->sess_ops->InitiatorName,
156 (void *)initiatorname_param->value) && 156 initiatorname_param->value) &&
157 (sess_p->sess_ops->SessionType == sessiontype))) { 157 (sess_p->sess_ops->SessionType == sessiontype))) {
158 atomic_set(&sess_p->session_reinstatement, 1); 158 atomic_set(&sess_p->session_reinstatement, 1);
159 spin_unlock(&sess_p->conn_lock); 159 spin_unlock(&sess_p->conn_lock);
@@ -229,7 +229,7 @@ static int iscsi_login_zero_tsih_s1(
229 229
230 iscsi_login_set_conn_values(sess, conn, pdu->cid); 230 iscsi_login_set_conn_values(sess, conn, pdu->cid);
231 sess->init_task_tag = pdu->itt; 231 sess->init_task_tag = pdu->itt;
232 memcpy((void *)&sess->isid, (void *)pdu->isid, 6); 232 memcpy(&sess->isid, pdu->isid, 6);
233 sess->exp_cmd_sn = pdu->cmdsn; 233 sess->exp_cmd_sn = pdu->cmdsn;
234 INIT_LIST_HEAD(&sess->sess_conn_list); 234 INIT_LIST_HEAD(&sess->sess_conn_list);
235 INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list); 235 INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list);
@@ -440,8 +440,7 @@ static int iscsi_login_non_zero_tsih_s2(
440 atomic_read(&sess_p->session_logout) || 440 atomic_read(&sess_p->session_logout) ||
441 (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) 441 (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED))
442 continue; 442 continue;
443 if (!memcmp((const void *)sess_p->isid, 443 if (!memcmp(sess_p->isid, pdu->isid, 6) &&
444 (const void *)pdu->isid, 6) &&
445 (sess_p->tsih == pdu->tsih)) { 444 (sess_p->tsih == pdu->tsih)) {
446 iscsit_inc_session_usage_count(sess_p); 445 iscsit_inc_session_usage_count(sess_p);
447 iscsit_stop_time2retain_timer(sess_p); 446 iscsit_stop_time2retain_timer(sess_p);
@@ -654,7 +653,7 @@ static int iscsi_post_login_handler(
654 653
655 spin_lock_bh(&se_tpg->session_lock); 654 spin_lock_bh(&se_tpg->session_lock);
656 __transport_register_session(&sess->tpg->tpg_se_tpg, 655 __transport_register_session(&sess->tpg->tpg_se_tpg,
657 se_sess->se_node_acl, se_sess, (void *)sess); 656 se_sess->se_node_acl, se_sess, sess);
658 pr_debug("Moving to TARG_SESS_STATE_LOGGED_IN.\n"); 657 pr_debug("Moving to TARG_SESS_STATE_LOGGED_IN.\n");
659 sess->session_state = TARG_SESS_STATE_LOGGED_IN; 658 sess->session_state = TARG_SESS_STATE_LOGGED_IN;
660 659
@@ -811,7 +810,7 @@ int iscsi_target_setup_login_socket(
811 * Setup the np->np_sockaddr from the passed sockaddr setup 810 * Setup the np->np_sockaddr from the passed sockaddr setup
812 * in iscsi_target_configfs.c code.. 811 * in iscsi_target_configfs.c code..
813 */ 812 */
814 memcpy((void *)&np->np_sockaddr, (void *)sockaddr, 813 memcpy(&np->np_sockaddr, sockaddr,
815 sizeof(struct __kernel_sockaddr_storage)); 814 sizeof(struct __kernel_sockaddr_storage));
816 815
817 if (sockaddr->ss_family == AF_INET6) 816 if (sockaddr->ss_family == AF_INET6)
@@ -821,6 +820,7 @@ int iscsi_target_setup_login_socket(
821 /* 820 /*
822 * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY. 821 * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY.
823 */ 822 */
823 /* FIXME: Someone please explain why this is endian-safe */
824 opt = 1; 824 opt = 1;
825 if (np->np_network_transport == ISCSI_TCP) { 825 if (np->np_network_transport == ISCSI_TCP) {
826 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, 826 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
@@ -832,6 +832,7 @@ int iscsi_target_setup_login_socket(
832 } 832 }
833 } 833 }
834 834
835 /* FIXME: Someone please explain why this is endian-safe */
835 ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 836 ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
836 (char *)&opt, sizeof(opt)); 837 (char *)&opt, sizeof(opt));
837 if (ret < 0) { 838 if (ret < 0) {
@@ -1206,7 +1207,7 @@ out:
1206 1207
1207int iscsi_target_login_thread(void *arg) 1208int iscsi_target_login_thread(void *arg)
1208{ 1209{
1209 struct iscsi_np *np = (struct iscsi_np *)arg; 1210 struct iscsi_np *np = arg;
1210 int ret; 1211 int ret;
1211 1212
1212 allow_signal(SIGINT); 1213 allow_signal(SIGINT);
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
index 98936cb7c294..e89fa7457254 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -21,7 +21,7 @@
21#include <linux/ctype.h> 21#include <linux/ctype.h>
22#include <scsi/iscsi_proto.h> 22#include <scsi/iscsi_proto.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_tpg.h> 24#include <target/target_core_fabric.h>
25 25
26#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
27#include "iscsi_target_parameters.h" 27#include "iscsi_target_parameters.h"
@@ -732,7 +732,7 @@ static void iscsi_initiatorname_tolower(
732 u32 iqn_size = strlen(param_buf), i; 732 u32 iqn_size = strlen(param_buf), i;
733 733
734 for (i = 0; i < iqn_size; i++) { 734 for (i = 0; i < iqn_size; i++) {
735 c = (char *)&param_buf[i]; 735 c = &param_buf[i];
736 if (!isupper(*c)) 736 if (!isupper(*c))
737 continue; 737 continue;
738 738
diff --git a/drivers/target/iscsi/iscsi_target_nodeattrib.c b/drivers/target/iscsi/iscsi_target_nodeattrib.c
index aeafbe0cd7d1..b3c699c4fe8c 100644
--- a/drivers/target/iscsi/iscsi_target_nodeattrib.c
+++ b/drivers/target/iscsi/iscsi_target_nodeattrib.c
@@ -19,7 +19,6 @@
19 ******************************************************************************/ 19 ******************************************************************************/
20 20
21#include <target/target_core_base.h> 21#include <target/target_core_base.h>
22#include <target/target_core_transport.h>
23 22
24#include "iscsi_target_core.h" 23#include "iscsi_target_core.h"
25#include "iscsi_target_device.h" 24#include "iscsi_target_device.h"
@@ -135,7 +134,7 @@ extern int iscsit_na_nopin_timeout(
135 spin_lock_bh(&se_nacl->nacl_sess_lock); 134 spin_lock_bh(&se_nacl->nacl_sess_lock);
136 se_sess = se_nacl->nacl_sess; 135 se_sess = se_nacl->nacl_sess;
137 if (se_sess) { 136 if (se_sess) {
138 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 137 sess = se_sess->fabric_sess_ptr;
139 138
140 spin_lock(&sess->conn_lock); 139 spin_lock(&sess->conn_lock);
141 list_for_each_entry(conn, &sess->sess_conn_list, 140 list_for_each_entry(conn, &sess->sess_conn_list,
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
index f1db83077e0a..421d6947dc64 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -23,7 +23,6 @@
23#include <linux/export.h> 23#include <linux/export.h>
24#include <scsi/iscsi_proto.h> 24#include <scsi/iscsi_proto.h>
25#include <target/target_core_base.h> 25#include <target/target_core_base.h>
26#include <target/target_core_transport.h>
27#include <target/configfs_macros.h> 26#include <target/configfs_macros.h>
28 27
29#include "iscsi_target_core.h" 28#include "iscsi_target_core.h"
@@ -746,7 +745,7 @@ static ssize_t iscsi_stat_sess_show_attr_node(
746 spin_lock_bh(&se_nacl->nacl_sess_lock); 745 spin_lock_bh(&se_nacl->nacl_sess_lock);
747 se_sess = se_nacl->nacl_sess; 746 se_sess = se_nacl->nacl_sess;
748 if (se_sess) { 747 if (se_sess) {
749 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 748 sess = se_sess->fabric_sess_ptr;
750 if (sess) 749 if (sess)
751 ret = snprintf(page, PAGE_SIZE, "%u\n", 750 ret = snprintf(page, PAGE_SIZE, "%u\n",
752 sess->sess_ops->SessionType ? 0 : ISCSI_NODE_INDEX); 751 sess->sess_ops->SessionType ? 0 : ISCSI_NODE_INDEX);
@@ -770,7 +769,7 @@ static ssize_t iscsi_stat_sess_show_attr_indx(
770 spin_lock_bh(&se_nacl->nacl_sess_lock); 769 spin_lock_bh(&se_nacl->nacl_sess_lock);
771 se_sess = se_nacl->nacl_sess; 770 se_sess = se_nacl->nacl_sess;
772 if (se_sess) { 771 if (se_sess) {
773 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 772 sess = se_sess->fabric_sess_ptr;
774 if (sess) 773 if (sess)
775 ret = snprintf(page, PAGE_SIZE, "%u\n", 774 ret = snprintf(page, PAGE_SIZE, "%u\n",
776 sess->session_index); 775 sess->session_index);
@@ -794,7 +793,7 @@ static ssize_t iscsi_stat_sess_show_attr_cmd_pdus(
794 spin_lock_bh(&se_nacl->nacl_sess_lock); 793 spin_lock_bh(&se_nacl->nacl_sess_lock);
795 se_sess = se_nacl->nacl_sess; 794 se_sess = se_nacl->nacl_sess;
796 if (se_sess) { 795 if (se_sess) {
797 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 796 sess = se_sess->fabric_sess_ptr;
798 if (sess) 797 if (sess)
799 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus); 798 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus);
800 } 799 }
@@ -817,7 +816,7 @@ static ssize_t iscsi_stat_sess_show_attr_rsp_pdus(
817 spin_lock_bh(&se_nacl->nacl_sess_lock); 816 spin_lock_bh(&se_nacl->nacl_sess_lock);
818 se_sess = se_nacl->nacl_sess; 817 se_sess = se_nacl->nacl_sess;
819 if (se_sess) { 818 if (se_sess) {
820 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 819 sess = se_sess->fabric_sess_ptr;
821 if (sess) 820 if (sess)
822 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus); 821 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus);
823 } 822 }
@@ -840,7 +839,7 @@ static ssize_t iscsi_stat_sess_show_attr_txdata_octs(
840 spin_lock_bh(&se_nacl->nacl_sess_lock); 839 spin_lock_bh(&se_nacl->nacl_sess_lock);
841 se_sess = se_nacl->nacl_sess; 840 se_sess = se_nacl->nacl_sess;
842 if (se_sess) { 841 if (se_sess) {
843 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 842 sess = se_sess->fabric_sess_ptr;
844 if (sess) 843 if (sess)
845 ret = snprintf(page, PAGE_SIZE, "%llu\n", 844 ret = snprintf(page, PAGE_SIZE, "%llu\n",
846 (unsigned long long)sess->tx_data_octets); 845 (unsigned long long)sess->tx_data_octets);
@@ -864,7 +863,7 @@ static ssize_t iscsi_stat_sess_show_attr_rxdata_octs(
864 spin_lock_bh(&se_nacl->nacl_sess_lock); 863 spin_lock_bh(&se_nacl->nacl_sess_lock);
865 se_sess = se_nacl->nacl_sess; 864 se_sess = se_nacl->nacl_sess;
866 if (se_sess) { 865 if (se_sess) {
867 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 866 sess = se_sess->fabric_sess_ptr;
868 if (sess) 867 if (sess)
869 ret = snprintf(page, PAGE_SIZE, "%llu\n", 868 ret = snprintf(page, PAGE_SIZE, "%llu\n",
870 (unsigned long long)sess->rx_data_octets); 869 (unsigned long long)sess->rx_data_octets);
@@ -888,7 +887,7 @@ static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors(
888 spin_lock_bh(&se_nacl->nacl_sess_lock); 887 spin_lock_bh(&se_nacl->nacl_sess_lock);
889 se_sess = se_nacl->nacl_sess; 888 se_sess = se_nacl->nacl_sess;
890 if (se_sess) { 889 if (se_sess) {
891 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 890 sess = se_sess->fabric_sess_ptr;
892 if (sess) 891 if (sess)
893 ret = snprintf(page, PAGE_SIZE, "%u\n", 892 ret = snprintf(page, PAGE_SIZE, "%u\n",
894 sess->conn_digest_errors); 893 sess->conn_digest_errors);
@@ -912,7 +911,7 @@ static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors(
912 spin_lock_bh(&se_nacl->nacl_sess_lock); 911 spin_lock_bh(&se_nacl->nacl_sess_lock);
913 se_sess = se_nacl->nacl_sess; 912 se_sess = se_nacl->nacl_sess;
914 if (se_sess) { 913 if (se_sess) {
915 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; 914 sess = se_sess->fabric_sess_ptr;
916 if (sess) 915 if (sess)
917 ret = snprintf(page, PAGE_SIZE, "%u\n", 916 ret = snprintf(page, PAGE_SIZE, "%u\n",
918 sess->conn_timeout_errors); 917 sess->conn_timeout_errors);
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c
index 490207eacde9..255ed35da815 100644
--- a/drivers/target/iscsi/iscsi_target_tmr.c
+++ b/drivers/target/iscsi/iscsi_target_tmr.c
@@ -21,7 +21,7 @@
21#include <asm/unaligned.h> 21#include <asm/unaligned.h>
22#include <scsi/iscsi_proto.h> 22#include <scsi/iscsi_proto.h>
23#include <target/target_core_base.h> 23#include <target/target_core_base.h>
24#include <target/target_core_transport.h> 24#include <target/target_core_fabric.h>
25 25
26#include "iscsi_target_core.h" 26#include "iscsi_target_core.h"
27#include "iscsi_target_seq_pdu_list.h" 27#include "iscsi_target_seq_pdu_list.h"
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index d4cf2cd25c44..879d8d0fa3fe 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -19,10 +19,8 @@
19 ******************************************************************************/ 19 ******************************************************************************/
20 20
21#include <target/target_core_base.h> 21#include <target/target_core_base.h>
22#include <target/target_core_transport.h> 22#include <target/target_core_fabric.h>
23#include <target/target_core_fabric_ops.h>
24#include <target/target_core_configfs.h> 23#include <target/target_core_configfs.h>
25#include <target/target_core_tpg.h>
26 24
27#include "iscsi_target_core.h" 25#include "iscsi_target_core.h"
28#include "iscsi_target_erl0.h" 26#include "iscsi_target_erl0.h"
@@ -72,7 +70,7 @@ int iscsit_load_discovery_tpg(void)
72 70
73 ret = core_tpg_register( 71 ret = core_tpg_register(
74 &lio_target_fabric_configfs->tf_ops, 72 &lio_target_fabric_configfs->tf_ops,
75 NULL, &tpg->tpg_se_tpg, (void *)tpg, 73 NULL, &tpg->tpg_se_tpg, tpg,
76 TRANSPORT_TPG_TYPE_DISCOVERY); 74 TRANSPORT_TPG_TYPE_DISCOVERY);
77 if (ret < 0) { 75 if (ret < 0) {
78 kfree(tpg); 76 kfree(tpg);
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 02348f727bd4..a05ca1c4f01c 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -22,9 +22,7 @@
22#include <scsi/scsi_tcq.h> 22#include <scsi/scsi_tcq.h>
23#include <scsi/iscsi_proto.h> 23#include <scsi/iscsi_proto.h>
24#include <target/target_core_base.h> 24#include <target/target_core_base.h>
25#include <target/target_core_transport.h> 25#include <target/target_core_fabric.h>
26#include <target/target_core_tmr.h>
27#include <target/target_core_fabric_ops.h>
28#include <target/target_core_configfs.h> 26#include <target/target_core_configfs.h>
29 27
30#include "iscsi_target_core.h" 28#include "iscsi_target_core.h"
@@ -289,7 +287,7 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
289 } 287 }
290 288
291 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, 289 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd,
292 (void *)cmd->tmr_req, tcm_function, 290 cmd->tmr_req, tcm_function,
293 GFP_KERNEL); 291 GFP_KERNEL);
294 if (!se_cmd->se_tmr_req) 292 if (!se_cmd->se_tmr_req)
295 goto out; 293 goto out;
@@ -1066,7 +1064,7 @@ static void iscsit_handle_nopin_response_timeout(unsigned long data)
1066 if (tiqn) { 1064 if (tiqn) {
1067 spin_lock_bh(&tiqn->sess_err_stats.lock); 1065 spin_lock_bh(&tiqn->sess_err_stats.lock);
1068 strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name, 1066 strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name,
1069 (void *)conn->sess->sess_ops->InitiatorName); 1067 conn->sess->sess_ops->InitiatorName);
1070 tiqn->sess_err_stats.last_sess_failure_type = 1068 tiqn->sess_err_stats.last_sess_failure_type =
1071 ISCSI_SESS_ERR_CXN_TIMEOUT; 1069 ISCSI_SESS_ERR_CXN_TIMEOUT;
1072 tiqn->sess_err_stats.cxn_timeout_errors++; 1070 tiqn->sess_err_stats.cxn_timeout_errors++;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 81d5832fbbd5..c47ff7f59e57 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -33,14 +33,9 @@
33#include <scsi/scsi_cmnd.h> 33#include <scsi/scsi_cmnd.h>
34 34
35#include <target/target_core_base.h> 35#include <target/target_core_base.h>
36#include <target/target_core_transport.h> 36#include <target/target_core_fabric.h>
37#include <target/target_core_fabric_ops.h>
38#include <target/target_core_fabric_configfs.h> 37#include <target/target_core_fabric_configfs.h>
39#include <target/target_core_fabric_lib.h>
40#include <target/target_core_configfs.h> 38#include <target/target_core_configfs.h>
41#include <target/target_core_device.h>
42#include <target/target_core_tpg.h>
43#include <target/target_core_tmr.h>
44 39
45#include "tcm_loop.h" 40#include "tcm_loop.h"
46 41
@@ -421,11 +416,11 @@ static struct scsi_host_template tcm_loop_driver_template = {
421 .queuecommand = tcm_loop_queuecommand, 416 .queuecommand = tcm_loop_queuecommand,
422 .change_queue_depth = tcm_loop_change_queue_depth, 417 .change_queue_depth = tcm_loop_change_queue_depth,
423 .eh_device_reset_handler = tcm_loop_device_reset, 418 .eh_device_reset_handler = tcm_loop_device_reset,
424 .can_queue = TL_SCSI_CAN_QUEUE, 419 .can_queue = 1024,
425 .this_id = -1, 420 .this_id = -1,
426 .sg_tablesize = TL_SCSI_SG_TABLESIZE, 421 .sg_tablesize = 256,
427 .cmd_per_lun = TL_SCSI_CMD_PER_LUN, 422 .cmd_per_lun = 1024,
428 .max_sectors = TL_SCSI_MAX_SECTORS, 423 .max_sectors = 0xFFFF,
429 .use_clustering = DISABLE_CLUSTERING, 424 .use_clustering = DISABLE_CLUSTERING,
430 .slave_alloc = tcm_loop_slave_alloc, 425 .slave_alloc = tcm_loop_slave_alloc,
431 .slave_configure = tcm_loop_slave_configure, 426 .slave_configure = tcm_loop_slave_configure,
@@ -564,8 +559,7 @@ static char *tcm_loop_get_fabric_name(void)
564 559
565static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg) 560static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg)
566{ 561{
567 struct tcm_loop_tpg *tl_tpg = 562 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
568 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
569 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; 563 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
570 /* 564 /*
571 * tl_proto_id is set at tcm_loop_configfs.c:tcm_loop_make_scsi_hba() 565 * tl_proto_id is set at tcm_loop_configfs.c:tcm_loop_make_scsi_hba()
@@ -592,8 +586,7 @@ static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg)
592 586
593static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg) 587static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg)
594{ 588{
595 struct tcm_loop_tpg *tl_tpg = 589 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
596 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
597 /* 590 /*
598 * Return the passed NAA identifier for the SAS Target Port 591 * Return the passed NAA identifier for the SAS Target Port
599 */ 592 */
@@ -602,8 +595,7 @@ static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg)
602 595
603static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg) 596static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg)
604{ 597{
605 struct tcm_loop_tpg *tl_tpg = 598 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
606 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
607 /* 599 /*
608 * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83 600 * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83
609 * to represent the SCSI Target Port. 601 * to represent the SCSI Target Port.
@@ -623,8 +615,7 @@ static u32 tcm_loop_get_pr_transport_id(
623 int *format_code, 615 int *format_code,
624 unsigned char *buf) 616 unsigned char *buf)
625{ 617{
626 struct tcm_loop_tpg *tl_tpg = 618 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
627 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
628 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; 619 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
629 620
630 switch (tl_hba->tl_proto_id) { 621 switch (tl_hba->tl_proto_id) {
@@ -653,8 +644,7 @@ static u32 tcm_loop_get_pr_transport_id_len(
653 struct t10_pr_registration *pr_reg, 644 struct t10_pr_registration *pr_reg,
654 int *format_code) 645 int *format_code)
655{ 646{
656 struct tcm_loop_tpg *tl_tpg = 647 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
657 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
658 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; 648 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
659 649
660 switch (tl_hba->tl_proto_id) { 650 switch (tl_hba->tl_proto_id) {
@@ -687,8 +677,7 @@ static char *tcm_loop_parse_pr_out_transport_id(
687 u32 *out_tid_len, 677 u32 *out_tid_len,
688 char **port_nexus_ptr) 678 char **port_nexus_ptr)
689{ 679{
690 struct tcm_loop_tpg *tl_tpg = 680 struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr;
691 (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
692 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; 681 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
693 682
694 switch (tl_hba->tl_proto_id) { 683 switch (tl_hba->tl_proto_id) {
diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h
index 6b76c7a22bb0..15a036441471 100644
--- a/drivers/target/loopback/tcm_loop.h
+++ b/drivers/target/loopback/tcm_loop.h
@@ -1,16 +1,7 @@
1#define TCM_LOOP_VERSION "v2.1-rc1" 1#define TCM_LOOP_VERSION "v2.1-rc1"
2#define TL_WWN_ADDR_LEN 256 2#define TL_WWN_ADDR_LEN 256
3#define TL_TPGS_PER_HBA 32 3#define TL_TPGS_PER_HBA 32
4/* 4
5 * Defaults for struct scsi_host_template tcm_loop_driver_template
6 *
7 * We use large can_queue and cmd_per_lun here and let TCM enforce
8 * the underlying se_device_t->queue_depth.
9 */
10#define TL_SCSI_CAN_QUEUE 1024
11#define TL_SCSI_CMD_PER_LUN 1024
12#define TL_SCSI_MAX_SECTORS 1024
13#define TL_SCSI_SG_TABLESIZE 256
14/* 5/*
15 * Used in tcm_loop_driver_probe() for struct Scsi_Host->max_cmd_len 6 * Used in tcm_loop_driver_probe() for struct Scsi_Host->max_cmd_len
16 */ 7 */
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 1dcbef499d6a..1b1edd14f4bf 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -32,13 +32,12 @@
32#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
33 33
34#include <target/target_core_base.h> 34#include <target/target_core_base.h>
35#include <target/target_core_device.h> 35#include <target/target_core_backend.h>
36#include <target/target_core_transport.h> 36#include <target/target_core_fabric.h>
37#include <target/target_core_fabric_ops.h>
38#include <target/target_core_configfs.h> 37#include <target/target_core_configfs.h>
39 38
39#include "target_core_internal.h"
40#include "target_core_alua.h" 40#include "target_core_alua.h"
41#include "target_core_hba.h"
42#include "target_core_ua.h" 41#include "target_core_ua.h"
43 42
44static int core_alua_check_transition(int state, int *primary); 43static int core_alua_check_transition(int state, int *primary);
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 831468b3163d..2f2235edefff 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -29,10 +29,11 @@
29#include <scsi/scsi.h> 29#include <scsi/scsi.h>
30 30
31#include <target/target_core_base.h> 31#include <target/target_core_base.h>
32#include <target/target_core_transport.h> 32#include <target/target_core_backend.h>
33#include <target/target_core_fabric_ops.h> 33#include <target/target_core_fabric.h>
34
35#include "target_core_internal.h"
34#include "target_core_ua.h" 36#include "target_core_ua.h"
35#include "target_core_cdb.h"
36 37
37static void 38static void
38target_fill_alua_data(struct se_port *port, unsigned char *buf) 39target_fill_alua_data(struct se_port *port, unsigned char *buf)
@@ -94,6 +95,18 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
94 buf[2] = dev->transport->get_device_rev(dev); 95 buf[2] = dev->transport->get_device_rev(dev);
95 96
96 /* 97 /*
98 * NORMACA and HISUP = 0, RESPONSE DATA FORMAT = 2
99 *
100 * SPC4 says:
101 * A RESPONSE DATA FORMAT field set to 2h indicates that the
102 * standard INQUIRY data is in the format defined in this
103 * standard. Response data format values less than 2h are
104 * obsolete. Response data format values greater than 2h are
105 * reserved.
106 */
107 buf[3] = 2;
108
109 /*
97 * Enable SCCS and TPGS fields for Emulated ALUA 110 * Enable SCCS and TPGS fields for Emulated ALUA
98 */ 111 */
99 if (dev->se_sub_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) 112 if (dev->se_sub_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED)
@@ -115,11 +128,9 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
115 goto out; 128 goto out;
116 } 129 }
117 130
118 snprintf((unsigned char *)&buf[8], 8, "LIO-ORG"); 131 snprintf(&buf[8], 8, "LIO-ORG");
119 snprintf((unsigned char *)&buf[16], 16, "%s", 132 snprintf(&buf[16], 16, "%s", dev->se_sub_dev->t10_wwn.model);
120 &dev->se_sub_dev->t10_wwn.model[0]); 133 snprintf(&buf[32], 4, "%s", dev->se_sub_dev->t10_wwn.revision);
121 snprintf((unsigned char *)&buf[32], 4, "%s",
122 &dev->se_sub_dev->t10_wwn.revision[0]);
123 buf[4] = 31; /* Set additional length to 31 */ 134 buf[4] = 31; /* Set additional length to 31 */
124 135
125out: 136out:
@@ -138,8 +149,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
138 SDF_EMULATED_VPD_UNIT_SERIAL) { 149 SDF_EMULATED_VPD_UNIT_SERIAL) {
139 u32 unit_serial_len; 150 u32 unit_serial_len;
140 151
141 unit_serial_len = 152 unit_serial_len = strlen(dev->se_sub_dev->t10_wwn.unit_serial);
142 strlen(&dev->se_sub_dev->t10_wwn.unit_serial[0]);
143 unit_serial_len++; /* For NULL Terminator */ 153 unit_serial_len++; /* For NULL Terminator */
144 154
145 if (((len + 4) + unit_serial_len) > cmd->data_length) { 155 if (((len + 4) + unit_serial_len) > cmd->data_length) {
@@ -148,8 +158,8 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
148 buf[3] = (len & 0xff); 158 buf[3] = (len & 0xff);
149 return 0; 159 return 0;
150 } 160 }
151 len += sprintf((unsigned char *)&buf[4], "%s", 161 len += sprintf(&buf[4], "%s",
152 &dev->se_sub_dev->t10_wwn.unit_serial[0]); 162 dev->se_sub_dev->t10_wwn.unit_serial);
153 len++; /* Extra Byte for NULL Terminator */ 163 len++; /* Extra Byte for NULL Terminator */
154 buf[3] = len; 164 buf[3] = len;
155 } 165 }
@@ -279,14 +289,13 @@ check_t10_vend_desc:
279 len += (prod_len + unit_serial_len); 289 len += (prod_len + unit_serial_len);
280 goto check_port; 290 goto check_port;
281 } 291 }
282 id_len += sprintf((unsigned char *)&buf[off+12], 292 id_len += sprintf(&buf[off+12], "%s:%s", prod,
283 "%s:%s", prod,
284 &dev->se_sub_dev->t10_wwn.unit_serial[0]); 293 &dev->se_sub_dev->t10_wwn.unit_serial[0]);
285 } 294 }
286 buf[off] = 0x2; /* ASCII */ 295 buf[off] = 0x2; /* ASCII */
287 buf[off+1] = 0x1; /* T10 Vendor ID */ 296 buf[off+1] = 0x1; /* T10 Vendor ID */
288 buf[off+2] = 0x0; 297 buf[off+2] = 0x0;
289 memcpy((unsigned char *)&buf[off+4], "LIO-ORG", 8); 298 memcpy(&buf[off+4], "LIO-ORG", 8);
290 /* Extra Byte for NULL Terminator */ 299 /* Extra Byte for NULL Terminator */
291 id_len++; 300 id_len++;
292 /* Identifier Length */ 301 /* Identifier Length */
diff --git a/drivers/target/target_core_cdb.h b/drivers/target/target_core_cdb.h
deleted file mode 100644
index ad6b1e393001..000000000000
--- a/drivers/target/target_core_cdb.h
+++ /dev/null
@@ -1,14 +0,0 @@
1#ifndef TARGET_CORE_CDB_H
2#define TARGET_CORE_CDB_H
3
4int target_emulate_inquiry(struct se_task *task);
5int target_emulate_readcapacity(struct se_task *task);
6int target_emulate_readcapacity_16(struct se_task *task);
7int target_emulate_modesense(struct se_task *task);
8int target_emulate_request_sense(struct se_task *task);
9int target_emulate_unmap(struct se_task *task);
10int target_emulate_write_same(struct se_task *task);
11int target_emulate_synchronize_cache(struct se_task *task);
12int target_emulate_noop(struct se_task *task);
13
14#endif /* TARGET_CORE_CDB_H */
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 93d4f6a1b798..0955bb8979fb 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -39,18 +39,16 @@
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40 40
41#include <target/target_core_base.h> 41#include <target/target_core_base.h>
42#include <target/target_core_device.h> 42#include <target/target_core_backend.h>
43#include <target/target_core_transport.h> 43#include <target/target_core_fabric.h>
44#include <target/target_core_fabric_ops.h>
45#include <target/target_core_fabric_configfs.h> 44#include <target/target_core_fabric_configfs.h>
46#include <target/target_core_configfs.h> 45#include <target/target_core_configfs.h>
47#include <target/configfs_macros.h> 46#include <target/configfs_macros.h>
48 47
48#include "target_core_internal.h"
49#include "target_core_alua.h" 49#include "target_core_alua.h"
50#include "target_core_hba.h"
51#include "target_core_pr.h" 50#include "target_core_pr.h"
52#include "target_core_rd.h" 51#include "target_core_rd.h"
53#include "target_core_stat.h"
54 52
55extern struct t10_alua_lu_gp *default_lu_gp; 53extern struct t10_alua_lu_gp *default_lu_gp;
56 54
@@ -1452,7 +1450,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
1452 return -ENOMEM; 1450 return -ENOMEM;
1453 1451
1454 orig = opts; 1452 orig = opts;
1455 while ((ptr = strsep(&opts, ",")) != NULL) { 1453 while ((ptr = strsep(&opts, ",\n")) != NULL) {
1456 if (!*ptr) 1454 if (!*ptr)
1457 continue; 1455 continue;
1458 1456
@@ -1631,7 +1629,7 @@ static struct config_item_type target_core_dev_pr_cit = {
1631 1629
1632static ssize_t target_core_show_dev_info(void *p, char *page) 1630static ssize_t target_core_show_dev_info(void *p, char *page)
1633{ 1631{
1634 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1632 struct se_subsystem_dev *se_dev = p;
1635 struct se_hba *hba = se_dev->se_dev_hba; 1633 struct se_hba *hba = se_dev->se_dev_hba;
1636 struct se_subsystem_api *t = hba->transport; 1634 struct se_subsystem_api *t = hba->transport;
1637 int bl = 0; 1635 int bl = 0;
@@ -1659,7 +1657,7 @@ static ssize_t target_core_store_dev_control(
1659 const char *page, 1657 const char *page,
1660 size_t count) 1658 size_t count)
1661{ 1659{
1662 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1660 struct se_subsystem_dev *se_dev = p;
1663 struct se_hba *hba = se_dev->se_dev_hba; 1661 struct se_hba *hba = se_dev->se_dev_hba;
1664 struct se_subsystem_api *t = hba->transport; 1662 struct se_subsystem_api *t = hba->transport;
1665 1663
@@ -1682,7 +1680,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_control = {
1682 1680
1683static ssize_t target_core_show_dev_alias(void *p, char *page) 1681static ssize_t target_core_show_dev_alias(void *p, char *page)
1684{ 1682{
1685 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1683 struct se_subsystem_dev *se_dev = p;
1686 1684
1687 if (!(se_dev->su_dev_flags & SDF_USING_ALIAS)) 1685 if (!(se_dev->su_dev_flags & SDF_USING_ALIAS))
1688 return 0; 1686 return 0;
@@ -1695,7 +1693,7 @@ static ssize_t target_core_store_dev_alias(
1695 const char *page, 1693 const char *page,
1696 size_t count) 1694 size_t count)
1697{ 1695{
1698 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1696 struct se_subsystem_dev *se_dev = p;
1699 struct se_hba *hba = se_dev->se_dev_hba; 1697 struct se_hba *hba = se_dev->se_dev_hba;
1700 ssize_t read_bytes; 1698 ssize_t read_bytes;
1701 1699
@@ -1710,6 +1708,9 @@ static ssize_t target_core_store_dev_alias(
1710 read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, 1708 read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN,
1711 "%s", page); 1709 "%s", page);
1712 1710
1711 if (se_dev->se_dev_alias[read_bytes - 1] == '\n')
1712 se_dev->se_dev_alias[read_bytes - 1] = '\0';
1713
1713 pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", 1714 pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n",
1714 config_item_name(&hba->hba_group.cg_item), 1715 config_item_name(&hba->hba_group.cg_item),
1715 config_item_name(&se_dev->se_dev_group.cg_item), 1716 config_item_name(&se_dev->se_dev_group.cg_item),
@@ -1728,7 +1729,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_alias = {
1728 1729
1729static ssize_t target_core_show_dev_udev_path(void *p, char *page) 1730static ssize_t target_core_show_dev_udev_path(void *p, char *page)
1730{ 1731{
1731 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1732 struct se_subsystem_dev *se_dev = p;
1732 1733
1733 if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) 1734 if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH))
1734 return 0; 1735 return 0;
@@ -1741,7 +1742,7 @@ static ssize_t target_core_store_dev_udev_path(
1741 const char *page, 1742 const char *page,
1742 size_t count) 1743 size_t count)
1743{ 1744{
1744 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1745 struct se_subsystem_dev *se_dev = p;
1745 struct se_hba *hba = se_dev->se_dev_hba; 1746 struct se_hba *hba = se_dev->se_dev_hba;
1746 ssize_t read_bytes; 1747 ssize_t read_bytes;
1747 1748
@@ -1756,6 +1757,9 @@ static ssize_t target_core_store_dev_udev_path(
1756 read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, 1757 read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN,
1757 "%s", page); 1758 "%s", page);
1758 1759
1760 if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n')
1761 se_dev->se_dev_udev_path[read_bytes - 1] = '\0';
1762
1759 pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", 1763 pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n",
1760 config_item_name(&hba->hba_group.cg_item), 1764 config_item_name(&hba->hba_group.cg_item),
1761 config_item_name(&se_dev->se_dev_group.cg_item), 1765 config_item_name(&se_dev->se_dev_group.cg_item),
@@ -1777,7 +1781,7 @@ static ssize_t target_core_store_dev_enable(
1777 const char *page, 1781 const char *page,
1778 size_t count) 1782 size_t count)
1779{ 1783{
1780 struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; 1784 struct se_subsystem_dev *se_dev = p;
1781 struct se_device *dev; 1785 struct se_device *dev;
1782 struct se_hba *hba = se_dev->se_dev_hba; 1786 struct se_hba *hba = se_dev->se_dev_hba;
1783 struct se_subsystem_api *t = hba->transport; 1787 struct se_subsystem_api *t = hba->transport;
@@ -1822,7 +1826,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_enable = {
1822static ssize_t target_core_show_alua_lu_gp(void *p, char *page) 1826static ssize_t target_core_show_alua_lu_gp(void *p, char *page)
1823{ 1827{
1824 struct se_device *dev; 1828 struct se_device *dev;
1825 struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; 1829 struct se_subsystem_dev *su_dev = p;
1826 struct config_item *lu_ci; 1830 struct config_item *lu_ci;
1827 struct t10_alua_lu_gp *lu_gp; 1831 struct t10_alua_lu_gp *lu_gp;
1828 struct t10_alua_lu_gp_member *lu_gp_mem; 1832 struct t10_alua_lu_gp_member *lu_gp_mem;
@@ -1860,7 +1864,7 @@ static ssize_t target_core_store_alua_lu_gp(
1860 size_t count) 1864 size_t count)
1861{ 1865{
1862 struct se_device *dev; 1866 struct se_device *dev;
1863 struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; 1867 struct se_subsystem_dev *su_dev = p;
1864 struct se_hba *hba = su_dev->se_dev_hba; 1868 struct se_hba *hba = su_dev->se_dev_hba;
1865 struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; 1869 struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL;
1866 struct t10_alua_lu_gp_member *lu_gp_mem; 1870 struct t10_alua_lu_gp_member *lu_gp_mem;
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 9b8639425472..0c5992f0d946 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -42,13 +42,11 @@
42#include <scsi/scsi_device.h> 42#include <scsi/scsi_device.h>
43 43
44#include <target/target_core_base.h> 44#include <target/target_core_base.h>
45#include <target/target_core_device.h> 45#include <target/target_core_backend.h>
46#include <target/target_core_tpg.h> 46#include <target/target_core_fabric.h>
47#include <target/target_core_transport.h>
48#include <target/target_core_fabric_ops.h>
49 47
48#include "target_core_internal.h"
50#include "target_core_alua.h" 49#include "target_core_alua.h"
51#include "target_core_hba.h"
52#include "target_core_pr.h" 50#include "target_core_pr.h"
53#include "target_core_ua.h" 51#include "target_core_ua.h"
54 52
@@ -1134,8 +1132,6 @@ int se_dev_set_emulate_rest_reord(struct se_device *dev, int flag)
1134 */ 1132 */
1135int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) 1133int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth)
1136{ 1134{
1137 u32 orig_queue_depth = dev->queue_depth;
1138
1139 if (atomic_read(&dev->dev_export_obj.obj_access_count)) { 1135 if (atomic_read(&dev->dev_export_obj.obj_access_count)) {
1140 pr_err("dev[%p]: Unable to change SE Device TCQ while" 1136 pr_err("dev[%p]: Unable to change SE Device TCQ while"
1141 " dev_export_obj: %d count exists\n", dev, 1137 " dev_export_obj: %d count exists\n", dev,
@@ -1169,11 +1165,6 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth)
1169 } 1165 }
1170 1166
1171 dev->se_sub_dev->se_dev_attrib.queue_depth = dev->queue_depth = queue_depth; 1167 dev->se_sub_dev->se_dev_attrib.queue_depth = dev->queue_depth = queue_depth;
1172 if (queue_depth > orig_queue_depth)
1173 atomic_add(queue_depth - orig_queue_depth, &dev->depth_left);
1174 else if (queue_depth < orig_queue_depth)
1175 atomic_sub(orig_queue_depth - queue_depth, &dev->depth_left);
1176
1177 pr_debug("dev[%p]: SE Device TCQ Depth changed to: %u\n", 1168 pr_debug("dev[%p]: SE Device TCQ Depth changed to: %u\n",
1178 dev, queue_depth); 1169 dev, queue_depth);
1179 return 0; 1170 return 0;
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 09b6f8729f91..4f77cce22646 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -36,18 +36,14 @@
36#include <linux/configfs.h> 36#include <linux/configfs.h>
37 37
38#include <target/target_core_base.h> 38#include <target/target_core_base.h>
39#include <target/target_core_device.h> 39#include <target/target_core_fabric.h>
40#include <target/target_core_tpg.h>
41#include <target/target_core_transport.h>
42#include <target/target_core_fabric_ops.h>
43#include <target/target_core_fabric_configfs.h> 40#include <target/target_core_fabric_configfs.h>
44#include <target/target_core_configfs.h> 41#include <target/target_core_configfs.h>
45#include <target/configfs_macros.h> 42#include <target/configfs_macros.h>
46 43
44#include "target_core_internal.h"
47#include "target_core_alua.h" 45#include "target_core_alua.h"
48#include "target_core_hba.h"
49#include "target_core_pr.h" 46#include "target_core_pr.h"
50#include "target_core_stat.h"
51 47
52#define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ 48#define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \
53static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ 49static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index ec4249be617e..283a36e464e6 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -34,13 +34,10 @@
34#include <scsi/scsi_cmnd.h> 34#include <scsi/scsi_cmnd.h>
35 35
36#include <target/target_core_base.h> 36#include <target/target_core_base.h>
37#include <target/target_core_device.h> 37#include <target/target_core_fabric.h>
38#include <target/target_core_transport.h>
39#include <target/target_core_fabric_lib.h>
40#include <target/target_core_fabric_ops.h>
41#include <target/target_core_configfs.h> 38#include <target/target_core_configfs.h>
42 39
43#include "target_core_hba.h" 40#include "target_core_internal.h"
44#include "target_core_pr.h" 41#include "target_core_pr.h"
45 42
46/* 43/*
@@ -402,7 +399,7 @@ char *iscsi_parse_pr_out_transport_id(
402 add_len = ((buf[2] >> 8) & 0xff); 399 add_len = ((buf[2] >> 8) & 0xff);
403 add_len |= (buf[3] & 0xff); 400 add_len |= (buf[3] & 0xff);
404 401
405 tid_len = strlen((char *)&buf[4]); 402 tid_len = strlen(&buf[4]);
406 tid_len += 4; /* Add four bytes for iSCSI Transport ID header */ 403 tid_len += 4; /* Add four bytes for iSCSI Transport ID header */
407 tid_len += 1; /* Add one byte for NULL terminator */ 404 tid_len += 1; /* Add one byte for NULL terminator */
408 padding = ((-tid_len) & 3); 405 padding = ((-tid_len) & 3);
@@ -423,11 +420,11 @@ char *iscsi_parse_pr_out_transport_id(
423 * format. 420 * format.
424 */ 421 */
425 if (format_code == 0x40) { 422 if (format_code == 0x40) {
426 p = strstr((char *)&buf[4], ",i,0x"); 423 p = strstr(&buf[4], ",i,0x");
427 if (!p) { 424 if (!p) {
428 pr_err("Unable to locate \",i,0x\" seperator" 425 pr_err("Unable to locate \",i,0x\" seperator"
429 " for Initiator port identifier: %s\n", 426 " for Initiator port identifier: %s\n",
430 (char *)&buf[4]); 427 &buf[4]);
431 return NULL; 428 return NULL;
432 } 429 }
433 *p = '\0'; /* Terminate iSCSI Name */ 430 *p = '\0'; /* Terminate iSCSI Name */
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index b4864fba4ef0..7ed58e2df791 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -37,8 +37,7 @@
37#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
38 38
39#include <target/target_core_base.h> 39#include <target/target_core_base.h>
40#include <target/target_core_device.h> 40#include <target/target_core_backend.h>
41#include <target/target_core_transport.h>
42 41
43#include "target_core_file.h" 42#include "target_core_file.h"
44 43
@@ -86,7 +85,7 @@ static void fd_detach_hba(struct se_hba *hba)
86static void *fd_allocate_virtdevice(struct se_hba *hba, const char *name) 85static void *fd_allocate_virtdevice(struct se_hba *hba, const char *name)
87{ 86{
88 struct fd_dev *fd_dev; 87 struct fd_dev *fd_dev;
89 struct fd_host *fd_host = (struct fd_host *) hba->hba_ptr; 88 struct fd_host *fd_host = hba->hba_ptr;
90 89
91 fd_dev = kzalloc(sizeof(struct fd_dev), GFP_KERNEL); 90 fd_dev = kzalloc(sizeof(struct fd_dev), GFP_KERNEL);
92 if (!fd_dev) { 91 if (!fd_dev) {
@@ -114,8 +113,8 @@ static struct se_device *fd_create_virtdevice(
114 struct se_device *dev; 113 struct se_device *dev;
115 struct se_dev_limits dev_limits; 114 struct se_dev_limits dev_limits;
116 struct queue_limits *limits; 115 struct queue_limits *limits;
117 struct fd_dev *fd_dev = (struct fd_dev *) p; 116 struct fd_dev *fd_dev = p;
118 struct fd_host *fd_host = (struct fd_host *) hba->hba_ptr; 117 struct fd_host *fd_host = hba->hba_ptr;
119 mm_segment_t old_fs; 118 mm_segment_t old_fs;
120 struct file *file; 119 struct file *file;
121 struct inode *inode = NULL; 120 struct inode *inode = NULL;
@@ -240,7 +239,7 @@ fail:
240 */ 239 */
241static void fd_free_device(void *p) 240static void fd_free_device(void *p)
242{ 241{
243 struct fd_dev *fd_dev = (struct fd_dev *) p; 242 struct fd_dev *fd_dev = p;
244 243
245 if (fd_dev->fd_file) { 244 if (fd_dev->fd_file) {
246 filp_close(fd_dev->fd_file, NULL); 245 filp_close(fd_dev->fd_file, NULL);
@@ -498,7 +497,7 @@ static ssize_t fd_set_configfs_dev_params(
498 497
499 orig = opts; 498 orig = opts;
500 499
501 while ((ptr = strsep(&opts, ",")) != NULL) { 500 while ((ptr = strsep(&opts, ",\n")) != NULL) {
502 if (!*ptr) 501 if (!*ptr)
503 continue; 502 continue;
504 503
@@ -559,7 +558,7 @@ out:
559 558
560static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsystem_dev *se_dev) 559static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsystem_dev *se_dev)
561{ 560{
562 struct fd_dev *fd_dev = (struct fd_dev *) se_dev->se_dev_su_ptr; 561 struct fd_dev *fd_dev = se_dev->se_dev_su_ptr;
563 562
564 if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { 563 if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) {
565 pr_err("Missing fd_dev_name=\n"); 564 pr_err("Missing fd_dev_name=\n");
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index c68019d6c406..3dd1bd4b6f71 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -37,11 +37,10 @@
37#include <net/tcp.h> 37#include <net/tcp.h>
38 38
39#include <target/target_core_base.h> 39#include <target/target_core_base.h>
40#include <target/target_core_device.h> 40#include <target/target_core_backend.h>
41#include <target/target_core_tpg.h> 41#include <target/target_core_fabric.h>
42#include <target/target_core_transport.h>
43 42
44#include "target_core_hba.h" 43#include "target_core_internal.h"
45 44
46static LIST_HEAD(subsystem_list); 45static LIST_HEAD(subsystem_list);
47static DEFINE_MUTEX(subsystem_mutex); 46static DEFINE_MUTEX(subsystem_mutex);
diff --git a/drivers/target/target_core_hba.h b/drivers/target/target_core_hba.h
deleted file mode 100644
index bb0fea5f730c..000000000000
--- a/drivers/target/target_core_hba.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef TARGET_CORE_HBA_H
2#define TARGET_CORE_HBA_H
3
4extern struct se_hba *core_alloc_hba(const char *, u32, u32);
5extern int core_delete_hba(struct se_hba *);
6
7#endif /* TARGET_CORE_HBA_H */
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 4aa992204438..cc8e6b58ef20 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -42,8 +42,7 @@
42#include <scsi/scsi_host.h> 42#include <scsi/scsi_host.h>
43 43
44#include <target/target_core_base.h> 44#include <target/target_core_base.h>
45#include <target/target_core_device.h> 45#include <target/target_core_backend.h>
46#include <target/target_core_transport.h>
47 46
48#include "target_core_iblock.h" 47#include "target_core_iblock.h"
49 48
@@ -391,7 +390,7 @@ static ssize_t iblock_set_configfs_dev_params(struct se_hba *hba,
391 390
392 orig = opts; 391 orig = opts;
393 392
394 while ((ptr = strsep(&opts, ",")) != NULL) { 393 while ((ptr = strsep(&opts, ",\n")) != NULL) {
395 if (!*ptr) 394 if (!*ptr)
396 continue; 395 continue;
397 396
@@ -465,7 +464,7 @@ static ssize_t iblock_show_configfs_dev_params(
465 if (bd) { 464 if (bd) {
466 bl += sprintf(b + bl, "Major: %d Minor: %d %s\n", 465 bl += sprintf(b + bl, "Major: %d Minor: %d %s\n",
467 MAJOR(bd->bd_dev), MINOR(bd->bd_dev), (!bd->bd_contains) ? 466 MAJOR(bd->bd_dev), MINOR(bd->bd_dev), (!bd->bd_contains) ?
468 "" : (bd->bd_holder == (struct iblock_dev *)ibd) ? 467 "" : (bd->bd_holder == ibd) ?
469 "CLAIMED: IBLOCK" : "CLAIMED: OS"); 468 "CLAIMED: IBLOCK" : "CLAIMED: OS");
470 } else { 469 } else {
471 bl += sprintf(b + bl, "Major: 0 Minor: 0\n"); 470 bl += sprintf(b + bl, "Major: 0 Minor: 0\n");
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
new file mode 100644
index 000000000000..26f135e94f6e
--- /dev/null
+++ b/drivers/target/target_core_internal.h
@@ -0,0 +1,123 @@
1#ifndef TARGET_CORE_INTERNAL_H
2#define TARGET_CORE_INTERNAL_H
3
4/* target_core_alua.c */
5extern struct t10_alua_lu_gp *default_lu_gp;
6
7/* target_core_cdb.c */
8int target_emulate_inquiry(struct se_task *task);
9int target_emulate_readcapacity(struct se_task *task);
10int target_emulate_readcapacity_16(struct se_task *task);
11int target_emulate_modesense(struct se_task *task);
12int target_emulate_request_sense(struct se_task *task);
13int target_emulate_unmap(struct se_task *task);
14int target_emulate_write_same(struct se_task *task);
15int target_emulate_synchronize_cache(struct se_task *task);
16int target_emulate_noop(struct se_task *task);
17
18/* target_core_device.c */
19struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
20int core_free_device_list_for_node(struct se_node_acl *,
21 struct se_portal_group *);
22void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *);
23void core_update_device_list_access(u32, u32, struct se_node_acl *);
24int core_update_device_list_for_node(struct se_lun *, struct se_lun_acl *,
25 u32, u32, struct se_node_acl *, struct se_portal_group *, int);
26void core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
27int core_dev_export(struct se_device *, struct se_portal_group *,
28 struct se_lun *);
29void core_dev_unexport(struct se_device *, struct se_portal_group *,
30 struct se_lun *);
31int target_report_luns(struct se_task *);
32void se_release_device_for_hba(struct se_device *);
33void se_release_vpd_for_dev(struct se_device *);
34int se_free_virtual_device(struct se_device *, struct se_hba *);
35int se_dev_check_online(struct se_device *);
36int se_dev_check_shutdown(struct se_device *);
37void se_dev_set_default_attribs(struct se_device *, struct se_dev_limits *);
38int se_dev_set_task_timeout(struct se_device *, u32);
39int se_dev_set_max_unmap_lba_count(struct se_device *, u32);
40int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32);
41int se_dev_set_unmap_granularity(struct se_device *, u32);
42int se_dev_set_unmap_granularity_alignment(struct se_device *, u32);
43int se_dev_set_emulate_dpo(struct se_device *, int);
44int se_dev_set_emulate_fua_write(struct se_device *, int);
45int se_dev_set_emulate_fua_read(struct se_device *, int);
46int se_dev_set_emulate_write_cache(struct se_device *, int);
47int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int);
48int se_dev_set_emulate_tas(struct se_device *, int);
49int se_dev_set_emulate_tpu(struct se_device *, int);
50int se_dev_set_emulate_tpws(struct se_device *, int);
51int se_dev_set_enforce_pr_isids(struct se_device *, int);
52int se_dev_set_is_nonrot(struct se_device *, int);
53int se_dev_set_emulate_rest_reord(struct se_device *dev, int);
54int se_dev_set_queue_depth(struct se_device *, u32);
55int se_dev_set_max_sectors(struct se_device *, u32);
56int se_dev_set_optimal_sectors(struct se_device *, u32);
57int se_dev_set_block_size(struct se_device *, u32);
58struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_hba *,
59 struct se_device *, u32);
60int core_dev_del_lun(struct se_portal_group *, u32);
61struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
62struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
63 u32, char *, int *);
64int core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
65 struct se_lun_acl *, u32, u32);
66int core_dev_del_initiator_node_lun_acl(struct se_portal_group *,
67 struct se_lun *, struct se_lun_acl *);
68void core_dev_free_initiator_node_lun_acl(struct se_portal_group *,
69 struct se_lun_acl *lacl);
70int core_dev_setup_virtual_lun0(void);
71void core_dev_release_virtual_lun0(void);
72
73/* target_core_hba.c */
74struct se_hba *core_alloc_hba(const char *, u32, u32);
75int core_delete_hba(struct se_hba *);
76
77/* target_core_tmr.c */
78int core_tmr_lun_reset(struct se_device *, struct se_tmr_req *,
79 struct list_head *, struct se_cmd *);
80
81/* target_core_tpg.c */
82extern struct se_device *g_lun0_dev;
83
84struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
85 const char *);
86struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
87 unsigned char *);
88void core_tpg_add_node_to_devs(struct se_node_acl *, struct se_portal_group *);
89void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
90struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32);
91int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *,
92 u32, void *);
93struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *);
94int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
95
96/* target_core_transport.c */
97extern struct kmem_cache *se_tmr_req_cache;
98
99int init_se_kmem_caches(void);
100void release_se_kmem_caches(void);
101u32 scsi_get_new_index(scsi_index_t);
102void transport_subsystem_check_init(void);
103void transport_cmd_finish_abort(struct se_cmd *, int);
104void __transport_remove_task_from_execute_queue(struct se_task *,
105 struct se_device *);
106unsigned char *transport_dump_cmd_direction(struct se_cmd *);
107void transport_dump_dev_state(struct se_device *, char *, int *);
108void transport_dump_dev_info(struct se_device *, struct se_lun *,
109 unsigned long long, char *, int *);
110void transport_dump_vpd_proto_id(struct t10_vpd *, unsigned char *, int);
111int transport_dump_vpd_assoc(struct t10_vpd *, unsigned char *, int);
112int transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int);
113int transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int);
114bool target_stop_task(struct se_task *task, unsigned long *flags);
115int transport_clear_lun_from_sessions(struct se_lun *);
116void transport_send_task_abort(struct se_cmd *);
117
118/* target_core_stat.c */
119void target_stat_setup_dev_default_groups(struct se_subsystem_dev *);
120void target_stat_setup_port_default_groups(struct se_lun *);
121void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *);
122
123#endif /* TARGET_CORE_INTERNAL_H */
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 95dee7074aeb..429ad7291664 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -33,14 +33,11 @@
33#include <asm/unaligned.h> 33#include <asm/unaligned.h>
34 34
35#include <target/target_core_base.h> 35#include <target/target_core_base.h>
36#include <target/target_core_device.h> 36#include <target/target_core_backend.h>
37#include <target/target_core_tmr.h> 37#include <target/target_core_fabric.h>
38#include <target/target_core_tpg.h>
39#include <target/target_core_transport.h>
40#include <target/target_core_fabric_ops.h>
41#include <target/target_core_configfs.h> 38#include <target/target_core_configfs.h>
42 39
43#include "target_core_hba.h" 40#include "target_core_internal.h"
44#include "target_core_pr.h" 41#include "target_core_pr.h"
45#include "target_core_ua.h" 42#include "target_core_ua.h"
46 43
@@ -2984,21 +2981,6 @@ static void core_scsi3_release_preempt_and_abort(
2984 } 2981 }
2985} 2982}
2986 2983
2987int core_scsi3_check_cdb_abort_and_preempt(
2988 struct list_head *preempt_and_abort_list,
2989 struct se_cmd *cmd)
2990{
2991 struct t10_pr_registration *pr_reg, *pr_reg_tmp;
2992
2993 list_for_each_entry_safe(pr_reg, pr_reg_tmp, preempt_and_abort_list,
2994 pr_reg_abort_list) {
2995 if (pr_reg->pr_res_key == cmd->pr_res_key)
2996 return 0;
2997 }
2998
2999 return 1;
3000}
3001
3002static int core_scsi3_pro_preempt( 2984static int core_scsi3_pro_preempt(
3003 struct se_cmd *cmd, 2985 struct se_cmd *cmd,
3004 int type, 2986 int type,
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
index b97f6940dd05..7a233feb7e99 100644
--- a/drivers/target/target_core_pr.h
+++ b/drivers/target/target_core_pr.h
@@ -60,8 +60,6 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *,
60 struct se_node_acl *); 60 struct se_node_acl *);
61extern void core_scsi3_free_all_registrations(struct se_device *); 61extern void core_scsi3_free_all_registrations(struct se_device *);
62extern unsigned char *core_scsi3_pr_dump_type(int); 62extern unsigned char *core_scsi3_pr_dump_type(int);
63extern int core_scsi3_check_cdb_abort_and_preempt(struct list_head *,
64 struct se_cmd *);
65 63
66extern int target_scsi3_emulate_pr_in(struct se_task *task); 64extern int target_scsi3_emulate_pr_in(struct se_task *task);
67extern int target_scsi3_emulate_pr_out(struct se_task *task); 65extern int target_scsi3_emulate_pr_out(struct se_task *task);
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 8b15e56b0384..d35467d42e12 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -44,8 +44,7 @@
44#include <scsi/scsi_tcq.h> 44#include <scsi/scsi_tcq.h>
45 45
46#include <target/target_core_base.h> 46#include <target/target_core_base.h>
47#include <target/target_core_device.h> 47#include <target/target_core_backend.h>
48#include <target/target_core_transport.h>
49 48
50#include "target_core_pscsi.h" 49#include "target_core_pscsi.h"
51 50
@@ -105,7 +104,7 @@ static void pscsi_detach_hba(struct se_hba *hba)
105 104
106static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) 105static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
107{ 106{
108 struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; 107 struct pscsi_hba_virt *phv = hba->hba_ptr;
109 struct Scsi_Host *sh = phv->phv_lld_host; 108 struct Scsi_Host *sh = phv->phv_lld_host;
110 /* 109 /*
111 * Release the struct Scsi_Host 110 * Release the struct Scsi_Host
@@ -351,7 +350,6 @@ static struct se_device *pscsi_add_device_to_list(
351 * scsi_device_put() and the pdv->pdv_sd cleared. 350 * scsi_device_put() and the pdv->pdv_sd cleared.
352 */ 351 */
353 pdv->pdv_sd = sd; 352 pdv->pdv_sd = sd;
354
355 dev = transport_add_device_to_core_hba(hba, &pscsi_template, 353 dev = transport_add_device_to_core_hba(hba, &pscsi_template,
356 se_dev, dev_flags, pdv, 354 se_dev, dev_flags, pdv,
357 &dev_limits, NULL, NULL); 355 &dev_limits, NULL, NULL);
@@ -406,7 +404,7 @@ static struct se_device *pscsi_create_type_disk(
406 __releases(sh->host_lock) 404 __releases(sh->host_lock)
407{ 405{
408 struct se_device *dev; 406 struct se_device *dev;
409 struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; 407 struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr;
410 struct Scsi_Host *sh = sd->host; 408 struct Scsi_Host *sh = sd->host;
411 struct block_device *bd; 409 struct block_device *bd;
412 u32 dev_flags = 0; 410 u32 dev_flags = 0;
@@ -454,7 +452,7 @@ static struct se_device *pscsi_create_type_rom(
454 __releases(sh->host_lock) 452 __releases(sh->host_lock)
455{ 453{
456 struct se_device *dev; 454 struct se_device *dev;
457 struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; 455 struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr;
458 struct Scsi_Host *sh = sd->host; 456 struct Scsi_Host *sh = sd->host;
459 u32 dev_flags = 0; 457 u32 dev_flags = 0;
460 458
@@ -489,7 +487,7 @@ static struct se_device *pscsi_create_type_other(
489 __releases(sh->host_lock) 487 __releases(sh->host_lock)
490{ 488{
491 struct se_device *dev; 489 struct se_device *dev;
492 struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; 490 struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr;
493 struct Scsi_Host *sh = sd->host; 491 struct Scsi_Host *sh = sd->host;
494 u32 dev_flags = 0; 492 u32 dev_flags = 0;
495 493
@@ -510,10 +508,10 @@ static struct se_device *pscsi_create_virtdevice(
510 struct se_subsystem_dev *se_dev, 508 struct se_subsystem_dev *se_dev,
511 void *p) 509 void *p)
512{ 510{
513 struct pscsi_dev_virt *pdv = (struct pscsi_dev_virt *)p; 511 struct pscsi_dev_virt *pdv = p;
514 struct se_device *dev; 512 struct se_device *dev;
515 struct scsi_device *sd; 513 struct scsi_device *sd;
516 struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; 514 struct pscsi_hba_virt *phv = hba->hba_ptr;
517 struct Scsi_Host *sh = phv->phv_lld_host; 515 struct Scsi_Host *sh = phv->phv_lld_host;
518 int legacy_mode_enable = 0; 516 int legacy_mode_enable = 0;
519 517
@@ -818,7 +816,7 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba,
818 816
819 orig = opts; 817 orig = opts;
820 818
821 while ((ptr = strsep(&opts, ",")) != NULL) { 819 while ((ptr = strsep(&opts, ",\n")) != NULL) {
822 if (!*ptr) 820 if (!*ptr)
823 continue; 821 continue;
824 822
@@ -1144,7 +1142,7 @@ static unsigned char *pscsi_get_sense_buffer(struct se_task *task)
1144{ 1142{
1145 struct pscsi_plugin_task *pt = PSCSI_TASK(task); 1143 struct pscsi_plugin_task *pt = PSCSI_TASK(task);
1146 1144
1147 return (unsigned char *)&pt->pscsi_sense[0]; 1145 return pt->pscsi_sense;
1148} 1146}
1149 1147
1150/* pscsi_get_device_rev(): 1148/* pscsi_get_device_rev():
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 02e51faa2f4e..8b68f7b82631 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -37,9 +37,7 @@
37#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
38 38
39#include <target/target_core_base.h> 39#include <target/target_core_base.h>
40#include <target/target_core_device.h> 40#include <target/target_core_backend.h>
41#include <target/target_core_transport.h>
42#include <target/target_core_fabric_ops.h>
43 41
44#include "target_core_rd.h" 42#include "target_core_rd.h"
45 43
@@ -474,7 +472,7 @@ static ssize_t rd_set_configfs_dev_params(
474 472
475 orig = opts; 473 orig = opts;
476 474
477 while ((ptr = strsep(&opts, ",")) != NULL) { 475 while ((ptr = strsep(&opts, ",\n")) != NULL) {
478 if (!*ptr) 476 if (!*ptr)
479 continue; 477 continue;
480 478
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 874152aed94a..f8c2d2cc3431 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -43,12 +43,12 @@
43#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
44 44
45#include <target/target_core_base.h> 45#include <target/target_core_base.h>
46#include <target/target_core_transport.h> 46#include <target/target_core_backend.h>
47#include <target/target_core_fabric_ops.h> 47#include <target/target_core_fabric.h>
48#include <target/target_core_configfs.h> 48#include <target/target_core_configfs.h>
49#include <target/configfs_macros.h> 49#include <target/configfs_macros.h>
50 50
51#include "target_core_hba.h" 51#include "target_core_internal.h"
52 52
53#ifndef INITIAL_JIFFIES 53#ifndef INITIAL_JIFFIES
54#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) 54#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
@@ -1755,8 +1755,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident(
1755 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ 1755 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
1756 memset(buf, 0, 64); 1756 memset(buf, 0, 64);
1757 if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) 1757 if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL)
1758 tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, 1758 tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64);
1759 (unsigned char *)&buf[0], 64);
1760 1759
1761 ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); 1760 ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf);
1762 spin_unlock_irq(&nacl->nacl_sess_lock); 1761 spin_unlock_irq(&nacl->nacl_sess_lock);
diff --git a/drivers/target/target_core_stat.h b/drivers/target/target_core_stat.h
deleted file mode 100644
index 86c252f9ea47..000000000000
--- a/drivers/target/target_core_stat.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef TARGET_CORE_STAT_H
2#define TARGET_CORE_STAT_H
3
4extern void target_stat_setup_dev_default_groups(struct se_subsystem_dev *);
5extern void target_stat_setup_port_default_groups(struct se_lun *);
6extern void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *);
7
8#endif /*** TARGET_CORE_STAT_H ***/
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 684522805a1f..dcb0618c9388 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -32,12 +32,11 @@
32#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
33 33
34#include <target/target_core_base.h> 34#include <target/target_core_base.h>
35#include <target/target_core_device.h> 35#include <target/target_core_backend.h>
36#include <target/target_core_tmr.h> 36#include <target/target_core_fabric.h>
37#include <target/target_core_transport.h>
38#include <target/target_core_fabric_ops.h>
39#include <target/target_core_configfs.h> 37#include <target/target_core_configfs.h>
40 38
39#include "target_core_internal.h"
41#include "target_core_alua.h" 40#include "target_core_alua.h"
42#include "target_core_pr.h" 41#include "target_core_pr.h"
43 42
@@ -101,6 +100,21 @@ static void core_tmr_handle_tas_abort(
101 transport_cmd_finish_abort(cmd, 0); 100 transport_cmd_finish_abort(cmd, 0);
102} 101}
103 102
103static int target_check_cdb_and_preempt(struct list_head *list,
104 struct se_cmd *cmd)
105{
106 struct t10_pr_registration *reg;
107
108 if (!list)
109 return 0;
110 list_for_each_entry(reg, list, pr_reg_abort_list) {
111 if (reg->pr_res_key == cmd->pr_res_key)
112 return 0;
113 }
114
115 return 1;
116}
117
104static void core_tmr_drain_tmr_list( 118static void core_tmr_drain_tmr_list(
105 struct se_device *dev, 119 struct se_device *dev,
106 struct se_tmr_req *tmr, 120 struct se_tmr_req *tmr,
@@ -132,9 +146,7 @@ static void core_tmr_drain_tmr_list(
132 * parameter (eg: for PROUT PREEMPT_AND_ABORT service action 146 * parameter (eg: for PROUT PREEMPT_AND_ABORT service action
133 * skip non regisration key matching TMRs. 147 * skip non regisration key matching TMRs.
134 */ 148 */
135 if (preempt_and_abort_list && 149 if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd))
136 (core_scsi3_check_cdb_abort_and_preempt(
137 preempt_and_abort_list, cmd) != 0))
138 continue; 150 continue;
139 151
140 spin_lock(&cmd->t_state_lock); 152 spin_lock(&cmd->t_state_lock);
@@ -211,9 +223,7 @@ static void core_tmr_drain_task_list(
211 * For PREEMPT_AND_ABORT usage, only process commands 223 * For PREEMPT_AND_ABORT usage, only process commands
212 * with a matching reservation key. 224 * with a matching reservation key.
213 */ 225 */
214 if (preempt_and_abort_list && 226 if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd))
215 (core_scsi3_check_cdb_abort_and_preempt(
216 preempt_and_abort_list, cmd) != 0))
217 continue; 227 continue;
218 /* 228 /*
219 * Not aborting PROUT PREEMPT_AND_ABORT CDB.. 229 * Not aborting PROUT PREEMPT_AND_ABORT CDB..
@@ -222,7 +232,7 @@ static void core_tmr_drain_task_list(
222 continue; 232 continue;
223 233
224 list_move_tail(&task->t_state_list, &drain_task_list); 234 list_move_tail(&task->t_state_list, &drain_task_list);
225 atomic_set(&task->task_state_active, 0); 235 task->t_state_active = false;
226 /* 236 /*
227 * Remove from task execute list before processing drain_task_list 237 * Remove from task execute list before processing drain_task_list
228 */ 238 */
@@ -321,9 +331,7 @@ static void core_tmr_drain_cmd_list(
321 * For PREEMPT_AND_ABORT usage, only process commands 331 * For PREEMPT_AND_ABORT usage, only process commands
322 * with a matching reservation key. 332 * with a matching reservation key.
323 */ 333 */
324 if (preempt_and_abort_list && 334 if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd))
325 (core_scsi3_check_cdb_abort_and_preempt(
326 preempt_and_abort_list, cmd) != 0))
327 continue; 335 continue;
328 /* 336 /*
329 * Not aborting PROUT PREEMPT_AND_ABORT CDB.. 337 * Not aborting PROUT PREEMPT_AND_ABORT CDB..
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 8ddd133025b9..b7668029bb31 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -39,13 +39,10 @@
39#include <scsi/scsi_cmnd.h> 39#include <scsi/scsi_cmnd.h>
40 40
41#include <target/target_core_base.h> 41#include <target/target_core_base.h>
42#include <target/target_core_device.h> 42#include <target/target_core_backend.h>
43#include <target/target_core_tpg.h> 43#include <target/target_core_fabric.h>
44#include <target/target_core_transport.h>
45#include <target/target_core_fabric_ops.h>
46 44
47#include "target_core_hba.h" 45#include "target_core_internal.h"
48#include "target_core_stat.h"
49 46
50extern struct se_device *g_lun0_dev; 47extern struct se_device *g_lun0_dev;
51 48
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 0257658e2e3e..d3ddd1361949 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -45,16 +45,12 @@
45#include <scsi/scsi_tcq.h> 45#include <scsi/scsi_tcq.h>
46 46
47#include <target/target_core_base.h> 47#include <target/target_core_base.h>
48#include <target/target_core_device.h> 48#include <target/target_core_backend.h>
49#include <target/target_core_tmr.h> 49#include <target/target_core_fabric.h>
50#include <target/target_core_tpg.h>
51#include <target/target_core_transport.h>
52#include <target/target_core_fabric_ops.h>
53#include <target/target_core_configfs.h> 50#include <target/target_core_configfs.h>
54 51
52#include "target_core_internal.h"
55#include "target_core_alua.h" 53#include "target_core_alua.h"
56#include "target_core_cdb.h"
57#include "target_core_hba.h"
58#include "target_core_pr.h" 54#include "target_core_pr.h"
59#include "target_core_ua.h" 55#include "target_core_ua.h"
60 56
@@ -72,7 +68,7 @@ struct kmem_cache *t10_alua_tg_pt_gp_mem_cache;
72 68
73static int transport_generic_write_pending(struct se_cmd *); 69static int transport_generic_write_pending(struct se_cmd *);
74static int transport_processing_thread(void *param); 70static int transport_processing_thread(void *param);
75static int __transport_execute_tasks(struct se_device *dev); 71static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *);
76static void transport_complete_task_attr(struct se_cmd *cmd); 72static void transport_complete_task_attr(struct se_cmd *cmd);
77static void transport_handle_queue_full(struct se_cmd *cmd, 73static void transport_handle_queue_full(struct se_cmd *cmd,
78 struct se_device *dev); 74 struct se_device *dev);
@@ -212,14 +208,13 @@ u32 scsi_get_new_index(scsi_index_t type)
212 return new_index; 208 return new_index;
213} 209}
214 210
215void transport_init_queue_obj(struct se_queue_obj *qobj) 211static void transport_init_queue_obj(struct se_queue_obj *qobj)
216{ 212{
217 atomic_set(&qobj->queue_cnt, 0); 213 atomic_set(&qobj->queue_cnt, 0);
218 INIT_LIST_HEAD(&qobj->qobj_list); 214 INIT_LIST_HEAD(&qobj->qobj_list);
219 init_waitqueue_head(&qobj->thread_wq); 215 init_waitqueue_head(&qobj->thread_wq);
220 spin_lock_init(&qobj->cmd_queue_lock); 216 spin_lock_init(&qobj->cmd_queue_lock);
221} 217}
222EXPORT_SYMBOL(transport_init_queue_obj);
223 218
224void transport_subsystem_check_init(void) 219void transport_subsystem_check_init(void)
225{ 220{
@@ -426,18 +421,18 @@ static void transport_all_task_dev_remove_state(struct se_cmd *cmd)
426 if (task->task_flags & TF_ACTIVE) 421 if (task->task_flags & TF_ACTIVE)
427 continue; 422 continue;
428 423
429 if (!atomic_read(&task->task_state_active))
430 continue;
431
432 spin_lock_irqsave(&dev->execute_task_lock, flags); 424 spin_lock_irqsave(&dev->execute_task_lock, flags);
433 list_del(&task->t_state_list); 425 if (task->t_state_active) {
434 pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n", 426 pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n",
435 cmd->se_tfo->get_task_tag(cmd), dev, task); 427 cmd->se_tfo->get_task_tag(cmd), dev, task);
436 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
437 428
438 atomic_set(&task->task_state_active, 0); 429 list_del(&task->t_state_list);
439 atomic_dec(&cmd->t_task_cdbs_ex_left); 430 atomic_dec(&cmd->t_task_cdbs_ex_left);
431 task->t_state_active = false;
432 }
433 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
440 } 434 }
435
441} 436}
442 437
443/* transport_cmd_check_stop(): 438/* transport_cmd_check_stop():
@@ -696,12 +691,6 @@ void transport_complete_task(struct se_task *task, int success)
696 struct se_cmd *cmd = task->task_se_cmd; 691 struct se_cmd *cmd = task->task_se_cmd;
697 struct se_device *dev = cmd->se_dev; 692 struct se_device *dev = cmd->se_dev;
698 unsigned long flags; 693 unsigned long flags;
699#if 0
700 pr_debug("task: %p CDB: 0x%02x obj_ptr: %p\n", task,
701 cmd->t_task_cdb[0], dev);
702#endif
703 if (dev)
704 atomic_inc(&dev->depth_left);
705 694
706 spin_lock_irqsave(&cmd->t_state_lock, flags); 695 spin_lock_irqsave(&cmd->t_state_lock, flags);
707 task->task_flags &= ~TF_ACTIVE; 696 task->task_flags &= ~TF_ACTIVE;
@@ -714,7 +703,7 @@ void transport_complete_task(struct se_task *task, int success)
714 if (dev && dev->transport->transport_complete) { 703 if (dev && dev->transport->transport_complete) {
715 if (dev->transport->transport_complete(task) != 0) { 704 if (dev->transport->transport_complete(task) != 0) {
716 cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; 705 cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
717 task->task_sense = 1; 706 task->task_flags |= TF_HAS_SENSE;
718 success = 1; 707 success = 1;
719 } 708 }
720 } 709 }
@@ -743,13 +732,7 @@ void transport_complete_task(struct se_task *task, int success)
743 } 732 }
744 733
745 if (cmd->t_tasks_failed) { 734 if (cmd->t_tasks_failed) {
746 if (!task->task_error_status) { 735 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
747 task->task_error_status =
748 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
749 cmd->scsi_sense_reason =
750 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
751 }
752
753 INIT_WORK(&cmd->work, target_complete_failure_work); 736 INIT_WORK(&cmd->work, target_complete_failure_work);
754 } else { 737 } else {
755 atomic_set(&cmd->t_transport_complete, 1); 738 atomic_set(&cmd->t_transport_complete, 1);
@@ -824,7 +807,7 @@ static void __transport_add_task_to_execute_queue(
824 head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev); 807 head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev);
825 atomic_inc(&dev->execute_tasks); 808 atomic_inc(&dev->execute_tasks);
826 809
827 if (atomic_read(&task->task_state_active)) 810 if (task->t_state_active)
828 return; 811 return;
829 /* 812 /*
830 * Determine if this task needs to go to HEAD_OF_QUEUE for the 813 * Determine if this task needs to go to HEAD_OF_QUEUE for the
@@ -838,7 +821,7 @@ static void __transport_add_task_to_execute_queue(
838 else 821 else
839 list_add_tail(&task->t_state_list, &dev->state_task_list); 822 list_add_tail(&task->t_state_list, &dev->state_task_list);
840 823
841 atomic_set(&task->task_state_active, 1); 824 task->t_state_active = true;
842 825
843 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", 826 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
844 task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd), 827 task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd),
@@ -853,29 +836,26 @@ static void transport_add_tasks_to_state_queue(struct se_cmd *cmd)
853 836
854 spin_lock_irqsave(&cmd->t_state_lock, flags); 837 spin_lock_irqsave(&cmd->t_state_lock, flags);
855 list_for_each_entry(task, &cmd->t_task_list, t_list) { 838 list_for_each_entry(task, &cmd->t_task_list, t_list) {
856 if (atomic_read(&task->task_state_active))
857 continue;
858
859 spin_lock(&dev->execute_task_lock); 839 spin_lock(&dev->execute_task_lock);
860 list_add_tail(&task->t_state_list, &dev->state_task_list); 840 if (!task->t_state_active) {
861 atomic_set(&task->task_state_active, 1); 841 list_add_tail(&task->t_state_list,
862 842 &dev->state_task_list);
863 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", 843 task->t_state_active = true;
864 task->task_se_cmd->se_tfo->get_task_tag( 844
865 task->task_se_cmd), task, dev); 845 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
866 846 task->task_se_cmd->se_tfo->get_task_tag(
847 task->task_se_cmd), task, dev);
848 }
867 spin_unlock(&dev->execute_task_lock); 849 spin_unlock(&dev->execute_task_lock);
868 } 850 }
869 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 851 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
870} 852}
871 853
872static void transport_add_tasks_from_cmd(struct se_cmd *cmd) 854static void __transport_add_tasks_from_cmd(struct se_cmd *cmd)
873{ 855{
874 struct se_device *dev = cmd->se_dev; 856 struct se_device *dev = cmd->se_dev;
875 struct se_task *task, *task_prev = NULL; 857 struct se_task *task, *task_prev = NULL;
876 unsigned long flags;
877 858
878 spin_lock_irqsave(&dev->execute_task_lock, flags);
879 list_for_each_entry(task, &cmd->t_task_list, t_list) { 859 list_for_each_entry(task, &cmd->t_task_list, t_list) {
880 if (!list_empty(&task->t_execute_list)) 860 if (!list_empty(&task->t_execute_list))
881 continue; 861 continue;
@@ -886,6 +866,15 @@ static void transport_add_tasks_from_cmd(struct se_cmd *cmd)
886 __transport_add_task_to_execute_queue(task, task_prev, dev); 866 __transport_add_task_to_execute_queue(task, task_prev, dev);
887 task_prev = task; 867 task_prev = task;
888 } 868 }
869}
870
871static void transport_add_tasks_from_cmd(struct se_cmd *cmd)
872{
873 unsigned long flags;
874 struct se_device *dev = cmd->se_dev;
875
876 spin_lock_irqsave(&dev->execute_task_lock, flags);
877 __transport_add_tasks_from_cmd(cmd);
889 spin_unlock_irqrestore(&dev->execute_task_lock, flags); 878 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
890} 879}
891 880
@@ -896,7 +885,7 @@ void __transport_remove_task_from_execute_queue(struct se_task *task,
896 atomic_dec(&dev->execute_tasks); 885 atomic_dec(&dev->execute_tasks);
897} 886}
898 887
899void transport_remove_task_from_execute_queue( 888static void transport_remove_task_from_execute_queue(
900 struct se_task *task, 889 struct se_task *task,
901 struct se_device *dev) 890 struct se_device *dev)
902{ 891{
@@ -983,9 +972,8 @@ void transport_dump_dev_state(
983 break; 972 break;
984 } 973 }
985 974
986 *bl += sprintf(b + *bl, " Execute/Left/Max Queue Depth: %d/%d/%d", 975 *bl += sprintf(b + *bl, " Execute/Max Queue Depth: %d/%d",
987 atomic_read(&dev->execute_tasks), atomic_read(&dev->depth_left), 976 atomic_read(&dev->execute_tasks), dev->queue_depth);
988 dev->queue_depth);
989 *bl += sprintf(b + *bl, " SectorSize: %u MaxSectors: %u\n", 977 *bl += sprintf(b + *bl, " SectorSize: %u MaxSectors: %u\n",
990 dev->se_sub_dev->se_dev_attrib.block_size, dev->se_sub_dev->se_dev_attrib.max_sectors); 978 dev->se_sub_dev->se_dev_attrib.block_size, dev->se_sub_dev->se_dev_attrib.max_sectors);
991 *bl += sprintf(b + *bl, " "); 979 *bl += sprintf(b + *bl, " ");
@@ -1340,9 +1328,6 @@ struct se_device *transport_add_device_to_core_hba(
1340 spin_lock_init(&dev->se_port_lock); 1328 spin_lock_init(&dev->se_port_lock);
1341 spin_lock_init(&dev->se_tmr_lock); 1329 spin_lock_init(&dev->se_tmr_lock);
1342 spin_lock_init(&dev->qf_cmd_lock); 1330 spin_lock_init(&dev->qf_cmd_lock);
1343
1344 dev->queue_depth = dev_limits->queue_depth;
1345 atomic_set(&dev->depth_left, dev->queue_depth);
1346 atomic_set(&dev->dev_ordered_id, 0); 1331 atomic_set(&dev->dev_ordered_id, 0);
1347 1332
1348 se_dev_set_default_attribs(dev, dev_limits); 1333 se_dev_set_default_attribs(dev, dev_limits);
@@ -1654,6 +1639,80 @@ int transport_handle_cdb_direct(
1654} 1639}
1655EXPORT_SYMBOL(transport_handle_cdb_direct); 1640EXPORT_SYMBOL(transport_handle_cdb_direct);
1656 1641
1642/**
1643 * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd
1644 *
1645 * @se_cmd: command descriptor to submit
1646 * @se_sess: associated se_sess for endpoint
1647 * @cdb: pointer to SCSI CDB
1648 * @sense: pointer to SCSI sense buffer
1649 * @unpacked_lun: unpacked LUN to reference for struct se_lun
1650 * @data_length: fabric expected data transfer length
1651 * @task_addr: SAM task attribute
1652 * @data_dir: DMA data direction
1653 * @flags: flags for command submission from target_sc_flags_tables
1654 *
1655 * This may only be called from process context, and also currently
1656 * assumes internal allocation of fabric payload buffer by target-core.
1657 **/
1658int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
1659 unsigned char *cdb, unsigned char *sense, u32 unpacked_lun,
1660 u32 data_length, int task_attr, int data_dir, int flags)
1661{
1662 struct se_portal_group *se_tpg;
1663 int rc;
1664
1665 se_tpg = se_sess->se_tpg;
1666 BUG_ON(!se_tpg);
1667 BUG_ON(se_cmd->se_tfo || se_cmd->se_sess);
1668 BUG_ON(in_interrupt());
1669 /*
1670 * Initialize se_cmd for target operation. From this point
1671 * exceptions are handled by sending exception status via
1672 * target_core_fabric_ops->queue_status() callback
1673 */
1674 transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess,
1675 data_length, data_dir, task_attr, sense);
1676 /*
1677 * Obtain struct se_cmd->cmd_kref reference and add new cmd to
1678 * se_sess->sess_cmd_list. A second kref_get here is necessary
1679 * for fabrics using TARGET_SCF_ACK_KREF that expect a second
1680 * kref_put() to happen during fabric packet acknowledgement.
1681 */
1682 target_get_sess_cmd(se_sess, se_cmd, (flags & TARGET_SCF_ACK_KREF));
1683 /*
1684 * Signal bidirectional data payloads to target-core
1685 */
1686 if (flags & TARGET_SCF_BIDI_OP)
1687 se_cmd->se_cmd_flags |= SCF_BIDI;
1688 /*
1689 * Locate se_lun pointer and attach it to struct se_cmd
1690 */
1691 if (transport_lookup_cmd_lun(se_cmd, unpacked_lun) < 0)
1692 goto out_check_cond;
1693 /*
1694 * Sanitize CDBs via transport_generic_cmd_sequencer() and
1695 * allocate the necessary tasks to complete the received CDB+data
1696 */
1697 rc = transport_generic_allocate_tasks(se_cmd, cdb);
1698 if (rc != 0)
1699 goto out_check_cond;
1700 /*
1701 * Dispatch se_cmd descriptor to se_lun->lun_se_dev backend
1702 * for immediate execution of READs, otherwise wait for
1703 * transport_generic_handle_data() to be called for WRITEs
1704 * when fabric has filled the incoming buffer.
1705 */
1706 transport_handle_cdb_direct(se_cmd);
1707 return 0;
1708
1709out_check_cond:
1710 transport_send_check_condition_and_sense(se_cmd,
1711 se_cmd->scsi_sense_reason, 0);
1712 return 0;
1713}
1714EXPORT_SYMBOL(target_submit_cmd);
1715
1657/* 1716/*
1658 * Used by fabric module frontends defining a TFO->new_cmd_map() caller 1717 * Used by fabric module frontends defining a TFO->new_cmd_map() caller
1659 * to queue up a newly setup se_cmd w/ TRANSPORT_NEW_CMD_MAP in order to 1718 * to queue up a newly setup se_cmd w/ TRANSPORT_NEW_CMD_MAP in order to
@@ -1920,18 +1979,6 @@ static void transport_set_supported_SAM_opcode(struct se_cmd *se_cmd)
1920 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); 1979 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
1921} 1980}
1922 1981
1923static inline int transport_tcq_window_closed(struct se_device *dev)
1924{
1925 if (dev->dev_tcq_window_closed++ <
1926 PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD) {
1927 msleep(PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT);
1928 } else
1929 msleep(PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG);
1930
1931 wake_up_interruptible(&dev->dev_queue_obj.thread_wq);
1932 return 0;
1933}
1934
1935/* 1982/*
1936 * Called from Fabric Module context from transport_execute_tasks() 1983 * Called from Fabric Module context from transport_execute_tasks()
1937 * 1984 *
@@ -2014,13 +2061,7 @@ static inline int transport_execute_task_attr(struct se_cmd *cmd)
2014static int transport_execute_tasks(struct se_cmd *cmd) 2061static int transport_execute_tasks(struct se_cmd *cmd)
2015{ 2062{
2016 int add_tasks; 2063 int add_tasks;
2017 2064 struct se_device *se_dev = cmd->se_dev;
2018 if (se_dev_check_online(cmd->se_dev) != 0) {
2019 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
2020 transport_generic_request_failure(cmd);
2021 return 0;
2022 }
2023
2024 /* 2065 /*
2025 * Call transport_cmd_check_stop() to see if a fabric exception 2066 * Call transport_cmd_check_stop() to see if a fabric exception
2026 * has occurred that prevents execution. 2067 * has occurred that prevents execution.
@@ -2034,19 +2075,16 @@ static int transport_execute_tasks(struct se_cmd *cmd)
2034 if (!add_tasks) 2075 if (!add_tasks)
2035 goto execute_tasks; 2076 goto execute_tasks;
2036 /* 2077 /*
2037 * This calls transport_add_tasks_from_cmd() to handle 2078 * __transport_execute_tasks() -> __transport_add_tasks_from_cmd()
2038 * HEAD_OF_QUEUE ordering for SAM Task Attribute emulation 2079 * adds associated se_tasks while holding dev->execute_task_lock
2039 * (if enabled) in __transport_add_task_to_execute_queue() and 2080 * before I/O dispath to avoid a double spinlock access.
2040 * transport_add_task_check_sam_attr().
2041 */ 2081 */
2042 transport_add_tasks_from_cmd(cmd); 2082 __transport_execute_tasks(se_dev, cmd);
2083 return 0;
2043 } 2084 }
2044 /* 2085
2045 * Kick the execution queue for the cmd associated struct se_device
2046 * storage object.
2047 */
2048execute_tasks: 2086execute_tasks:
2049 __transport_execute_tasks(cmd->se_dev); 2087 __transport_execute_tasks(se_dev, NULL);
2050 return 0; 2088 return 0;
2051} 2089}
2052 2090
@@ -2056,24 +2094,18 @@ execute_tasks:
2056 * 2094 *
2057 * Called from transport_processing_thread() 2095 * Called from transport_processing_thread()
2058 */ 2096 */
2059static int __transport_execute_tasks(struct se_device *dev) 2097static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *new_cmd)
2060{ 2098{
2061 int error; 2099 int error;
2062 struct se_cmd *cmd = NULL; 2100 struct se_cmd *cmd = NULL;
2063 struct se_task *task = NULL; 2101 struct se_task *task = NULL;
2064 unsigned long flags; 2102 unsigned long flags;
2065 2103
2066 /*
2067 * Check if there is enough room in the device and HBA queue to send
2068 * struct se_tasks to the selected transport.
2069 */
2070check_depth: 2104check_depth:
2071 if (!atomic_read(&dev->depth_left))
2072 return transport_tcq_window_closed(dev);
2073
2074 dev->dev_tcq_window_closed = 0;
2075
2076 spin_lock_irq(&dev->execute_task_lock); 2105 spin_lock_irq(&dev->execute_task_lock);
2106 if (new_cmd != NULL)
2107 __transport_add_tasks_from_cmd(new_cmd);
2108
2077 if (list_empty(&dev->execute_task_list)) { 2109 if (list_empty(&dev->execute_task_list)) {
2078 spin_unlock_irq(&dev->execute_task_lock); 2110 spin_unlock_irq(&dev->execute_task_lock);
2079 return 0; 2111 return 0;
@@ -2083,10 +2115,7 @@ check_depth:
2083 __transport_remove_task_from_execute_queue(task, dev); 2115 __transport_remove_task_from_execute_queue(task, dev);
2084 spin_unlock_irq(&dev->execute_task_lock); 2116 spin_unlock_irq(&dev->execute_task_lock);
2085 2117
2086 atomic_dec(&dev->depth_left);
2087
2088 cmd = task->task_se_cmd; 2118 cmd = task->task_se_cmd;
2089
2090 spin_lock_irqsave(&cmd->t_state_lock, flags); 2119 spin_lock_irqsave(&cmd->t_state_lock, flags);
2091 task->task_flags |= (TF_ACTIVE | TF_SENT); 2120 task->task_flags |= (TF_ACTIVE | TF_SENT);
2092 atomic_inc(&cmd->t_task_cdbs_sent); 2121 atomic_inc(&cmd->t_task_cdbs_sent);
@@ -2107,10 +2136,10 @@ check_depth:
2107 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2136 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2108 atomic_set(&cmd->t_transport_sent, 0); 2137 atomic_set(&cmd->t_transport_sent, 0);
2109 transport_stop_tasks_for_cmd(cmd); 2138 transport_stop_tasks_for_cmd(cmd);
2110 atomic_inc(&dev->depth_left);
2111 transport_generic_request_failure(cmd); 2139 transport_generic_request_failure(cmd);
2112 } 2140 }
2113 2141
2142 new_cmd = NULL;
2114 goto check_depth; 2143 goto check_depth;
2115 2144
2116 return 0; 2145 return 0;
@@ -2351,7 +2380,7 @@ static int transport_get_sense_data(struct se_cmd *cmd)
2351 2380
2352 list_for_each_entry_safe(task, task_tmp, 2381 list_for_each_entry_safe(task, task_tmp,
2353 &cmd->t_task_list, t_list) { 2382 &cmd->t_task_list, t_list) {
2354 if (!task->task_sense) 2383 if (!(task->task_flags & TF_HAS_SENSE))
2355 continue; 2384 continue;
2356 2385
2357 if (!dev->transport->get_sense_buffer) { 2386 if (!dev->transport->get_sense_buffer) {
@@ -3346,6 +3375,32 @@ static inline void transport_free_pages(struct se_cmd *cmd)
3346} 3375}
3347 3376
3348/** 3377/**
3378 * transport_release_cmd - free a command
3379 * @cmd: command to free
3380 *
3381 * This routine unconditionally frees a command, and reference counting
3382 * or list removal must be done in the caller.
3383 */
3384static void transport_release_cmd(struct se_cmd *cmd)
3385{
3386 BUG_ON(!cmd->se_tfo);
3387
3388 if (cmd->se_tmr_req)
3389 core_tmr_release_req(cmd->se_tmr_req);
3390 if (cmd->t_task_cdb != cmd->__t_task_cdb)
3391 kfree(cmd->t_task_cdb);
3392 /*
3393 * If this cmd has been setup with target_get_sess_cmd(), drop
3394 * the kref and call ->release_cmd() in kref callback.
3395 */
3396 if (cmd->check_release != 0) {
3397 target_put_sess_cmd(cmd->se_sess, cmd);
3398 return;
3399 }
3400 cmd->se_tfo->release_cmd(cmd);
3401}
3402
3403/**
3349 * transport_put_cmd - release a reference to a command 3404 * transport_put_cmd - release a reference to a command
3350 * @cmd: command to release 3405 * @cmd: command to release
3351 * 3406 *
@@ -3870,33 +3925,6 @@ queue_full:
3870 return 0; 3925 return 0;
3871} 3926}
3872 3927
3873/**
3874 * transport_release_cmd - free a command
3875 * @cmd: command to free
3876 *
3877 * This routine unconditionally frees a command, and reference counting
3878 * or list removal must be done in the caller.
3879 */
3880void transport_release_cmd(struct se_cmd *cmd)
3881{
3882 BUG_ON(!cmd->se_tfo);
3883
3884 if (cmd->se_tmr_req)
3885 core_tmr_release_req(cmd->se_tmr_req);
3886 if (cmd->t_task_cdb != cmd->__t_task_cdb)
3887 kfree(cmd->t_task_cdb);
3888 /*
3889 * Check if target_wait_for_sess_cmds() is expecting to
3890 * release se_cmd directly here..
3891 */
3892 if (cmd->check_release != 0 && cmd->se_tfo->check_release_cmd)
3893 if (cmd->se_tfo->check_release_cmd(cmd) != 0)
3894 return;
3895
3896 cmd->se_tfo->release_cmd(cmd);
3897}
3898EXPORT_SYMBOL(transport_release_cmd);
3899
3900void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) 3928void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
3901{ 3929{
3902 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { 3930 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
@@ -3923,11 +3951,22 @@ EXPORT_SYMBOL(transport_generic_free_cmd);
3923/* target_get_sess_cmd - Add command to active ->sess_cmd_list 3951/* target_get_sess_cmd - Add command to active ->sess_cmd_list
3924 * @se_sess: session to reference 3952 * @se_sess: session to reference
3925 * @se_cmd: command descriptor to add 3953 * @se_cmd: command descriptor to add
3954 * @ack_kref: Signal that fabric will perform an ack target_put_sess_cmd()
3926 */ 3955 */
3927void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) 3956void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
3957 bool ack_kref)
3928{ 3958{
3929 unsigned long flags; 3959 unsigned long flags;
3930 3960
3961 kref_init(&se_cmd->cmd_kref);
3962 /*
3963 * Add a second kref if the fabric caller is expecting to handle
3964 * fabric acknowledgement that requires two target_put_sess_cmd()
3965 * invocations before se_cmd descriptor release.
3966 */
3967 if (ack_kref == true)
3968 kref_get(&se_cmd->cmd_kref);
3969
3931 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); 3970 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
3932 list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); 3971 list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list);
3933 se_cmd->check_release = 1; 3972 se_cmd->check_release = 1;
@@ -3935,30 +3974,36 @@ void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
3935} 3974}
3936EXPORT_SYMBOL(target_get_sess_cmd); 3975EXPORT_SYMBOL(target_get_sess_cmd);
3937 3976
3938/* target_put_sess_cmd - Check for active I/O shutdown or list delete 3977static void target_release_cmd_kref(struct kref *kref)
3939 * @se_sess: session to reference
3940 * @se_cmd: command descriptor to drop
3941 */
3942int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
3943{ 3978{
3979 struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref);
3980 struct se_session *se_sess = se_cmd->se_sess;
3944 unsigned long flags; 3981 unsigned long flags;
3945 3982
3946 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); 3983 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
3947 if (list_empty(&se_cmd->se_cmd_list)) { 3984 if (list_empty(&se_cmd->se_cmd_list)) {
3948 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 3985 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
3949 WARN_ON(1); 3986 WARN_ON(1);
3950 return 0; 3987 return;
3951 } 3988 }
3952
3953 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { 3989 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) {
3954 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 3990 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
3955 complete(&se_cmd->cmd_wait_comp); 3991 complete(&se_cmd->cmd_wait_comp);
3956 return 1; 3992 return;
3957 } 3993 }
3958 list_del(&se_cmd->se_cmd_list); 3994 list_del(&se_cmd->se_cmd_list);
3959 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 3995 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
3960 3996
3961 return 0; 3997 se_cmd->se_tfo->release_cmd(se_cmd);
3998}
3999
4000/* target_put_sess_cmd - Check for active I/O shutdown via kref_put
4001 * @se_sess: session to reference
4002 * @se_cmd: command descriptor to drop
4003 */
4004int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
4005{
4006 return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref);
3962} 4007}
3963EXPORT_SYMBOL(target_put_sess_cmd); 4008EXPORT_SYMBOL(target_put_sess_cmd);
3964 4009
@@ -4174,7 +4219,7 @@ check_cond:
4174 4219
4175static int transport_clear_lun_thread(void *p) 4220static int transport_clear_lun_thread(void *p)
4176{ 4221{
4177 struct se_lun *lun = (struct se_lun *)p; 4222 struct se_lun *lun = p;
4178 4223
4179 __transport_clear_lun_from_sessions(lun); 4224 __transport_clear_lun_from_sessions(lun);
4180 complete(&lun->lun_shutdown_comp); 4225 complete(&lun->lun_shutdown_comp);
@@ -4353,6 +4398,7 @@ int transport_send_check_condition_and_sense(
4353 case TCM_NON_EXISTENT_LUN: 4398 case TCM_NON_EXISTENT_LUN:
4354 /* CURRENT ERROR */ 4399 /* CURRENT ERROR */
4355 buffer[offset] = 0x70; 4400 buffer[offset] = 0x70;
4401 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4356 /* ILLEGAL REQUEST */ 4402 /* ILLEGAL REQUEST */
4357 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; 4403 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4358 /* LOGICAL UNIT NOT SUPPORTED */ 4404 /* LOGICAL UNIT NOT SUPPORTED */
@@ -4362,6 +4408,7 @@ int transport_send_check_condition_and_sense(
4362 case TCM_SECTOR_COUNT_TOO_MANY: 4408 case TCM_SECTOR_COUNT_TOO_MANY:
4363 /* CURRENT ERROR */ 4409 /* CURRENT ERROR */
4364 buffer[offset] = 0x70; 4410 buffer[offset] = 0x70;
4411 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4365 /* ILLEGAL REQUEST */ 4412 /* ILLEGAL REQUEST */
4366 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; 4413 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4367 /* INVALID COMMAND OPERATION CODE */ 4414 /* INVALID COMMAND OPERATION CODE */
@@ -4370,6 +4417,7 @@ int transport_send_check_condition_and_sense(
4370 case TCM_UNKNOWN_MODE_PAGE: 4417 case TCM_UNKNOWN_MODE_PAGE:
4371 /* CURRENT ERROR */ 4418 /* CURRENT ERROR */
4372 buffer[offset] = 0x70; 4419 buffer[offset] = 0x70;
4420 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4373 /* ILLEGAL REQUEST */ 4421 /* ILLEGAL REQUEST */
4374 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; 4422 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4375 /* INVALID FIELD IN CDB */ 4423 /* INVALID FIELD IN CDB */
@@ -4378,6 +4426,7 @@ int transport_send_check_condition_and_sense(
4378 case TCM_CHECK_CONDITION_ABORT_CMD: 4426 case TCM_CHECK_CONDITION_ABORT_CMD:
4379 /* CURRENT ERROR */ 4427 /* CURRENT ERROR */
4380 buffer[offset] = 0x70; 4428 buffer[offset] = 0x70;
4429 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4381 /* ABORTED COMMAND */ 4430 /* ABORTED COMMAND */
4382 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4431 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4383 /* BUS DEVICE RESET FUNCTION OCCURRED */ 4432 /* BUS DEVICE RESET FUNCTION OCCURRED */
@@ -4387,6 +4436,7 @@ int transport_send_check_condition_and_sense(
4387 case TCM_INCORRECT_AMOUNT_OF_DATA: 4436 case TCM_INCORRECT_AMOUNT_OF_DATA:
4388 /* CURRENT ERROR */ 4437 /* CURRENT ERROR */
4389 buffer[offset] = 0x70; 4438 buffer[offset] = 0x70;
4439 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4390 /* ABORTED COMMAND */ 4440 /* ABORTED COMMAND */
4391 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4441 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4392 /* WRITE ERROR */ 4442 /* WRITE ERROR */
@@ -4397,6 +4447,7 @@ int transport_send_check_condition_and_sense(
4397 case TCM_INVALID_CDB_FIELD: 4447 case TCM_INVALID_CDB_FIELD:
4398 /* CURRENT ERROR */ 4448 /* CURRENT ERROR */
4399 buffer[offset] = 0x70; 4449 buffer[offset] = 0x70;
4450 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4400 /* ABORTED COMMAND */ 4451 /* ABORTED COMMAND */
4401 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4452 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4402 /* INVALID FIELD IN CDB */ 4453 /* INVALID FIELD IN CDB */
@@ -4405,6 +4456,7 @@ int transport_send_check_condition_and_sense(
4405 case TCM_INVALID_PARAMETER_LIST: 4456 case TCM_INVALID_PARAMETER_LIST:
4406 /* CURRENT ERROR */ 4457 /* CURRENT ERROR */
4407 buffer[offset] = 0x70; 4458 buffer[offset] = 0x70;
4459 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4408 /* ABORTED COMMAND */ 4460 /* ABORTED COMMAND */
4409 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4461 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4410 /* INVALID FIELD IN PARAMETER LIST */ 4462 /* INVALID FIELD IN PARAMETER LIST */
@@ -4413,6 +4465,7 @@ int transport_send_check_condition_and_sense(
4413 case TCM_UNEXPECTED_UNSOLICITED_DATA: 4465 case TCM_UNEXPECTED_UNSOLICITED_DATA:
4414 /* CURRENT ERROR */ 4466 /* CURRENT ERROR */
4415 buffer[offset] = 0x70; 4467 buffer[offset] = 0x70;
4468 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4416 /* ABORTED COMMAND */ 4469 /* ABORTED COMMAND */
4417 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4470 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4418 /* WRITE ERROR */ 4471 /* WRITE ERROR */
@@ -4423,6 +4476,7 @@ int transport_send_check_condition_and_sense(
4423 case TCM_SERVICE_CRC_ERROR: 4476 case TCM_SERVICE_CRC_ERROR:
4424 /* CURRENT ERROR */ 4477 /* CURRENT ERROR */
4425 buffer[offset] = 0x70; 4478 buffer[offset] = 0x70;
4479 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4426 /* ABORTED COMMAND */ 4480 /* ABORTED COMMAND */
4427 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4481 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4428 /* PROTOCOL SERVICE CRC ERROR */ 4482 /* PROTOCOL SERVICE CRC ERROR */
@@ -4433,6 +4487,7 @@ int transport_send_check_condition_and_sense(
4433 case TCM_SNACK_REJECTED: 4487 case TCM_SNACK_REJECTED:
4434 /* CURRENT ERROR */ 4488 /* CURRENT ERROR */
4435 buffer[offset] = 0x70; 4489 buffer[offset] = 0x70;
4490 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4436 /* ABORTED COMMAND */ 4491 /* ABORTED COMMAND */
4437 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; 4492 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
4438 /* READ ERROR */ 4493 /* READ ERROR */
@@ -4443,6 +4498,7 @@ int transport_send_check_condition_and_sense(
4443 case TCM_WRITE_PROTECTED: 4498 case TCM_WRITE_PROTECTED:
4444 /* CURRENT ERROR */ 4499 /* CURRENT ERROR */
4445 buffer[offset] = 0x70; 4500 buffer[offset] = 0x70;
4501 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4446 /* DATA PROTECT */ 4502 /* DATA PROTECT */
4447 buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; 4503 buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT;
4448 /* WRITE PROTECTED */ 4504 /* WRITE PROTECTED */
@@ -4451,6 +4507,7 @@ int transport_send_check_condition_and_sense(
4451 case TCM_CHECK_CONDITION_UNIT_ATTENTION: 4507 case TCM_CHECK_CONDITION_UNIT_ATTENTION:
4452 /* CURRENT ERROR */ 4508 /* CURRENT ERROR */
4453 buffer[offset] = 0x70; 4509 buffer[offset] = 0x70;
4510 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4454 /* UNIT ATTENTION */ 4511 /* UNIT ATTENTION */
4455 buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; 4512 buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;
4456 core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); 4513 core_scsi3_ua_for_check_condition(cmd, &asc, &ascq);
@@ -4460,6 +4517,7 @@ int transport_send_check_condition_and_sense(
4460 case TCM_CHECK_CONDITION_NOT_READY: 4517 case TCM_CHECK_CONDITION_NOT_READY:
4461 /* CURRENT ERROR */ 4518 /* CURRENT ERROR */
4462 buffer[offset] = 0x70; 4519 buffer[offset] = 0x70;
4520 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4463 /* Not Ready */ 4521 /* Not Ready */
4464 buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; 4522 buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY;
4465 transport_get_sense_codes(cmd, &asc, &ascq); 4523 transport_get_sense_codes(cmd, &asc, &ascq);
@@ -4470,6 +4528,7 @@ int transport_send_check_condition_and_sense(
4470 default: 4528 default:
4471 /* CURRENT ERROR */ 4529 /* CURRENT ERROR */
4472 buffer[offset] = 0x70; 4530 buffer[offset] = 0x70;
4531 buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
4473 /* ILLEGAL REQUEST */ 4532 /* ILLEGAL REQUEST */
4474 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; 4533 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4475 /* LOGICAL UNIT COMMUNICATION FAILURE */ 4534 /* LOGICAL UNIT COMMUNICATION FAILURE */
@@ -4545,11 +4604,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
4545 cmd->se_tfo->queue_status(cmd); 4604 cmd->se_tfo->queue_status(cmd);
4546} 4605}
4547 4606
4548/* transport_generic_do_tmr(): 4607static int transport_generic_do_tmr(struct se_cmd *cmd)
4549 *
4550 *
4551 */
4552int transport_generic_do_tmr(struct se_cmd *cmd)
4553{ 4608{
4554 struct se_device *dev = cmd->se_dev; 4609 struct se_device *dev = cmd->se_dev;
4555 struct se_tmr_req *tmr = cmd->se_tmr_req; 4610 struct se_tmr_req *tmr = cmd->se_tmr_req;
@@ -4597,7 +4652,7 @@ static int transport_processing_thread(void *param)
4597{ 4652{
4598 int ret; 4653 int ret;
4599 struct se_cmd *cmd; 4654 struct se_cmd *cmd;
4600 struct se_device *dev = (struct se_device *) param; 4655 struct se_device *dev = param;
4601 4656
4602 while (!kthread_should_stop()) { 4657 while (!kthread_should_stop()) {
4603 ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq, 4658 ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq,
@@ -4607,8 +4662,6 @@ static int transport_processing_thread(void *param)
4607 goto out; 4662 goto out;
4608 4663
4609get_cmd: 4664get_cmd:
4610 __transport_execute_tasks(dev);
4611
4612 cmd = transport_get_cmd_from_queue(&dev->dev_queue_obj); 4665 cmd = transport_get_cmd_from_queue(&dev->dev_queue_obj);
4613 if (!cmd) 4666 if (!cmd)
4614 continue; 4667 continue;
diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c
index 50a480db7a66..3e12f6bcfa10 100644
--- a/drivers/target/target_core_ua.c
+++ b/drivers/target/target_core_ua.c
@@ -30,13 +30,11 @@
30#include <scsi/scsi_cmnd.h> 30#include <scsi/scsi_cmnd.h>
31 31
32#include <target/target_core_base.h> 32#include <target/target_core_base.h>
33#include <target/target_core_device.h> 33#include <target/target_core_fabric.h>
34#include <target/target_core_transport.h>
35#include <target/target_core_fabric_ops.h>
36#include <target/target_core_configfs.h> 34#include <target/target_core_configfs.h>
37 35
36#include "target_core_internal.h"
38#include "target_core_alua.h" 37#include "target_core_alua.h"
39#include "target_core_hba.h"
40#include "target_core_pr.h" 38#include "target_core_pr.h"
41#include "target_core_ua.h" 39#include "target_core_ua.h"
42 40
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 71fc9cea5dc9..addc18f727ea 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -39,12 +39,8 @@
39#include <scsi/fc_encode.h> 39#include <scsi/fc_encode.h>
40 40
41#include <target/target_core_base.h> 41#include <target/target_core_base.h>
42#include <target/target_core_transport.h> 42#include <target/target_core_fabric.h>
43#include <target/target_core_fabric_ops.h>
44#include <target/target_core_device.h>
45#include <target/target_core_tpg.h>
46#include <target/target_core_configfs.h> 43#include <target/target_core_configfs.h>
47#include <target/target_core_tmr.h>
48#include <target/configfs_macros.h> 44#include <target/configfs_macros.h>
49 45
50#include "tcm_fc.h" 46#include "tcm_fc.h"
@@ -367,6 +363,11 @@ static void ft_send_tm(struct ft_cmd *cmd)
367 struct ft_sess *sess; 363 struct ft_sess *sess;
368 u8 tm_func; 364 u8 tm_func;
369 365
366 transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops,
367 cmd->sess->se_sess, 0, DMA_NONE, 0,
368 &cmd->ft_sense_buffer[0]);
369 target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false);
370
370 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); 371 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp));
371 372
372 switch (fcp->fc_tm_flags) { 373 switch (fcp->fc_tm_flags) {
@@ -420,7 +421,6 @@ static void ft_send_tm(struct ft_cmd *cmd)
420 sess = cmd->sess; 421 sess = cmd->sess;
421 transport_send_check_condition_and_sense(&cmd->se_cmd, 422 transport_send_check_condition_and_sense(&cmd->se_cmd,
422 cmd->se_cmd.scsi_sense_reason, 0); 423 cmd->se_cmd.scsi_sense_reason, 0);
423 transport_generic_free_cmd(&cmd->se_cmd, 0);
424 ft_sess_put(sess); 424 ft_sess_put(sess);
425 return; 425 return;
426 } 426 }
@@ -536,7 +536,6 @@ static void ft_send_work(struct work_struct *work)
536{ 536{
537 struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); 537 struct ft_cmd *cmd = container_of(work, struct ft_cmd, work);
538 struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); 538 struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame);
539 struct se_cmd *se_cmd;
540 struct fcp_cmnd *fcp; 539 struct fcp_cmnd *fcp;
541 int data_dir = 0; 540 int data_dir = 0;
542 u32 data_len; 541 u32 data_len;
@@ -591,15 +590,6 @@ static void ft_send_work(struct work_struct *work)
591 data_len = ntohl(fcp->fc_dl); 590 data_len = ntohl(fcp->fc_dl);
592 cmd->cdb = fcp->fc_cdb; 591 cmd->cdb = fcp->fc_cdb;
593 } 592 }
594
595 se_cmd = &cmd->se_cmd;
596 /*
597 * Initialize struct se_cmd descriptor from target_core_mod
598 * infrastructure
599 */
600 transport_init_se_cmd(se_cmd, &ft_configfs->tf_ops, cmd->sess->se_sess,
601 data_len, data_dir, task_attr,
602 &cmd->ft_sense_buffer[0]);
603 /* 593 /*
604 * Check for FCP task management flags 594 * Check for FCP task management flags
605 */ 595 */
@@ -607,39 +597,20 @@ static void ft_send_work(struct work_struct *work)
607 ft_send_tm(cmd); 597 ft_send_tm(cmd);
608 return; 598 return;
609 } 599 }
610
611 fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); 600 fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd);
612
613 cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); 601 cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
614 ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun); 602 /*
603 * Use a single se_cmd->cmd_kref as we expect to release se_cmd
604 * directly from ft_check_stop_free callback in response path.
605 */
606 ret = target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb,
607 &cmd->ft_sense_buffer[0], cmd->lun, data_len,
608 task_attr, data_dir, 0);
609 pr_debug("r_ctl %x alloc target_submit_cmd %d\n", fh->fh_r_ctl, ret);
615 if (ret < 0) { 610 if (ret < 0) {
616 ft_dump_cmd(cmd, __func__); 611 ft_dump_cmd(cmd, __func__);
617 transport_send_check_condition_and_sense(&cmd->se_cmd,
618 cmd->se_cmd.scsi_sense_reason, 0);
619 return;
620 }
621
622 ret = transport_generic_allocate_tasks(se_cmd, cmd->cdb);
623
624 pr_debug("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
625 ft_dump_cmd(cmd, __func__);
626
627 if (ret == -ENOMEM) {
628 transport_send_check_condition_and_sense(se_cmd,
629 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
630 transport_generic_free_cmd(se_cmd, 0);
631 return;
632 }
633 if (ret == -EINVAL) {
634 if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
635 ft_queue_status(se_cmd);
636 else
637 transport_send_check_condition_and_sense(se_cmd,
638 se_cmd->scsi_sense_reason, 0);
639 transport_generic_free_cmd(se_cmd, 0);
640 return; 612 return;
641 } 613 }
642 transport_handle_cdb_direct(se_cmd);
643 return; 614 return;
644 615
645err: 616err:
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 9402b7387cac..73852fbc857b 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -41,12 +41,8 @@
41#include <scsi/libfc.h> 41#include <scsi/libfc.h>
42 42
43#include <target/target_core_base.h> 43#include <target/target_core_base.h>
44#include <target/target_core_transport.h> 44#include <target/target_core_fabric.h>
45#include <target/target_core_fabric_ops.h>
46#include <target/target_core_fabric_configfs.h> 45#include <target/target_core_fabric_configfs.h>
47#include <target/target_core_fabric_lib.h>
48#include <target/target_core_device.h>
49#include <target/target_core_tpg.h>
50#include <target/target_core_configfs.h> 46#include <target/target_core_configfs.h>
51#include <target/configfs_macros.h> 47#include <target/configfs_macros.h>
52 48
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 1369b1cb103d..d8cabc21036d 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -48,10 +48,7 @@
48#include <scsi/fc_encode.h> 48#include <scsi/fc_encode.h>
49 49
50#include <target/target_core_base.h> 50#include <target/target_core_base.h>
51#include <target/target_core_transport.h> 51#include <target/target_core_fabric.h>
52#include <target/target_core_fabric_ops.h>
53#include <target/target_core_device.h>
54#include <target/target_core_tpg.h>
55#include <target/target_core_configfs.h> 52#include <target/target_core_configfs.h>
56#include <target/configfs_macros.h> 53#include <target/configfs_macros.h>
57 54
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index 326921385aff..4c0507cf808c 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -40,10 +40,7 @@
40#include <scsi/libfc.h> 40#include <scsi/libfc.h>
41 41
42#include <target/target_core_base.h> 42#include <target/target_core_base.h>
43#include <target/target_core_transport.h> 43#include <target/target_core_fabric.h>
44#include <target/target_core_fabric_ops.h>
45#include <target/target_core_device.h>
46#include <target/target_core_tpg.h>
47#include <target/target_core_configfs.h> 44#include <target/target_core_configfs.h>
48#include <target/configfs_macros.h> 45#include <target/configfs_macros.h>
49 46
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
new file mode 100644
index 000000000000..4866499bdeeb
--- /dev/null
+++ b/include/target/target_core_backend.h
@@ -0,0 +1,65 @@
1#ifndef TARGET_CORE_BACKEND_H
2#define TARGET_CORE_BACKEND_H
3
4#define TRANSPORT_PLUGIN_PHBA_PDEV 1
5#define TRANSPORT_PLUGIN_VHBA_PDEV 2
6#define TRANSPORT_PLUGIN_VHBA_VDEV 3
7
8struct se_subsystem_api {
9 struct list_head sub_api_list;
10
11 char name[16];
12 struct module *owner;
13
14 u8 transport_type;
15
16 unsigned int fua_write_emulated : 1;
17 unsigned int write_cache_emulated : 1;
18
19 int (*attach_hba)(struct se_hba *, u32);
20 void (*detach_hba)(struct se_hba *);
21 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
22 void *(*allocate_virtdevice)(struct se_hba *, const char *);
23 struct se_device *(*create_virtdevice)(struct se_hba *,
24 struct se_subsystem_dev *, void *);
25 void (*free_device)(void *);
26 int (*transport_complete)(struct se_task *task);
27 struct se_task *(*alloc_task)(unsigned char *cdb);
28 int (*do_task)(struct se_task *);
29 int (*do_discard)(struct se_device *, sector_t, u32);
30 void (*do_sync_cache)(struct se_task *);
31 void (*free_task)(struct se_task *);
32 ssize_t (*check_configfs_dev_params)(struct se_hba *,
33 struct se_subsystem_dev *);
34 ssize_t (*set_configfs_dev_params)(struct se_hba *,
35 struct se_subsystem_dev *, const char *, ssize_t);
36 ssize_t (*show_configfs_dev_params)(struct se_hba *,
37 struct se_subsystem_dev *, char *);
38 u32 (*get_device_rev)(struct se_device *);
39 u32 (*get_device_type)(struct se_device *);
40 sector_t (*get_blocks)(struct se_device *);
41 unsigned char *(*get_sense_buffer)(struct se_task *);
42};
43
44int transport_subsystem_register(struct se_subsystem_api *);
45void transport_subsystem_release(struct se_subsystem_api *);
46
47struct se_device *transport_add_device_to_core_hba(struct se_hba *,
48 struct se_subsystem_api *, struct se_subsystem_dev *, u32,
49 void *, struct se_dev_limits *, const char *, const char *);
50
51void transport_complete_sync_cache(struct se_cmd *, int);
52void transport_complete_task(struct se_task *, int);
53
54void target_get_task_cdb(struct se_task *, unsigned char *);
55
56void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
57int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
58int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
59int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
60
61/* core helpers also used by command snooping in pscsi */
62void *transport_kmap_first_data_page(struct se_cmd *);
63void transport_kunmap_first_data_page(struct se_cmd *);
64
65#endif /* TARGET_CORE_BACKEND_H */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 6873c7dd9145..daf532bc721a 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -10,6 +10,7 @@
10#include <net/tcp.h> 10#include <net/tcp.h>
11 11
12#define TARGET_CORE_MOD_VERSION "v4.1.0-rc1-ml" 12#define TARGET_CORE_MOD_VERSION "v4.1.0-rc1-ml"
13#define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION
13 14
14/* Maximum Number of LUNs per Target Portal Group */ 15/* Maximum Number of LUNs per Target Portal Group */
15/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */ 16/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */
@@ -34,6 +35,7 @@
34#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE 35#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE
35/* Used by transport_send_check_condition_and_sense() */ 36/* Used by transport_send_check_condition_and_sense() */
36#define SPC_SENSE_KEY_OFFSET 2 37#define SPC_SENSE_KEY_OFFSET 2
38#define SPC_ADD_SENSE_LEN_OFFSET 7
37#define SPC_ASC_KEY_OFFSET 12 39#define SPC_ASC_KEY_OFFSET 12
38#define SPC_ASCQ_KEY_OFFSET 13 40#define SPC_ASCQ_KEY_OFFSET 13
39#define TRANSPORT_IQN_LEN 224 41#define TRANSPORT_IQN_LEN 224
@@ -53,6 +55,72 @@
53/* Used by transport_get_inquiry_vpd_device_ident() */ 55/* Used by transport_get_inquiry_vpd_device_ident() */
54#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254 56#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254
55 57
58/* Attempts before moving from SHORT to LONG */
59#define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
60#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
61#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG 10 /* In milliseconds */
62
63#define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */
64
65/*
66 * struct se_subsystem_dev->su_dev_flags
67*/
68#define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001
69#define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002
70#define SDF_USING_UDEV_PATH 0x00000004
71#define SDF_USING_ALIAS 0x00000008
72
73/*
74 * struct se_device->dev_flags
75 */
76#define DF_READ_ONLY 0x00000001
77#define DF_SPC2_RESERVATIONS 0x00000002
78#define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
79
80/* struct se_dev_attrib sanity values */
81/* Default max_unmap_lba_count */
82#define DA_MAX_UNMAP_LBA_COUNT 0
83/* Default max_unmap_block_desc_count */
84#define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
85/* Default unmap_granularity */
86#define DA_UNMAP_GRANULARITY_DEFAULT 0
87/* Default unmap_granularity_alignment */
88#define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
89/* Emulation for Direct Page Out */
90#define DA_EMULATE_DPO 0
91/* Emulation for Forced Unit Access WRITEs */
92#define DA_EMULATE_FUA_WRITE 1
93/* Emulation for Forced Unit Access READs */
94#define DA_EMULATE_FUA_READ 0
95/* Emulation for WriteCache and SYNCHRONIZE_CACHE */
96#define DA_EMULATE_WRITE_CACHE 0
97/* Emulation for UNIT ATTENTION Interlock Control */
98#define DA_EMULATE_UA_INTLLCK_CTRL 0
99/* Emulation for TASK_ABORTED status (TAS) by default */
100#define DA_EMULATE_TAS 1
101/* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
102#define DA_EMULATE_TPU 0
103/*
104 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
105 * block/blk-lib.c:blkdev_issue_discard()
106 */
107#define DA_EMULATE_TPWS 0
108/* No Emulation for PSCSI by default */
109#define DA_EMULATE_RESERVATIONS 0
110/* No Emulation for PSCSI by default */
111#define DA_EMULATE_ALUA 0
112/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
113#define DA_ENFORCE_PR_ISIDS 1
114#define DA_STATUS_MAX_SECTORS_MIN 16
115#define DA_STATUS_MAX_SECTORS_MAX 8192
116/* By default don't report non-rotating (solid state) medium */
117#define DA_IS_NONROT 0
118/* Queue Algorithm Modifier default for restricted reordering in control mode page */
119#define DA_EMULATE_REST_REORD 0
120
121#define SE_MODE_PAGE_BUF 512
122
123
56/* struct se_hba->hba_flags */ 124/* struct se_hba->hba_flags */
57enum hba_flags_table { 125enum hba_flags_table {
58 HBA_FLAGS_INTERNAL_USE = 0x01, 126 HBA_FLAGS_INTERNAL_USE = 0x01,
@@ -71,11 +139,12 @@ enum transport_tpg_type_table {
71 TRANSPORT_TPG_TYPE_DISCOVERY = 1, 139 TRANSPORT_TPG_TYPE_DISCOVERY = 1,
72}; 140};
73 141
74/* Used for generate timer flags */ 142/* struct se_task->task_flags */
75enum se_task_flags { 143enum se_task_flags {
76 TF_ACTIVE = (1 << 0), 144 TF_ACTIVE = (1 << 0),
77 TF_SENT = (1 << 1), 145 TF_SENT = (1 << 1),
78 TF_REQUEST_STOP = (1 << 2), 146 TF_REQUEST_STOP = (1 << 2),
147 TF_HAS_SENSE = (1 << 3),
79}; 148};
80 149
81/* Special transport agnostic struct se_cmd->t_states */ 150/* Special transport agnostic struct se_cmd->t_states */
@@ -158,9 +227,38 @@ enum tcm_sense_reason_table {
158 TCM_RESERVATION_CONFLICT = 0x10, 227 TCM_RESERVATION_CONFLICT = 0x10,
159}; 228};
160 229
230enum target_sc_flags_table {
231 TARGET_SCF_BIDI_OP = 0x01,
232 TARGET_SCF_ACK_KREF = 0x02,
233};
234
235/* fabric independent task management function values */
236enum tcm_tmreq_table {
237 TMR_ABORT_TASK = 1,
238 TMR_ABORT_TASK_SET = 2,
239 TMR_CLEAR_ACA = 3,
240 TMR_CLEAR_TASK_SET = 4,
241 TMR_LUN_RESET = 5,
242 TMR_TARGET_WARM_RESET = 6,
243 TMR_TARGET_COLD_RESET = 7,
244 TMR_FABRIC_TMR = 255,
245};
246
247/* fabric independent task management response values */
248enum tcm_tmrsp_table {
249 TMR_FUNCTION_COMPLETE = 0,
250 TMR_TASK_DOES_NOT_EXIST = 1,
251 TMR_LUN_DOES_NOT_EXIST = 2,
252 TMR_TASK_STILL_ALLEGIANT = 3,
253 TMR_TASK_FAILOVER_NOT_SUPPORTED = 4,
254 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 5,
255 TMR_FUNCTION_AUTHORIZATION_FAILED = 6,
256 TMR_FUNCTION_REJECTED = 255,
257};
258
161struct se_obj { 259struct se_obj {
162 atomic_t obj_access_count; 260 atomic_t obj_access_count;
163} ____cacheline_aligned; 261};
164 262
165/* 263/*
166 * Used by TCM Core internally to signal if ALUA emulation is enabled or 264 * Used by TCM Core internally to signal if ALUA emulation is enabled or
@@ -207,7 +305,7 @@ struct t10_alua {
207 struct config_group alua_tg_pt_gps_group; 305 struct config_group alua_tg_pt_gps_group;
208 int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *); 306 int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *);
209 struct list_head tg_pt_gps_list; 307 struct list_head tg_pt_gps_list;
210} ____cacheline_aligned; 308};
211 309
212struct t10_alua_lu_gp { 310struct t10_alua_lu_gp {
213 u16 lu_gp_id; 311 u16 lu_gp_id;
@@ -218,7 +316,7 @@ struct t10_alua_lu_gp {
218 struct config_group lu_gp_group; 316 struct config_group lu_gp_group;
219 struct list_head lu_gp_node; 317 struct list_head lu_gp_node;
220 struct list_head lu_gp_mem_list; 318 struct list_head lu_gp_mem_list;
221} ____cacheline_aligned; 319};
222 320
223struct t10_alua_lu_gp_member { 321struct t10_alua_lu_gp_member {
224 bool lu_gp_assoc; 322 bool lu_gp_assoc;
@@ -227,7 +325,7 @@ struct t10_alua_lu_gp_member {
227 struct t10_alua_lu_gp *lu_gp; 325 struct t10_alua_lu_gp *lu_gp;
228 struct se_device *lu_gp_mem_dev; 326 struct se_device *lu_gp_mem_dev;
229 struct list_head lu_gp_mem_list; 327 struct list_head lu_gp_mem_list;
230} ____cacheline_aligned; 328};
231 329
232struct t10_alua_tg_pt_gp { 330struct t10_alua_tg_pt_gp {
233 u16 tg_pt_gp_id; 331 u16 tg_pt_gp_id;
@@ -250,7 +348,7 @@ struct t10_alua_tg_pt_gp {
250 struct config_group tg_pt_gp_group; 348 struct config_group tg_pt_gp_group;
251 struct list_head tg_pt_gp_list; 349 struct list_head tg_pt_gp_list;
252 struct list_head tg_pt_gp_mem_list; 350 struct list_head tg_pt_gp_mem_list;
253} ____cacheline_aligned; 351};
254 352
255struct t10_alua_tg_pt_gp_member { 353struct t10_alua_tg_pt_gp_member {
256 bool tg_pt_gp_assoc; 354 bool tg_pt_gp_assoc;
@@ -259,7 +357,7 @@ struct t10_alua_tg_pt_gp_member {
259 struct t10_alua_tg_pt_gp *tg_pt_gp; 357 struct t10_alua_tg_pt_gp *tg_pt_gp;
260 struct se_port *tg_pt; 358 struct se_port *tg_pt;
261 struct list_head tg_pt_gp_mem_list; 359 struct list_head tg_pt_gp_mem_list;
262} ____cacheline_aligned; 360};
263 361
264struct t10_vpd { 362struct t10_vpd {
265 unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN]; 363 unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN];
@@ -269,7 +367,7 @@ struct t10_vpd {
269 u32 association; 367 u32 association;
270 u32 device_identifier_type; 368 u32 device_identifier_type;
271 struct list_head vpd_list; 369 struct list_head vpd_list;
272} ____cacheline_aligned; 370};
273 371
274struct t10_wwn { 372struct t10_wwn {
275 char vendor[8]; 373 char vendor[8];
@@ -280,7 +378,7 @@ struct t10_wwn {
280 struct se_subsystem_dev *t10_sub_dev; 378 struct se_subsystem_dev *t10_sub_dev;
281 struct config_group t10_wwn_group; 379 struct config_group t10_wwn_group;
282 struct list_head t10_vpd_list; 380 struct list_head t10_vpd_list;
283} ____cacheline_aligned; 381};
284 382
285 383
286/* 384/*
@@ -333,7 +431,7 @@ struct t10_pr_registration {
333 struct list_head pr_reg_aptpl_list; 431 struct list_head pr_reg_aptpl_list;
334 struct list_head pr_reg_atp_list; 432 struct list_head pr_reg_atp_list;
335 struct list_head pr_reg_atp_mem_list; 433 struct list_head pr_reg_atp_mem_list;
336} ____cacheline_aligned; 434};
337 435
338/* 436/*
339 * This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS, 437 * This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS,
@@ -374,20 +472,20 @@ struct t10_reservation {
374 struct list_head registration_list; 472 struct list_head registration_list;
375 struct list_head aptpl_reg_list; 473 struct list_head aptpl_reg_list;
376 struct t10_reservation_ops pr_ops; 474 struct t10_reservation_ops pr_ops;
377} ____cacheline_aligned; 475};
378 476
379struct se_queue_req { 477struct se_queue_req {
380 int state; 478 int state;
381 struct se_cmd *cmd; 479 struct se_cmd *cmd;
382 struct list_head qr_list; 480 struct list_head qr_list;
383} ____cacheline_aligned; 481};
384 482
385struct se_queue_obj { 483struct se_queue_obj {
386 atomic_t queue_cnt; 484 atomic_t queue_cnt;
387 spinlock_t cmd_queue_lock; 485 spinlock_t cmd_queue_lock;
388 struct list_head qobj_list; 486 struct list_head qobj_list;
389 wait_queue_head_t thread_wq; 487 wait_queue_head_t thread_wq;
390} ____cacheline_aligned; 488};
391 489
392struct se_task { 490struct se_task {
393 unsigned long long task_lba; 491 unsigned long long task_lba;
@@ -397,16 +495,14 @@ struct se_task {
397 struct scatterlist *task_sg; 495 struct scatterlist *task_sg;
398 u32 task_sg_nents; 496 u32 task_sg_nents;
399 u16 task_flags; 497 u16 task_flags;
400 u8 task_sense;
401 u8 task_scsi_status; 498 u8 task_scsi_status;
402 int task_error_status;
403 enum dma_data_direction task_data_direction; 499 enum dma_data_direction task_data_direction;
404 atomic_t task_state_active;
405 struct list_head t_list; 500 struct list_head t_list;
406 struct list_head t_execute_list; 501 struct list_head t_execute_list;
407 struct list_head t_state_list; 502 struct list_head t_state_list;
503 bool t_state_active;
408 struct completion task_stop_comp; 504 struct completion task_stop_comp;
409} ____cacheline_aligned; 505};
410 506
411struct se_cmd { 507struct se_cmd {
412 /* SAM response code being sent to initiator */ 508 /* SAM response code being sent to initiator */
@@ -451,6 +547,7 @@ struct se_cmd {
451 struct list_head se_queue_node; 547 struct list_head se_queue_node;
452 struct list_head se_cmd_list; 548 struct list_head se_cmd_list;
453 struct completion cmd_wait_comp; 549 struct completion cmd_wait_comp;
550 struct kref cmd_kref;
454 struct target_core_fabric_ops *se_tfo; 551 struct target_core_fabric_ops *se_tfo;
455 int (*execute_task)(struct se_task *); 552 int (*execute_task)(struct se_task *);
456 void (*transport_complete_callback)(struct se_cmd *); 553 void (*transport_complete_callback)(struct se_cmd *);
@@ -492,7 +589,7 @@ struct se_cmd {
492 struct list_head t_task_list; 589 struct list_head t_task_list;
493 u32 t_task_list_num; 590 u32 t_task_list_num;
494 591
495} ____cacheline_aligned; 592};
496 593
497struct se_tmr_req { 594struct se_tmr_req {
498 /* Task Management function to be preformed */ 595 /* Task Management function to be preformed */
@@ -510,7 +607,7 @@ struct se_tmr_req {
510 struct se_device *tmr_dev; 607 struct se_device *tmr_dev;
511 struct se_lun *tmr_lun; 608 struct se_lun *tmr_lun;
512 struct list_head tmr_list; 609 struct list_head tmr_list;
513} ____cacheline_aligned; 610};
514 611
515struct se_ua { 612struct se_ua {
516 u8 ua_asc; 613 u8 ua_asc;
@@ -518,7 +615,7 @@ struct se_ua {
518 struct se_node_acl *ua_nacl; 615 struct se_node_acl *ua_nacl;
519 struct list_head ua_dev_list; 616 struct list_head ua_dev_list;
520 struct list_head ua_nacl_list; 617 struct list_head ua_nacl_list;
521} ____cacheline_aligned; 618};
522 619
523struct se_node_acl { 620struct se_node_acl {
524 char initiatorname[TRANSPORT_IQN_LEN]; 621 char initiatorname[TRANSPORT_IQN_LEN];
@@ -545,7 +642,7 @@ struct se_node_acl {
545 struct config_group *acl_default_groups[5]; 642 struct config_group *acl_default_groups[5];
546 struct list_head acl_list; 643 struct list_head acl_list;
547 struct list_head acl_sess_list; 644 struct list_head acl_sess_list;
548} ____cacheline_aligned; 645};
549 646
550struct se_session { 647struct se_session {
551 unsigned sess_tearing_down:1; 648 unsigned sess_tearing_down:1;
@@ -558,7 +655,7 @@ struct se_session {
558 struct list_head sess_cmd_list; 655 struct list_head sess_cmd_list;
559 struct list_head sess_wait_list; 656 struct list_head sess_wait_list;
560 spinlock_t sess_cmd_lock; 657 spinlock_t sess_cmd_lock;
561} ____cacheline_aligned; 658};
562 659
563struct se_device; 660struct se_device;
564struct se_transform_info; 661struct se_transform_info;
@@ -578,7 +675,7 @@ struct se_lun_acl {
578 struct list_head lacl_list; 675 struct list_head lacl_list;
579 struct config_group se_lun_group; 676 struct config_group se_lun_group;
580 struct se_ml_stat_grps ml_stat_grps; 677 struct se_ml_stat_grps ml_stat_grps;
581} ____cacheline_aligned; 678};
582 679
583struct se_dev_entry { 680struct se_dev_entry {
584 bool def_pr_registered; 681 bool def_pr_registered;
@@ -603,7 +700,7 @@ struct se_dev_entry {
603 struct se_lun *se_lun; 700 struct se_lun *se_lun;
604 struct list_head alua_port_list; 701 struct list_head alua_port_list;
605 struct list_head ua_list; 702 struct list_head ua_list;
606} ____cacheline_aligned; 703};
607 704
608struct se_dev_limits { 705struct se_dev_limits {
609 /* Max supported HW queue depth */ 706 /* Max supported HW queue depth */
@@ -612,7 +709,7 @@ struct se_dev_limits {
612 u32 queue_depth; 709 u32 queue_depth;
613 /* From include/linux/blkdev.h for the other HW/SW limits. */ 710 /* From include/linux/blkdev.h for the other HW/SW limits. */
614 struct queue_limits limits; 711 struct queue_limits limits;
615} ____cacheline_aligned; 712};
616 713
617struct se_dev_attrib { 714struct se_dev_attrib {
618 int emulate_dpo; 715 int emulate_dpo;
@@ -641,7 +738,7 @@ struct se_dev_attrib {
641 u32 unmap_granularity_alignment; 738 u32 unmap_granularity_alignment;
642 struct se_subsystem_dev *da_sub_dev; 739 struct se_subsystem_dev *da_sub_dev;
643 struct config_group da_group; 740 struct config_group da_group;
644} ____cacheline_aligned; 741};
645 742
646struct se_dev_stat_grps { 743struct se_dev_stat_grps {
647 struct config_group stat_group; 744 struct config_group stat_group;
@@ -674,7 +771,7 @@ struct se_subsystem_dev {
674 struct config_group se_dev_pr_group; 771 struct config_group se_dev_pr_group;
675 /* For target_core_stat.c groups */ 772 /* For target_core_stat.c groups */
676 struct se_dev_stat_grps dev_stat_grps; 773 struct se_dev_stat_grps dev_stat_grps;
677} ____cacheline_aligned; 774};
678 775
679struct se_device { 776struct se_device {
680 /* RELATIVE TARGET PORT IDENTIFER Counter */ 777 /* RELATIVE TARGET PORT IDENTIFER Counter */
@@ -685,7 +782,6 @@ struct se_device {
685 u32 dev_port_count; 782 u32 dev_port_count;
686 /* See transport_device_status_table */ 783 /* See transport_device_status_table */
687 u32 dev_status; 784 u32 dev_status;
688 u32 dev_tcq_window_closed;
689 /* Physical device queue depth */ 785 /* Physical device queue depth */
690 u32 queue_depth; 786 u32 queue_depth;
691 /* Used for SPC-2 reservations enforce of ISIDs */ 787 /* Used for SPC-2 reservations enforce of ISIDs */
@@ -702,7 +798,6 @@ struct se_device {
702 spinlock_t stats_lock; 798 spinlock_t stats_lock;
703 /* Active commands on this virtual SE device */ 799 /* Active commands on this virtual SE device */
704 atomic_t simple_cmds; 800 atomic_t simple_cmds;
705 atomic_t depth_left;
706 atomic_t dev_ordered_id; 801 atomic_t dev_ordered_id;
707 atomic_t execute_tasks; 802 atomic_t execute_tasks;
708 atomic_t dev_ordered_sync; 803 atomic_t dev_ordered_sync;
@@ -740,7 +835,7 @@ struct se_device {
740 struct se_subsystem_api *transport; 835 struct se_subsystem_api *transport;
741 /* Linked list for struct se_hba struct se_device list */ 836 /* Linked list for struct se_hba struct se_device list */
742 struct list_head dev_list; 837 struct list_head dev_list;
743} ____cacheline_aligned; 838};
744 839
745struct se_hba { 840struct se_hba {
746 u16 hba_tpgt; 841 u16 hba_tpgt;
@@ -759,7 +854,7 @@ struct se_hba {
759 struct config_group hba_group; 854 struct config_group hba_group;
760 struct mutex hba_access_mutex; 855 struct mutex hba_access_mutex;
761 struct se_subsystem_api *transport; 856 struct se_subsystem_api *transport;
762} ____cacheline_aligned; 857};
763 858
764struct se_port_stat_grps { 859struct se_port_stat_grps {
765 struct config_group stat_group; 860 struct config_group stat_group;
@@ -785,13 +880,13 @@ struct se_lun {
785 struct se_port *lun_sep; 880 struct se_port *lun_sep;
786 struct config_group lun_group; 881 struct config_group lun_group;
787 struct se_port_stat_grps port_stat_grps; 882 struct se_port_stat_grps port_stat_grps;
788} ____cacheline_aligned; 883};
789 884
790struct scsi_port_stats { 885struct scsi_port_stats {
791 u64 cmd_pdus; 886 u64 cmd_pdus;
792 u64 tx_data_octets; 887 u64 tx_data_octets;
793 u64 rx_data_octets; 888 u64 rx_data_octets;
794} ____cacheline_aligned; 889};
795 890
796struct se_port { 891struct se_port {
797 /* RELATIVE TARGET PORT IDENTIFER */ 892 /* RELATIVE TARGET PORT IDENTIFER */
@@ -811,12 +906,12 @@ struct se_port {
811 struct se_portal_group *sep_tpg; 906 struct se_portal_group *sep_tpg;
812 struct list_head sep_alua_list; 907 struct list_head sep_alua_list;
813 struct list_head sep_list; 908 struct list_head sep_list;
814} ____cacheline_aligned; 909};
815 910
816struct se_tpg_np { 911struct se_tpg_np {
817 struct se_portal_group *tpg_np_parent; 912 struct se_portal_group *tpg_np_parent;
818 struct config_group tpg_np_group; 913 struct config_group tpg_np_group;
819} ____cacheline_aligned; 914};
820 915
821struct se_portal_group { 916struct se_portal_group {
822 /* Type of target portal group, see transport_tpg_type_table */ 917 /* Type of target portal group, see transport_tpg_type_table */
@@ -849,13 +944,13 @@ struct se_portal_group {
849 struct config_group tpg_acl_group; 944 struct config_group tpg_acl_group;
850 struct config_group tpg_attrib_group; 945 struct config_group tpg_attrib_group;
851 struct config_group tpg_param_group; 946 struct config_group tpg_param_group;
852} ____cacheline_aligned; 947};
853 948
854struct se_wwn { 949struct se_wwn {
855 struct target_fabric_configfs *wwn_tf; 950 struct target_fabric_configfs *wwn_tf;
856 struct config_group wwn_group; 951 struct config_group wwn_group;
857 struct config_group *wwn_default_groups[2]; 952 struct config_group *wwn_default_groups[2];
858 struct config_group fabric_stat_group; 953 struct config_group fabric_stat_group;
859} ____cacheline_aligned; 954};
860 955
861#endif /* TARGET_CORE_BASE_H */ 956#endif /* TARGET_CORE_BASE_H */
diff --git a/include/target/target_core_device.h b/include/target/target_core_device.h
deleted file mode 100644
index 2be31ff8763b..000000000000
--- a/include/target/target_core_device.h
+++ /dev/null
@@ -1,63 +0,0 @@
1#ifndef TARGET_CORE_DEVICE_H
2#define TARGET_CORE_DEVICE_H
3
4extern int transport_lookup_cmd_lun(struct se_cmd *, u32);
5extern int transport_lookup_tmr_lun(struct se_cmd *, u32);
6extern struct se_dev_entry *core_get_se_deve_from_rtpi(
7 struct se_node_acl *, u16);
8extern int core_free_device_list_for_node(struct se_node_acl *,
9 struct se_portal_group *);
10extern void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *);
11extern void core_update_device_list_access(u32, u32, struct se_node_acl *);
12extern int core_update_device_list_for_node(struct se_lun *, struct se_lun_acl *, u32,
13 u32, struct se_node_acl *,
14 struct se_portal_group *, int);
15extern void core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
16extern int core_dev_export(struct se_device *, struct se_portal_group *,
17 struct se_lun *);
18extern void core_dev_unexport(struct se_device *, struct se_portal_group *,
19 struct se_lun *);
20extern int target_report_luns(struct se_task *);
21extern void se_release_device_for_hba(struct se_device *);
22extern void se_release_vpd_for_dev(struct se_device *);
23extern void se_clear_dev_ports(struct se_device *);
24extern int se_free_virtual_device(struct se_device *, struct se_hba *);
25extern int se_dev_check_online(struct se_device *);
26extern int se_dev_check_shutdown(struct se_device *);
27extern void se_dev_set_default_attribs(struct se_device *, struct se_dev_limits *);
28extern int se_dev_set_task_timeout(struct se_device *, u32);
29extern int se_dev_set_max_unmap_lba_count(struct se_device *, u32);
30extern int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32);
31extern int se_dev_set_unmap_granularity(struct se_device *, u32);
32extern int se_dev_set_unmap_granularity_alignment(struct se_device *, u32);
33extern int se_dev_set_emulate_dpo(struct se_device *, int);
34extern int se_dev_set_emulate_fua_write(struct se_device *, int);
35extern int se_dev_set_emulate_fua_read(struct se_device *, int);
36extern int se_dev_set_emulate_write_cache(struct se_device *, int);
37extern int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int);
38extern int se_dev_set_emulate_tas(struct se_device *, int);
39extern int se_dev_set_emulate_tpu(struct se_device *, int);
40extern int se_dev_set_emulate_tpws(struct se_device *, int);
41extern int se_dev_set_enforce_pr_isids(struct se_device *, int);
42extern int se_dev_set_is_nonrot(struct se_device *, int);
43extern int se_dev_set_emulate_rest_reord(struct se_device *dev, int);
44extern int se_dev_set_queue_depth(struct se_device *, u32);
45extern int se_dev_set_max_sectors(struct se_device *, u32);
46extern int se_dev_set_optimal_sectors(struct se_device *, u32);
47extern int se_dev_set_block_size(struct se_device *, u32);
48extern struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_hba *,
49 struct se_device *, u32);
50extern int core_dev_del_lun(struct se_portal_group *, u32);
51extern struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
52extern struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
53 u32, char *, int *);
54extern int core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
55 struct se_lun_acl *, u32, u32);
56extern int core_dev_del_initiator_node_lun_acl(struct se_portal_group *,
57 struct se_lun *, struct se_lun_acl *);
58extern void core_dev_free_initiator_node_lun_acl(struct se_portal_group *,
59 struct se_lun_acl *lacl);
60extern int core_dev_setup_virtual_lun0(void);
61extern void core_dev_release_virtual_lun0(void);
62
63#endif /* TARGET_CORE_DEVICE_H */
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric.h
index 0256825f923d..523e8bc104d4 100644
--- a/include/target/target_core_fabric_ops.h
+++ b/include/target/target_core_fabric.h
@@ -1,5 +1,5 @@
1/* Defined in target_core_configfs.h */ 1#ifndef TARGET_CORE_FABRIC_H
2struct target_fabric_configfs; 2#define TARGET_CORE_FABRIC_H
3 3
4struct target_core_fabric_ops { 4struct target_core_fabric_ops {
5 struct configfs_subsystem *tf_subsys; 5 struct configfs_subsystem *tf_subsys;
@@ -52,10 +52,6 @@ struct target_core_fabric_ops {
52 * Returning 0 will signal a descriptor has not been released. 52 * Returning 0 will signal a descriptor has not been released.
53 */ 53 */
54 int (*check_stop_free)(struct se_cmd *); 54 int (*check_stop_free)(struct se_cmd *);
55 /*
56 * Optional check for active I/O shutdown
57 */
58 int (*check_release_cmd)(struct se_cmd *);
59 void (*release_cmd)(struct se_cmd *); 55 void (*release_cmd)(struct se_cmd *);
60 /* 56 /*
61 * Called with spin_lock_bh(struct se_portal_group->session_lock held. 57 * Called with spin_lock_bh(struct se_portal_group->session_lock held.
@@ -103,3 +99,89 @@ struct target_core_fabric_ops {
103 struct config_group *, const char *); 99 struct config_group *, const char *);
104 void (*fabric_drop_nodeacl)(struct se_node_acl *); 100 void (*fabric_drop_nodeacl)(struct se_node_acl *);
105}; 101};
102
103struct se_session *transport_init_session(void);
104void __transport_register_session(struct se_portal_group *,
105 struct se_node_acl *, struct se_session *, void *);
106void transport_register_session(struct se_portal_group *,
107 struct se_node_acl *, struct se_session *, void *);
108void transport_free_session(struct se_session *);
109void transport_deregister_session_configfs(struct se_session *);
110void transport_deregister_session(struct se_session *);
111
112
113void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *,
114 struct se_session *, u32, int, int, unsigned char *);
115int transport_lookup_cmd_lun(struct se_cmd *, u32);
116int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
117int target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *,
118 unsigned char *, u32, u32, int, int, int);
119int transport_handle_cdb_direct(struct se_cmd *);
120int transport_generic_handle_cdb_map(struct se_cmd *);
121int transport_generic_handle_data(struct se_cmd *);
122int transport_generic_map_mem_to_cmd(struct se_cmd *cmd,
123 struct scatterlist *, u32, struct scatterlist *, u32);
124void transport_do_task_sg_chain(struct se_cmd *);
125int transport_generic_new_cmd(struct se_cmd *);
126
127void transport_generic_process_write(struct se_cmd *);
128
129void transport_generic_free_cmd(struct se_cmd *, int);
130
131bool transport_wait_for_tasks(struct se_cmd *);
132int transport_check_aborted_status(struct se_cmd *, int);
133int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
134
135void target_get_sess_cmd(struct se_session *, struct se_cmd *, bool);
136int target_put_sess_cmd(struct se_session *, struct se_cmd *);
137void target_splice_sess_cmd_list(struct se_session *);
138void target_wait_for_sess_cmds(struct se_session *, int);
139
140int core_alua_check_nonop_delay(struct se_cmd *);
141
142struct se_tmr_req *core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t);
143void core_tmr_release_req(struct se_tmr_req *);
144int transport_generic_handle_tmr(struct se_cmd *);
145int transport_lookup_tmr_lun(struct se_cmd *, u32);
146
147struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *,
148 unsigned char *);
149void core_tpg_clear_object_luns(struct se_portal_group *);
150struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *,
151 struct se_node_acl *, const char *, u32);
152int core_tpg_del_initiator_node_acl(struct se_portal_group *,
153 struct se_node_acl *, int);
154int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
155 unsigned char *, u32, int);
156int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *,
157 struct se_portal_group *, void *, int);
158int core_tpg_deregister(struct se_portal_group *);
159
160/* SAS helpers */
161u8 sas_get_fabric_proto_ident(struct se_portal_group *);
162u32 sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
163 struct t10_pr_registration *, int *, unsigned char *);
164u32 sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
165 struct t10_pr_registration *, int *);
166char *sas_parse_pr_out_transport_id(struct se_portal_group *, const char *,
167 u32 *, char **);
168
169/* FC helpers */
170u8 fc_get_fabric_proto_ident(struct se_portal_group *);
171u32 fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
172 struct t10_pr_registration *, int *, unsigned char *);
173u32 fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
174 struct t10_pr_registration *, int *);
175char *fc_parse_pr_out_transport_id(struct se_portal_group *, const char *,
176 u32 *, char **);
177
178/* iSCSI helpers */
179u8 iscsi_get_fabric_proto_ident(struct se_portal_group *);
180u32 iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
181 struct t10_pr_registration *, int *, unsigned char *);
182u32 iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
183 struct t10_pr_registration *, int *);
184char *iscsi_parse_pr_out_transport_id(struct se_portal_group *, const char *,
185 u32 *, char **);
186
187#endif /* TARGET_CORE_FABRICH */
diff --git a/include/target/target_core_fabric_lib.h b/include/target/target_core_fabric_lib.h
deleted file mode 100644
index c2f8d0e3a03b..000000000000
--- a/include/target/target_core_fabric_lib.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef TARGET_CORE_FABRIC_LIB_H
2#define TARGET_CORE_FABRIC_LIB_H
3
4extern u8 sas_get_fabric_proto_ident(struct se_portal_group *);
5extern u32 sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
6 struct t10_pr_registration *, int *, unsigned char *);
7extern u32 sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
8 struct t10_pr_registration *, int *);
9extern char *sas_parse_pr_out_transport_id(struct se_portal_group *,
10 const char *, u32 *, char **);
11
12extern u8 fc_get_fabric_proto_ident(struct se_portal_group *);
13extern u32 fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
14 struct t10_pr_registration *, int *, unsigned char *);
15extern u32 fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
16 struct t10_pr_registration *, int *);
17extern char *fc_parse_pr_out_transport_id(struct se_portal_group *,
18 const char *, u32 *, char **);
19
20extern u8 iscsi_get_fabric_proto_ident(struct se_portal_group *);
21extern u32 iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
22 struct t10_pr_registration *, int *, unsigned char *);
23extern u32 iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
24 struct t10_pr_registration *, int *);
25extern char *iscsi_parse_pr_out_transport_id(struct se_portal_group *,
26 const char *, u32 *, char **);
27
28#endif /* TARGET_CORE_FABRIC_LIB_H */
diff --git a/include/target/target_core_tmr.h b/include/target/target_core_tmr.h
deleted file mode 100644
index d5876e17d3fb..000000000000
--- a/include/target/target_core_tmr.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef TARGET_CORE_TMR_H
2#define TARGET_CORE_TMR_H
3
4/* fabric independent task management function values */
5enum tcm_tmreq_table {
6 TMR_ABORT_TASK = 1,
7 TMR_ABORT_TASK_SET = 2,
8 TMR_CLEAR_ACA = 3,
9 TMR_CLEAR_TASK_SET = 4,
10 TMR_LUN_RESET = 5,
11 TMR_TARGET_WARM_RESET = 6,
12 TMR_TARGET_COLD_RESET = 7,
13 TMR_FABRIC_TMR = 255,
14};
15
16/* fabric independent task management response values */
17enum tcm_tmrsp_table {
18 TMR_FUNCTION_COMPLETE = 0,
19 TMR_TASK_DOES_NOT_EXIST = 1,
20 TMR_LUN_DOES_NOT_EXIST = 2,
21 TMR_TASK_STILL_ALLEGIANT = 3,
22 TMR_TASK_FAILOVER_NOT_SUPPORTED = 4,
23 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 5,
24 TMR_FUNCTION_AUTHORIZATION_FAILED = 6,
25 TMR_FUNCTION_REJECTED = 255,
26};
27
28extern struct kmem_cache *se_tmr_req_cache;
29
30extern struct se_tmr_req *core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t);
31extern void core_tmr_release_req(struct se_tmr_req *);
32extern int core_tmr_lun_reset(struct se_device *, struct se_tmr_req *,
33 struct list_head *, struct se_cmd *);
34
35#endif /* TARGET_CORE_TMR_H */
diff --git a/include/target/target_core_tpg.h b/include/target/target_core_tpg.h
deleted file mode 100644
index 77e18729c4c1..000000000000
--- a/include/target/target_core_tpg.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef TARGET_CORE_TPG_H
2#define TARGET_CORE_TPG_H
3
4extern struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
5 const char *);
6extern struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
7 unsigned char *);
8extern void core_tpg_add_node_to_devs(struct se_node_acl *,
9 struct se_portal_group *);
10extern struct se_node_acl *core_tpg_check_initiator_node_acl(
11 struct se_portal_group *,
12 unsigned char *);
13extern void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
14extern void core_tpg_wait_for_mib_ref(struct se_node_acl *);
15extern void core_tpg_clear_object_luns(struct se_portal_group *);
16extern struct se_node_acl *core_tpg_add_initiator_node_acl(
17 struct se_portal_group *,
18 struct se_node_acl *,
19 const char *, u32);
20extern int core_tpg_del_initiator_node_acl(struct se_portal_group *,
21 struct se_node_acl *, int);
22extern int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
23 unsigned char *, u32, int);
24extern int core_tpg_register(struct target_core_fabric_ops *,
25 struct se_wwn *,
26 struct se_portal_group *, void *,
27 int);
28extern int core_tpg_deregister(struct se_portal_group *);
29extern struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32);
30extern int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *, u32,
31 void *);
32extern struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *);
33extern int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
34
35#endif /* TARGET_CORE_TPG_H */
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
deleted file mode 100644
index dac4f2d859fd..000000000000
--- a/include/target/target_core_transport.h
+++ /dev/null
@@ -1,287 +0,0 @@
1#ifndef TARGET_CORE_TRANSPORT_H
2#define TARGET_CORE_TRANSPORT_H
3
4#define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION
5
6/* Attempts before moving from SHORT to LONG */
7#define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
8#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
9#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG 10 /* In milliseconds */
10
11#define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */
12
13#define TRANSPORT_PLUGIN_PHBA_PDEV 1
14#define TRANSPORT_PLUGIN_VHBA_PDEV 2
15#define TRANSPORT_PLUGIN_VHBA_VDEV 3
16
17/*
18 * struct se_subsystem_dev->su_dev_flags
19*/
20#define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001
21#define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002
22#define SDF_USING_UDEV_PATH 0x00000004
23#define SDF_USING_ALIAS 0x00000008
24
25/*
26 * struct se_device->dev_flags
27 */
28#define DF_READ_ONLY 0x00000001
29#define DF_SPC2_RESERVATIONS 0x00000002
30#define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
31
32/* struct se_dev_attrib sanity values */
33/* Default max_unmap_lba_count */
34#define DA_MAX_UNMAP_LBA_COUNT 0
35/* Default max_unmap_block_desc_count */
36#define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
37/* Default unmap_granularity */
38#define DA_UNMAP_GRANULARITY_DEFAULT 0
39/* Default unmap_granularity_alignment */
40#define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
41/* Emulation for Direct Page Out */
42#define DA_EMULATE_DPO 0
43/* Emulation for Forced Unit Access WRITEs */
44#define DA_EMULATE_FUA_WRITE 1
45/* Emulation for Forced Unit Access READs */
46#define DA_EMULATE_FUA_READ 0
47/* Emulation for WriteCache and SYNCHRONIZE_CACHE */
48#define DA_EMULATE_WRITE_CACHE 0
49/* Emulation for UNIT ATTENTION Interlock Control */
50#define DA_EMULATE_UA_INTLLCK_CTRL 0
51/* Emulation for TASK_ABORTED status (TAS) by default */
52#define DA_EMULATE_TAS 1
53/* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
54#define DA_EMULATE_TPU 0
55/*
56 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
57 * block/blk-lib.c:blkdev_issue_discard()
58 */
59#define DA_EMULATE_TPWS 0
60/* No Emulation for PSCSI by default */
61#define DA_EMULATE_RESERVATIONS 0
62/* No Emulation for PSCSI by default */
63#define DA_EMULATE_ALUA 0
64/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
65#define DA_ENFORCE_PR_ISIDS 1
66#define DA_STATUS_MAX_SECTORS_MIN 16
67#define DA_STATUS_MAX_SECTORS_MAX 8192
68/* By default don't report non-rotating (solid state) medium */
69#define DA_IS_NONROT 0
70/* Queue Algorithm Modifier default for restricted reordering in control mode page */
71#define DA_EMULATE_REST_REORD 0
72
73#define SE_MODE_PAGE_BUF 512
74
75#define MOD_MAX_SECTORS(ms, bs) (ms % (PAGE_SIZE / bs))
76
77struct se_subsystem_api;
78
79extern int init_se_kmem_caches(void);
80extern void release_se_kmem_caches(void);
81extern u32 scsi_get_new_index(scsi_index_t);
82extern void transport_init_queue_obj(struct se_queue_obj *);
83extern void transport_subsystem_check_init(void);
84extern int transport_subsystem_register(struct se_subsystem_api *);
85extern void transport_subsystem_release(struct se_subsystem_api *);
86extern void transport_load_plugins(void);
87extern struct se_session *transport_init_session(void);
88extern void __transport_register_session(struct se_portal_group *,
89 struct se_node_acl *,
90 struct se_session *, void *);
91extern void transport_register_session(struct se_portal_group *,
92 struct se_node_acl *,
93 struct se_session *, void *);
94extern void transport_free_session(struct se_session *);
95extern void transport_deregister_session_configfs(struct se_session *);
96extern void transport_deregister_session(struct se_session *);
97extern void transport_cmd_finish_abort(struct se_cmd *, int);
98extern void transport_complete_sync_cache(struct se_cmd *, int);
99extern void transport_complete_task(struct se_task *, int);
100extern void transport_add_task_to_execute_queue(struct se_task *,
101 struct se_task *,
102 struct se_device *);
103extern void transport_remove_task_from_execute_queue(struct se_task *,
104 struct se_device *);
105extern void __transport_remove_task_from_execute_queue(struct se_task *,
106 struct se_device *);
107unsigned char *transport_dump_cmd_direction(struct se_cmd *);
108extern void transport_dump_dev_state(struct se_device *, char *, int *);
109extern void transport_dump_dev_info(struct se_device *, struct se_lun *,
110 unsigned long long, char *, int *);
111extern void transport_dump_vpd_proto_id(struct t10_vpd *,
112 unsigned char *, int);
113extern void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
114extern int transport_dump_vpd_assoc(struct t10_vpd *,
115 unsigned char *, int);
116extern int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
117extern int transport_dump_vpd_ident_type(struct t10_vpd *,
118 unsigned char *, int);
119extern int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
120extern int transport_dump_vpd_ident(struct t10_vpd *,
121 unsigned char *, int);
122extern int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
123extern struct se_device *transport_add_device_to_core_hba(struct se_hba *,
124 struct se_subsystem_api *,
125 struct se_subsystem_dev *, u32,
126 void *, struct se_dev_limits *,
127 const char *, const char *);
128extern void transport_init_se_cmd(struct se_cmd *,
129 struct target_core_fabric_ops *,
130 struct se_session *, u32, int, int,
131 unsigned char *);
132void *transport_kmap_first_data_page(struct se_cmd *cmd);
133void transport_kunmap_first_data_page(struct se_cmd *cmd);
134extern int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
135extern int transport_handle_cdb_direct(struct se_cmd *);
136extern int transport_generic_handle_cdb_map(struct se_cmd *);
137extern int transport_generic_handle_data(struct se_cmd *);
138extern int transport_generic_handle_tmr(struct se_cmd *);
139extern bool target_stop_task(struct se_task *task, unsigned long *flags);
140extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32,
141 struct scatterlist *, u32);
142extern int transport_clear_lun_from_sessions(struct se_lun *);
143extern bool transport_wait_for_tasks(struct se_cmd *);
144extern int transport_check_aborted_status(struct se_cmd *, int);
145extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
146extern void transport_send_task_abort(struct se_cmd *);
147extern void transport_release_cmd(struct se_cmd *);
148extern void transport_generic_free_cmd(struct se_cmd *, int);
149extern void target_get_sess_cmd(struct se_session *, struct se_cmd *);
150extern int target_put_sess_cmd(struct se_session *, struct se_cmd *);
151extern void target_splice_sess_cmd_list(struct se_session *);
152extern void target_wait_for_sess_cmds(struct se_session *, int);
153extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
154extern void transport_do_task_sg_chain(struct se_cmd *);
155extern void transport_generic_process_write(struct se_cmd *);
156extern int transport_generic_new_cmd(struct se_cmd *);
157extern int transport_generic_do_tmr(struct se_cmd *);
158/* From target_core_alua.c */
159extern int core_alua_check_nonop_delay(struct se_cmd *);
160/* From target_core_cdb.c */
161extern int transport_emulate_control_cdb(struct se_task *);
162extern void target_get_task_cdb(struct se_task *task, unsigned char *cdb);
163
164/*
165 * Each se_transport_task_t can have N number of possible struct se_task's
166 * for the storage transport(s) to possibly execute.
167 * Used primarily for splitting up CDBs that exceed the physical storage
168 * HBA's maximum sector count per task.
169 */
170struct se_mem {
171 struct page *se_page;
172 u32 se_len;
173 u32 se_off;
174 struct list_head se_list;
175} ____cacheline_aligned;
176
177/*
178 * Each type of disk transport supported MUST have a template defined
179 * within its .h file.
180 */
181struct se_subsystem_api {
182 /*
183 * The Name. :-)
184 */
185 char name[16];
186 /*
187 * Transport Type.
188 */
189 u8 transport_type;
190
191 unsigned int fua_write_emulated : 1;
192 unsigned int write_cache_emulated : 1;
193
194 /*
195 * struct module for struct se_hba references
196 */
197 struct module *owner;
198 /*
199 * Used for global se_subsystem_api list_head
200 */
201 struct list_head sub_api_list;
202 /*
203 * attach_hba():
204 */
205 int (*attach_hba)(struct se_hba *, u32);
206 /*
207 * detach_hba():
208 */
209 void (*detach_hba)(struct se_hba *);
210 /*
211 * pmode_hba(): Used for TCM/pSCSI subsystem plugin HBA ->
212 * Linux/SCSI struct Scsi_Host passthrough
213 */
214 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
215 /*
216 * allocate_virtdevice():
217 */
218 void *(*allocate_virtdevice)(struct se_hba *, const char *);
219 /*
220 * create_virtdevice(): Only for Virtual HBAs
221 */
222 struct se_device *(*create_virtdevice)(struct se_hba *,
223 struct se_subsystem_dev *, void *);
224 /*
225 * free_device():
226 */
227 void (*free_device)(void *);
228
229 /*
230 * transport_complete():
231 *
232 * Use transport_generic_complete() for majority of DAS transport
233 * drivers. Provided out of convenience.
234 */
235 int (*transport_complete)(struct se_task *task);
236 struct se_task *(*alloc_task)(unsigned char *cdb);
237 /*
238 * do_task():
239 */
240 int (*do_task)(struct se_task *);
241 /*
242 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
243 * UNMAP and WRITE_SAME_* w/ UNMAP=1 <-> Linux/Block Discard
244 */
245 int (*do_discard)(struct se_device *, sector_t, u32);
246 /*
247 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
248 * SYNCHRONIZE_CACHE_* <-> Linux/Block blkdev_issue_flush()
249 */
250 void (*do_sync_cache)(struct se_task *);
251 /*
252 * free_task():
253 */
254 void (*free_task)(struct se_task *);
255 /*
256 * check_configfs_dev_params():
257 */
258 ssize_t (*check_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *);
259 /*
260 * set_configfs_dev_params():
261 */
262 ssize_t (*set_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
263 const char *, ssize_t);
264 /*
265 * show_configfs_dev_params():
266 */
267 ssize_t (*show_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
268 char *);
269 /*
270 * get_device_rev():
271 */
272 u32 (*get_device_rev)(struct se_device *);
273 /*
274 * get_device_type():
275 */
276 u32 (*get_device_type)(struct se_device *);
277 /*
278 * Get the sector_t from a subsystem backstore..
279 */
280 sector_t (*get_blocks)(struct se_device *);
281 /*
282 * get_sense_buffer():
283 */
284 unsigned char *(*get_sense_buffer)(struct se_task *);
285} ____cacheline_aligned;
286
287#endif /* TARGET_CORE_TRANSPORT_H */