From bd217b8c3a1f705f2d92d30974412fbd5f43271a Mon Sep 17 00:00:00 2001 From: Dmitry Bogdanov Date: Tue, 6 Sep 2022 13:34:19 +0300 Subject: scsi: target: core: Add emulate_rsoc attribute Allow support for RSOC to be turned off via the emulate_rsoc attibute. This is just for testing purposes. Reviewed-by: Roman Bolshakov Signed-off-by: Dmitry Bogdanov Link: https://lore.kernel.org/r/20220906103421.22348-5-d.bogdanov@yadro.com Reviewed-by: Mike Christie Signed-off-by: Martin K. Petersen --- drivers/target/target_core_spc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/target/target_core_spc.c') diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index e1cf9c352fd3..91f03312a5ea 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -1889,6 +1889,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, @@ -1899,6 +1907,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) @@ -2135,6 +2144,9 @@ spc_emulate_report_supp_op_codes(struct se_cmd *cmd) sense_reason_t 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; -- cgit v1.2.3