* [PATCH 0/6] add support of RSOC command
@ 2022-07-18 12:01 Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 1/6] scsi: target: core: " Dmitry Bogdanov
` (5 more replies)
0 siblings, 6 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel; +Cc: linux-scsi, linux, Dmitry Bogdanov
This patchset is based on 5.20/scsi-queue.
The patchset adds support of REPORT SUPPORTED OPERATION CODES command
according to SPC4. Including CDB USAGE DATA and timeout descriptors.
Timeout descriptors are zeroed currently, meaning that no time is
indicated, but an encoding of it there is.
Opcode support and Usage Data is dynamically generated.
libiscsi tests for RSOC and tests that uses RSOC command are all PASSED.
Dmitry Bogdanov (6):
scsi: target: core: add support of RSOC command
scsi: target: core: add list of opcodes for RSOC
scsi: target: core: dynamic opcode support in RSOC
scsi: target: core: add emulate_rsoc attribute
scsi: target: core: dynamicaly set dpofua in usage_bits
scsi: target: check emulate_3pc for RECEIVE COPY
drivers/target/target_core_configfs.c | 20 +
drivers/target/target_core_device.c | 1 +
drivers/target/target_core_spc.c | 947 ++++++++++++++++++++++++++
drivers/target/target_core_xcopy.c | 6 +
include/scsi/scsi_proto.h | 10 +
include/target/target_core_base.h | 18 +
6 files changed, 1002 insertions(+)
--
2.25.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/6] scsi: target: core: add support of RSOC command
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
2022-07-19 10:08 ` kernel test robot
2022-07-18 12:01 ` [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC Dmitry Bogdanov
` (4 subsequent siblings)
5 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Add support of REPORT SUPPORTED OPERATION CODES command according
to SPC4.
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_spc.c | 200 ++++++++++++++++++++++++++++++
include/scsi/scsi_proto.h | 7 ++
include/target/target_core_base.h | 12 ++
3 files changed, 219 insertions(+)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index c14441c89bed..4157f73977cf 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1308,6 +1308,202 @@ spc_emulate_testunitready(struct se_cmd *cmd)
return 0;
}
+
+static struct target_opcode_descriptor *tcm_supported_opcodes[] = {
+};
+
+static int
+spc_rsoc_encode_command_timeouts_descriptor(unsigned char *buf, u8 ctdp,
+ struct target_opcode_descriptor *descr)
+{
+ if (!ctdp)
+ return 0;
+
+ put_unaligned_be16(0xa, buf);
+ buf[3] = descr->specific_timeout;
+ put_unaligned_be32(descr->nominal_timeout, &buf[4]);
+ put_unaligned_be32(descr->recommended_timeout, &buf[8]);
+
+ return 12;
+}
+
+static int
+spc_rsoc_encode_command_descriptor(unsigned char *buf, u8 ctdp,
+ struct target_opcode_descriptor *descr)
+{
+ int td_size = 0;
+
+ buf[0] = descr->opcode;
+
+ put_unaligned_be16(descr->service_action, &buf[2]);
+
+ buf[5] = (ctdp << 1) | descr->serv_action_valid;
+ put_unaligned_be16(descr->cdb_size, &buf[6]);
+
+ td_size = spc_rsoc_encode_command_timeouts_descriptor(&buf[8], ctdp,
+ descr);
+
+ return 8 + td_size;
+}
+
+static int
+spc_rsoc_encode_one_command_descriptor(unsigned char *buf, u8 ctdp,
+ struct target_opcode_descriptor *descr)
+{
+ int td_size = 0;
+
+ if (!descr) {
+ buf[1] = (ctdp << 7) | SCSI_SUPPORT_NOT_SUPPORTED;
+ return 2;
+ }
+
+ buf[1] = (ctdp << 7) | SCSI_SUPPORT_FULL;
+ put_unaligned_be16(descr->cdb_size, &buf[2]);
+ memcpy(&buf[4], descr->usage_bits, descr->cdb_size);
+
+ td_size = spc_rsoc_encode_command_timeouts_descriptor(
+ &buf[4 + descr->cdb_size], ctdp, descr);
+
+ return 4 + descr->cdb_size + td_size;
+}
+
+static sense_reason_t
+spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
+{
+ struct target_opcode_descriptor *descr;
+ struct se_session *sess = cmd->se_sess;
+ unsigned char *cdb = cmd->t_task_cdb;
+ u8 opts = cdb[2] & 0x3;
+ u8 requested_opcode;
+ u16 requested_sa;
+ int i;
+
+ requested_opcode = cdb[3];
+ requested_sa = ((u16)cdb[4]) << 8 | cdb[5];
+ *opcode = NULL;
+
+ if (opts > 3) {
+ pr_debug("TARGET_CORE[%s]: Invalid REPORT SUPPORTED OPERATION CODES"
+ " with unsupported REPORTING OPTIONS %#x for 0x%08llx from %s\n",
+ cmd->se_tfo->fabric_name, opts,
+ cmd->se_lun->unpacked_lun,
+ sess->se_node_acl->initiatorname);
+ return TCM_INVALID_CDB_FIELD;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(tcm_supported_opcodes); i++) {
+ descr = tcm_supported_opcodes[i];
+ if (descr->opcode != requested_opcode)
+ continue;
+
+ switch (opts) {
+ case 0x1:
+ /*
+ * If the REQUESTED OPERATION CODE field specifies an
+ * operation code for which the device server implements
+ * service actions, then the device server shall
+ * terminate the command with CHECK CONDITION status,
+ * with the sense key set to ILLEGAL REQUEST, and the
+ * additional sense code set to INVALID FIELD IN CDB
+ */
+ if (descr->serv_action_valid)
+ return TCM_INVALID_CDB_FIELD;
+ *opcode = descr;
+ break;
+ case 0x2:
+ /*
+ * If the REQUESTED OPERATION CODE field specifies an
+ * operation code for which the device server does not
+ * implement service actions, then the device server
+ * shall terminate the command with CHECK CONDITION
+ * status, with the sense key set to ILLEGAL REQUEST,
+ * and the additional sense code set to INVALID FIELD IN CDB.
+ */
+ if (descr->serv_action_valid &&
+ descr->service_action == requested_sa)
+ *opcode = descr;
+ else if (!descr->serv_action_valid)
+ return TCM_INVALID_CDB_FIELD;
+ break;
+ case 0x3:
+ /*
+ * The command support data for the operation code and
+ * service action a specified in the REQUESTED OPERATION
+ * CODE field and REQUESTED SERVICE ACTION field shall
+ * be returned in the one_command parameter data format.
+ */
+ if (descr->service_action == requested_sa)
+ *opcode = descr;
+ break;
+ }
+ }
+ return 0;
+}
+
+static sense_reason_t
+spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
+{
+ int descr_num = ARRAY_SIZE(tcm_supported_opcodes);
+ struct target_opcode_descriptor *descr = NULL;
+ unsigned char *cdb = cmd->t_task_cdb;
+ u8 rctd = (cdb[2] >> 7) & 0x1;
+ unsigned char *buf = NULL;
+ int response_length = 0;
+ u8 opts = cdb[2] & 0x3;
+ unsigned char *rbuf;
+ int ret = 0;
+ int i;
+
+ rbuf = transport_kmap_data_sg(cmd);
+ if (cmd->data_length && !rbuf) {
+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+ goto out;
+ }
+
+ if (opts == 0)
+ response_length = 4 + (8 + rctd * 12) * descr_num;
+ else {
+ ret = spc_rsoc_get_descr(cmd, &descr);
+ if (ret)
+ goto out;
+
+ if (descr)
+ response_length = 4 + descr->cdb_size + rctd * 12;
+ else
+ response_length = 2;
+ }
+
+ buf = kzalloc(response_length, GFP_KERNEL);
+ if (!buf) {
+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+ goto out;
+ }
+ response_length = 0;
+
+ if (opts == 0) {
+ response_length += 4;
+
+ for (i = 0; i < ARRAY_SIZE(tcm_supported_opcodes); i++) {
+ descr = tcm_supported_opcodes[i];
+ response_length += spc_rsoc_encode_command_descriptor(
+ &buf[response_length], rctd, descr);
+ }
+ put_unaligned_be32(response_length - 3, buf);
+ } else {
+ response_length = spc_rsoc_encode_one_command_descriptor(
+ &buf[response_length], rctd, descr);
+ }
+
+ memcpy(rbuf, buf, min_t(u32, response_length, cmd->data_length));
+out:
+ kfree(buf);
+ transport_kunmap_data_sg(cmd);
+
+ if (!ret)
+ target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, response_length);
+ return ret;
+}
+
sense_reason_t
spc_parse_cdb(struct se_cmd *cmd, unsigned int *size)
{
@@ -1433,6 +1629,10 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size)
cmd->execute_cmd =
target_emulate_report_target_port_groups;
}
+ if ((cdb[1] & 0x1f) ==
+ MI_REPORT_SUPPORTED_OPERATION_CODES)
+ cmd->execute_cmd =
+ spc_emulate_report_supp_op_codes;
*size = get_unaligned_be32(&cdb[6]);
} else {
/*
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index c03e35fc382c..651b5183451c 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -342,4 +342,11 @@ enum scsi_version_descriptor {
SCSI_VERSION_DESCRIPTOR_SRP = 0x0940
};
+enum scsi_support_opcode {
+ SCSI_SUPPORT_NO_INFO = 0,
+ SCSI_SUPPORT_NOT_SUPPORTED = 1,
+ SCSI_SUPPORT_FULL = 3,
+ SCSI_SUPPORT_VENDOR = 5,
+};
+
#endif /* _SCSI_PROTO_H_ */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index c2b36f7d917d..d93c65bcbc11 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -867,6 +867,18 @@ struct se_device {
struct se_device_queue *queues;
};
+struct target_opcode_descriptor {
+ u8 support:3;
+ u8 serv_action_valid:1;
+ u8 opcode;
+ u16 service_action;
+ u32 cdb_size;
+ u8 specific_timeout;
+ u16 nominal_timeout;
+ u16 recommended_timeout;
+ u8 usage_bits[];
+};
+
struct se_hba {
u16 hba_tpgt;
u32 hba_id;
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 1/6] scsi: target: core: " Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
2022-08-12 3:38 ` Mike Christie
2022-07-18 12:01 ` [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC Dmitry Bogdanov
` (3 subsequent siblings)
5 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_spc.c | 595 +++++++++++++++++++++++++++++++
include/scsi/scsi_proto.h | 3 +
2 files changed, 598 insertions(+)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 4157f73977cf..506e28b14e5a 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1308,8 +1308,603 @@ spc_emulate_testunitready(struct se_cmd *cmd)
return 0;
}
+static struct target_opcode_descriptor tcm_opcode_read6 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = READ_6,
+ .cdb_size = 6,
+ .usage_bits = {READ_6, 0x1f, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = READ_10,
+ .cdb_size = 10,
+ .usage_bits = {READ_10, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read12 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = READ_12,
+ .cdb_size = 12,
+ .usage_bits = {READ_12, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = READ_16,
+ .cdb_size = 16,
+ .usage_bits = {READ_16, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write6 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_6,
+ .cdb_size = 6,
+ .usage_bits = {WRITE_6, 0x1f, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_10,
+ .cdb_size = 10,
+ .usage_bits = {WRITE_10, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write_verify10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_VERIFY,
+ .cdb_size = 10,
+ .usage_bits = {WRITE_VERIFY, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write12 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_12,
+ .cdb_size = 12,
+ .usage_bits = {WRITE_12, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_16,
+ .cdb_size = 16,
+ .usage_bits = {WRITE_16, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write_verify16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_VERIFY_16,
+ .cdb_size = 16,
+ .usage_bits = {WRITE_VERIFY_16, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_xdwriteread10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = XDWRITEREAD_10,
+ .cdb_size = 10,
+ .usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = VARIABLE_LENGTH_CMD,
+ .service_action = XDWRITEREAD_32,
+ .cdb_size = 32,
+ .usage_bits = {VARIABLE_LENGTH_CMD, SCSI_CONTROL_MASK, 0x00, 0x00,
+ 0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0x18,
+ 0x00, XDWRITEREAD_32, 0x18, 0x00,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write_same32 = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = VARIABLE_LENGTH_CMD,
+ .service_action = WRITE_SAME_32,
+ .cdb_size = 32,
+ .usage_bits = {VARIABLE_LENGTH_CMD, SCSI_CONTROL_MASK, 0x00, 0x00,
+ 0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0x18,
+ 0x00, WRITE_SAME_32, 0xe8, 0x00,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff},
+};
+
+static struct target_opcode_descriptor tcm_opcode_compare_write = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = COMPARE_AND_WRITE,
+ .cdb_size = 16,
+ .usage_bits = {COMPARE_AND_WRITE, 0x18, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read_capacity = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = READ_CAPACITY,
+ .cdb_size = 10,
+ .usage_bits = {READ_CAPACITY, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00,
+ 0x01, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read_capacity16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = SERVICE_ACTION_IN_16,
+ .service_action = SAI_READ_CAPACITY_16,
+ .cdb_size = 16,
+ .usage_bits = {SERVICE_ACTION_IN_16, SAI_READ_CAPACITY_16, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_read_report_refferals = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = SERVICE_ACTION_IN_16,
+ .service_action = SAI_REPORT_REFERRALS,
+ .cdb_size = 16,
+ .usage_bits = {SERVICE_ACTION_IN_16, SAI_REPORT_REFERRALS, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_sync_cache = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = SYNCHRONIZE_CACHE,
+ .cdb_size = 10,
+ .usage_bits = {SYNCHRONIZE_CACHE, 0x02, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_sync_cache16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = SYNCHRONIZE_CACHE_16,
+ .cdb_size = 16,
+ .usage_bits = {SYNCHRONIZE_CACHE_16, 0x02, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_unmap = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = UNMAP,
+ .cdb_size = 10,
+ .usage_bits = {UNMAP, 0x00, 0x00, 0x00,
+ 0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write_same = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_SAME,
+ .cdb_size = 10,
+ .usage_bits = {WRITE_SAME, 0xe8, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_write_same16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = WRITE_SAME_16,
+ .cdb_size = 16,
+ .usage_bits = {WRITE_SAME_16, 0xe8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_verify = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = VERIFY,
+ .cdb_size = 10,
+ .usage_bits = {VERIFY, 0x00, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_verify16 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = VERIFY_16,
+ .cdb_size = 16,
+ .usage_bits = {VERIFY_16, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_start_stop = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = START_STOP,
+ .cdb_size = 6,
+ .usage_bits = {START_STOP, 0x01, 0x00, 0x00,
+ 0x01, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_mode_select = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = MODE_SELECT,
+ .cdb_size = 6,
+ .usage_bits = {MODE_SELECT, 0x10, 0x00, 0x00,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_mode_select10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = MODE_SELECT_10,
+ .cdb_size = 10,
+ .usage_bits = {MODE_SELECT_10, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_mode_sense = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = MODE_SENSE,
+ .cdb_size = 6,
+ .usage_bits = {MODE_SENSE, 0x08, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_mode_sense10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = MODE_SENSE_10,
+ .cdb_size = 10,
+ .usage_bits = {MODE_SENSE_10, 0x18, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pri_read_keys = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_IN,
+ .service_action = PRI_READ_KEYS,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_IN, PRI_READ_KEYS, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pri_read_resrv = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_IN,
+ .service_action = PRI_READ_RESERVATION,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_IN, PRI_READ_RESERVATION, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pri_read_caps = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_IN,
+ .service_action = PRI_REPORT_CAPABILITIES,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_IN, PRI_REPORT_CAPABILITIES, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pri_read_full_status = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_IN,
+ .service_action = PRI_READ_FULL_STATUS,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_IN, PRI_READ_FULL_STATUS, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_register = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_REGISTER,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_REGISTER, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_reserve = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_RESERVE,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_RESERVE, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_release = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_RELEASE,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_RELEASE, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_clear = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_CLEAR,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_CLEAR, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_preempt = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_PREEMPT,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_PREEMPT, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_preempt_abort = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_PREEMPT_AND_ABORT,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_PREEMPT_AND_ABORT, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_reg_ign_exist = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_REGISTER_AND_IGNORE_EXISTING_KEY,
+ .cdb_size = 10,
+ .usage_bits = {
+ PERSISTENT_RESERVE_OUT, PRO_REGISTER_AND_IGNORE_EXISTING_KEY,
+ 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_pro_register_move = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = PERSISTENT_RESERVE_OUT,
+ .service_action = PRO_REGISTER_AND_MOVE,
+ .cdb_size = 10,
+ .usage_bits = {PERSISTENT_RESERVE_OUT, PRO_REGISTER_AND_MOVE, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_release = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = RELEASE,
+ .cdb_size = 6,
+ .usage_bits = {RELEASE, 0x00, 0x00, 0x00,
+ 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_release10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = RELEASE_10,
+ .cdb_size = 10,
+ .usage_bits = {RELEASE_10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_reserve = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = RESERVE,
+ .cdb_size = 6,
+ .usage_bits = {RESERVE, 0x00, 0x00, 0x00,
+ 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_reserve10 = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = RESERVE_10,
+ .cdb_size = 10,
+ .usage_bits = {RESERVE_10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_request_sense = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = REQUEST_SENSE,
+ .cdb_size = 6,
+ .usage_bits = {REQUEST_SENSE, 0x00, 0x00, 0x00,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_inquiry = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = INQUIRY,
+ .cdb_size = 6,
+ .usage_bits = {INQUIRY, 0x01, 0xff, 0xff,
+ 0xff, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_extended_copy_lid1 = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = EXTENDED_COPY,
+ .cdb_size = 16,
+ .usage_bits = {EXTENDED_COPY, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_rcv_copy_res_op_params = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = RECEIVE_COPY_RESULTS,
+ .service_action = RCR_SA_OPERATING_PARAMETERS,
+ .cdb_size = 16,
+ .usage_bits = {RECEIVE_COPY_RESULTS, RCR_SA_OPERATING_PARAMETERS,
+ 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_report_luns = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = REPORT_LUNS,
+ .cdb_size = 12,
+ .usage_bits = {REPORT_LUNS, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_test_unit_ready = {
+ .support = SCSI_SUPPORT_FULL,
+ .opcode = TEST_UNIT_READY,
+ .cdb_size = 6,
+ .usage_bits = {TEST_UNIT_READY, 0x00, 0x00, 0x00,
+ 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_report_target_pgs = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = MAINTENANCE_IN,
+ .service_action = MI_REPORT_TARGET_PGS,
+ .cdb_size = 12,
+ .usage_bits = {MAINTENANCE_IN, 0xE0 | MI_REPORT_TARGET_PGS, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = MAINTENANCE_IN,
+ .service_action = MI_REPORT_SUPPORTED_OPERATION_CODES,
+ .cdb_size = 12,
+ .usage_bits = {MAINTENANCE_IN, MI_REPORT_SUPPORTED_OPERATION_CODES,
+ 0x87, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
+
+static struct target_opcode_descriptor tcm_opcode_set_tpg = {
+ .support = SCSI_SUPPORT_FULL,
+ .serv_action_valid = 1,
+ .opcode = MAINTENANCE_OUT,
+ .service_action = MO_SET_TARGET_PGS,
+ .cdb_size = 12,
+ .usage_bits = {MAINTENANCE_OUT, MO_SET_TARGET_PGS, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+};
static struct target_opcode_descriptor *tcm_supported_opcodes[] = {
+ &tcm_opcode_read6,
+ &tcm_opcode_read10,
+ &tcm_opcode_read12,
+ &tcm_opcode_read16,
+ &tcm_opcode_write6,
+ &tcm_opcode_write10,
+ &tcm_opcode_write_verify10,
+ &tcm_opcode_write12,
+ &tcm_opcode_write16,
+ &tcm_opcode_write_verify16,
+ &tcm_opcode_xdwriteread10,
+ &tcm_opcode_xdwriteread32,
+ &tcm_opcode_write_same32,
+ &tcm_opcode_compare_write,
+ &tcm_opcode_read_capacity,
+ &tcm_opcode_read_capacity16,
+ &tcm_opcode_read_report_refferals,
+ &tcm_opcode_sync_cache,
+ &tcm_opcode_sync_cache16,
+ &tcm_opcode_unmap,
+ &tcm_opcode_write_same,
+ &tcm_opcode_write_same16,
+ &tcm_opcode_verify,
+ &tcm_opcode_verify16,
+ &tcm_opcode_start_stop,
+ &tcm_opcode_mode_select,
+ &tcm_opcode_mode_select10,
+ &tcm_opcode_mode_sense,
+ &tcm_opcode_mode_sense10,
+ &tcm_opcode_pri_read_keys,
+ &tcm_opcode_pri_read_resrv,
+ &tcm_opcode_pri_read_caps,
+ &tcm_opcode_pri_read_full_status,
+ &tcm_opcode_pro_register,
+ &tcm_opcode_pro_reserve,
+ &tcm_opcode_pro_release,
+ &tcm_opcode_pro_clear,
+ &tcm_opcode_pro_preempt,
+ &tcm_opcode_pro_preempt_abort,
+ &tcm_opcode_pro_reg_ign_exist,
+ &tcm_opcode_pro_register_move,
+ &tcm_opcode_release,
+ &tcm_opcode_release10,
+ &tcm_opcode_reserve,
+ &tcm_opcode_reserve10,
+ &tcm_opcode_request_sense,
+ &tcm_opcode_inquiry,
+ &tcm_opcode_extended_copy_lid1,
+ &tcm_opcode_rcv_copy_res_op_params,
+ &tcm_opcode_report_luns,
+ &tcm_opcode_test_unit_ready,
+ &tcm_opcode_report_target_pgs,
+ &tcm_opcode_report_supp_opcodes,
+ &tcm_opcode_set_tpg,
};
static int
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index 651b5183451c..cb722225b3bc 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -349,4 +349,7 @@ enum scsi_support_opcode {
SCSI_SUPPORT_VENDOR = 5,
};
+#define SCSI_CONTROL_MASK 0
+#define SCSI_GROUP_NUMBER_MASK 0
+
#endif /* _SCSI_PROTO_H_ */
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 1/6] scsi: target: core: " Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
2022-07-19 12:40 ` kernel test robot
2022-08-12 3:43 ` Mike Christie
2022-07-18 12:01 ` [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute Dmitry Bogdanov
` (2 subsequent siblings)
5 siblings, 2 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Report supported opcodes depending on a dynamic device configuration
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_spc.c | 118 ++++++++++++++++++++++++++++--
include/target/target_core_base.h | 1 +
2 files changed, 114 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 506e28b14e5a..cf516136b933 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1424,6 +1424,13 @@ static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
0xff, 0xff, 0xff, 0xff},
};
+static bool tcm_is_ws_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_tpws;
+}
+
static struct target_opcode_descriptor tcm_opcode_write_same32 = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1438,8 +1445,16 @@ static struct target_opcode_descriptor tcm_opcode_write_same32 = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff},
+ .enabled = tcm_is_ws_enabled,
};
+static bool tcm_is_caw_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_caw;
+}
+
static struct target_opcode_descriptor tcm_opcode_compare_write = {
.support = SCSI_SUPPORT_FULL,
.opcode = COMPARE_AND_WRITE,
@@ -1448,6 +1463,7 @@ static struct target_opcode_descriptor tcm_opcode_compare_write = {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0x00,
0x00, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_caw_enabled,
};
static struct target_opcode_descriptor tcm_opcode_read_capacity = {
@@ -1471,6 +1487,20 @@ static struct target_opcode_descriptor tcm_opcode_read_capacity16 = {
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
};
+static bool tcm_is_rep_ref_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ spin_lock(&dev->t10_alua.lba_map_lock);
+ if (list_empty(&dev->t10_alua.lba_map_list)) {
+ spin_unlock(&dev->t10_alua.lba_map_lock);
+ return false;
+ }
+ spin_unlock(&dev->t10_alua.lba_map_lock);
+ return true;
+
+}
+
static struct target_opcode_descriptor tcm_opcode_read_report_refferals = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1481,6 +1511,7 @@ static struct target_opcode_descriptor tcm_opcode_read_report_refferals = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_rep_ref_enabled,
};
static struct target_opcode_descriptor tcm_opcode_sync_cache = {
@@ -1502,6 +1533,14 @@ static struct target_opcode_descriptor tcm_opcode_sync_cache16 = {
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
};
+static bool tcm_is_unmap_enabled(struct se_cmd *cmd)
+{
+ struct sbc_ops *ops = cmd->protocol_data;
+ struct se_device *dev = cmd->se_dev;
+
+ return ops->execute_unmap && dev->dev_attrib.emulate_tpu;
+}
+
static struct target_opcode_descriptor tcm_opcode_unmap = {
.support = SCSI_SUPPORT_FULL,
.opcode = UNMAP,
@@ -1509,6 +1548,7 @@ static struct target_opcode_descriptor tcm_opcode_unmap = {
.usage_bits = {UNMAP, 0x00, 0x00, 0x00,
0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_unmap_enabled,
};
static struct target_opcode_descriptor tcm_opcode_write_same = {
@@ -1518,6 +1558,7 @@ static struct target_opcode_descriptor tcm_opcode_write_same = {
.usage_bits = {WRITE_SAME, 0xe8, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_ws_enabled,
};
static struct target_opcode_descriptor tcm_opcode_write_same16 = {
@@ -1528,6 +1569,7 @@ static struct target_opcode_descriptor tcm_opcode_write_same16 = {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_ws_enabled,
};
static struct target_opcode_descriptor tcm_opcode_verify = {
@@ -1613,6 +1655,13 @@ static struct target_opcode_descriptor tcm_opcode_pri_read_resrv = {
0xff, SCSI_CONTROL_MASK},
};
+static bool tcm_is_pr_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_pr;
+}
+
static struct target_opcode_descriptor tcm_opcode_pri_read_caps = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1622,6 +1671,7 @@ static struct target_opcode_descriptor tcm_opcode_pri_read_caps = {
.usage_bits = {PERSISTENT_RESERVE_IN, PRI_REPORT_CAPABILITIES, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pri_read_full_status = {
@@ -1633,6 +1683,7 @@ static struct target_opcode_descriptor tcm_opcode_pri_read_full_status = {
.usage_bits = {PERSISTENT_RESERVE_IN, PRI_READ_FULL_STATUS, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_register = {
@@ -1644,6 +1695,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_register = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_REGISTER, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_reserve = {
@@ -1655,6 +1707,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_reserve = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_RESERVE, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_release = {
@@ -1666,6 +1719,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_release = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_RELEASE, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_clear = {
@@ -1677,6 +1731,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_clear = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_CLEAR, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_preempt = {
@@ -1688,6 +1743,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_preempt = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_PREEMPT, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_preempt_abort = {
@@ -1699,6 +1755,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_preempt_abort = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_PREEMPT_AND_ABORT, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_reg_ign_exist = {
@@ -1712,6 +1769,7 @@ static struct target_opcode_descriptor tcm_opcode_pro_reg_ign_exist = {
0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
static struct target_opcode_descriptor tcm_opcode_pro_register_move = {
@@ -1723,14 +1781,23 @@ static struct target_opcode_descriptor tcm_opcode_pro_register_move = {
.usage_bits = {PERSISTENT_RESERVE_OUT, PRO_REGISTER_AND_MOVE, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_pr_enabled,
};
+static bool tcm_is_scsi2_reservations_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_pr;
+}
+
static struct target_opcode_descriptor tcm_opcode_release = {
.support = SCSI_SUPPORT_FULL,
.opcode = RELEASE,
.cdb_size = 6,
.usage_bits = {RELEASE, 0x00, 0x00, 0x00,
0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_scsi2_reservations_enabled,
};
static struct target_opcode_descriptor tcm_opcode_release10 = {
@@ -1740,6 +1807,7 @@ static struct target_opcode_descriptor tcm_opcode_release10 = {
.usage_bits = {RELEASE_10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_scsi2_reservations_enabled,
};
static struct target_opcode_descriptor tcm_opcode_reserve = {
@@ -1748,6 +1816,7 @@ static struct target_opcode_descriptor tcm_opcode_reserve = {
.cdb_size = 6,
.usage_bits = {RESERVE, 0x00, 0x00, 0x00,
0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_scsi2_reservations_enabled,
};
static struct target_opcode_descriptor tcm_opcode_reserve10 = {
@@ -1757,6 +1826,7 @@ static struct target_opcode_descriptor tcm_opcode_reserve10 = {
.usage_bits = {RESERVE_10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_scsi2_reservations_enabled,
};
static struct target_opcode_descriptor tcm_opcode_request_sense = {
@@ -1775,6 +1845,13 @@ static struct target_opcode_descriptor tcm_opcode_inquiry = {
0xff, SCSI_CONTROL_MASK},
};
+static bool tcm_is_3pc_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_3pc;
+}
+
static struct target_opcode_descriptor tcm_opcode_extended_copy_lid1 = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1784,6 +1861,7 @@ static struct target_opcode_descriptor tcm_opcode_extended_copy_lid1 = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_3pc_enabled,
};
static struct target_opcode_descriptor tcm_opcode_rcv_copy_res_op_params = {
@@ -1797,6 +1875,7 @@ static struct target_opcode_descriptor tcm_opcode_rcv_copy_res_op_params = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_3pc_enabled,
};
static struct target_opcode_descriptor tcm_opcode_report_luns = {
@@ -1839,6 +1918,26 @@ static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
};
+static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd)
+{
+ struct t10_alua_tg_pt_gp *l_tg_pt_gp;
+ struct se_lun *l_lun = cmd->se_lun;
+
+ spin_lock(&l_lun->lun_tg_pt_gp_lock);
+ l_tg_pt_gp = l_lun->lun_tg_pt_gp;
+ if (!l_tg_pt_gp) {
+ spin_unlock(&l_lun->lun_tg_pt_gp_lock);
+ return false;
+ }
+ if (!(l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICIT_ALUA)) {
+ spin_unlock(&l_lun->lun_tg_pt_gp_lock);
+ return false;
+ }
+ spin_unlock(&l_lun->lun_tg_pt_gp_lock);
+
+ return true;
+}
+
static struct target_opcode_descriptor tcm_opcode_set_tpg = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1848,6 +1947,7 @@ static struct target_opcode_descriptor tcm_opcode_set_tpg = {
.usage_bits = {MAINTENANCE_OUT, MO_SET_TARGET_PGS, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+ .enabled = tcm_is_set_tpg_enabled,
};
static struct target_opcode_descriptor *tcm_supported_opcodes[] = {
@@ -2003,7 +2103,9 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
*/
if (descr->serv_action_valid)
return TCM_INVALID_CDB_FIELD;
- *opcode = descr;
+
+ if (!descr->enabled || descr->enabled(cmd))
+ *opcode = descr;
break;
case 0x2:
/*
@@ -2015,9 +2117,10 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
* and the additional sense code set to INVALID FIELD IN CDB.
*/
if (descr->serv_action_valid &&
- descr->service_action == requested_sa)
- *opcode = descr;
- else if (!descr->serv_action_valid)
+ descr->service_action == requested_sa) {
+ if (!descr->enabled || descr->enabled(cmd))
+ *opcode = descr;
+ } else if (!descr->serv_action_valid)
return TCM_INVALID_CDB_FIELD;
break;
case 0x3:
@@ -2028,10 +2131,12 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
* be returned in the one_command parameter data format.
*/
if (descr->service_action == requested_sa)
- *opcode = descr;
+ if (!descr->enabled || descr->enabled(cmd))
+ *opcode = descr;
break;
}
}
+
return 0;
}
@@ -2080,6 +2185,9 @@ spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
for (i = 0; i < ARRAY_SIZE(tcm_supported_opcodes); i++) {
descr = tcm_supported_opcodes[i];
+ if (descr->enabled && !descr->enabled(cmd))
+ continue;
+
response_length += spc_rsoc_encode_command_descriptor(
&buf[response_length], rctd, descr);
}
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index d93c65bcbc11..329f88680367 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -876,6 +876,7 @@ struct target_opcode_descriptor {
u8 specific_timeout;
u16 nominal_timeout;
u16 recommended_timeout;
+ bool (*enabled)(struct se_cmd *cmd);
u8 usage_bits[];
};
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
` (2 preceding siblings ...)
2022-07-18 12:01 ` [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
2022-08-12 3:43 ` Mike Christie
2022-07-18 12:01 ` [PATCH 5/6] scsi: target: core: dynamicaly set dpofua in usage_bits Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 6/6] scsi: target: check emulate_3pc for RECEIVE COPY Dmitry Bogdanov
5 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Make support of RSOC turned off by emulate_rsoc attibute.
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_configfs.c | 20 ++++++++++++++++++++
drivers/target/target_core_device.c | 1 +
drivers/target/target_core_spc.c | 12 ++++++++++++
include/target/target_core_base.h | 3 +++
4 files changed, 36 insertions(+)
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index bbcbbfa72b07..0c1fb222c9da 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -547,6 +547,7 @@ DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity);
DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment);
DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data);
DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len);
+DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc);
#define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \
static ssize_t _name##_store(struct config_item *item, const char *page,\
@@ -1175,6 +1176,23 @@ static ssize_t pgr_support_store(struct config_item *item,
return count;
}
+static ssize_t emulate_rsoc_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct se_dev_attrib *da = to_attrib(item);
+ bool flag;
+ int ret;
+
+ ret = strtobool(page, &flag);
+ if (ret < 0)
+ return ret;
+
+ da->emulate_rsoc = flag;
+ pr_debug("dev[%p]: SE Device REPORT_SUPPORTED_OPERATION_CODES_EMULATION flag: %d\n",
+ da->da_dev, flag);
+ return count;
+}
+
CONFIGFS_ATTR(, emulate_model_alias);
CONFIGFS_ATTR(, emulate_dpo);
CONFIGFS_ATTR(, emulate_fua_write);
@@ -1187,6 +1205,7 @@ CONFIGFS_ATTR(, emulate_tpws);
CONFIGFS_ATTR(, emulate_caw);
CONFIGFS_ATTR(, emulate_3pc);
CONFIGFS_ATTR(, emulate_pr);
+CONFIGFS_ATTR(, emulate_rsoc);
CONFIGFS_ATTR(, pi_prot_type);
CONFIGFS_ATTR_RO(, hw_pi_prot_type);
CONFIGFS_ATTR(, pi_prot_format);
@@ -1250,6 +1269,7 @@ struct configfs_attribute *sbc_attrib_attrs[] = {
&attr_max_write_same_len,
&attr_alua_support,
&attr_pgr_support,
+ &attr_emulate_rsoc,
NULL,
};
EXPORT_SYMBOL(sbc_attrib_attrs);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 25f33eb25337..600f038217c0 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -795,6 +795,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
dev->dev_attrib.emulate_caw = DA_EMULATE_CAW;
dev->dev_attrib.emulate_3pc = DA_EMULATE_3PC;
dev->dev_attrib.emulate_pr = DA_EMULATE_PR;
+ dev->dev_attrib.emulate_rsoc = DA_EMULATE_RSOC;
dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE0_PROT;
dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS;
dev->dev_attrib.force_pr_aptpl = DA_FORCE_PR_APTPL;
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index cf516136b933..a86f4d917aad 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1906,6 +1906,14 @@ static struct target_opcode_descriptor tcm_opcode_report_target_pgs = {
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
};
+
+static bool spc_rsoc_enabled(struct se_cmd *cmd)
+{
+ struct se_device *dev = cmd->se_dev;
+
+ return dev->dev_attrib.emulate_rsoc;
+}
+
static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
.support = SCSI_SUPPORT_FULL,
.serv_action_valid = 1,
@@ -1916,6 +1924,7 @@ static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
0x87, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
+ .enabled = spc_rsoc_enabled,
};
static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd)
@@ -2154,6 +2163,9 @@ spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
int ret = 0;
int i;
+ if (!cmd->se_dev->dev_attrib.emulate_rsoc)
+ return TCM_UNSUPPORTED_SCSI_OPCODE;
+
rbuf = transport_kmap_data_sg(cmd);
if (cmd->data_length && !rbuf) {
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 329f88680367..8f8b51d2bc7b 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -91,6 +91,8 @@
#define DA_EMULATE_ALUA 0
/* Emulate SCSI2 RESERVE/RELEASE and Persistent Reservations by default */
#define DA_EMULATE_PR 1
+/* Emulation for REPORT SUPPORTED OPERATION CODES */
+#define DA_EMULATE_RSOC 1
/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
#define DA_ENFORCE_PR_ISIDS 1
/* Force SPC-3 PR Activate Persistence across Target Power Loss */
@@ -690,6 +692,7 @@ struct se_dev_attrib {
bool emulate_caw;
bool emulate_3pc;
bool emulate_pr;
+ bool emulate_rsoc;
enum target_prot_type pi_prot_type;
enum target_prot_type hw_pi_prot_type;
bool pi_prot_verify;
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/6] scsi: target: core: dynamicaly set dpofua in usage_bits
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
` (3 preceding siblings ...)
2022-07-18 12:01 ` [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 6/6] scsi: target: check emulate_3pc for RECEIVE COPY Dmitry Bogdanov
5 siblings, 0 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov,
Konstantin Shelekhin
libiscsi tests check the support of DPO & FUA bits in usage bits of RSOC
response.
This patch adds support of dynamic usage bits for each opcode.
Set support of DPO & FUA bits in usage_bits of RSOC response depending
on support DPOFUA in the backstore device.
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_spc.c | 36 +++++++++++++++++++++++++++++--
include/target/target_core_base.h | 2 ++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index a86f4d917aad..27b4546d7d2c 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1308,6 +1308,22 @@ spc_emulate_testunitready(struct se_cmd *cmd)
return 0;
}
+static void set_dpofua_usage_bits(u8 *usage_bits, struct se_device *dev)
+{
+ if (!target_check_fua(dev))
+ usage_bits[1] &= ~0x18;
+ else
+ usage_bits[1] |= 0x18;
+}
+
+static void set_dpofua_usage_bits32(u8 *usage_bits, struct se_device *dev)
+{
+ if (!target_check_fua(dev))
+ usage_bits[10] &= ~0x18;
+ else
+ usage_bits[10] |= 0x18;
+}
+
static struct target_opcode_descriptor tcm_opcode_read6 = {
.support = SCSI_SUPPORT_FULL,
.opcode = READ_6,
@@ -1323,6 +1339,7 @@ static struct target_opcode_descriptor tcm_opcode_read10 = {
.usage_bits = {READ_10, 0xf8, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_read12 = {
@@ -1332,6 +1349,7 @@ static struct target_opcode_descriptor tcm_opcode_read12 = {
.usage_bits = {READ_12, 0xf8, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_read16 = {
@@ -1342,6 +1360,7 @@ static struct target_opcode_descriptor tcm_opcode_read16 = {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_write6 = {
@@ -1359,6 +1378,7 @@ static struct target_opcode_descriptor tcm_opcode_write10 = {
.usage_bits = {WRITE_10, 0xf8, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_write_verify10 = {
@@ -1368,6 +1388,7 @@ static struct target_opcode_descriptor tcm_opcode_write_verify10 = {
.usage_bits = {WRITE_VERIFY, 0xf0, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_write12 = {
@@ -1377,6 +1398,7 @@ static struct target_opcode_descriptor tcm_opcode_write12 = {
.usage_bits = {WRITE_12, 0xf8, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_write16 = {
@@ -1387,6 +1409,7 @@ static struct target_opcode_descriptor tcm_opcode_write16 = {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_write_verify16 = {
@@ -1397,6 +1420,7 @@ static struct target_opcode_descriptor tcm_opcode_write_verify16 = {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_xdwriteread10 = {
@@ -1406,6 +1430,7 @@ static struct target_opcode_descriptor tcm_opcode_xdwriteread10 = {
.usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
0xff, SCSI_CONTROL_MASK},
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
@@ -1422,6 +1447,7 @@ static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff},
+ .update_usage_bits = set_dpofua_usage_bits32,
};
static bool tcm_is_ws_enabled(struct se_cmd *cmd)
@@ -1446,6 +1472,7 @@ static struct target_opcode_descriptor tcm_opcode_write_same32 = {
0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff},
.enabled = tcm_is_ws_enabled,
+ .update_usage_bits = set_dpofua_usage_bits32,
};
static bool tcm_is_caw_enabled(struct se_cmd *cmd)
@@ -1464,6 +1491,7 @@ static struct target_opcode_descriptor tcm_opcode_compare_write = {
0xff, 0xff, 0x00, 0x00,
0x00, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
.enabled = tcm_is_caw_enabled,
+ .update_usage_bits = set_dpofua_usage_bits,
};
static struct target_opcode_descriptor tcm_opcode_read_capacity = {
@@ -2052,7 +2080,8 @@ spc_rsoc_encode_command_descriptor(unsigned char *buf, u8 ctdp,
static int
spc_rsoc_encode_one_command_descriptor(unsigned char *buf, u8 ctdp,
- struct target_opcode_descriptor *descr)
+ struct target_opcode_descriptor *descr,
+ struct se_device *dev)
{
int td_size = 0;
@@ -2064,6 +2093,8 @@ spc_rsoc_encode_one_command_descriptor(unsigned char *buf, u8 ctdp,
buf[1] = (ctdp << 7) | SCSI_SUPPORT_FULL;
put_unaligned_be16(descr->cdb_size, &buf[2]);
memcpy(&buf[4], descr->usage_bits, descr->cdb_size);
+ if (descr->update_usage_bits)
+ descr->update_usage_bits(&buf[4], dev);
td_size = spc_rsoc_encode_command_timeouts_descriptor(
&buf[4 + descr->cdb_size], ctdp, descr);
@@ -2206,7 +2237,8 @@ spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
put_unaligned_be32(response_length - 3, buf);
} else {
response_length = spc_rsoc_encode_one_command_descriptor(
- &buf[response_length], rctd, descr);
+ &buf[response_length], rctd, descr,
+ cmd->se_dev);
}
memcpy(rbuf, buf, min_t(u32, response_length, cmd->data_length));
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 8f8b51d2bc7b..71811b49f154 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -880,6 +880,8 @@ struct target_opcode_descriptor {
u16 nominal_timeout;
u16 recommended_timeout;
bool (*enabled)(struct se_cmd *cmd);
+ void (*update_usage_bits)(u8 *usage_bits,
+ struct se_device *dev);
u8 usage_bits[];
};
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/6] scsi: target: check emulate_3pc for RECEIVE COPY
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
` (4 preceding siblings ...)
2022-07-18 12:01 ` [PATCH 5/6] scsi: target: core: dynamicaly set dpofua in usage_bits Dmitry Bogdanov
@ 2022-07-18 12:01 ` Dmitry Bogdanov
5 siblings, 0 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-07-18 12:01 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
RECEIVE COPY RESULTS is an opcode from 3rd party copy command set and
shall be rejected if emulate_3pc attribute is off like EXTENDED COPY
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_xcopy.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 6bb20aa9c5bc..37e6b4fef0e5 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -1009,8 +1009,14 @@ sense_reason_t target_do_receive_copy_results(struct se_cmd *se_cmd)
{
unsigned char *cdb = &se_cmd->t_task_cdb[0];
int sa = (cdb[1] & 0x1f), list_id = cdb[2];
+ struct se_device *dev = se_cmd->se_dev;
sense_reason_t rc = TCM_NO_SENSE;
+ if (!dev->dev_attrib.emulate_3pc) {
+ pr_debug("Third-party copy operations explicitly disabled\n");
+ return TCM_UNSUPPORTED_SCSI_OPCODE;
+ }
+
pr_debug("Entering target_do_receive_copy_results: SA: 0x%02x, List ID:"
" 0x%02x, AL: %u\n", sa, list_id, se_cmd->data_length);
--
2.25.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 1/6] scsi: target: core: add support of RSOC command
2022-07-18 12:01 ` [PATCH 1/6] scsi: target: core: " Dmitry Bogdanov
@ 2022-07-19 10:08 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2022-07-19 10:08 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: kbuild-all, linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Hi Dmitry,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next linus/master v5.19-rc7 next-20220718]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: nios2-randconfig-s042-20220718 (https://download.01.org/0day-ci/archive/20220719/202207191727.tSUku1lU-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/dd5367ced3f2a2d631776343184cca65d8cfbed8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
git checkout dd5367ced3f2a2d631776343184cca65d8cfbed8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/target/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/target/target_core_spc.c:1459:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1459:21: sparse: expected int ret
drivers/target/target_core_spc.c:1459:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:1466:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1466:21: sparse: expected int ret
drivers/target/target_core_spc.c:1466:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:1478:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1478:21: sparse: expected int ret
drivers/target/target_core_spc.c:1478:21: sparse: got restricted sense_reason_t
>> drivers/target/target_core_spc.c:1504:16: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted sense_reason_t @@ got int ret @@
drivers/target/target_core_spc.c:1504:16: sparse: expected restricted sense_reason_t
drivers/target/target_core_spc.c:1504:16: sparse: got int ret
vim +1459 drivers/target/target_core_spc.c
1442
1443 static sense_reason_t
1444 spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
1445 {
1446 int descr_num = ARRAY_SIZE(tcm_supported_opcodes);
1447 struct target_opcode_descriptor *descr = NULL;
1448 unsigned char *cdb = cmd->t_task_cdb;
1449 u8 rctd = (cdb[2] >> 7) & 0x1;
1450 unsigned char *buf = NULL;
1451 int response_length = 0;
1452 u8 opts = cdb[2] & 0x3;
1453 unsigned char *rbuf;
1454 int ret = 0;
1455 int i;
1456
1457 rbuf = transport_kmap_data_sg(cmd);
1458 if (cmd->data_length && !rbuf) {
> 1459 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1460 goto out;
1461 }
1462
1463 if (opts == 0)
1464 response_length = 4 + (8 + rctd * 12) * descr_num;
1465 else {
1466 ret = spc_rsoc_get_descr(cmd, &descr);
1467 if (ret)
1468 goto out;
1469
1470 if (descr)
1471 response_length = 4 + descr->cdb_size + rctd * 12;
1472 else
1473 response_length = 2;
1474 }
1475
1476 buf = kzalloc(response_length, GFP_KERNEL);
1477 if (!buf) {
1478 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1479 goto out;
1480 }
1481 response_length = 0;
1482
1483 if (opts == 0) {
1484 response_length += 4;
1485
1486 for (i = 0; i < ARRAY_SIZE(tcm_supported_opcodes); i++) {
1487 descr = tcm_supported_opcodes[i];
1488 response_length += spc_rsoc_encode_command_descriptor(
1489 &buf[response_length], rctd, descr);
1490 }
1491 put_unaligned_be32(response_length - 3, buf);
1492 } else {
1493 response_length = spc_rsoc_encode_one_command_descriptor(
1494 &buf[response_length], rctd, descr);
1495 }
1496
1497 memcpy(rbuf, buf, min_t(u32, response_length, cmd->data_length));
1498 out:
1499 kfree(buf);
1500 transport_kunmap_data_sg(cmd);
1501
1502 if (!ret)
1503 target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, response_length);
> 1504 return ret;
1505 }
1506
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC
2022-07-18 12:01 ` [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC Dmitry Bogdanov
@ 2022-07-19 12:40 ` kernel test robot
2022-08-12 3:43 ` Mike Christie
1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2022-07-19 12:40 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: kbuild-all, linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov
Hi Dmitry,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next linus/master v5.19-rc7 next-20220719]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: nios2-randconfig-s042-20220718 (https://download.01.org/0day-ci/archive/20220719/202207192030.yfVYkp2d-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/5aa6c10f37c99c3321ff7675ffbb6fea99219263
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
git checkout 5aa6c10f37c99c3321ff7675ffbb6fea99219263
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/target/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/target/target_core_spc.c:1927:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct t10_alua_tg_pt_gp *l_tg_pt_gp @@ got struct t10_alua_tg_pt_gp [noderef] __rcu *lun_tg_pt_gp @@
drivers/target/target_core_spc.c:1927:20: sparse: expected struct t10_alua_tg_pt_gp *l_tg_pt_gp
drivers/target/target_core_spc.c:1927:20: sparse: got struct t10_alua_tg_pt_gp [noderef] __rcu *lun_tg_pt_gp
drivers/target/target_core_spc.c:2159:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:2159:21: sparse: expected int ret
drivers/target/target_core_spc.c:2159:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:2166:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:2166:21: sparse: expected int ret
drivers/target/target_core_spc.c:2166:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:2178:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:2178:21: sparse: expected int ret
drivers/target/target_core_spc.c:2178:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:2207:16: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted sense_reason_t @@ got int ret @@
drivers/target/target_core_spc.c:2207:16: sparse: expected restricted sense_reason_t
drivers/target/target_core_spc.c:2207:16: sparse: got int ret
vim +1927 drivers/target/target_core_spc.c
1920
1921 static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd)
1922 {
1923 struct t10_alua_tg_pt_gp *l_tg_pt_gp;
1924 struct se_lun *l_lun = cmd->se_lun;
1925
1926 spin_lock(&l_lun->lun_tg_pt_gp_lock);
> 1927 l_tg_pt_gp = l_lun->lun_tg_pt_gp;
1928 if (!l_tg_pt_gp) {
1929 spin_unlock(&l_lun->lun_tg_pt_gp_lock);
1930 return false;
1931 }
1932 if (!(l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICIT_ALUA)) {
1933 spin_unlock(&l_lun->lun_tg_pt_gp_lock);
1934 return false;
1935 }
1936 spin_unlock(&l_lun->lun_tg_pt_gp_lock);
1937
1938 return true;
1939 }
1940
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC
2022-07-18 12:01 ` [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC Dmitry Bogdanov
@ 2022-08-12 3:38 ` Mike Christie
2022-08-12 8:03 ` Dmitry Bogdanov
0 siblings, 1 reply; 20+ messages in thread
From: Mike Christie @ 2022-08-12 3:38 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: linux-scsi, linux, Roman Bolshakov
On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> ---
> drivers/target/target_core_spc.c | 595 +++++++++++++++++++++++++++++++
> include/scsi/scsi_proto.h | 3 +
> 2 files changed, 598 insertions(+)
>
> diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> index 4157f73977cf..506e28b14e5a 100644
> --- a/drivers/target/target_core_spc.c
> +++ b/drivers/target/target_core_spc.c
> +static struct target_opcode_descriptor tcm_opcode_xdwriteread10 = {
> + .support = SCSI_SUPPORT_FULL,
> + .opcode = XDWRITEREAD_10,
> + .cdb_size = 10,
> + .usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
> + 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
> + 0xff, SCSI_CONTROL_MASK},
> +};
> +
> +static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
> + .support = SCSI_SUPPORT_FULL,
> + .serv_action_valid = 1,
> + .opcode = VARIABLE_LENGTH_CMD,
> + .service_action = XDWRITEREAD_32,
> + .cdb_size = 32,
> + .usage_bits = {VARIABLE_LENGTH_CMD, SCSI_CONTROL_MASK, 0x00, 0x00,
> + 0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0x18,
> + 0x00, XDWRITEREAD_32, 0x18, 0x00,
> + 0xff, 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff,
> + 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00,
> + 0xff, 0xff, 0xff, 0xff},
> +};
> +
I just removed these because they didn't work. I think the patch was added to
one of Martin's tree after you made this patch.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC
2022-07-18 12:01 ` [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC Dmitry Bogdanov
2022-07-19 12:40 ` kernel test robot
@ 2022-08-12 3:43 ` Mike Christie
2022-08-12 11:30 ` Dmitry Bogdanov
1 sibling, 1 reply; 20+ messages in thread
From: Mike Christie @ 2022-08-12 3:43 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: linux-scsi, linux, Roman Bolshakov
On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> Report supported opcodes depending on a dynamic device configuration
>
> Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> ---
> drivers/target/target_core_spc.c | 118 ++++++++++++++++++++++++++++--
> include/target/target_core_base.h | 1 +
> 2 files changed, 114 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> index 506e28b14e5a..cf516136b933 100644
> --- a/drivers/target/target_core_spc.c
> +++ b/drivers/target/target_core_spc.c
> @@ -1424,6 +1424,13 @@ static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
> 0xff, 0xff, 0xff, 0xff},
> };
>
> +static bool tcm_is_ws_enabled(struct se_cmd *cmd)
> +{
> + struct se_device *dev = cmd->se_dev;
> +
> + return dev->dev_attrib.emulate_tpws;
> +}
> +
> static struct target_opcode_descriptor tcm_opcode_write_same32 = {
> .support = SCSI_SUPPORT_FULL,
> .serv_action_valid = 1,
> @@ -1438,8 +1445,16 @@ static struct target_opcode_descriptor tcm_opcode_write_same32 = {
> 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00,
> 0xff, 0xff, 0xff, 0xff},
> + .enabled = tcm_is_ws_enabled,
> };
I'm not sure what's incorrect. I think your patch is correct but the write
same code is wrong.
If emulate_tpws is 0, we will still execute the command. We actually only fail
with TCM_UNSUPPORTED_SCSI_OPCODE if it's a WRITE_SAME with the UNMAP bit = 1
and emulate_tpws=0.
If it's just a normal WRITE_SAME we maybe go by if by max_write_same_len is
greater than zero? Maybe that was a mistake and sbc_setup_write_same needs
a emulate_tpws check.
> static struct target_opcode_descriptor tcm_opcode_sync_cache = {
> @@ -1502,6 +1533,14 @@ static struct target_opcode_descriptor tcm_opcode_sync_cache16 = {
> 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
> };
>
> +static bool tcm_is_unmap_enabled(struct se_cmd *cmd)
> +{
> + struct sbc_ops *ops = cmd->protocol_data;
> + struct se_device *dev = cmd->se_dev;
> +
> + return ops->execute_unmap && dev->dev_attrib.emulate_tpu;
> +}
Just a trivial nit. You had an extra space there.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-07-18 12:01 ` [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute Dmitry Bogdanov
@ 2022-08-12 3:43 ` Mike Christie
2022-08-12 11:34 ` Dmitry Bogdanov
0 siblings, 1 reply; 20+ messages in thread
From: Mike Christie @ 2022-08-12 3:43 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: linux-scsi, linux, Roman Bolshakov
On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> Make support of RSOC turned off by emulate_rsoc attibute.
>
What was the reason for this?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC
2022-08-12 3:38 ` Mike Christie
@ 2022-08-12 8:03 ` Dmitry Bogdanov
2022-08-13 7:49 ` Christoph Hellwig
0 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-08-12 8:03 UTC (permalink / raw)
To: Mike Christie
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On Thu, Aug 11, 2022 at 10:38:29PM -0500, Mike Christie wrote:
> «Внимание! Данное письмо от внешнего адресата!»
>
> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> > Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> > Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> > ---
> > drivers/target/target_core_spc.c | 595 +++++++++++++++++++++++++++++++
> > include/scsi/scsi_proto.h | 3 +
> > 2 files changed, 598 insertions(+)
> >
> > diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> > index 4157f73977cf..506e28b14e5a 100644
> > --- a/drivers/target/target_core_spc.c
> > +++ b/drivers/target/target_core_spc.c
>
>
> > +static struct target_opcode_descriptor tcm_opcode_xdwriteread10 = {
> > + .support = SCSI_SUPPORT_FULL,
> > + .opcode = XDWRITEREAD_10,
> > + .cdb_size = 10,
> > + .usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
> > + 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
> > + 0xff, SCSI_CONTROL_MASK},
> > +};
> > +
> > +static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
> > + .support = SCSI_SUPPORT_FULL,
> > + .serv_action_valid = 1,
> > + .opcode = VARIABLE_LENGTH_CMD,
> > + .service_action = XDWRITEREAD_32,
> > + .cdb_size = 32,
> > + .usage_bits = {VARIABLE_LENGTH_CMD, SCSI_CONTROL_MASK, 0x00, 0x00,
> > + 0x00, 0x00, SCSI_GROUP_NUMBER_MASK, 0x18,
> > + 0x00, XDWRITEREAD_32, 0x18, 0x00,
> > + 0xff, 0xff, 0xff, 0xff,
> > + 0xff, 0xff, 0xff, 0xff,
> > + 0x00, 0x00, 0x00, 0x00,
> > + 0x00, 0x00, 0x00, 0x00,
> > + 0xff, 0xff, 0xff, 0xff},
> > +};
> > +
>
> I just removed these because they didn't work. I think the patch was added to
> one of Martin's tree after you made this patch.
Yes, I saw, Iwill remove XDWRITEREAD_* in the next revision.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC
2022-08-12 3:43 ` Mike Christie
@ 2022-08-12 11:30 ` Dmitry Bogdanov
0 siblings, 0 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-08-12 11:30 UTC (permalink / raw)
To: Mike Christie
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On Thu, Aug 11, 2022 at 10:43:05PM -0500, Mike Christie wrote:
> «Внимание! Данное письмо от внешнего адресата!»
>
> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> > Report supported opcodes depending on a dynamic device configuration
> >
> > Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> > Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> > ---
> > drivers/target/target_core_spc.c | 118 ++++++++++++++++++++++++++++--
> > include/target/target_core_base.h | 1 +
> > 2 files changed, 114 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> > index 506e28b14e5a..cf516136b933 100644
> > --- a/drivers/target/target_core_spc.c
> > +++ b/drivers/target/target_core_spc.c
> > @@ -1424,6 +1424,13 @@ static struct target_opcode_descriptor tcm_opcode_xdwriteread32 = {
> > 0xff, 0xff, 0xff, 0xff},
> > };
> >
> > +static bool tcm_is_ws_enabled(struct se_cmd *cmd)
> > +{
> > + struct se_device *dev = cmd->se_dev;
> > +
> > + return dev->dev_attrib.emulate_tpws;
> > +}
> > +
> > static struct target_opcode_descriptor tcm_opcode_write_same32 = {
> > .support = SCSI_SUPPORT_FULL,
> > .serv_action_valid = 1,
> > @@ -1438,8 +1445,16 @@ static struct target_opcode_descriptor tcm_opcode_write_same32 = {
> > 0x00, 0x00, 0x00, 0x00,
> > 0x00, 0x00, 0x00, 0x00,
> > 0xff, 0xff, 0xff, 0xff},
> > + .enabled = tcm_is_ws_enabled,
> > };
>
> I'm not sure what's incorrect. I think your patch is correct but the write
> same code is wrong.
>
> If emulate_tpws is 0, we will still execute the command. We actually only fail
> with TCM_UNSUPPORTED_SCSI_OPCODE if it's a WRITE_SAME with the UNMAP bit = 1
> and emulate_tpws=0.
>
> If it's just a normal WRITE_SAME we maybe go by if by max_write_same_len is
> greater than zero? Maybe that was a mistake and sbc_setup_write_same needs
> a emulate_tpws check.
Looks like emulate_tpws was introduced exaclty for WS+UNMAP bit case
and it can not be used in tcm_is_ws_enabled as only check. Because of
WS is actually two different commands selected by UNMAP bit it is
unable somehow to differentiate them in RSOC. So I will reformulate
the check in tcm_is_ws_enabled to be true if some of cases is
supported by the backstore device.
+ return (dev->dev_attrib.emulate_tpws && !!ops->execute_unmap) ||
+ !!ops->execute_write_same;
>
> > static struct target_opcode_descriptor tcm_opcode_sync_cache = {
> > @@ -1502,6 +1533,14 @@ static struct target_opcode_descriptor tcm_opcode_sync_cache16 = {
> > 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, SCSI_CONTROL_MASK},
> > };
> >
> > +static bool tcm_is_unmap_enabled(struct se_cmd *cmd)
> > +{
> > + struct sbc_ops *ops = cmd->protocol_data;
> > + struct se_device *dev = cmd->se_dev;
> > +
> > + return ops->execute_unmap && dev->dev_attrib.emulate_tpu;
> > +}
>
> Just a trivial nit. You had an extra space there.
yep, will fix
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-08-12 3:43 ` Mike Christie
@ 2022-08-12 11:34 ` Dmitry Bogdanov
2022-08-12 18:12 ` michael.christie
0 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-08-12 11:34 UTC (permalink / raw)
To: Mike Christie
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On Thu, Aug 11, 2022 at 10:43:24PM -0500, Mike Christie wrote:
> «Внимание! Данное письмо от внешнего адресата!»
>
> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> > Make support of RSOC turned off by emulate_rsoc attibute.
> >
>
> What was the reason for this?
Looks like, it was by analogue to other emulate_* attibutes. But
actually RSOC itself is independent to a backstore device, so better to
drop this patch :)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-08-12 11:34 ` Dmitry Bogdanov
@ 2022-08-12 18:12 ` michael.christie
2022-08-15 6:35 ` Dmitry Bogdanov
0 siblings, 1 reply; 20+ messages in thread
From: michael.christie @ 2022-08-12 18:12 UTC (permalink / raw)
To: Dmitry Bogdanov
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On 8/12/22 6:34 AM, Dmitry Bogdanov wrote:
> On Thu, Aug 11, 2022 at 10:43:24PM -0500, Mike Christie wrote:
>> «Внимание! Данное письмо от внешнего адресата!»
>>
>> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
>>> Make support of RSOC turned off by emulate_rsoc attibute.
>>>
>>
>> What was the reason for this?
> Looks like, it was by analogue to other emulate_* attibutes. But
> actually RSOC itself is independent to a backstore device, so better to
> drop this patch :)
I was actually ok with it in general. It seemed nice for testing.
I was asking because I thought you hit some regressions when it was
on and just wanted you add that info to the git commit.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC
2022-08-12 8:03 ` Dmitry Bogdanov
@ 2022-08-13 7:49 ` Christoph Hellwig
2022-08-15 10:59 ` Dmitry Bogdanov
0 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2022-08-13 7:49 UTC (permalink / raw)
To: Dmitry Bogdanov
Cc: Mike Christie, Martin Petersen, target-devel, linux-scsi, linux,
Roman Bolshakov
On Fri, Aug 12, 2022 at 11:03:07AM +0300, Dmitry Bogdanov wrote:
> > > + .support = SCSI_SUPPORT_FULL,
> > > + .opcode = XDWRITEREAD_10,
> > > + .cdb_size = 10,
> > > + .usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
> > > + 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
> > > + 0xff, SCSI_CONTROL_MASK},
> > > +};
> > one of Martin's tree after you made this patch.
> Yes, I saw, Iwill remove XDWRITEREAD_* in the next revision.
What this does point out is that the way the patches are done,
we have a fundamental issue with these descriptors being potentially
out of sync with the actually supported commands. Once way to fix
this would be to add a parse callback to these dscriptors to unwind
sbc_parse_cdb. The big downside would be an extra expensive indirect
call per command, though.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-08-12 18:12 ` michael.christie
@ 2022-08-15 6:35 ` Dmitry Bogdanov
2022-08-29 18:13 ` Mike Christie
0 siblings, 1 reply; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-08-15 6:35 UTC (permalink / raw)
To: michael.christie
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On Fri, Aug 12, 2022 at 01:12:12PM -0500, michael.christie@oracle.com wrote:
>
> On 8/12/22 6:34 AM, Dmitry Bogdanov wrote:
> > On Thu, Aug 11, 2022 at 10:43:24PM -0500, Mike Christie wrote:
> >>
> >> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
> >>> Make support of RSOC turned off by emulate_rsoc attibute.
> >>>
> >>
> >> What was the reason for this?
> > Looks like, it was by analogue to other emulate_* attibutes. But
> > actually RSOC itself is independent to a backstore device, so better to
> > drop this patch :)
>
> I was actually ok with it in general. It seemed nice for testing.
>
> I was asking because I thought you hit some regressions when it was
> on and just wanted you add that info to the git commit.
No, there was no regression.
So, better to keep this patch but to add to a commit message, that it
is just for testing purposes?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC
2022-08-13 7:49 ` Christoph Hellwig
@ 2022-08-15 10:59 ` Dmitry Bogdanov
0 siblings, 0 replies; 20+ messages in thread
From: Dmitry Bogdanov @ 2022-08-15 10:59 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Mike Christie, Martin Petersen, target-devel, linux-scsi, linux,
Roman Bolshakov
On Sat, Aug 13, 2022 at 12:49:43AM -0700, Christoph Hellwig wrote:
>
> On Fri, Aug 12, 2022 at 11:03:07AM +0300, Dmitry Bogdanov wrote:
> > > > + .support = SCSI_SUPPORT_FULL,
> > > > + .opcode = XDWRITEREAD_10,
> > > > + .cdb_size = 10,
> > > > + .usage_bits = {XDWRITEREAD_10, 0x18, 0xff, 0xff,
> > > > + 0xff, 0xff, SCSI_GROUP_NUMBER_MASK, 0xff,
> > > > + 0xff, SCSI_CONTROL_MASK},
> > > > +};
>
> > > one of Martin's tree after you made this patch.
> > Yes, I saw, Iwill remove XDWRITEREAD_* in the next revision.
>
> What this does point out is that the way the patches are done,
> we have a fundamental issue with these descriptors being potentially
> out of sync with the actually supported commands. Once way to fix
> this would be to add a parse callback to these dscriptors to unwind
> sbc_parse_cdb. The big downside would be an extra expensive indirect
> call per command, though.
Yes, there is such a risk. I was raising it in our company 2 years ago
when I did this patchset. We agreed that, until there is somebody who
can notice about it, it's OK :). It's happened not so often. There was
just one case when we changed RSOC structs - when I was adding support
of ACA condition.
Recently someone wants to have some defence against fuzzy-logic attacks,
may be he (or someone else) will intergate RSOC descriptors into
sbc_parse_cmd within his task.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute
2022-08-15 6:35 ` Dmitry Bogdanov
@ 2022-08-29 18:13 ` Mike Christie
0 siblings, 0 replies; 20+ messages in thread
From: Mike Christie @ 2022-08-29 18:13 UTC (permalink / raw)
To: Dmitry Bogdanov
Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov
On 8/15/22 1:35 AM, Dmitry Bogdanov wrote:
> On Fri, Aug 12, 2022 at 01:12:12PM -0500, michael.christie@oracle.com wrote:
>>
>> On 8/12/22 6:34 AM, Dmitry Bogdanov wrote:
>>> On Thu, Aug 11, 2022 at 10:43:24PM -0500, Mike Christie wrote:
>>>>
>>>> On 7/18/22 7:01 AM, Dmitry Bogdanov wrote:
>>>>> Make support of RSOC turned off by emulate_rsoc attibute.
>>>>>
>>>>
>>>> What was the reason for this?
>>> Looks like, it was by analogue to other emulate_* attibutes. But
>>> actually RSOC itself is independent to a backstore device, so better to
>>> drop this patch :)
>>
>> I was actually ok with it in general. It seemed nice for testing.
>>
>> I was asking because I thought you hit some regressions when it was
>> on and just wanted you add that info to the git commit.
> No, there was no regression.
> So, better to keep this patch but to add to a commit message, that it
> is just for testing purposes?
Sorry for the late reply. I was on vacation.
Yeah, that seems fine. scsi-ml will take different code paths if
RSOC is supported. Other OSs might do the same so it might be useful.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2022-08-29 18:13 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 12:01 [PATCH 0/6] add support of RSOC command Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 1/6] scsi: target: core: " Dmitry Bogdanov
2022-07-19 10:08 ` kernel test robot
2022-07-18 12:01 ` [PATCH 2/6] scsi: target: core: add list of opcodes for RSOC Dmitry Bogdanov
2022-08-12 3:38 ` Mike Christie
2022-08-12 8:03 ` Dmitry Bogdanov
2022-08-13 7:49 ` Christoph Hellwig
2022-08-15 10:59 ` Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 3/6] scsi: target: core: dynamic opcode support in RSOC Dmitry Bogdanov
2022-07-19 12:40 ` kernel test robot
2022-08-12 3:43 ` Mike Christie
2022-08-12 11:30 ` Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 4/6] scsi: target: core: add emulate_rsoc attribute Dmitry Bogdanov
2022-08-12 3:43 ` Mike Christie
2022-08-12 11:34 ` Dmitry Bogdanov
2022-08-12 18:12 ` michael.christie
2022-08-15 6:35 ` Dmitry Bogdanov
2022-08-29 18:13 ` Mike Christie
2022-07-18 12:01 ` [PATCH 5/6] scsi: target: core: dynamicaly set dpofua in usage_bits Dmitry Bogdanov
2022-07-18 12:01 ` [PATCH 6/6] scsi: target: check emulate_3pc for RECEIVE COPY Dmitry Bogdanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).