All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Satish Kharat <satishkh@cisco.com>,
	Sesidhar Baddela <sebaddel@cisco.com>,
	Karan Tilak Kumar <kartilak@cisco.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>
Subject: [PATCH 19/44] fnic: Stop using the SCSI pointer
Date: Fri, 28 Jan 2022 14:18:44 -0800	[thread overview]
Message-ID: <20220128221909.8141-20-bvanassche@acm.org> (raw)
In-Reply-To: <20220128221909.8141-1-bvanassche@acm.org>

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
from struct scsi_cmnd.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/fnic/fnic.h      |  27 +++-
 drivers/scsi/fnic/fnic_main.c |   1 +
 drivers/scsi/fnic/fnic_scsi.c | 289 +++++++++++++++++-----------------
 3 files changed, 163 insertions(+), 154 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index b95d0063dedb..aa07189fb5fb 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -89,15 +89,28 @@
 #define FNIC_DEV_RST_ABTS_PENDING       BIT(21)
 
 /*
- * Usage of the scsi_cmnd scratchpad.
+ * fnic private data per SCSI command.
  * These fields are locked by the hashed io_req_lock.
  */
-#define CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)
-#define CMD_STATE(Cmnd)		((Cmnd)->SCp.phase)
-#define CMD_ABTS_STATUS(Cmnd)	((Cmnd)->SCp.Message)
-#define CMD_LR_STATUS(Cmnd)	((Cmnd)->SCp.have_data_in)
-#define CMD_TAG(Cmnd)           ((Cmnd)->SCp.sent_command)
-#define CMD_FLAGS(Cmnd)         ((Cmnd)->SCp.Status)
+struct fnic_cmd_priv {
+	struct fnic_io_req *io_req;
+	enum fnic_ioreq_state state;
+	u32 flags;
+	u16 abts_status;
+	u16 lr_status;
+};
+
+static inline struct fnic_cmd_priv *fnic_priv(struct scsi_cmnd *cmd)
+{
+	return scsi_cmd_priv(cmd);
+}
+
+static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)
+{
+	struct fnic_cmd_priv *fcmd = fnic_priv(cmd);
+
+	return ((u64)fcmd->flags << 32) | fcmd->state;
+}
 
 #define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */
 
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 44dbaa662d94..9161bd2fd421 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -124,6 +124,7 @@ static struct scsi_host_template fnic_host_template = {
 	.max_sectors = 0xffff,
 	.shost_groups = fnic_host_groups,
 	.track_queue_depth = 1,
+	.cmd_size = sizeof(struct fnic_cmd_priv),
 };
 
 static void
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 549754245f7a..3c00e5b88350 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -497,8 +497,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	 * caller disabling them.
 	 */
 	spin_unlock(lp->host->host_lock);
-	CMD_STATE(sc) = FNIC_IOREQ_NOT_INITED;
-	CMD_FLAGS(sc) = FNIC_NO_FLAGS;
+	fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED;
+	fnic_priv(sc)->flags = FNIC_NO_FLAGS;
 
 	/* Get a new io_req for this SCSI IO */
 	io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC);
@@ -513,7 +513,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	sg_count = scsi_dma_map(sc);
 	if (sg_count < 0) {
 		FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
-			  tag, sc, 0, sc->cmnd[0], sg_count, CMD_STATE(sc));
+			  tag, sc, 0, sc->cmnd[0], sg_count, fnic_priv(sc)->state);
 		mempool_free(io_req, fnic->io_req_pool);
 		goto out;
 	}
@@ -558,9 +558,9 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	io_lock_acquired = 1;
 	io_req->port_id = rport->port_id;
 	io_req->start_time = jiffies;
-	CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
-	CMD_SP(sc) = (char *)io_req;
-	CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED;
+	fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING;
+	fnic_priv(sc)->io_req = io_req;
+	fnic_priv(sc)->flags |= FNIC_IO_INITIALIZED;
 
 	/* create copy wq desc and enqueue it */
 	wq = &fnic->wq_copy[0];
@@ -571,11 +571,10 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 		 * refetch the pointer under the lock.
 		 */
 		FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
-			  tag, sc, 0, 0, 0,
-			  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
-		CMD_SP(sc) = NULL;
-		CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
+			  tag, sc, 0, 0, 0, fnic_flags_and_state(sc));
+		io_req = fnic_priv(sc)->io_req;
+		fnic_priv(sc)->io_req = NULL;
+		fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE;
 		spin_unlock_irqrestore(io_lock, flags);
 		if (io_req) {
 			fnic_release_ioreq_buf(fnic, io_req, sc);
@@ -594,7 +593,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 			     atomic64_read(&fnic_stats->io_stats.active_ios));
 
 		/* REVISIT: Use per IO lock in the final code */
-		CMD_FLAGS(sc) |= FNIC_IO_ISSUED;
+		fnic_priv(sc)->flags |= FNIC_IO_ISSUED;
 	}
 out:
 	cmd_trace = ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 |
