]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tcm_qla2xxx Add SCSI command jammer/discard capability
authorLaurence Oberman <loberman@redhat.com>
Tue, 10 May 2016 08:23:17 +0000 (01:23 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 10 May 2016 08:27:17 +0000 (01:27 -0700)
This patch introduces support for TCM_QLA2XXX_DEBUG and
associated tcm_qla2xxx_tpg->tpg_attrib.jam_host checking
used to test dropped packets to FC host environments.

Tested by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Laurence Oberman <loberman@redhat.com>
Acked-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Documentation/scsi/tcm_qla2xxx.txt [new file with mode: 0644]
drivers/scsi/qla2xxx/Kconfig
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/scsi/qla2xxx/tcm_qla2xxx.h

diff --git a/Documentation/scsi/tcm_qla2xxx.txt b/Documentation/scsi/tcm_qla2xxx.txt
new file mode 100644 (file)
index 0000000..c3a670a
--- /dev/null
@@ -0,0 +1,22 @@
+tcm_qla2xxx jam_host attribute
+------------------------------
+There is now a new module endpoint atribute called jam_host
+attribute: jam_host: boolean=0/1
+This attribute and accompanying code is only included if the
+Kconfig parameter TCM_QLA2XXX_DEBUG is set to Y
+By default this jammer code and functionality is disabled
+
+Use this attribute to control the discarding of SCSI commands to a
+selected host.
+This may be useful for testing error handling and simulating slow drain
+and other fabric issues.
+
+Setting a boolean of 1 for the jam_host attribute for a particular host
+ will discard the commands for that host.
+Reset back to 0 to stop the jamming.
+
+Enable host 4 to be jammed
+echo 1 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_host
+
+Disable jamming on host 4
+echo 0 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_host
index 10aa18ba05fdc6e6585502eda3a7dd1351db8099..67c0d5aa32125ca135ccb6cc2bd83af76b0ffd1b 100644 (file)
@@ -36,3 +36,12 @@ config TCM_QLA2XXX
        default n
        ---help---
        Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs
+
+if TCM_QLA2XXX
+config TCM_QLA2XXX_DEBUG
+       bool "TCM_QLA2XXX fabric module DEBUG mode for QLogic 24xx+ series target mode HBAs"
+       default n
+       ---help---
+       Say Y here to enable the TCM_QLA2XXX fabric module DEBUG for QLogic 24xx+ series target mode HBAs
+       This will include code to enable the SCSI command jammer
+endif
index 675f75bafc3c5d6a4d0487e4ee9e1c6a55a034c5..6643f6fc7795bcc09fc0c3ffd79a85b907ce6d94 100644 (file)
@@ -442,6 +442,10 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
        struct se_cmd *se_cmd = &cmd->se_cmd;
        struct se_session *se_sess;
        struct qla_tgt_sess *sess;
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+       struct se_portal_group *se_tpg;
+       struct tcm_qla2xxx_tpg *tpg;
+#endif
        int flags = TARGET_SCF_ACK_KREF;
 
        if (bidi)
@@ -462,6 +466,15 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
                return -EINVAL;
        }
 
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+       se_tpg = se_sess->se_tpg;
+       tpg = container_of(se_tpg, struct tcm_qla2xxx_tpg, se_tpg);
+       if (unlikely(tpg->tpg_attrib.jam_host)) {
+               /* return, and dont run target_submit_cmd,discarding command */
+               return 0;
+       }
+#endif
+
        cmd->vha->tgt_counters.qla_core_sbt_cmd++;
        return target_submit_cmd(se_cmd, se_sess, cdb, &cmd->sense_buffer[0],
                                cmd->unpacked_lun, data_length, fcp_task_attr,
@@ -812,6 +825,9 @@ DEF_QLA_TPG_ATTRIB(cache_dynamic_acls);
 DEF_QLA_TPG_ATTRIB(demo_mode_write_protect);
 DEF_QLA_TPG_ATTRIB(prod_mode_write_protect);
 DEF_QLA_TPG_ATTRIB(demo_mode_login_only);
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+DEF_QLA_TPG_ATTRIB(jam_host);
+#endif
 
 static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
        &tcm_qla2xxx_tpg_attrib_attr_generate_node_acls,
@@ -819,6 +835,9 @@ static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
        &tcm_qla2xxx_tpg_attrib_attr_demo_mode_write_protect,
        &tcm_qla2xxx_tpg_attrib_attr_prod_mode_write_protect,
        &tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only,
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+       &tcm_qla2xxx_tpg_attrib_attr_jam_host,
+#endif
        NULL,
 };
 
@@ -991,6 +1010,7 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
        tpg->tpg_attrib.demo_mode_write_protect = 1;
        tpg->tpg_attrib.cache_dynamic_acls = 1;
        tpg->tpg_attrib.demo_mode_login_only = 1;
+       tpg->tpg_attrib.jam_host = 0;
 
        ret = core_tpg_register(wwn, &tpg->se_tpg, SCSI_PROTOCOL_FCP);
        if (ret < 0) {
index 3bbf4cb6fd97e5c9f68fb61e633c7a222f76422c..37e026a4823d6fdeb1048dd7f419f7ca253417c0 100644 (file)
@@ -34,6 +34,7 @@ struct tcm_qla2xxx_tpg_attrib {
        int prod_mode_write_protect;
        int demo_mode_login_only;
        int fabric_prot_type;
+       int jam_host;
 };
 
 struct tcm_qla2xxx_tpg {