Commit 04957d8c authored by Tony Battersby's avatar Tony Battersby Committed by Martin K. Petersen
Browse files

scsi: qla2xxx: target: Improve cmd logging



 - Add the command tag to various messages so that different messages
   about the same command can be correlated.

 - For CTIO errors (i.e. when the HW reports an error about a cmd),
   print the cmd tag, opcode, state, initiator WWPN, and LUN.  This info
   helps an administrator determine what is going wrong.

 - When a command experiences a transport error, log a message when it
   is freed.  This makes debugging exceptions easier.

Signed-off-by: default avatarTony Battersby <tonyb@cybernetics.com>
Link: https://patch.msgid.link/c579987d-5658-41ae-9653-f0e58c9d1880@cybernetics.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f4199d58
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@
 * | Misc                         |       0xd303       | 0xd031-0xd0ff	|
 * |                              |                    | 0xd101-0xd1fe	|
 * |                              |                    | 0xd214-0xd2fe	|
 * | Target Mode		  |	  0xe084       |		|
 * | Target Mode		  |	  0xe086       |		|
 * | Target Mode Management	  |	  0xf09b       | 0xf002		|
 * |                              |                    | 0xf046-0xf049  |
 * | Target Mode Task Management  |	  0x1000d      |		|
+63 −25
Original line number Diff line number Diff line
@@ -1984,9 +1984,13 @@ static void abort_cmds_for_lun(struct scsi_qla_host *vha, u64 lun, be_id_t s_id)
		cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
		cmd_lun = scsilun_to_int(
			(struct scsi_lun *)&cmd->atio.u.isp24.fcp_cmnd.lun);
		if (cmd_key == key && cmd_lun == lun)
		if (cmd_key == key && cmd_lun == lun) {
			ql_dbg(ql_dbg_tgt_mgt, vha, 0xe085,
			    "qla_target(%d): tag %lld: aborted by TMR\n",
			    vha->vp_idx, cmd->se_cmd.tag);
			cmd->aborted = 1;
		}
	}
	spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
}

@@ -3841,6 +3845,15 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)

	BUG_ON(cmd->sg_mapped);

	if (unlikely(cmd->aborted ||
		     (cmd->trc_flags & (TRC_CTIO_STRANGE | TRC_CTIO_ERR)))) {
		ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xe086,
		    "qla_target(%d): tag %lld: free cmd (trc_flags %x, aborted %u, sent_term_exchg %u, rsp_sent %u)\n",
		    cmd->vha->vp_idx, cmd->se_cmd.tag,
		    cmd->trc_flags, cmd->aborted, cmd->sent_term_exchg,
		    cmd->rsp_sent);
	}

	if (unlikely(cmd->cdb != &cmd->atio.u.isp24.fcp_cmnd.cdb[0])) {
		kfree(cmd->cdb);
		cmd->cdb = &cmd->atio.u.isp24.fcp_cmnd.cdb[0];
@@ -3853,7 +3866,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
		WARN_ON(1);
		return;
	}
	cmd->jiffies_at_free = get_jiffies_64();
	cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd);
}
EXPORT_SYMBOL(qlt_free_cmd);
@@ -3918,7 +3930,6 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
	struct ctio7_from_24xx *ctio)
{
	struct qla_hw_data *ha = vha->hw;
	struct se_cmd *se_cmd;
	struct qla_tgt_cmd *cmd;
	struct qla_qpair *qpair = rsp->qpair;
	uint16_t ctio_flags;
@@ -3957,12 +3968,12 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
	if ((ctio_flags & CTIO7_FLAGS_DATA_OUT) && cmd->sess)
		qlt_chk_edif_rx_sa_delete_pending(vha, cmd->sess, ctio);

	se_cmd = &cmd->se_cmd;
	cmd->cmd_sent_to_fw = 0;

	qlt_unmap_sg(vha, cmd);