@@ -603,8 +602,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 			sc->cmnd[5]);
 
 	FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no,
-		  tag, sc, io_req, sg_count, cmd_trace,
-		  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		   tag, sc, io_req, sg_count, cmd_trace,
+		   fnic_flags_and_state(sc));
 
 	/* if only we issued IO, will we have the io lock */
 	if (io_lock_acquired)
@@ -867,11 +866,11 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 
 	io_lock = fnic_io_lock_hash(fnic, sc);
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	WARN_ON_ONCE(!io_req);
 	if (!io_req) {
 		atomic64_inc(&fnic_stats->io_stats.ioreq_null);
-		CMD_FLAGS(sc) |= FNIC_IO_REQ_NULL;
+		fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL;
 		spin_unlock_irqrestore(io_lock, flags);
 		shost_printk(KERN_ERR, fnic->lport->host,
 			  "icmnd_cmpl io_req is null - "
@@ -888,17 +887,17 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 	 *  if SCSI-ML has already issued abort on this command,
 	 *  set completion of the IO. The abts path will clean it up
 	 */
-	if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+	if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) {
 
 		/*
 		 * set the FNIC_IO_DONE so that this doesn't get
 		 * flagged as 'out of order' if it was not aborted
 		 */
-		CMD_FLAGS(sc) |= FNIC_IO_DONE;
-		CMD_FLAGS(sc) |= FNIC_IO_ABTS_PENDING;
+		fnic_priv(sc)->flags |= FNIC_IO_DONE;
+		fnic_priv(sc)->flags |= FNIC_IO_ABTS_PENDING;
 		spin_unlock_irqrestore(io_lock, flags);
 		if(FCPIO_ABORTED == hdr_status)
-			CMD_FLAGS(sc) |= FNIC_IO_ABORTED;
+			fnic_priv(sc)->flags |= FNIC_IO_ABORTED;
 
 		FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
 			"icmnd_cmpl abts pending "
@@ -912,7 +911,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 	}
 
 	/* Mark the IO as complete */
-	CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
+	fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE;
 
 	icmnd_cmpl = &desc->u.icmnd_cmpl;
 
@@ -983,8 +982,8 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 	}
 
 	/* Break link with the SCSI command */
-	CMD_SP(sc) = NULL;
-	CMD_FLAGS(sc) |= FNIC_IO_DONE;
+	fnic_priv(sc)->io_req = NULL;
+	fnic_priv(sc)->flags |= FNIC_IO_DONE;
 
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -1009,8 +1008,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
 		  ((u64)icmnd_cmpl->_resvd0[1] << 56 |
 		  (u64)icmnd_cmpl->_resvd0[0] << 48 |
 		  jiffies_to_msecs(jiffies - start_time)),
-		  desc, cmd_trace,
-		  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		  desc, cmd_trace, fnic_flags_and_state(sc));
 
 	if (sc->sc_data_direction == DMA_FROM_DEVICE) {
 		fnic->lport->host_stats.fcp_input_requests++;
@@ -1095,12 +1093,12 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 	}
 	io_lock = fnic_io_lock_hash(fnic, sc);
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	WARN_ON_ONCE(!io_req);
 	if (!io_req) {
 		atomic64_inc(&fnic_stats->io_stats.ioreq_null);
 		spin_unlock_irqrestore(io_lock, flags);
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL;
 		shost_printk(KERN_ERR, fnic->lport->host,
 			  "itmf_cmpl io_req is null - "
 			  "hdr status = %s tag = 0x%x sc 0x%p\n",
@@ -1115,9 +1113,9 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			      "dev reset abts cmpl recd. id %x status %s\n",
 			      id, fnic_fcpio_status_to_str(hdr_status));
-		CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
-		CMD_ABTS_STATUS(sc) = hdr_status;
-		CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
+		fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE;
+		fnic_priv(sc)->abts_status = hdr_status;
+		fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE;
 		if (io_req->abts_done)
 			complete(io_req->abts_done);
 		spin_unlock_irqrestore(io_lock, flags);
@@ -1127,7 +1125,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 		case FCPIO_SUCCESS:
 			break;
 		case FCPIO_TIMEOUT:
-			if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED)
+			if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED)
 				atomic64_inc(&abts_stats->abort_fw_timeouts);
 			else
 				atomic64_inc(
@@ -1139,34 +1137,34 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 				(int)(id & FNIC_TAG_MASK));
 			break;
 		case FCPIO_IO_NOT_FOUND:
-			if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED)
+			if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED)
 				atomic64_inc(&abts_stats->abort_io_not_found);
 			else
 				atomic64_inc(
 					&term_stats->terminate_io_not_found);
 			break;
 		default:
-			if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED)
+			if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED)
 				atomic64_inc(&abts_stats->abort_failures);
 			else
 				atomic64_inc(
 					&term_stats->terminate_failures);
 			break;
 		}
