linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com,
	mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com,
	varun@chelsio.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, jejb@linux.ibm.com
Subject: [PATCH 18/22] qedi: prep driver for switch to blk tags
Date: Thu, 17 Dec 2020 00:42:08 -0600	[thread overview]
Message-ID: <1608187332-4434-19-git-send-email-michael.christie@oracle.com> (raw)
In-Reply-To: <1608187332-4434-1-git-send-email-michael.christie@oracle.com>

We currently implement our own tagging which just adds another
layer of locks. For scsi cmds we can just use the block layer
tags. This patch preps qedi for this change by:

1. Having it use the correct itt to task look up function.
See below for info and question.

2. Using iscsi_complete_scsi_task when it has access to the task
instead of playing tricks with the itt which may not work with
multiple queues.

Question for Manish:

We are supposed to use iscsi_itt_to_ctask for scsi tasks and
iscsi_itt_to_task for iscsi "mgmt" tasks. The latter are nops,
login, logout, etc.

I could not tell if the !found cases in
qedi_process_cmd_cleanup_resp were for scsi cmds or mgmt ones.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/qedi/qedi_fw.c | 57 ++++++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
index 440ddd2..d93a6b2 100644
--- a/drivers/scsi/qedi/qedi_fw.c
+++ b/drivers/scsi/qedi/qedi_fw.c
@@ -627,20 +627,15 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi,
 
 	qedi_iscsi_unmap_sg_list(cmd);
 
