aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2014-02-19 10:50:17 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2014-04-07 04:48:42 -0400
commitb5b8e2989e3406798dbb88fbb4eaafbbf1a56f6a (patch)
treecd301ec29007c124aaa71ac6ce4fb60231761719
parent80dcd0c10482719bd9250b7d11bd5c360a02403a (diff)
Target/dif: Introduce protection-passthough-only mode
Some transports (iSCSI/iSER/SRP/FC) support hardware INSERT/STRIP capabilities while other transports like loopback/vhost-scsi need perform this is software. This patch allows fabrics using SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC to signal the early LUN scan handling case where PROTECT CDB bits are set, but no fabric buffer has been provided. For transports which use generic new command these buffers have yet to be allocated. Also this way, target may support protection information against legacy initiators (writes are inserted and reads are stripped). (Only set prot_pto for loopback during early special case - nab) Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/loopback/tcm_loop.c4
-rw-r--r--drivers/target/target_core_sbc.c2
-rw-r--r--drivers/target/target_core_transport.c12
-rw-r--r--include/target/target_core_base.h1
4 files changed, 13 insertions, 6 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index fadad7c5f635..a49ef0a49fa9 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -212,6 +212,10 @@ static void tcm_loop_submission_work(struct work_struct *work)
212 se_cmd->se_cmd_flags |= SCF_BIDI; 212 se_cmd->se_cmd_flags |= SCF_BIDI;
213 213
214 } 214 }
215
216 if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
217 se_cmd->prot_pto = true;
218
215 rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, 219 rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
216 &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, 220 &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
217 scsi_bufflen(sc), tcm_loop_sam_attr(sc), 221 scsi_bufflen(sc), tcm_loop_sam_attr(sc),
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index a1e75dd636ac..c301d9b6874d 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -634,7 +634,7 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
634{ 634{
635 u8 protect = cdb[1] >> 5; 635 u8 protect = cdb[1] >> 5;
636 636
637 if (!cmd->t_prot_sg || !cmd->t_prot_nents) 637 if ((!cmd->t_prot_sg || !cmd->t_prot_nents) && cmd->prot_pto)
638 return true; 638 return true;
639 639
640 switch (dev->dev_attrib.pi_prot_type) { 640 switch (dev->dev_attrib.pi_prot_type) {
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4653d826e595..0a359fa82bd3 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1365,6 +1365,13 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
1365 target_put_sess_cmd(se_sess, se_cmd); 1365 target_put_sess_cmd(se_sess, se_cmd);
1366 return 0; 1366 return 0;
1367 } 1367 }
1368
1369 rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1370 if (rc != 0) {
1371 transport_generic_request_failure(se_cmd, rc);
1372 return 0;
1373 }
1374
1368 /* 1375 /*
1369 * Save pointers for SGLs containing protection information, 1376 * Save pointers for SGLs containing protection information,
1370 * if present. 1377 * if present.
@@ -1374,11 +1381,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
1374 se_cmd->t_prot_nents = sgl_prot_count; 1381 se_cmd->t_prot_nents = sgl_prot_count;
1375 } 1382 }
1376 1383
1377 rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1378 if (rc != 0) {
1379 transport_generic_request_failure(se_cmd, rc);
1380 return 0;
1381 }
1382 /* 1384 /*
1383 * When a non zero sgl_count has been passed perform SGL passthrough 1385 * When a non zero sgl_count has been passed perform SGL passthrough
1384 * mapping for pre-allocated fabric memory instead of having target 1386 * mapping for pre-allocated fabric memory instead of having target
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 5ae92492d1ee..82cb4ed06f71 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -570,6 +570,7 @@ struct se_cmd {
570 enum target_prot_ho prot_handover; 570 enum target_prot_ho prot_handover;
571 sense_reason_t pi_err; 571 sense_reason_t pi_err;
572 sector_t bad_sector; 572 sector_t bad_sector;
573 bool prot_pto;
573}; 574};
574 575
575struct se_ua { 576struct se_ua {