scsi: qla2xxx: Turn on FW option for exchange check
authorQuinn Tran <quinn.tran@cavium.com>
Fri, 2 Jun 2017 16:12:02 +0000 (09:12 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Jun 2017 00:48:07 +0000 (20:48 -0400)
Tell FW to track exchange/cmd state to prevent driver from using stale
exchange or exchange that is not meant for this command.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla2xxx/qla_target.h

index c425d061cd8026f03eb4792a8c721750da806737..f92e74639bb1a85d630bc480d3f87a208bd72475 100644 (file)
@@ -2969,6 +2969,18 @@ qla24xx_update_fw_options(scsi_qla_host_t *vha)
                        ha->fw_options[2] &= ~BIT_11;
        }
 
+       if (IS_QLA25XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
+               /*
+                * Tell FW to track each exchange to prevent
+                * driver from using stale exchange.
+                */
+               if (qla_tgt_mode_enabled(vha) ||
+                   qla_dual_mode_enabled(vha))
+                       ha->fw_options[2] |= BIT_4;
+               else
+                       ha->fw_options[2] &= ~BIT_4;
+       }
+
        ql_dbg(ql_dbg_init, vha, 0x00e8,
            "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n",
            __func__, ha->fw_options[1], ha->fw_options[2],
@@ -7361,6 +7373,12 @@ qla81xx_update_fw_options(scsi_qla_host_t *vha)
                        ha->fw_options[2] &= ~BIT_11;
        }
 
+       if (qla_tgt_mode_enabled(vha) ||
+           qla_dual_mode_enabled(vha))
+               ha->fw_options[2] |= BIT_4;
+       else
+               ha->fw_options[2] &= ~BIT_4;
+
        if (ql2xetsenable) {
                /* Enable ETS Burst. */
                memset(ha->fw_options, 0, sizeof(ha->fw_options));
index 4ad09584d4a8fb805d445896495955e169bcab03..3cdffdd90279f1ba90f56eda6e9d6280815b4265 100644 (file)
@@ -2016,8 +2016,9 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha,
        ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio->exchange_addr = atio->u.isp24.exchange_addr;
-       ctio->u.status1.flags = (atio->u.isp24.attr << 9) |
-           cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS);
+       temp = (atio->u.isp24.attr << 9)|
+               CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS;
+       ctio->u.status1.flags = cpu_to_le16(temp);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        ctio->u.status1.ox_id = cpu_to_le16(temp);
        ctio->u.status1.scsi_status =
@@ -2070,8 +2071,9 @@ void qlt_send_resp_ctio(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
        ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio->exchange_addr = atio->u.isp24.exchange_addr;
-       ctio->u.status1.flags = (atio->u.isp24.attr << 9) |
-           cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS);
+       temp = (atio->u.isp24.attr << 9) |
+           CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS;
+       ctio->u.status1.flags = cpu_to_le16(temp);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        ctio->u.status1.ox_id = cpu_to_le16(temp);
        ctio->u.status1.scsi_status =
@@ -2359,7 +2361,8 @@ static int qlt_24xx_build_ctio_pkt(struct qla_tgt_prm *prm,
        pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        pkt->exchange_addr = atio->u.isp24.exchange_addr;
-       pkt->u.status0.flags |= (atio->u.isp24.attr << 9);
+       temp = atio->u.isp24.attr << 9;
+       pkt->u.status0.flags |= cpu_to_le16(temp);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        pkt->u.status0.ox_id = cpu_to_le16(temp);
        pkt->u.status0.relative_offset = cpu_to_le32(prm->cmd->offset);
@@ -3484,9 +3487,9 @@ static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
        ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio24->exchange_addr = atio->u.isp24.exchange_addr;
-       ctio24->u.status1.flags = (atio->u.isp24.attr << 9) |
-           cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
-               CTIO7_FLAGS_TERMINATE);
+       temp = (atio->u.isp24.attr << 9) | CTIO7_FLAGS_STATUS_MODE_1 |
+               CTIO7_FLAGS_TERMINATE;
+       ctio24->u.status1.flags = cpu_to_le16(temp);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        ctio24->u.status1.ox_id = cpu_to_le16(temp);
 
@@ -4978,6 +4981,7 @@ static int __qlt_send_busy(struct scsi_qla_host *vha,
        request_t *pkt;
        struct fc_port *sess = NULL;
        unsigned long flags;
+       u16 temp;
 
        spin_lock_irqsave(&ha->tgt.sess_lock, flags);
        sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha,
@@ -5010,10 +5014,10 @@ static int __qlt_send_busy(struct scsi_qla_host *vha,
        ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio24->exchange_addr = atio->u.isp24.exchange_addr;
-       ctio24->u.status1.flags = (atio->u.isp24.attr << 9) |
-           cpu_to_le16(
+       temp = (atio->u.isp24.attr << 9) |
                CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS |
-               CTIO7_FLAGS_DONT_RET_CTIO);
+               CTIO7_FLAGS_DONT_RET_CTIO;
+       ctio24->u.status1.flags = cpu_to_le16(temp);
        /*
         * CTIO from fw w/o se_cmd doesn't provide enough info to retry it,
         * if the explicit conformation is used.
index 25ea90b8f6c924c1e3d66c30b1e4563906159ad2..07ff565485b7682f28999e578a580107a61d5fb2 100644 (file)
@@ -426,7 +426,7 @@ struct ctio7_to_24xx {
                } status0;
                struct {
                        uint16_t sense_length;
-                       uint16_t flags;
+                       __le16 flags;
                        uint32_t residual;
                        __le16 ox_id;
                        uint16_t scsi_status;