-	hdr = (struct iscsi_scsi_rsp *)task->hdr;
-	hdr->opcode = cqe_data_in->opcode;
-	hdr->max_cmdsn = cpu_to_be32(cqe_data_in->max_cmd_sn);
-	hdr->exp_cmdsn = cpu_to_be32(cqe_data_in->exp_cmd_sn);
-	hdr->itt = build_itt(cqe->cqe_solicited.itid, conn->session->age);
-	hdr->response = cqe_data_in->reserved1;
-	hdr->cmd_status = cqe_data_in->status_rsvd;
-	hdr->flags = cqe_data_in->flags;
-	hdr->residual_count = cpu_to_be32(cqe_data_in->residual_count);
-
-	if (hdr->cmd_status == SAM_STAT_CHECK_CONDITION) {
+	sc_cmd->result = (DID_OK << 16) | cqe_data_in->status_rsvd;
+	if (cqe_data_in->reserved1 != ISCSI_STATUS_CMD_COMPLETED)
+		sc_cmd->result = DID_ERROR << 16;
+
+	if (cqe_data_in->status_rsvd == SAM_STAT_CHECK_CONDITION) {
 		datalen = cqe_data_in->reserved2 &
 			  ISCSI_COMMON_HDR_DATA_SEG_LEN_MASK;
-		memcpy((char *)conn->data, (char *)cmd->sense_buffer, datalen);
+		memcpy(sc_cmd->sense_buffer, cmd->sense_buffer,
+		       min(datalen, SCSI_SENSE_BUFFERSIZE));
 	}
 
 	/* If f/w reports data underrun err then set residual to IO transfer
@@ -653,9 +648,23 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi,
 			  hdr->itt, cqe_data_in->flags, cmd->task_id,
 			  qedi_conn->iscsi_conn_id, hdr->residual_count,
 			  scsi_bufflen(sc_cmd));
-		hdr->residual_count = cpu_to_be32(scsi_bufflen(sc_cmd));
-		hdr->flags |= ISCSI_FLAG_CMD_UNDERFLOW;
-		hdr->flags &= (~ISCSI_FLAG_CMD_OVERFLOW);
+
+		cqe_data_in->residual_count = scsi_bufflen(sc_cmd);
+		cqe_data_in->flags |= ISCSI_FLAG_CMD_UNDERFLOW;
+		cqe_data_in->flags &= (~ISCSI_FLAG_CMD_OVERFLOW);
+	}
+
+	if (cqe_data_in->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
+				  ISCSI_FLAG_CMD_OVERFLOW)) {
+		int res_count = cqe_data_in->residual_count;
+
+		if (res_count > 0 &&
+		    (cqe_data_in->flags & ISCSI_FLAG_CMD_OVERFLOW ||
+		    res_count <= scsi_bufflen(sc_cmd)))
+			scsi_set_resid(sc_cmd, res_count);
+		else
+			sc_cmd->result = (DID_BAD_TARGET << 16) |
+						cqe_data_in->status_rsvd;
 	}
 
 	spin_lock(&qedi_conn->list_lock);
@@ -674,8 +683,8 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi,
 		qedi_trace_io(qedi, task, cmd->task_id, QEDI_IO_TRACE_RSP);
 
 	qedi_clear_task_idx(qedi, cmd->task_id);
-	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr,
-			     conn->data, datalen);
+	iscsi_complete_scsi_task(task, cqe_data_in->exp_cmd_sn,
+				 cqe_data_in->max_cmd_sn);
 error:
 	spin_unlock_bh(&session->back_lock);
 }
@@ -796,11 +805,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi,
 		if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) ==
 		    ISCSI_TM_FUNC_ABORT_TASK) {
 			spin_lock_bh(&conn->session->back_lock);
-
-			protoitt = build_itt(get_itt(tmf_hdr->rtt),
-					     conn->session->age);
-			task = iscsi_itt_to_task(conn, protoitt);
-
+			task = iscsi_itt_to_ctask(conn, tmf_hdr->rtt);
 			spin_unlock_bh(&conn->session->back_lock);
 
 			if (!task) {
@@ -1387,8 +1392,8 @@ static void qedi_tmf_work(struct work_struct *work)
 	tmf_hdr = (struct iscsi_tm *)mtask->hdr;
 	set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
 
-	ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt);
-	if (!ctask || !ctask->sc) {
+	ctask = iscsi_itt_to_ctask(conn, tmf_hdr->rtt);
+	if (!ctask) {
 		QEDI_ERR(&qedi->dbg_ctx, "Task already completed\n");
 		goto abort_ret;
 	}
@@ -1520,8 +1525,8 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn,
 
 	if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) ==
 	     ISCSI_TM_FUNC_ABORT_TASK) {
-		ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt);
-		if (!ctask || !ctask->sc) {
+		ctask = iscsi_itt_to_ctask(conn, tmf_hdr->rtt);
+		if (!ctask) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Could not get reference task\n");
 			return 0;
-- 
1.8.3.1


  parent reply	other threads:[~2020-12-17  6:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  6:41 [RFC PATCH 00/22 V3] iscsi: lock clean ups Mike Christie
2020-12-17  6:41 ` [PATCH 01/22] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Mike Christie
2020-12-17  6:41 ` [PATCH 02/22] libiscsi: drop taskqueuelock Mike Christie
2020-12-17  6:41 ` [PATCH 03/22] libiscsi: fix iscsi_task use after free Mike Christie
2020-12-17  6:41 ` [PATCH 04/22] qla4xxx: use iscsi_is_session_online Mike Christie
2020-12-17  6:41 ` [PATCH 05/22] iscsi class: drop session lock in iscsi_session_chkready Mike Christie
2020-12-17  6:41 ` [PATCH 06/22] libiscsi: remove queued_cmdsn Mike Christie
2020-12-17  6:41 ` [PATCH 07/22] libiscsi: drop frwd lock for session state Mike Christie
2020-12-17  6:41 ` [PATCH 08/22] libiscsi: add task prealloc/free callouts Mike Christie
2020-12-17  6:41 ` [PATCH 09/22] qedi: implement alloc_task_priv/free_task_priv Mike Christie
2020-12-17  6:42 ` [PATCH 10/22] bnx2i: " Mike Christie
2020-12-17  6:42 ` [PATCH 11/22] iser, be2iscsi, qla4xxx: set scsi_host_template cmd_size Mike Christie
2020-12-17  6:42 ` [PATCH 12/22] bnx2i: " Mike Christie
2020-12-17  6:42 ` [PATCH 13/22] qedi: " Mike Christie
2020-12-17  6:42 ` [PATCH 14/22] iscsi_tcp, libcxgbi: " Mike Christie
2020-12-17  6:42 ` [PATCH 15/22] libiscsi: use scsi_host_busy_iter Mike Christie
2020-12-17  6:42 ` [PATCH 16/22] be2iscsi: " Mike Christie
2020-12-17  6:42 ` [PATCH 17/22] bnx2i: prep driver for switch to blk tags Mike Christie
2020-12-17  6:42 ` Mike Christie [this message]
2020-12-17  6:42 ` [PATCH 19/22] libiscsi: use blk/scsi-ml mq cmd pre-allocator Mike Christie
2020-12-17  6:42 ` [PATCH 20/22] libiscsi: rm iscsi_put_task back_lock requirement Mike Christie
2020-12-17  6:42 ` [PATCH 21/22] libiscsi: drop back_lock from xmit path Mike Christie
2020-12-17  6:42 ` [PATCH 22/22] libiscsi: fix conn_send_pdu API Mike Christie

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=1608187332-4434-19-git-send-email-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=cleech@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mrangankar@marvell.com \
    --cc=njavali@marvell.com \
    --cc=varun@chelsio.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).