summaryrefslogtreecommitdiff
path: root/drivers/target/target_core_user.c
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2015-05-19 14:44:40 -0700
committerNicholas Bellinger <nab@linux-iscsi.org>2015-05-30 19:57:59 -0700
commit7bfea53b5c936d706d0bf60ec218fa72cde77121 (patch)
tree1bed6667ac527acab7c2b2fb72e2bb1aa7b4cca5 /drivers/target/target_core_user.c
parent9c1cd1b68cd15c81d12a0cf2402129475882b620 (diff)
target: Move passthrough CDB parsing into a common function
Aside from whether they handle BIDI ops or not, parsing of the CDB by kernel and user SCSI passthrough modules should be identical. Move this into a new passthrough_parse_cdb() and call it from tcm-pscsi and tcm-user. Reported-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ilias Tsitsimpis <iliastsi@arrikto.com> Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_user.c')
-rw-r--r--drivers/target/target_core_user.c43
1 files changed, 1 insertions, 42 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 90e084ea7b92..2768ea2cfd7a 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1049,48 +1049,7 @@ tcmu_pass_op(struct se_cmd *se_cmd)
static sense_reason_t
tcmu_parse_cdb(struct se_cmd *cmd)
{
- unsigned char *cdb = cmd->t_task_cdb;
-
- /*
- * For REPORT LUNS we always need to emulate the response, for everything
- * else, pass it up.
- */
- if (cdb[0] == REPORT_LUNS) {
- cmd->execute_cmd = spc_emulate_report_luns;
- return TCM_NO_SENSE;
- }
-
- /* Set DATA_CDB flag for ops that should have it */
- switch (cdb[0]) {
- case READ_6:
- case READ_10:
- case READ_12:
- case READ_16:
- case WRITE_6:
- case WRITE_10:
- case WRITE_12:
- case WRITE_16:
- case WRITE_VERIFY:
- case WRITE_VERIFY_12:
- case 0x8e: /* WRITE_VERIFY_16 */
- case COMPARE_AND_WRITE:
- case XDWRITEREAD_10:
- cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
- break;
- case VARIABLE_LENGTH_CMD:
- switch (get_unaligned_be16(&cdb[8])) {
- case READ_32:
- case WRITE_32:
- case 0x0c: /* WRITE_VERIFY_32 */
- case XDWRITEREAD_32:
- cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
- break;
- }
- }
-
- cmd->execute_cmd = tcmu_pass_op;
-
- return TCM_NO_SENSE;
+ return passthrough_parse_cdb(cmd, tcmu_pass_op);
}
DEF_TB_DEV_ATTRIB_RO(tcmu, hw_pi_prot_type);