Re: [PATCH v2 11/17] qla2xxx: Turn on FW option for exchange check

2017-05-31 Thread Bart Van Assche
On Tue, 2017-05-30 at 10:54 -0700, Himanshu Madhani wrote:
> - 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);

This patch not only includes the functional changes explained in the patch
description but also several changes that do not change any functionality
like the above. Please keep functional and non-functional changes separate
for future patch submissions.

Thanks,

Bart.

[PATCH v2 11/17] qla2xxx: Turn on FW option for exchange check

2017-05-30 Thread Himanshu Madhani
From: Quinn Tran 

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 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_init.c   | 18 ++
 drivers/scsi/qla2xxx/qla_target.c | 26 +++---
 drivers/scsi/qla2xxx/qla_target.h |  2 +-
 3 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 9f14e6752b83..c422c14dfb07 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2976,6 +2976,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],
@@ -7368,6 +7380,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));
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 4ad09584d4a8..3cdffdd90279 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -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