All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@cavium.com>
To: target-devel@vger.kernel.org, Bart.VanAssche@sandisk.com,
	hch@infradead.org, nab@linux-iscsi.org
Cc: giridhar.malavali@cavium.com, linux-scsi@vger.kernel.org,
	himanshu.madhani@cavium.com
Subject: [PATCH v2 02/14] qla2xxx: Allow relogin to proceed if remote login did not finish
Date: Fri, 3 Feb 2017 14:40:43 -0800	[thread overview]
Message-ID: <1486161655-2307-3-git-send-email-himanshu.madhani@cavium.com> (raw)
In-Reply-To: <1486161655-2307-1-git-send-email-himanshu.madhani@cavium.com>

From: Quinn Tran <quinn.tran@cavium.com>

If the remote port have started the login process, then the
PLOGI and PRLI should be back to back. Driver will allow
the remote port to complete the process. For the case where
the remote port decide to back off from sending PRLI, this
local port sets an expiration timer for the PRLI. Once the
expiration time passes, the relogin retry logic is allowed
to go through and perform login with the remote port.

Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
---
 drivers/scsi/qla2xxx/qla_def.h    |  2 ++
 drivers/scsi/qla2xxx/qla_init.c   | 16 ++++++++++++++--
 drivers/scsi/qla2xxx/qla_isr.c    | 25 +++++++++++++++++++------
 drivers/scsi/qla2xxx/qla_target.c |  1 +
 4 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index fbaa39b..bf2ae8d3 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2300,6 +2300,8 @@ enum rscn_addr_format {
 	struct ct_sns_desc ct_desc;
 	enum discovery_state disc_state;
 	enum login_state fw_login_state;
+	unsigned long plogi_nack_done_jiff;
+
 	u32 login_gen, last_login_gen;
 	u32 rscn_gen, last_rscn_gen;
 	u32 chip_reset;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 9f3db52..e84ab37 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -876,10 +876,16 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
 	fcport->login_retry--;
 
 	if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
-	    (fcport->fw_login_state == DSC_LS_PLOGI_COMP) ||
 	    (fcport->fw_login_state == DSC_LS_PRLI_PEND))
 		return 0;
 
+	if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) {
+		unsigned long t = fcport->plogi_nack_done_jiff + HZ;
+
+		if (time_before_eq(jiffies, t))
+			return 0;
+	}
+
 	/* for pure Target Mode. Login will not be initiated */
 	if (vha->host->active_mode == MODE_TARGET)
 		return 0;
@@ -1041,10 +1047,16 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
 		fcport->flags);
 
 	if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
-	    (fcport->fw_login_state == DSC_LS_PLOGI_COMP) ||
 	    (fcport->fw_login_state == DSC_LS_PRLI_PEND))
 		return;
 