-		if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) {
+		if (fnic_priv(sc)->state != FNIC_IOREQ_ABTS_PENDING) {
 			/* This is a late completion. Ignore it */
 			spin_unlock_irqrestore(io_lock, flags);
 			return;
 		}
 
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
-		CMD_ABTS_STATUS(sc) = hdr_status;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE;
+		fnic_priv(sc)->abts_status = hdr_status;
 
 		/* If the status is IO not found consider it as success */
 		if (hdr_status == FCPIO_IO_NOT_FOUND)
-			CMD_ABTS_STATUS(sc) = FCPIO_SUCCESS;
+			fnic_priv(sc)->abts_status = FCPIO_SUCCESS;
 
-		if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE)))
+		if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE)))
 			atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls);
 
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
@@ -1185,7 +1183,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 		} else {
 			FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				      "abts cmpl, completing IO\n");
-			CMD_SP(sc) = NULL;
+			fnic_priv(sc)->io_req = NULL;
 			sc->result = (DID_ERROR << 16);
 
 			spin_unlock_irqrestore(io_lock, flags);
@@ -1202,8 +1200,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 				    (u64)sc->cmnd[2] << 24 |
 				    (u64)sc->cmnd[3] << 16 |
 				    (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
-				   (((u64)CMD_FLAGS(sc) << 32) |
-				    CMD_STATE(sc)));
+				   fnic_flags_and_state(sc));
 			scsi_done(sc);
 			atomic64_dec(&fnic_stats->io_stats.active_ios);
 			if (atomic64_read(&fnic->io_cmpl_skip))
@@ -1213,15 +1210,14 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 		}
 	} else if (id & FNIC_TAG_DEV_RST) {
 		/* Completion of device reset */
-		CMD_LR_STATUS(sc) = hdr_status;
-		if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+		fnic_priv(sc)->lr_status = hdr_status;
+		if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) {
 			spin_unlock_irqrestore(io_lock, flags);
-			CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING;
+			fnic_priv(sc)->flags |= FNIC_DEV_RST_ABTS_PENDING;
 			FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
 				  sc->device->host->host_no, id, sc,
 				  jiffies_to_msecs(jiffies - start_time),
-				  desc, 0,
-				  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+				  desc, 0, fnic_flags_and_state(sc));
 			FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				"Terminate pending "
 				"dev reset cmpl recd. id %d status %s\n",
@@ -1229,14 +1225,13 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 				fnic_fcpio_status_to_str(hdr_status));
 			return;
 		}
-		if (CMD_FLAGS(sc) & FNIC_DEV_RST_TIMED_OUT) {
+		if (fnic_priv(sc)->flags & FNIC_DEV_RST_TIMED_OUT) {
 			/* Need to wait for terminate completion */
 			spin_unlock_irqrestore(io_lock, flags);
 			FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
 				  sc->device->host->host_no, id, sc,
 				  jiffies_to_msecs(jiffies - start_time),
-				  desc, 0,
-				  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+				  desc, 0, fnic_flags_and_state(sc));
 			FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				"dev reset cmpl recd after time out. "
 				"id %d status %s\n",
@@ -1244,8 +1239,8 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 				fnic_fcpio_status_to_str(hdr_status));
 			return;
 		}
-		CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE;
-		CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
+		fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE;
+		fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE;
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			      "dev reset cmpl recd. id %d status %s\n",
 			      (int)(id & FNIC_TAG_MASK),
@@ -1257,7 +1252,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
 	} else {
 		shost_printk(KERN_ERR, fnic->lport->host,
 			     "Unexpected itmf io state %s tag %x\n",
-			     fnic_ioreq_state_to_str(CMD_STATE(sc)), id);
+			     fnic_ioreq_state_to_str(fnic_priv(sc)->state), id);
 		spin_unlock_irqrestore(io_lock, flags);
 	}
 
@@ -1370,21 +1365,21 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
 	io_lock = fnic_io_lock_tag(fnic, tag);
 	spin_lock_irqsave(io_lock, flags);
 
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
-	if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
-	    !(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) {
+	io_req = fnic_priv(sc)->io_req;
+	if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) &&
+	    !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) {
 		/*
 		 * We will be here only when FW completes reset
 		 * without sending completions for outstanding ios.
 		 */
-		CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE;
+		fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE;
 		if (io_req && io_req->dr_done)
 			complete(io_req->dr_done);
 		else if (io_req && io_req->abts_done)
 			complete(io_req->abts_done);
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
-	} else if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
+	} else if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
 	}
@@ -1393,7 +1388,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
 		goto cleanup_scsi_cmd;
 	}
 
-	CMD_SP(sc) = NULL;
+	fnic_priv(sc)->io_req = NULL;
 
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -1417,7 +1412,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
 		atomic64_inc(&fnic_stats->io_stats.io_completions);
 
 	/* Complete the command to SCSI */
