diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-02-28 01:05:33 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-04-08 02:26:09 -0400 |
commit | 9ef5466ee2f0599caf8d84203d36e581c6fc7035 (patch) | |
tree | 03317fe25e4c27bb98664fec6ebd8e340bde2676 /drivers/target | |
parent | 38b57f82f66dfb21ebe321d71c84c0e3469980c4 (diff) |
target: Update SPC/SBC emulation for sess_prot_type
This patch updates standard INQUIRY, INQUIRY EVPD=0x86, READ_CAPACITY_16
and control mode pages to use se_sess->sess_prot_type when determing which
type of T10-PI related feature bits can be exposed.
This is required for fabric sessions supporting T10-PI metadata to
backend devices that don't have protection enabled.
Reviewed-by: Martin Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Doug Gilbert <dgilbert@interlog.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_sbc.c | 13 | ||||
-rw-r--r-- | drivers/target/target_core_spc.c | 14 |
2 files changed, 20 insertions, 7 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 9efd1fd985ee..67bc1886f004 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -93,6 +93,8 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) | |||
93 | { | 93 | { |
94 | struct se_device *dev = cmd->se_dev; | 94 | struct se_device *dev = cmd->se_dev; |
95 | struct se_session *sess = cmd->se_sess; | 95 | struct se_session *sess = cmd->se_sess; |
96 | int pi_prot_type = dev->dev_attrib.pi_prot_type; | ||
97 | |||
96 | unsigned char *rbuf; | 98 | unsigned char *rbuf; |
97 | unsigned char buf[32]; | 99 | unsigned char buf[32]; |
98 | unsigned long long blocks = dev->transport->get_blocks(dev); | 100 | unsigned long long blocks = dev->transport->get_blocks(dev); |
@@ -114,8 +116,15 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) | |||
114 | * Set P_TYPE and PROT_EN bits for DIF support | 116 | * Set P_TYPE and PROT_EN bits for DIF support |
115 | */ | 117 | */ |
116 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { | 118 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { |
117 | if (dev->dev_attrib.pi_prot_type) | 119 | /* |
118 | buf[12] = (dev->dev_attrib.pi_prot_type - 1) << 1 | 0x1; | 120 | * Only override a device's pi_prot_type if no T10-PI is |
121 | * available, and sess_prot_type has been explicitly enabled. | ||
122 | */ | ||
123 | if (!pi_prot_type) | ||
124 | pi_prot_type = sess->sess_prot_type; | ||
125 | |||
126 | if (pi_prot_type) | ||
127 | buf[12] = (pi_prot_type - 1) << 1 | 0x1; | ||
119 | } | 128 | } |
120 | 129 | ||
121 | if (dev->transport->get_lbppbe) | 130 | if (dev->transport->get_lbppbe) |
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index f310aac38bd8..9ec64596588c 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -103,10 +103,12 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) | |||
103 | buf[5] |= 0x8; | 103 | buf[5] |= 0x8; |
104 | /* | 104 | /* |
105 | * Set Protection (PROTECT) bit when DIF has been enabled on the | 105 | * Set Protection (PROTECT) bit when DIF has been enabled on the |
106 | * device, and the transport supports VERIFY + PASS. | 106 | * device, and the fabric supports VERIFY + PASS. Also report |
107 | * PROTECT=1 if sess_prot_type has been configured to allow T10-PI | ||
108 | * to unprotected devices. | ||
107 | */ | 109 | */ |
108 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { | 110 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { |
109 | if (dev->dev_attrib.pi_prot_type) | 111 | if (dev->dev_attrib.pi_prot_type || cmd->se_sess->sess_prot_type) |
110 | buf[5] |= 0x1; | 112 | buf[5] |= 0x1; |
111 | } | 113 | } |
112 | 114 | ||
@@ -480,9 +482,11 @@ spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) | |||
480 | * only for TYPE3 protection. | 482 | * only for TYPE3 protection. |
481 | */ | 483 | */ |
482 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { | 484 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { |
483 | if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT) | 485 | if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT || |
486 | cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE1_PROT) | ||
484 | buf[4] = 0x5; | 487 | buf[4] = 0x5; |
485 | else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT) | 488 | else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT || |
489 | cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT) | ||
486 | buf[4] = 0x4; | 490 | buf[4] = 0x4; |
487 | } | 491 | } |
488 | 492 | ||
@@ -874,7 +878,7 @@ static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p) | |||
874 | * TAG field. | 878 | * TAG field. |
875 | */ | 879 | */ |
876 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { | 880 | if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { |
877 | if (dev->dev_attrib.pi_prot_type) | 881 | if (dev->dev_attrib.pi_prot_type || sess->sess_prot_type) |
878 | p[5] |= 0x80; | 882 | p[5] |= 0x80; |
879 | } | 883 | } |
880 | 884 | ||