+	if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) {
+		unsigned long t = fcport->plogi_nack_done_jiff + HZ;
+
+		if (time_before_eq(jiffies, t))
+			return;
+	}
+
 	if (fcport->flags & FCF_ASYNC_SENT) {
 		fcport->login_retry++;
 		set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 0fd3258..f1da53d 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1630,9 +1630,9 @@ static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
 		QLA_LOGIO_LOGIN_RETRIED : 0;
 	if (logio->entry_status) {
 		ql_log(ql_log_warn, fcport->vha, 0x5034,
-		    "Async-%s error entry - hdl=%x"
+		    "Async-%s error entry - %8phC hdl=%x"
 		    "portid=%02x%02x%02x entry-status=%x.\n",
-		    type, sp->handle, fcport->d_id.b.domain,
+		    type, fcport->port_name, sp->handle, fcport->d_id.b.domain,
 		    fcport->d_id.b.area, fcport->d_id.b.al_pa,
 		    logio->entry_status);
 		ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x504d,
@@ -1643,8 +1643,9 @@ static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
 
 	if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) {
 		ql_dbg(ql_dbg_async, fcport->vha, 0x5036,
-		    "Async-%s complete - hdl=%x portid=%02x%02x%02x "
-		    "iop0=%x.\n", type, sp->handle, fcport->d_id.b.domain,
+		    "Async-%s complete - %8phC hdl=%x portid=%02x%02x%02x "
+		    "iop0=%x.\n", type, fcport->port_name, sp->handle,
+		    fcport->d_id.b.domain,
 		    fcport->d_id.b.area, fcport->d_id.b.al_pa,
 		    le32_to_cpu(logio->io_parameter[0]));
 
@@ -1684,6 +1685,17 @@ static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
 	case LSC_SCODE_NPORT_USED:
 		data[0] = MBS_LOOP_ID_USED;
 		break;
+	case LSC_SCODE_CMD_FAILED:
+		if (iop[1] == 0x0606) {
+			/*
+			 * PLOGI/PRLI Completed. We must have Recv PLOGI/PRLI,
+			 * Target side acked.
+			 */
+			data[0] = MBS_COMMAND_COMPLETE;
+			goto logio_done;
+		}
+		data[0] = MBS_COMMAND_ERROR;
+		break;
 	case LSC_SCODE_NOXCB:
 		vha->hw->exch_starvation++;
 		if (vha->hw->exch_starvation > 5) {
@@ -1705,8 +1717,9 @@ static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
 	}
 
 	ql_dbg(ql_dbg_async, fcport->vha, 0x5037,
-	    "Async-%s failed - hdl=%x portid=%02x%02x%02x comp=%x "
-	    "iop0=%x iop1=%x.\n", type, sp->handle, fcport->d_id.b.domain,
+	    "Async-%s failed - %8phC hdl=%x portid=%02x%02x%02x comp=%x "
+	    "iop0=%x iop1=%x.\n", type, fcport->port_name,
+		sp->handle, fcport->d_id.b.domain,
 	    fcport->d_id.b.area, fcport->d_id.b.al_pa,
 	    le16_to_cpu(logio->comp_status),
 	    le32_to_cpu(logio->io_parameter[0]),
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 19ac2b5..8d21c04 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -554,6 +554,7 @@ void qla2x00_async_nack_sp_done(void *s, int res)
 		sp->fcport->login_gen++;
 		sp->fcport->fw_login_state = DSC_LS_PLOGI_COMP;
 		sp->fcport->logout_on_delete = 1;
+		sp->fcport->plogi_nack_done_jiff = jiffies;
 		break;
 
 	case SRB_NACK_PRLI:
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-03 22:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 22:40 [PATCH v2 00/14] qla2xxx: Bug Fixes and updates for target Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 01/14] qla2xxx: Fix delayed response to command for loop mode/direct connect Himanshu Madhani
2017-02-08 18:35   ` Bart Van Assche
2017-02-03 22:40 ` Himanshu Madhani [this message]
2017-02-08 18:42   ` [PATCH v2 02/14] qla2xxx: Allow relogin to proceed if remote login did not finish Bart Van Assche
2017-02-08 19:16     ` Madhani, Himanshu
2017-02-03 22:40 ` [PATCH v2 03/14] qla2xxx: Allow vref count to timeout on vport delete Himanshu Madhani
2017-02-08 13:03   ` Christoph Hellwig
2017-02-08 18:25     ` Madhani, Himanshu
2017-02-03 22:40 ` [PATCH v2 04/14] qla2xxx: Use IOCB interface to submit non-critical MBX Himanshu Madhani
2017-02-08 18:48   ` Bart Van Assche
2017-02-08 19:15     ` Madhani, Himanshu
2017-02-03 22:40 ` [PATCH v2 05/14] qla2xxx: Add DebugFS node to display Port Database Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 06/14] qla2xxx: Improve T10-DIF/PI handling in driver Himanshu Madhani
2017-02-08  4:13   ` Nicholas A. Bellinger
2017-02-08 19:12     ` Madhani, Himanshu
2017-02-08 18:57   ` Bart Van Assche
2017-02-08 19:11     ` Madhani, Himanshu
2017-02-03 22:40 ` [PATCH v2 07/14] qla2xxx: Export DIF stats via debugfs Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 08/14] qla2xxx: Change scsi host lookup method Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 09/14] qla2xxx: Fix memory leak for abts processing Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 10/14] qla2xxx: Fix request queue corruption Himanshu Madhani
2017-02-08 19:22   ` Bart Van Assche
2017-02-09 21:34     ` Tran, Quinn
2017-02-03 22:40 ` [PATCH v2 11/14] qla2xxx: Fix inadequate lock protection for ABTS Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 12/14] qla2xxx: Add async new target notification Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 13/14] qla2xxx: Fix sess_lock & hardware_lock lock order problem Himanshu Madhani
2017-02-03 22:40 ` [PATCH v2 14/14] qla2xxx: Update driver version to 9.00.00.00-k Himanshu Madhani
2017-02-08 15:02 ` [PATCH v2 00/14] qla2xxx: Bug Fixes and updates for target Bart Van Assche
2017-02-08 17:11   ` Madhani, Himanshu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486161655-2307-3-git-send-email-himanshu.madhani@cavium.com \
    --to=himanshu.madhani@cavium.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=giridhar.malavali@cavium.com \
    --cc=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.