-	if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED))
+	if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED))
 		shost_printk(KERN_ERR, fnic->lport->host,
 			     "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n",
 			     tag, sc);
@@ -1429,7 +1424,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
 		       (u64)sc->cmnd[2] << 24 |
 		       (u64)sc->cmnd[3] << 16 |
 		       (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
-		   (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		   fnic_flags_and_state(sc));
 
 	scsi_done(sc);
 
@@ -1468,7 +1463,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
 	spin_lock_irqsave(io_lock, flags);
 
 	/* Get the IO context which this desc refers to */
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 
 	/* fnic interrupts are turned off by now */
 
@@ -1477,7 +1472,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
 		goto wq_copy_cleanup_scsi_cmd;
 	}
 
-	CMD_SP(sc) = NULL;
+	fnic_priv(sc)->io_req = NULL;
 
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -1496,7 +1491,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
 		   0, ((u64)sc->cmnd[0] << 32 |
 		       (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
 		       (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
-		   (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		   fnic_flags_and_state(sc));
 
 	scsi_done(sc);
 }
@@ -1571,15 +1566,15 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data,
 	io_lock = fnic_io_lock_tag(fnic, abt_tag);
 	spin_lock_irqsave(io_lock, flags);
 
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 
 	if (!io_req || io_req->port_id != iter_data->port_id) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
 	}
 
-	if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
-	    (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) {
+	if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) &&
+	    !(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) {
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			"fnic_rport_exch_reset dev rst not pending sc 0x%p\n",
 			sc);
@@ -1591,7 +1586,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data,
 	 * Found IO that is still pending with firmware and
 	 * belongs to rport that went away
 	 */
-	if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+	if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
 	}
@@ -1599,20 +1594,20 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data,
 		shost_printk(KERN_ERR, fnic->lport->host,
 			"fnic_rport_exch_reset: io_req->abts_done is set "
 			"state is %s\n",
-			fnic_ioreq_state_to_str(CMD_STATE(sc)));
+			fnic_ioreq_state_to_str(fnic_priv(sc)->state));
 	}
 
-	if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) {
+	if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) {
 		shost_printk(KERN_ERR, fnic->lport->host,
 			     "rport_exch_reset "
 			     "IO not yet issued %p tag 0x%x flags "
 			     "%x state %d\n",
-			     sc, abt_tag, CMD_FLAGS(sc), CMD_STATE(sc));
+			     sc, abt_tag, fnic_priv(sc)->flags, fnic_priv(sc)->state);
 	}
-	old_ioreq_state = CMD_STATE(sc);
-	CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
-	CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
-	if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
+	old_ioreq_state = fnic_priv(sc)->state;
+	fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING;
+	fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE;
+	if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) {
 		atomic64_inc(&reset_stats->device_reset_terminates);
 		abt_tag |= FNIC_TAG_DEV_RST;
 	}
@@ -1638,15 +1633,15 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data,
 		 * lun reset
 		 */
 		spin_lock_irqsave(io_lock, flags);
-		if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
-			CMD_STATE(sc) = old_ioreq_state;
+		if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING)
+			fnic_priv(sc)->state = old_ioreq_state;
 		spin_unlock_irqrestore(io_lock, flags);
 	} else {
 		spin_lock_irqsave(io_lock, flags);
-		if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET)
-			CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
+		if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET)
+			fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED;
 		else
-			CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED;
+			fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED;
 		spin_unlock_irqrestore(io_lock, flags);
 		atomic64_inc(&term_stats->terminates);
 		iter_data->term_cnt++;
@@ -1754,9 +1749,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	FNIC_SCSI_DBG(KERN_DEBUG,
 		fnic->lport->host,
 		"Abort Cmd called FCID 0x%x, LUN 0x%llx TAG %x flags %x\n",
-		rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc));
+		rport->port_id, sc->device->lun, tag, fnic_priv(sc)->flags);
 
-	CMD_FLAGS(sc) = FNIC_NO_FLAGS;
+	fnic_priv(sc)->flags = FNIC_NO_FLAGS;
 
 	if (lp->state != LPORT_ST_READY || !(lp->link_up)) {
 		ret = FAILED;
@@ -1773,11 +1768,11 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	 * happened, the completion wont actually complete the command
 	 * and it will be considered as an aborted command
 	 *
-	 * The CMD_SP will not be cleared except while holding io_req_lock.
+	 * .io_req will not be cleared except while holding io_req_lock.
 	 */
 	io_lock = fnic_io_lock_hash(fnic, sc);
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		spin_unlock_irqrestore(io_lock, flags);
 		goto fnic_abort_cmd_end;
@@ -1785,7 +1780,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 
 	io_req->abts_done = &tm_done;
 
-	if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+	if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) {
 		spin_unlock_irqrestore(io_lock, flags);
 		goto wait_pending;
 	}
