aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2014-04-02 16:27:43 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2014-04-07 04:48:55 -0400
commitd2c5304c7ade0356c63e31f79a33452b3d4e3772 (patch)
tree10980798b8ac3c2d073795c8416f974bedb8ca0b
parente70beee783d6977d80eede88a3394f02eabddad1 (diff)
target/spc: Only expose PI inquiry bits when supported by fabric
Only expose standard INQUIRY PROTECT=1 and EVPD=0x86 TYPE1/TYPE3 PI control bits if the session + fabric support DIX PASS operations. Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Or Gerlitz <ogerlitz@mellanox.com> Cc: Quinn Tran <quinn.tran@qlogic.com> Cc: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_spc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 3bebc71ea033..d4c6a318d4c2 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -71,6 +71,7 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
71{ 71{
72 struct se_lun *lun = cmd->se_lun; 72 struct se_lun *lun = cmd->se_lun;
73 struct se_device *dev = cmd->se_dev; 73 struct se_device *dev = cmd->se_dev;
74 struct se_session *sess = cmd->se_sess;
74 75
75 /* Set RMB (removable media) for tape devices */ 76 /* Set RMB (removable media) for tape devices */
76 if (dev->transport->get_device_type(dev) == TYPE_TAPE) 77 if (dev->transport->get_device_type(dev) == TYPE_TAPE)
@@ -101,10 +102,13 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
101 if (dev->dev_attrib.emulate_3pc) 102 if (dev->dev_attrib.emulate_3pc)
102 buf[5] |= 0x8; 103 buf[5] |= 0x8;
103 /* 104 /*
104 * Set Protection (PROTECT) bit when DIF has been enabled. 105 * Set Protection (PROTECT) bit when DIF has been enabled on the
106 * device, and the transport supports VERIFY + PASS.
105 */ 107 */
106 if (dev->dev_attrib.pi_prot_type) 108 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
107 buf[5] |= 0x1; 109 if (dev->dev_attrib.pi_prot_type)
110 buf[5] |= 0x1;
111 }
108 112
109 buf[7] = 0x2; /* CmdQue=1 */ 113 buf[7] = 0x2; /* CmdQue=1 */
110 114
@@ -473,16 +477,19 @@ static sense_reason_t
473spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) 477spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
474{ 478{
475 struct se_device *dev = cmd->se_dev; 479 struct se_device *dev = cmd->se_dev;
480 struct se_session *sess = cmd->se_sess;
476 481
477 buf[3] = 0x3c; 482 buf[3] = 0x3c;
478 /* 483 /*
479 * Set GRD_CHK + REF_CHK for TYPE1 protection, or GRD_CHK 484 * Set GRD_CHK + REF_CHK for TYPE1 protection, or GRD_CHK
480 * only for TYPE3 protection. 485 * only for TYPE3 protection.
481 */ 486 */
482 if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT) 487 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
483 buf[4] = 0x5; 488 if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT)
484 else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT) 489 buf[4] = 0x5;
485 buf[4] = 0x4; 490 else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT)
491 buf[4] = 0x4;
492 }
486 493
487 /* Set HEADSUP, ORDSUP, SIMPSUP */ 494 /* Set HEADSUP, ORDSUP, SIMPSUP */
488 buf[5] = 0x07; 495 buf[5] = 0x07;