	if (unlikely(status != CTIO_SUCCESS)) {
		u8 op = cmd->cdb ? cmd->cdb[0] : 0;
		bool term_exchg = false;

		/*
@@ -3980,8 +3991,10 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
			term_exchg = true;
			if (printk_ratelimit())
				dev_info(&vha->hw->pdev->dev,
				    "qla_target(%d): CTIO with INVALID_RX_ID ATIO attr %x CTIO Flags %x|%x\n",
				    vha->vp_idx, cmd->atio.u.isp24.attr,
				    "qla_target(%d): tag %lld, op %x: CTIO with INVALID_RX_ID status 0x%x received (state %d, port %8phC, LUN %lld, ATIO attr %x, CTIO Flags %x|%x)\n",
				    vha->vp_idx, cmd->se_cmd.tag, op,
				    status, cmd->state, cmd->sess->port_name,
				    cmd->unpacked_lun, cmd->atio.u.isp24.attr,
				    ((cmd->ctio_flags >> 9) & 0xf),
				    cmd->ctio_flags);
			break;
@@ -3992,13 +4005,31 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
			term_exchg = true;
			fallthrough;
		case CTIO_TIMEOUT:
		{
			const char *status_str;

			switch (status & 0xFFFF) {
			case CTIO_LIP_RESET:
				status_str = "LIP_RESET";
				break;
			case CTIO_TARGET_RESET:
				status_str = "TARGET_RESET";
				break;
			case CTIO_ABORTED:
				status_str = "ABORTED";
				break;
			case CTIO_TIMEOUT:
			default:
				status_str = "TIMEOUT";
				break;
			}
			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf058,
			    "qla_target(%d): CTIO with "
			    "status %#x received, state %x, se_cmd %p, "
			    "(LIP_RESET=e, ABORTED=2, TARGET_RESET=17, "
			    "TIMEOUT=b, INVALID_RX_ID=8)\n", vha->vp_idx,
			    status, cmd->state, se_cmd);
			    "qla_target(%d): tag %lld, op %x: CTIO with %s status 0x%x received (state %d, port %8phC, LUN %lld)\n",
			    vha->vp_idx, cmd->se_cmd.tag, op,
			    status_str, status, cmd->state,
			    cmd->sess->port_name, cmd->unpacked_lun);
			break;
		}

		case CTIO_PORT_LOGGED_OUT:
		case CTIO_PORT_UNAVAILABLE:
@@ -4007,10 +4038,11 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
				(status & 0xFFFF) == CTIO_PORT_LOGGED_OUT;

			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
			    "qla_target(%d): CTIO with %s status %x "
			    "received (state %x, se_cmd %p)\n", vha->vp_idx,
			    "qla_target(%d): tag %lld, op %x: CTIO with %s status 0x%x received (state %d, port %8phC, LUN %lld)\n",
			    vha->vp_idx, cmd->se_cmd.tag, op,
			    logged_out ? "PORT LOGGED OUT" : "PORT UNAVAILABLE",
			    status, cmd->state, se_cmd);
			    status, cmd->state, cmd->sess->port_name,
			    cmd->unpacked_lun);

			term_exchg = true;
			if (logged_out && cmd->sess) {
@@ -4027,14 +4059,15 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
			}
			break;
		}

		case CTIO_DIF_ERROR: {
			struct ctio_crc_from_fw *crc =
				(struct ctio_crc_from_fw *)ctio;
			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf073,
			    "qla_target(%d): CTIO with DIF_ERROR status %x "
			    "received (state %x, ulp_cmd %p) actual_dif[0x%llx] "
			    "expect_dif[0x%llx]\n",
			    vha->vp_idx, status, cmd->state, se_cmd,
			    "qla_target(%d): tag %lld, op %x: CTIO with DIF_ERROR status 0x%x received (state %d, port %8phC, LUN %lld, actual_dif[0x%llx] expect_dif[0x%llx])\n",
			    vha->vp_idx, cmd->se_cmd.tag, op, status,
			    cmd->state, cmd->sess->port_name,
			    cmd->unpacked_lun,
			    *((u64 *)&crc->actual_dif[0]),
			    *((u64 *)&crc->expected_dif[0]));

@@ -4047,14 +4080,18 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
		case CTIO_FAST_INVALID_REQ:
		case CTIO_FAST_SPI_ERR:
			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05b,
			    "qla_target(%d): CTIO with EDIF error status 0x%x received (state %x, se_cmd %p\n",
			    vha->vp_idx, status, cmd->state, se_cmd);
			    "qla_target(%d): tag %lld, op %x: CTIO with EDIF error status 0x%x received (state %d, port %8phC, LUN %lld)\n",
			    vha->vp_idx, cmd->se_cmd.tag, op, status,
			    cmd->state, cmd->sess->port_name,
			    cmd->unpacked_lun);
			break;

		default:
			ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05b,
			    "qla_target(%d): CTIO with error status 0x%x received (state %x, se_cmd %p\n",
			    vha->vp_idx, status, cmd->state, se_cmd);
			    "qla_target(%d): tag %lld, op %x: CTIO with error status 0x%x received (state %d, port %8phC, LUN %lld)\n",
			    vha->vp_idx, cmd->se_cmd.tag, op, status,
			    cmd->state, cmd->sess->port_name,
			    cmd->unpacked_lun);
			break;
		}

@@ -4092,12 +4129,13 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
	} else if (cmd->aborted) {
		cmd->trc_flags |= TRC_CTIO_ABORTED;
		ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e,
		  "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag);
		    "qla_target(%d): tag %lld: Aborted command finished\n",
		    vha->vp_idx, cmd->se_cmd.tag);
	} else {
		cmd->trc_flags |= TRC_CTIO_STRANGE;
		ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c,
		    "qla_target(%d): A command in state (%d) should "
		    "not return a CTIO complete\n", vha->vp_idx, cmd->state);
		    "qla_target(%d): tag %lld: A command in state (%d) should not return a CTIO complete\n",
		    vha->vp_idx, cmd->se_cmd.tag, cmd->state);
	}

	if (unlikely(status != CTIO_SUCCESS) &&