@@ -1814,9 +1809,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	 * the completion wont be done till mid-layer, since abort
 	 * has already started.
 	 */
-	old_ioreq_state = CMD_STATE(sc);
-	CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
-	CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+	old_ioreq_state = fnic_priv(sc)->state;
+	fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING;
+	fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE;
 
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -1838,9 +1833,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	if (fnic_queue_abort_io_req(fnic, tag, task_req, fc_lun.scsi_lun,
 				    io_req)) {
 		spin_lock_irqsave(io_lock, flags);
-		if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
-			CMD_STATE(sc) = old_ioreq_state;
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING)
+			fnic_priv(sc)->state = old_ioreq_state;
+		io_req = fnic_priv(sc)->io_req;
 		if (io_req)
 			io_req->abts_done = NULL;
 		spin_unlock_irqrestore(io_lock, flags);
@@ -1848,10 +1843,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 		goto fnic_abort_cmd_end;
 	}
 	if (task_req == FCPIO_ITMF_ABT_TASK) {
-		CMD_FLAGS(sc) |= FNIC_IO_ABTS_ISSUED;
+		fnic_priv(sc)->flags |= FNIC_IO_ABTS_ISSUED;
 		atomic64_inc(&fnic_stats->abts_stats.aborts);
 	} else {
-		CMD_FLAGS(sc) |= FNIC_IO_TERM_ISSUED;
+		fnic_priv(sc)->flags |= FNIC_IO_TERM_ISSUED;
 		atomic64_inc(&fnic_stats->term_stats.terminates);
 	}
 
@@ -1869,32 +1864,32 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	/* Check the abort status */
 	spin_lock_irqsave(io_lock, flags);
 
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		atomic64_inc(&fnic_stats->io_stats.ioreq_null);
 		spin_unlock_irqrestore(io_lock, flags);
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL;
 		ret = FAILED;
 		goto fnic_abort_cmd_end;
 	}
 	io_req->abts_done = NULL;
 
 	/* fw did not complete abort, timed out */
-	if (CMD_ABTS_STATUS(sc) == FCPIO_INVALID_CODE) {
+	if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) {
 		spin_unlock_irqrestore(io_lock, flags);
 		if (task_req == FCPIO_ITMF_ABT_TASK) {
 			atomic64_inc(&abts_stats->abort_drv_timeouts);
 		} else {
 			atomic64_inc(&term_stats->terminate_drv_timeouts);
 		}
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_TIMED_OUT;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_TIMED_OUT;
 		ret = FAILED;
 		goto fnic_abort_cmd_end;
 	}
 
 	/* IO out of order */
 
-	if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE))) {
+	if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) {
 		spin_unlock_irqrestore(io_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			"Issuing Host reset due to out of order IO\n");
@@ -1903,7 +1898,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 		goto fnic_abort_cmd_end;
 	}
 
-	CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
+	fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE;
 
 	start_time = io_req->start_time;
 	/*
@@ -1911,9 +1906,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 	 * free the io_req if successful. If abort fails,
 	 * Device reset will clean the I/O.
 	 */
-	if (CMD_ABTS_STATUS(sc) == FCPIO_SUCCESS)
-		CMD_SP(sc) = NULL;
-	else {
+	if (fnic_priv(sc)->abts_status == FCPIO_SUCCESS) {
+		fnic_priv(sc)->io_req = NULL;
+	} else {
 		ret = FAILED;
 		spin_unlock_irqrestore(io_lock, flags);
 		goto fnic_abort_cmd_end;
@@ -1939,7 +1934,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
 		  0, ((u64)sc->cmnd[0] << 32 |
 		  (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
 		  (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
-		  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		  fnic_flags_and_state(sc));
 
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 		      "Returning from abort cmd type %x %s\n", task_req,
@@ -2030,7 +2025,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
 
 	io_lock = fnic_io_lock_tag(fnic, abt_tag);
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
@@ -2042,14 +2037,14 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
 	 */
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 		      "Found IO in %s on lun\n",
-		      fnic_ioreq_state_to_str(CMD_STATE(sc)));
+		      fnic_ioreq_state_to_str(fnic_priv(sc)->state));
 
-	if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) {
+	if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
 	}
-	if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) &&
-	    (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) {
+	if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) &&
+	    (!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) {
 		FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
 			      "%s dev rst not pending sc 0x%p\n", __func__,
 			      sc);
@@ -2060,8 +2055,8 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
 	if (io_req->abts_done)
 		shost_printk(KERN_ERR, fnic->lport->host,
 			     "%s: io_req->abts_done is set state is %s\n",
-			     __func__, fnic_ioreq_state_to_str(CMD_STATE(sc)));
-	old_ioreq_state = CMD_STATE(sc);
+			     __func__, fnic_ioreq_state_to_str(fnic_priv(sc)->state));
+	old_ioreq_state = fnic_priv(sc)->state;
 	/*
 	 * Any pending IO issued prior to reset is expected to be
 	 * in abts pending state, if not we need to set
@@ -2069,17 +2064,17 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
 	 * When IO is completed, the IO will be handed over and
 	 * handled in this function.
 	 */
