Commit 27258a57 authored by Shyam Sundar's avatar Shyam Sundar Committed by Martin K. Petersen
Browse files

scsi: qla2xxx: Add a shadow variable to hold disc_state history of fcport

This patch adds a shadow variable to hold disc_state history for the fcport
and prints state transition when the logging is enabled.

Link: https://lore.kernel.org/r/20191217220617.28084-4-hmadhani@marvell.com


Signed-off-by: default avatarShyam Sundar <ssundar@marvell.com>
Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f57a0107
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
 * | Device Discovery             |       0x2134       | 0x210e-0x2116  |
 * |				  | 		       | 0x211a         |
 * |                              |                    | 0x211c-0x2128  |
 * |                              |                    | 0x212a-0x2130  |
 * |                              |                    | 0x212a-0x2134  |
 * | Queue Command and IO tracing |       0x3074       | 0x300b         |
 * |                              |                    | 0x3027-0x3028  |
 * |                              |                    | 0x303d-0x3041  |
+14 −0
Original line number Diff line number Diff line
@@ -2464,6 +2464,7 @@ typedef struct fc_port {
	struct qla_tgt_sess *tgt_session;
	struct ct_sns_desc ct_desc;
	enum discovery_state disc_state;
	atomic_t shadow_disc_state;
	enum discovery_state next_disc_state;
	enum login_state fw_login_state;
	unsigned long dm_login_expire;
@@ -2510,6 +2511,19 @@ struct event_arg {

extern const char *const port_state_str[5];

static const char * const port_dstate_str[] = {
	"DELETED",
	"GNN_ID",
	"GNL",
	"LOGIN_PEND",
	"LOGIN_FAILED",
	"GPDB",
	"UPD_FCPORT",
	"LOGIN_COMPLETE",
	"ADISC",
	"DELETE_PEND"
};

/*
 * FC port flags.
 */
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ extern int qla24xx_async_gnl(struct scsi_qla_host *, fc_port_t *);
int qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e);
extern void *qla2x00_alloc_iocbs_ready(struct qla_qpair *, srb_t *);
extern int qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *, fc_port_t *);
extern int qla24xx_async_abort_cmd(srb_t *, bool);

extern void qla2x00_set_fcport_state(fc_port_t *fcport, int state);
extern fc_port_t *
+1 −1
Original line number Diff line number Diff line
@@ -4290,7 +4290,7 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport)
	if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
		return rval;

	fcport->disc_state = DSC_GNN_ID;
	qla2x00_set_fcport_disc_state(fcport, DSC_GNN_ID);
	sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
	if (!sp)
		goto done;
+15 −14
Original line number Diff line number Diff line
@@ -316,10 +316,10 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
	if (!sp)
		goto done;

	qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND);
	fcport->flags |= FCF_ASYNC_SENT;
	fcport->logout_completed = 0;

	fcport->disc_state = DSC_LOGIN_PEND;
	sp->type = SRB_LOGIN_CMD;
	sp->name = "login";
	sp->gen1 = fcport->rscn_gen;
@@ -523,7 +523,7 @@ static int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport)

	e->u.fcport.fcport = fcport;
	fcport->flags |= FCF_ASYNC_ACTIVE;
	fcport->disc_state = DSC_LOGIN_PEND;
	qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND);
	return qla2x00_post_work(vha, e);
}

@@ -826,7 +826,8 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
				 * with GNL. Push disc_state back to DELETED
				 * so GNL can go out again
				 */
				fcport->disc_state = DSC_DELETED;
				qla2x00_set_fcport_disc_state(fcport,
				    DSC_DELETED);
				break;
			case DSC_LS_PRLI_COMP:
				if ((e->prli_svc_param_word_3[0] & BIT_4) == 0)
@@ -902,7 +903,7 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
			qla24xx_fcport_handle_login(vha, fcport);
			break;
		case ISP_CFG_N:
			fcport->disc_state = DSC_DELETED;
			qla2x00_set_fcport_disc_state(fcport, DSC_DELETED);
			if (time_after_eq(jiffies, fcport->dm_login_expire)) {
				if (fcport->n2n_link_reset_cnt < 2) {
					fcport->n2n_link_reset_cnt++;
@@ -1062,7 +1063,7 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)

	spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
	fcport->flags |= FCF_ASYNC_SENT;
	fcport->disc_state = DSC_GNL;
	qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
	fcport->last_rscn_gen = fcport->rscn_gen;
	fcport->last_login_gen = fcport->login_gen;

@@ -1285,12 +1286,12 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
		return rval;
	}

	fcport->disc_state = DSC_GPDB;

	sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
	if (!sp)
		goto done;

	qla2x00_set_fcport_disc_state(fcport, DSC_GPDB);

	fcport->flags |= FCF_ASYNC_SENT;
	sp->type = SRB_MB_IOCB;
	sp->name = "gpdb";
@@ -1369,7 +1370,7 @@ void __qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea)
		ql_dbg(ql_dbg_disc, vha, 0x20d6,
		    "%s %d %8phC session revalidate success\n",
		    __func__, __LINE__, ea->fcport->port_name);
		ea->fcport->disc_state = DSC_LOGIN_COMPLETE;
		qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE);
	}
	spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
}
@@ -1423,7 +1424,7 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea)
		/* Set discovery state back to GNL to Relogin attempt */
		if (qla_dual_mode_enabled(vha) ||
		    qla_ini_mode_enabled(vha)) {
			fcport->disc_state = DSC_GNL;
			qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
			set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
		}
		return;
@@ -2000,7 +2001,7 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
		    __func__, __LINE__, ea->fcport->port_name, ea->data[1]);

		ea->fcport->flags &= ~FCF_ASYNC_SENT;
		ea->fcport->disc_state = DSC_LOGIN_FAILED;
		qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_FAILED);
		if (ea->data[1] & QLA_LOGIO_LOGIN_RETRIED)
			set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
		else
@@ -5389,7 +5390,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
	ql_dbg(ql_dbg_disc, vha, 0x20ef, "%s %8phC\n",
	    __func__, fcport->port_name);

	fcport->disc_state = DSC_UPD_FCPORT;
	qla2x00_set_fcport_disc_state(fcport, DSC_UPD_FCPORT);
	fcport->login_retry = vha->hw->login_retry_count;
	fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
	fcport->deleted = 0;
@@ -5409,7 +5410,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)

	if (NVME_TARGET(vha->hw, fcport)) {
		qla_nvme_register_remote(vha, fcport);
		fcport->disc_state = DSC_LOGIN_COMPLETE;
		qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
		return;
	}
@@ -5454,7 +5455,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
		}
	}

	fcport->disc_state = DSC_LOGIN_COMPLETE;
	qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
}

void qla_register_fcport_fn(struct work_struct *work)
@@ -5863,7 +5864,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha)

		if (NVME_TARGET(vha->hw, fcport)) {
			if (fcport->disc_state == DSC_DELETE_PEND) {
				fcport->disc_state = DSC_GNL;
				qla2x00_set_fcport_disc_state(fcport, DSC_GNL);
				vha->fcport_count--;
				fcport->login_succ = 0;
			}
Loading