-	CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
+	fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING;
 
 	BUG_ON(io_req->abts_done);
 
-	if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) {
+	if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) {
 		abt_tag |= FNIC_TAG_DEV_RST;
 		FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
 			      "%s: dev rst sc 0x%p\n", __func__, sc);
 	}
 
-	CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE;
+	fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE;
 	io_req->abts_done = &tm_done;
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -2090,48 +2085,48 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
 				    FCPIO_ITMF_ABT_TASK_TERM,
 				    fc_lun.scsi_lun, io_req)) {
 		spin_lock_irqsave(io_lock, flags);
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		io_req = fnic_priv(sc)->io_req;
 		if (io_req)
 			io_req->abts_done = NULL;
-		if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING)
-			CMD_STATE(sc) = old_ioreq_state;
+		if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING)
+			fnic_priv(sc)->state = old_ioreq_state;
 		spin_unlock_irqrestore(io_lock, flags);
 		iter_data->ret = FAILED;
 		return false;
 	} else {
 		spin_lock_irqsave(io_lock, flags);
-		if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET)
-			CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
+		if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET)
+			fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED;
 		spin_unlock_irqrestore(io_lock, flags);
 	}
-	CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED;
+	fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED;
 
 	wait_for_completion_timeout(&tm_done, msecs_to_jiffies
 				    (fnic->config.ed_tov));
 
 	/* Recheck cmd state to check if it is now aborted */
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		spin_unlock_irqrestore(io_lock, flags);
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL;
 		return true;
 	}
 
 	io_req->abts_done = NULL;
 
 	/* if abort is still pending with fw, fail */
-	if (CMD_ABTS_STATUS(sc) == FCPIO_INVALID_CODE) {
+	if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) {
 		spin_unlock_irqrestore(io_lock, flags);
-		CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE;
+		fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE;
 		iter_data->ret = FAILED;
 		return false;
 	}
-	CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
+	fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE;
 
 	/* original sc used for lr is handled by dev reset code */
 	if (sc != iter_data->lr_sc)
-		CMD_SP(sc) = NULL;
+		fnic_priv(sc)->io_req = NULL;
 	spin_unlock_irqrestore(io_lock, flags);
 
 	/* original sc used for lr is handled by dev reset code */
@@ -2272,7 +2267,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		goto fnic_device_reset_end;
 	}
 
-	CMD_FLAGS(sc) = FNIC_DEVICE_RESET;
+	fnic_priv(sc)->flags = FNIC_DEVICE_RESET;
 	/* Allocate tag if not present */
 
 	if (unlikely(tag < 0)) {
@@ -2288,7 +2283,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	}
 	io_lock = fnic_io_lock_hash(fnic, sc);
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 
 	/*
 	 * If there is a io_req attached to this command, then use it,
@@ -2302,11 +2297,11 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		}
 		memset(io_req, 0, sizeof(*io_req));
 		io_req->port_id = rport->port_id;
-		CMD_SP(sc) = (char *)io_req;
+		fnic_priv(sc)->io_req = io_req;
 	}
 	io_req->dr_done = &tm_done;
-	CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
-	CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE;
+	fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING;
+	fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE;
 	spin_unlock_irqrestore(io_lock, flags);
 
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %x\n", tag);
@@ -2317,13 +2312,13 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	 */
 	if (fnic_queue_dr_io_req(fnic, sc, io_req)) {
 		spin_lock_irqsave(io_lock, flags);
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		io_req = fnic_priv(sc)->io_req;
 		if (io_req)
 			io_req->dr_done = NULL;
 		goto fnic_device_reset_clean;
 	}
 	spin_lock_irqsave(io_lock, flags);
-	CMD_FLAGS(sc) |= FNIC_DEV_RST_ISSUED;
+	fnic_priv(sc)->flags |= FNIC_DEV_RST_ISSUED;
 	spin_unlock_irqrestore(io_lock, flags);
 
 	/*
@@ -2334,7 +2329,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 				    msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT));
 
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		spin_unlock_irqrestore(io_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
@@ -2343,7 +2338,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	}
 	io_req->dr_done = NULL;
 
-	status = CMD_LR_STATUS(sc);
+	status = fnic_priv(sc)->lr_status;
 
 	/*
 	 * If lun reset not completed, bail out with failed. io_req
@@ -2353,7 +2348,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		atomic64_inc(&reset_stats->device_reset_timeouts);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			      "Device reset timed out\n");
-		CMD_FLAGS(sc) |= FNIC_DEV_RST_TIMED_OUT;
+		fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT;
 		spin_unlock_irqrestore(io_lock, flags);
 		int_to_scsilun(sc->device->lun, &fc_lun);
 		/*
@@ -2362,7 +2357,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		 */
 		while (1) {
 			spin_lock_irqsave(io_lock, flags);
-			if (CMD_FLAGS(sc) & FNIC_DEV_RST_TERM_ISSUED) {
+			if (fnic_priv(sc)->flags & FNIC_DEV_RST_TERM_ISSUED) {
 				spin_unlock_irqrestore(io_lock, flags);
 				break;
 			}
@@ -2375,8 +2370,8 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 				msecs_to_jiffies(FNIC_ABT_TERM_DELAY_TIMEOUT));
 			} else {
 				spin_lock_irqsave(io_lock, flags);
-				CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED;
-				CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING;
+				fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED;
+				fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING;
 				io_req->abts_done = &tm_done;
 				spin_unlock_irqrestore(io_lock, flags);
 				FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
@@ -2387,13 +2382,13 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		}
 		while (1) {
 			spin_lock_irqsave(io_lock, flags);
-			if (!(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) {
+			if (!(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) {
 				spin_unlock_irqrestore(io_lock, flags);
 				wait_for_completion_timeout(&tm_done,
 				msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT));
 				break;
 			} else {
-				io_req = (struct fnic_io_req *)CMD_SP(sc);
+				io_req = fnic_priv(sc)->io_req;
 				io_req->abts_done = NULL;
 				goto fnic_device_reset_clean;
 			}
@@ -2408,7 +2403,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		FNIC_SCSI_DBG(KERN_DEBUG,
 			      fnic->lport->host,
 			      "Device reset completed - failed\n");
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		io_req = fnic_priv(sc)->io_req;
 		goto fnic_device_reset_clean;
 	}
 
@@ -2421,7 +2416,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	 */
 	if (fnic_clean_pending_aborts(fnic, sc, new_sc)) {
 		spin_lock_irqsave(io_lock, flags);
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		io_req = fnic_priv(sc)->io_req;
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			      "Device reset failed"
 			      " since could not abort all IOs\n");
@@ -2430,14 +2425,14 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 
 	/* Clean lun reset command */
 	spin_lock_irqsave(io_lock, flags);
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (io_req)
 		/* Completed, and successful */
 		ret = SUCCESS;
 
 fnic_device_reset_clean:
 	if (io_req)
-		CMD_SP(sc) = NULL;
+		fnic_priv(sc)->io_req = NULL;
 
 	spin_unlock_irqrestore(io_lock, flags);
 
@@ -2453,7 +2448,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 		  0, ((u64)sc->cmnd[0] << 32 |
 		  (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
 		  (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
-		  (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
+		  fnic_flags_and_state(sc));
 
 	/* free tag if it is allocated */
 	if (unlikely(tag_gen_flag))
@@ -2698,7 +2693,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data,
 	io_lock = fnic_io_lock_hash(fnic, sc);
 	spin_lock_irqsave(io_lock, flags);
 
-	io_req = (struct fnic_io_req *)CMD_SP(sc);
+	io_req = fnic_priv(sc)->io_req;
 	if (!io_req) {
 		spin_unlock_irqrestore(io_lock, flags);
 		return true;
@@ -2710,8 +2705,8 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data,
 	 */
 	FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
 		      "Found IO in %s on lun\n",
-		      fnic_ioreq_state_to_str(CMD_STATE(sc)));
-	cmd_state = CMD_STATE(sc);
+		      fnic_ioreq_state_to_str(fnic_priv(sc)->state));
+	cmd_state = fnic_priv(sc)->state;
 	spin_unlock_irqrestore(io_lock, flags);
 	if (cmd_state == FNIC_IOREQ_ABTS_PENDING)
 		iter_data->ret = 1;

  parent reply	other threads:[~2022-01-28 22:21 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 22:18 [PATCH 00/44] Remove the SCSI pointer from struct scsi_cmnd Bart Van Assche
2022-01-28 22:18 ` [PATCH 01/44] ips: Use true and false instead of TRUE and FALSE Bart Van Assche
2022-01-31  9:53   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 02/44] nsp_cs: " Bart Van Assche
2022-01-31  9:55   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 03/44] scsi: Remove drivers/scsi/scsi.h Bart Van Assche
2022-01-31 12:53   ` Greg Kroah-Hartman
2022-01-28 22:18 ` [PATCH 04/44] NCR5380: Remove the NCR5380_CMD_SIZE macro Bart Van Assche
2022-01-31  9:58   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 05/44] NCR5380: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 10:04   ` Johannes Thumshirn
2022-01-31 22:39   ` Finn Thain
2022-01-31 23:36     ` Bart Van Assche
2022-02-01  0:11       ` Finn Thain
2022-01-28 22:18 ` [PATCH 06/44] scsi: arm: Rename arm/scsi.h into arm/arm_scsi.h Bart Van Assche
2022-01-31 10:09   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 07/44] scsi: arm: Move the SCSI pointer to private command data Bart Van Assche
2022-01-28 22:18 ` [PATCH 08/44] 53c700: Stop clearing SCSI pointer fields Bart Van Assche
2022-01-31 10:15   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 09/44] aacraid: Move the SCSI pointer to private command data Bart Van Assche
2022-01-28 22:18 ` [PATCH 10/44] advansys: " Bart Van Assche
2022-01-31 10:23   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 11/44] aha1542: Remove a set-but-not-used array Bart Van Assche
2022-01-31 10:25   ` Johannes Thumshirn
2022-01-31 17:13     ` Bart Van Assche
2022-01-28 22:18 ` [PATCH 12/44] aha152x: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 10:32   ` Johannes Thumshirn
2022-01-31 17:16     ` Bart Van Assche
2022-01-28 22:18 ` [PATCH 13/44] bfa: Stop using the SCSI pointer Bart Van Assche
2022-01-31 10:39   ` Johannes Thumshirn
2022-01-31 17:19     ` Bart Van Assche
2022-02-01  9:16       ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 14/44] csio: " Bart Van Assche
2022-01-31 10:41   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 15/44] dc395x: " Bart Van Assche
2022-01-31 10:42   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 16/44] esp_scsi: " Bart Van Assche
2022-01-31 10:43   ` Johannes Thumshirn
2022-01-31 22:46   ` Finn Thain
2022-02-01 21:20     ` Bart Van Assche
2022-01-28 22:18 ` [PATCH 17/44] fdomain: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 10:44   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 18/44] fnic: Fix a tracing statement Bart Van Assche
2022-01-28 22:18 ` Bart Van Assche [this message]
2022-01-31 11:01   ` [PATCH 19/44] fnic: Stop using the SCSI pointer Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 20/44] hptiop: " Bart Van Assche
2022-01-31 11:03   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 21/44] imm: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 11:17   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 22/44] iscsi: Stop using the SCSI pointer Bart Van Assche
2022-01-28 22:18 ` [PATCH 23/44] initio: " Bart Van Assche
2022-01-31 11:19   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 24/44] libfc: " Bart Van Assche
2022-01-28 22:18 ` [PATCH 25/44] mac53c94: Fix a set-but-not-used compiler warning Bart Van Assche
2022-01-31 11:21   ` Johannes Thumshirn
2022-01-31 17:22     ` Bart Van Assche
2022-01-28 22:18 ` [PATCH 26/44] mac53c94: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 11:22   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 27/44] megaraid: Stop using the SCSI pointer Bart Van Assche
2022-01-31 11:27   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 28/44] megasas: " Bart Van Assche
2022-01-31 11:28   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 29/44] mesh: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 11:31   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 30/44] mvsas: Fix a set-but-not-used warning Bart Van Assche
2022-01-31 11:33   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 31/44] mvumi: Stop using the SCSI pointer Bart Van Assche
2022-01-31 11:34   ` Johannes Thumshirn
2022-01-28 22:18 ` [PATCH 32/44] nsp32: " Bart Van Assche
2022-01-31  2:53   ` Masanori Goto
2022-01-31 17:28     ` Bart Van Assche
2022-01-28 22:18 ` [PATCH 33/44] nsp_cs: Move the SCSI pointer to private command data Bart Van Assche
2022-01-28 22:18 ` [PATCH 34/44] sym53c500_cs: " Bart Van Assche
2022-01-31 11:37   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 35/44] ppa: " Bart Van Assche
2022-01-31 11:38   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 36/44] qla1280: " Bart Van Assche
2022-01-31 11:39   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 37/44] qla2xxx: Stop using the SCSI pointer Bart Van Assche
2022-01-28 22:19 ` [PATCH 38/44] smartpqi: " Bart Van Assche
2022-01-31 11:41   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 39/44] sym53c8xx_2: Move the SCSI pointer to private command data Bart Van Assche
2022-01-31 11:42   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 40/44] scsi: usb: Stop using the SCSI pointer Bart Van Assche
2022-01-31 11:43   ` Johannes Thumshirn
2022-01-31 12:53   ` Greg Kroah-Hartman
2022-02-02  8:14   ` Oliver Neukum
2022-01-28 22:19 ` [PATCH 41/44] wd719x: " Bart Van Assche
2022-01-31 11:44   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 42/44] wdc33c93: Move the SCSI pointer to private command data Bart Van Assche
2022-01-28 22:19 ` [PATCH 43/44] zalon: Stop using the SCSI pointer Bart Van Assche
2022-01-31 11:46   ` Johannes Thumshirn
2022-01-28 22:19 ` [PATCH 44/44] scsi: core: Remove struct scsi_pointer from struct scsi_cmnd Bart Van Assche
2022-01-31 11:47   ` Johannes Thumshirn

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=20220128221909.8141-20-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=kartilak@cisco.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.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 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.