--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_iocb.c	Mon Aug  5 17:28:43 2019
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_iocb.c	Mon Aug  5 17:28:43 2019
@@ -19,13 +19,13 @@
  * CDDL HEADER END
  */
 
-/* Copyright 2010 QLogic Corporation */
+/* Copyright 2015 QLogic Corporation */
 
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"Copyright 2010 QLogic Corporation; ql_iocb.c"
+#pragma ident	"Copyright 2015 QLogic Corporation; ql_iocb.c"
 
 /*
  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
@@ -33,7 +33,7 @@
  * ***********************************************************************
  * *									**
  * *				NOTICE					**
- * *		COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION		**
+ * *		COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION		**
  * *			ALL RIGHTS RESERVED				**
  * *									**
  * ***********************************************************************
@@ -45,16 +45,21 @@
 #include <ql_debug.h>
 #include <ql_iocb.h>
 #include <ql_isr.h>
+#include <ql_nx.h>
 #include <ql_xioctl.h>
+#include <ql_fm.h>
 
+
 /*
  * Local Function Prototypes.
  */
-static int ql_req_pkt(ql_adapter_state_t *, request_t **);
-static void ql_continuation_iocb(ql_adapter_state_t *, ddi_dma_cookie_t *,
-    uint16_t, boolean_t);
+static int ql_req_pkt(ql_adapter_state_t *, ql_request_q_t *, request_t **);
+static void ql_isp_cmd(ql_adapter_state_t *, ql_request_q_t *);
+static void ql_continuation_iocb(ql_adapter_state_t *, ql_request_q_t *,
+    ddi_dma_cookie_t *, uint16_t, boolean_t);
 static void ql_isp24xx_rcvbuf(ql_adapter_state_t *);
-static void ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
+static void ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *, ql_request_q_t *,
+    ql_srb_t *, void *);
 
 /*
  * ql_start_iocb
@@ -72,12 +77,13 @@
 ql_start_iocb(ql_adapter_state_t *vha, ql_srb_t *sp)
 {
 	ql_link_t		*link;
+	ql_request_q_t		*req_q;
 	request_t		*pkt;
 	uint64_t		*ptr64;
 	uint32_t		cnt;
 	ql_adapter_state_t	*ha = vha->pha;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Acquire ring lock. */
 	REQUEST_RING_LOCK(ha);
@@ -98,8 +104,7 @@
 		if ((link = ha->pending_cmds.first) == NULL) {
 			/* Release ring specific lock */
 			REQUEST_RING_UNLOCK(ha);
-			QL_PRINT_3(CE_CONT, "(%d): empty done\n",
-			    ha->instance);
+			QL_PRINT_3(ha, "empty done\n");
 			return;
 		}
 		/* Remove command from pending command queue */
@@ -109,29 +114,45 @@
 
 	/* start this request and as many others as possible */
 	for (;;) {
-		if (ha->req_q_cnt < sp->req_cnt) {
+		if (ha->req_q[1] != NULL && sp->rsp_q_number != 0) {
+			req_q = ha->req_q[1];
+		} else {
+			req_q = ha->req_q[0];
+		}
+
+		if (req_q->req_q_cnt < sp->req_cnt) {
 			/* Calculate number of free request entries. */
-			cnt = RD16_IO_REG(ha, req_out);
-			if (ha->req_ring_index < cnt)  {
-				ha->req_q_cnt = (uint16_t)
-				    (cnt - ha->req_ring_index);
+			if (ha->flags & QUEUE_SHADOW_PTRS) {
+				(void) ddi_dma_sync(req_q->req_ring.dma_handle,
+				    (off_t)req_q->req_out_shadow_ofst,
+				    SHADOW_ENTRY_SIZE, DDI_DMA_SYNC_FORCPU);
+				cnt = ddi_get32(req_q->req_ring.acc_handle,
+				    req_q->req_out_shadow_ptr);
+			} else if (ha->flags & MULTI_QUEUE) {
+				cnt = RD16_MBAR_REG(ha, req_q->mbar_req_out);
 			} else {
-				ha->req_q_cnt = (uint16_t)(REQUEST_ENTRY_CNT -
-				    (ha->req_ring_index - cnt));
+				cnt = RD16_IO_REG(ha, req_out);
 			}
-			if (ha->req_q_cnt != 0) {
-				ha->req_q_cnt--;
+			if (req_q->req_ring_index < cnt) {
+				req_q->req_q_cnt = (uint16_t)
+				    (cnt - req_q->req_ring_index);
+			} else {
+				req_q->req_q_cnt =
+				    (uint16_t)(req_q->req_entry_cnt -
+				    (req_q->req_ring_index - cnt));
 			}
+			if (req_q->req_q_cnt != 0) {
+				req_q->req_q_cnt--;
+			}
 
 			/*
 			 * If no room in request ring put this srb at
 			 * the head of the pending queue and exit.
 			 */
-			if (ha->req_q_cnt < sp->req_cnt) {
-				QL_PRINT_8(CE_CONT, "(%d): request ring full,"
+			if (req_q->req_q_cnt < sp->req_cnt) {
+				QL_PRINT_8(ha, "request ring full,"
 				    " req_q_cnt=%d, req_ring_index=%d\n",
-				    ha->instance, ha->req_q_cnt,
-				    ha->req_ring_index);
+				    req_q->req_q_cnt, req_q->req_ring_index);
 				ql_add_link_t(&ha->pending_cmds, &sp->cmd);
 				break;
 			}
@@ -138,9 +159,9 @@
 		}
 
 		/* Check for room in outstanding command list. */
-		for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+		for (cnt = 1; cnt < ha->osc_max_cnt; cnt++) {
 			ha->osc_index++;
-			if (ha->osc_index == MAX_OUTSTANDING_COMMANDS) {
+			if (ha->osc_index == ha->osc_max_cnt) {
 				ha->osc_index = 1;
 			}
 			if (ha->outstanding_cmds[ha->osc_index] == NULL) {
@@ -151,9 +172,8 @@
 		 * If no room in outstanding array put this srb at
 		 * the head of the pending queue and exit.
 		 */
-		if (cnt == MAX_OUTSTANDING_COMMANDS) {
-			QL_PRINT_8(CE_CONT, "(%d): no room in outstanding "
-			    "array\n", ha->instance);
+		if (cnt == ha->osc_max_cnt) {
+			QL_PRINT_8(ha, "no room in outstanding array\n");
 			ql_add_link_t(&ha->pending_cmds, &sp->cmd);
 			break;
 		}
@@ -163,11 +183,12 @@
 		/* create and save a unique response identifier in the srb */
 		sp->handle = ha->adapter_stats->ncmds << OSC_INDEX_SHIFT |
 		    ha->osc_index;
-		ha->req_q_cnt -= sp->req_cnt;
+		req_q->req_q_cnt = (uint16_t)(req_q->req_q_cnt - sp->req_cnt);
 
 		/* build the iocb in the request ring */
-		pkt = ha->request_ring_ptr;
+		pkt = req_q->req_ring_ptr;
 		sp->request_ring_ptr = pkt;
+		sp->req_q_number = req_q->req_q_number;
 		sp->flags |= SRB_IN_TOKEN_ARRAY;
 
 		/* Zero out packet. */
@@ -179,33 +200,35 @@
 
 		/* Setup IOCB common data. */
 		pkt->entry_count = (uint8_t)sp->req_cnt;
-		pkt->sys_define = (uint8_t)ha->req_ring_index;
+		if (ha->req_q[1] != NULL && sp->rsp_q_number != 0) {
+			pkt->entry_status = sp->rsp_q_number;
+		}
+		pkt->sys_define = (uint8_t)req_q->req_ring_index;
+
 		/* mark the iocb with the response identifier */
-		ddi_put32(ha->hba_buf.acc_handle, &pkt->handle,
+		ddi_put32(req_q->req_ring.acc_handle, &pkt->handle,
 		    (uint32_t)sp->handle);
 
 		/* Setup IOCB unique data. */
-		(sp->iocb)(vha, sp, pkt);
+		(sp->iocb)(vha, req_q, sp, pkt);
 
 		sp->flags |= SRB_ISP_STARTED;
 
-		QL_PRINT_5(CE_CONT, "(%d,%d): req packet, sp=%p\n",
-		    ha->instance, vha->vp_index, (void *)sp);
+		QL_PRINT_5(ha, "req packet, sp=%p\n", (void *)sp);
 		QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
 
 		/* Sync DMA buffer. */
-		(void) ddi_dma_sync(ha->hba_buf.dma_handle,
-		    (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
-		    REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
-		    DDI_DMA_SYNC_FORDEV);
+		(void) ddi_dma_sync(req_q->req_ring.dma_handle,
+		    (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
+		    (size_t)REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
 
 		/* Adjust ring index. */
-		ha->req_ring_index++;
-		if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
-			ha->req_ring_index = 0;
-			ha->request_ring_ptr = ha->request_ring_bp;
+		req_q->req_ring_index++;
+		if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
+			req_q->req_ring_index = 0;
+			req_q->req_ring_ptr = req_q->req_ring.bp;
 		} else {
-			ha->request_ring_ptr++;
+			req_q->req_ring_ptr++;
 		}
 
 		/* Reset watchdog timer */
@@ -217,18 +240,13 @@
 		 * used to notify the isp that a new iocb has been
 		 * placed on the request ring.
 		 */
-		if (CFG_IST(ha, CFG_CTRL_8021)) {
-			uint32_t	w32;
-
-			w32 = ha->req_ring_index << 16 |
-			    ha->function_number << 5 | 4;
-			do {
-				ddi_put32(ha->db_dev_handle, ha->nx_req_in,
-				    w32);
-			} while (RD_REG_DWORD(ha, ha->db_read) != w32);
-
+		if (ha->flags & MULTI_QUEUE) {
+			WR16_MBAR_REG(ha, req_q->mbar_req_in,
+			    req_q->req_ring_index);
+		} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			ql_8021_wr_req_in(ha, req_q->req_ring_index);
 		} else {
-			WRT16_IO_REG(ha, req_in, ha->req_ring_index);
+			WRT16_IO_REG(ha, req_in, req_q->req_ring_index);
 		}
 
 		/* Update outstanding command count statistic. */
@@ -244,10 +262,16 @@
 		ql_remove_link(&ha->pending_cmds, &sp->cmd);
 	}
 
+	if (qlc_fm_check_acc_handle(ha, ha->dev_handle)
+	    != DDI_FM_OK) {
+		qlc_fm_report_err_impact(ha,
+		    QL_FM_EREPORT_ACC_HANDLE_CHECK);
+	}
+
 	/* Release ring specific lock */
 	REQUEST_RING_UNLOCK(ha);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -257,6 +281,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	pkt:	address for packet pointer.
  *
  * Returns:
@@ -266,15 +291,15 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 static int
-ql_req_pkt(ql_adapter_state_t *vha, request_t **pktp)
+ql_req_pkt(ql_adapter_state_t *vha, ql_request_q_t *req_q, request_t **pktp)
 {
 	uint16_t		cnt;
-	uint32_t		*long_ptr;
+	uint64_t		*ptr64;
 	uint32_t		timer;
 	int			rval = QL_FUNCTION_TIMEOUT;
 	ql_adapter_state_t	*ha = vha->pha;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Wait for 30 seconds for slot. */
 	for (timer = 30000; timer != 0; timer--) {
@@ -281,39 +306,50 @@
 		/* Acquire ring lock. */
 		REQUEST_RING_LOCK(ha);
 
-		if (ha->req_q_cnt == 0) {
+		if (req_q->req_q_cnt == 0) {
 			/* Calculate number of free request entries. */
-			cnt = RD16_IO_REG(ha, req_out);
-			if (ha->req_ring_index < cnt) {
-				ha->req_q_cnt = (uint16_t)
-				    (cnt - ha->req_ring_index);
+			if (ha->flags & QUEUE_SHADOW_PTRS) {
+				(void) ddi_dma_sync(req_q->req_ring.dma_handle,
+				    (off_t)req_q->req_out_shadow_ofst,
+				    SHADOW_ENTRY_SIZE, DDI_DMA_SYNC_FORCPU);
+				cnt = ddi_get32(req_q->req_ring.acc_handle,
+				    req_q->req_out_shadow_ptr);
+			} else if (ha->flags & MULTI_QUEUE) {
+				cnt = RD16_MBAR_REG(ha, req_q->mbar_req_out);
 			} else {
-				ha->req_q_cnt = (uint16_t)
+				cnt = RD16_IO_REG(ha, req_out);
+			}
+			if (req_q->req_ring_index < cnt) {
+				req_q->req_q_cnt = (uint16_t)
+				    (cnt - req_q->req_ring_index);
+			} else {
+				req_q->req_q_cnt = (uint16_t)
 				    (REQUEST_ENTRY_CNT -
-				    (ha->req_ring_index - cnt));
+				    (req_q->req_ring_index - cnt));
 			}
-			if (ha->req_q_cnt != 0) {
-				ha->req_q_cnt--;
+			if (req_q->req_q_cnt != 0) {
+				req_q->req_q_cnt--;
 			}
 		}
 
 		/* Found empty request ring slot? */
-		if (ha->req_q_cnt != 0) {
-			ha->req_q_cnt--;
-			*pktp = ha->request_ring_ptr;
+		if (req_q->req_q_cnt != 0) {
+			req_q->req_q_cnt--;
+			*pktp = req_q->req_ring_ptr;
 
 			/* Zero out packet. */
-			long_ptr = (uint32_t *)ha->request_ring_ptr;
-			for (cnt = 0; cnt < REQUEST_ENTRY_SIZE/4; cnt++) {
-				*long_ptr++ = 0;
-			}
+			ptr64 = (uint64_t *)req_q->req_ring_ptr;
+			*ptr64++ = 0; *ptr64++ = 0;
+			*ptr64++ = 0; *ptr64++ = 0;
+			*ptr64++ = 0; *ptr64++ = 0;
+			*ptr64++ = 0; *ptr64 = 0;
 
 			/* Setup IOCB common data. */
-			ha->request_ring_ptr->entry_count = 1;
-			ha->request_ring_ptr->sys_define =
-			    (uint8_t)ha->req_ring_index;
-			ddi_put32(ha->hba_buf.acc_handle,
-			    &ha->request_ring_ptr->handle,
+			req_q->req_ring_ptr->entry_count = 1;
+			req_q->req_ring_ptr->sys_define =
+			    (uint8_t)req_q->req_ring_index;
+			ddi_put32(req_q->req_ring.acc_handle,
+			    &req_q->req_ring_ptr->handle,
 			    (uint32_t)QL_FCA_BRAND);
 
 			rval = QL_SUCCESS;
@@ -346,7 +382,7 @@
 		EL(ha, "failed, rval = %xh, isp_abort_needed\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -360,54 +396,50 @@
  *	Releases ring lock.
  *
  * Input:
- *	ha:	adapter state pointer.
+ *	vha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *
  * Context:
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
-void
-ql_isp_cmd(ql_adapter_state_t *vha)
+static void
+ql_isp_cmd(ql_adapter_state_t *vha, ql_request_q_t *req_q)
 {
 	ql_adapter_state_t	*ha = vha->pha;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	QL_PRINT_5(CE_CONT, "(%d): req packet:\n", ha->instance);
-	QL_DUMP_5((uint8_t *)ha->request_ring_ptr, 8, REQUEST_ENTRY_SIZE);
+	QL_PRINT_5(ha, "req packet:\n");
+	QL_DUMP_5((uint8_t *)req_q->req_ring_ptr, 8, REQUEST_ENTRY_SIZE);
 
 	/* Sync DMA buffer. */
-	(void) ddi_dma_sync(ha->hba_buf.dma_handle,
-	    (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
-	    REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
-	    DDI_DMA_SYNC_FORDEV);
+	(void) ddi_dma_sync(req_q->req_ring.dma_handle,
+	    (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
+	    (size_t)REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
 
 	/* Adjust ring index. */
-	ha->req_ring_index++;
-	if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
-		ha->req_ring_index = 0;
-		ha->request_ring_ptr = ha->request_ring_bp;
+	req_q->req_ring_index++;
+	if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
+		req_q->req_ring_index = 0;
+		req_q->req_ring_ptr = req_q->req_ring.bp;
 	} else {
-		ha->request_ring_ptr++;
+		req_q->req_ring_ptr++;
 	}
 
 	/* Set chip new ring index. */
-	if (CFG_IST(ha, CFG_CTRL_8021)) {
-		uint32_t	w32;
-
-		w32 = ha->req_ring_index << 16 |
-		    ha->function_number << 5 | 4;
-		do {
-			ddi_put32(ha->db_dev_handle, ha->nx_req_in, w32);
-		} while (RD_REG_DWORD(ha, ha->db_read) != w32);
-
+	if (ha->flags & MULTI_QUEUE) {
+		WR16_MBAR_REG(ha, req_q->mbar_req_in,
+		    req_q->req_ring_index);
+	} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
+		ql_8021_wr_req_in(ha, req_q->req_ring_index);
 	} else {
-		WRT16_IO_REG(ha, req_in, ha->req_ring_index);
+		WRT16_IO_REG(ha, req_in, req_q->req_ring_index);
 	}
 
 	/* Release ring lock. */
 	REQUEST_RING_UNLOCK(ha);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -416,8 +448,8 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
- *
  *	arg:	request queue packet.
  *
  * Context:
@@ -424,7 +456,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_command_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_command_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
+    void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32, cnt;
@@ -432,8 +465,9 @@
 	fcp_cmd_t		*fcp = sp->fcp;
 	ql_tgt_t		*tq = sp->lun_queue->target_queue;
 	cmd_entry_t		*pkt = arg;
+	cmd_3_entry_t		*pkt3 = arg;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Set LUN number */
 	pkt->lun_l = LSB(sp->lun_queue->lun_no);
@@ -461,22 +495,15 @@
 	}
 
 	/* Set ISP command timeout. */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
 
 	/* Load SCSI CDB */
-	ddi_rep_put8(ha->hba_buf.acc_handle, fcp->fcp_cdb,
+	ddi_rep_put8(req_q->req_ring.acc_handle, fcp->fcp_cdb,
 	    pkt->scsi_cdb, MAX_CMDSZ, DDI_DEV_AUTOINCR);
 
-	if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
-		pkt->entry_type = IOCB_CMD_TYPE_3;
-		cnt = CMD_TYPE_3_DATA_SEGMENTS;
-	} else {
-		pkt->entry_type = IOCB_CMD_TYPE_2;
-		cnt = CMD_TYPE_2_DATA_SEGMENTS;
-	}
-
 	if (fcp->fcp_data_len == 0) {
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
+		pkt->entry_type = IOCB_CMD_TYPE_2;
 		ha->xioctl->IOControlRequests++;
 		return;
 	}
@@ -498,25 +525,45 @@
 
 	/* Set data segment count. */
 	seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
 
 	/* Load total byte count. */
-	ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count, fcp->fcp_data_len);
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
+	    fcp->fcp_data_len);
 
 	/* Load command data segment. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
 	cp = sp->pkt->pkt_data_cookie;
-	while (cnt && seg_cnt) {
-		ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-		if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
-			ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+
+	if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
+		pkt3->entry_type = IOCB_CMD_TYPE_3;
+		cnt = CMD_TYPE_3_DATA_SEGMENTS;
+
+		ptr32 = (uint32_t *)&pkt3->dseg;
+		while (cnt && seg_cnt) {
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    cp->dmac_address);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 			    cp->dmac_notused);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    (uint32_t)cp->dmac_size);
+			seg_cnt--;
+			cnt--;
+			cp++;
 		}
-		ddi_put32(ha->hba_buf.acc_handle, ptr32++,
-		    (uint32_t)cp->dmac_size);
-		seg_cnt--;
-		cnt--;
-		cp++;
+	} else {
+		pkt->entry_type = IOCB_CMD_TYPE_2;
+		cnt = CMD_TYPE_2_DATA_SEGMENTS;
+
+		ptr32 = (uint32_t *)&pkt->dseg;
+		while (cnt && seg_cnt) {
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    cp->dmac_address);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    (uint32_t)cp->dmac_size);
+			seg_cnt--;
+			cnt--;
+			cp++;
+		}
 	}
 
 	/*
@@ -523,11 +570,11 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(ha, cp, seg_cnt,
+		ql_continuation_iocb(ha, req_q, cp, seg_cnt,
 		    (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -536,6 +583,7 @@
  *
  * Input:
  *	ha:		adapter state pointer.
+ *	req_q:		request queue structure pointer.
  *	cp:		cookie list pointer.
  *	seg_cnt:	number of segments.
  *	addr64:		64 bit addresses.
@@ -543,15 +591,17 @@
  * Context:
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
+/* ARGSUSED */
 static void
-ql_continuation_iocb(ql_adapter_state_t *ha, ddi_dma_cookie_t *cp,
-    uint16_t seg_cnt, boolean_t addr64)
+ql_continuation_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
+    ddi_dma_cookie_t *cp, uint16_t seg_cnt, boolean_t addr64)
 {
-	cont_entry_t	*pkt;
-	uint64_t	*ptr64;
-	uint32_t	*ptr32, cnt;
+	cont_entry_t		*pkt;
+	cont_type_1_entry_t	*pkt1;
+	uint64_t		*ptr64;
+	uint32_t		*ptr32, cnt;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/*
 	 * Build continuation packets.
@@ -558,20 +608,20 @@
 	 */
 	while (seg_cnt) {
 		/* Sync DMA buffer. */
-		(void) ddi_dma_sync(ha->hba_buf.dma_handle,
-		    (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
-		    REQUEST_Q_BUFFER_OFFSET), REQUEST_ENTRY_SIZE,
-		    DDI_DMA_SYNC_FORDEV);
+		(void) ddi_dma_sync(req_q->req_ring.dma_handle,
+		    (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
+		    REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
 
 		/* Adjust ring pointer, and deal with wrap. */
-		ha->req_ring_index++;
-		if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
-			ha->req_ring_index = 0;
-			ha->request_ring_ptr = ha->request_ring_bp;
+		req_q->req_ring_index++;
+		if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
+			req_q->req_ring_index = 0;
+			req_q->req_ring_ptr = req_q->req_ring.bp;
 		} else {
-			ha->request_ring_ptr++;
+			req_q->req_ring_ptr++;
 		}
-		pkt = (cont_entry_t *)ha->request_ring_ptr;
+		pkt = (cont_entry_t *)req_q->req_ring_ptr;
+		pkt1 = (cont_type_1_entry_t *)req_q->req_ring_ptr;
 
 		/* Zero out packet. */
 		ptr64 = (uint64_t *)pkt;
@@ -584,18 +634,17 @@
 		 * Build continuation packet.
 		 */
 		pkt->entry_count = 1;
-		pkt->sys_define = (uint8_t)ha->req_ring_index;
+		pkt->sys_define = (uint8_t)req_q->req_ring_index;
 		if (addr64) {
-			pkt->entry_type = CONTINUATION_TYPE_1;
+			pkt1->entry_type = CONTINUATION_TYPE_1;
 			cnt = CONT_TYPE_1_DATA_SEGMENTS;
-			ptr32 = (uint32_t *)
-			    &((cont_type_1_entry_t *)pkt)->dseg_0_address;
+			ptr32 = (uint32_t *)&pkt1->dseg;
 			while (cnt && seg_cnt) {
-				ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+				ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 				    cp->dmac_address);
-				ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+				ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 				    cp->dmac_notused);
-				ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+				ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 				    (uint32_t)cp->dmac_size);
 				seg_cnt--;
 				cnt--;
@@ -604,11 +653,11 @@
 		} else {
 			pkt->entry_type = CONTINUATION_TYPE_0;
 			cnt = CONT_TYPE_0_DATA_SEGMENTS;
-			ptr32 = (uint32_t *)&pkt->dseg_0_address;
+			ptr32 = (uint32_t *)&pkt->dseg;
 			while (cnt && seg_cnt) {
-				ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+				ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 				    cp->dmac_address);
-				ddi_put32(ha->hba_buf.acc_handle, ptr32++,
+				ddi_put32(req_q->req_ring.acc_handle, ptr32++,
 				    (uint32_t)cp->dmac_size);
 				seg_cnt--;
 				cnt--;
@@ -616,11 +665,11 @@
 			}
 		}
 
-		QL_PRINT_5(CE_CONT, "(%d): packet:\n", ha->instance);
+		QL_PRINT_5(ha, "packet:\n");
 		QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -629,6 +678,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
  *	arg:	request queue packet.
  *
@@ -636,7 +686,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_command_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_command_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
+    ql_srb_t *sp, void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32, cnt;
@@ -645,13 +696,14 @@
 	ql_tgt_t		*tq = sp->lun_queue->target_queue;
 	cmd7_24xx_entry_t	*pkt = arg;
 	ql_adapter_state_t	*pha = ha->pha;
+	fcp_ent_addr_t		*fcp_ent_addr;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (fcp->fcp_data_len != 0 && sp->sg_dma.dma_handle != NULL &&
 	    sp->pkt->pkt_data_cookie_cnt > 1) {
-		ql_cmd_24xx_type_6_iocb(ha, sp, arg);
-		QL_PRINT_3(CE_CONT, "(%d): cmd6 exit\n", ha->instance);
+		ql_cmd_24xx_type_6_iocb(ha, req_q, sp, arg);
+		QL_PRINT_3(ha, "cmd6 exit\n");
 		return;
 	}
 
@@ -658,11 +710,18 @@
 	pkt->entry_type = IOCB_CMD_TYPE_7;
 
 	/* Set LUN number */
-	pkt->fcp_lun[2] = LSB(sp->lun_queue->lun_no);
-	pkt->fcp_lun[3] = MSB(sp->lun_queue->lun_no);
+	fcp_ent_addr = (fcp_ent_addr_t *)&sp->lun_queue->lun_addr;
+	pkt->fcp_lun[2] = lobyte(fcp_ent_addr->ent_addr_0);
+	pkt->fcp_lun[3] = hibyte(fcp_ent_addr->ent_addr_0);
+	pkt->fcp_lun[0] = lobyte(fcp_ent_addr->ent_addr_1);
+	pkt->fcp_lun[1] = hibyte(fcp_ent_addr->ent_addr_1);
+	pkt->fcp_lun[6] = lobyte(fcp_ent_addr->ent_addr_2);
+	pkt->fcp_lun[7] = hibyte(fcp_ent_addr->ent_addr_2);
+	pkt->fcp_lun[4] = lobyte(fcp_ent_addr->ent_addr_3);
+	pkt->fcp_lun[5] = hibyte(fcp_ent_addr->ent_addr_3);
 
 	/* Set N_port handle */
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
 
 	/* Set target ID */
 	pkt->target_id[0] = tq->d_id.b.al_pa;
@@ -673,12 +732,12 @@
 
 	/* Set ISP command timeout. */
 	if (sp->isp_timeout < 0x1999) {
-		ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
+		ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
 		    sp->isp_timeout);
 	}
 
 	/* Load SCSI CDB */
-	ddi_rep_put8(pha->hba_buf.acc_handle, fcp->fcp_cdb, pkt->scsi_cdb,
+	ddi_rep_put8(req_q->req_ring.acc_handle, fcp->fcp_cdb, pkt->scsi_cdb,
 	    MAX_CMDSZ, DDI_DEV_AUTOINCR);
 	for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
 		ql_chg_endian((uint8_t *)&pkt->scsi_cdb + cnt, 4);
@@ -711,7 +770,7 @@
 	}
 
 	if (fcp->fcp_data_len == 0) {
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 		pha->xioctl->IOControlRequests++;
 		return;
 	}
@@ -729,18 +788,18 @@
 
 	/* Set data segment count. */
 	seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
 
 	/* Load total byte count. */
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->total_byte_count,
 	    fcp->fcp_data_len);
 
 	/* Load command data segment. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
+	ptr32 = (uint32_t *)&pkt->dseg;
 	cp = sp->pkt->pkt_data_cookie;
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
 	seg_cnt--;
 	cp++;
 
@@ -748,10 +807,10 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
+		ql_continuation_iocb(pha, req_q, cp, seg_cnt, B_TRUE);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -760,6 +819,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
  *	arg:	request queue packet.
  *
@@ -767,7 +827,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 static void
-ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
+    ql_srb_t *sp, void *arg)
 {
 	uint64_t		addr;
 	ddi_dma_cookie_t	*cp;
@@ -779,8 +840,9 @@
 	ql_adapter_state_t	*pha = ha->pha;
 	dma_mem_t		*cmem = &sp->sg_dma;
 	cmd6_2400_dma_t		*cdma = cmem->bp;
+	fcp_ent_addr_t		*fcp_ent_addr;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	pkt->entry_type = IOCB_CMD_TYPE_6;
 
@@ -787,11 +849,26 @@
 	bzero(cdma, sizeof (cmd6_2400_dma_t));
 
 	/* Set LUN number */
-	pkt->fcp_lun[2] = cdma->cmd.fcp_lun[1] = LSB(sp->lun_queue->lun_no);
-	pkt->fcp_lun[3] = cdma->cmd.fcp_lun[0] = MSB(sp->lun_queue->lun_no);
+	fcp_ent_addr = (fcp_ent_addr_t *)&sp->lun_queue->lun_addr;
+	pkt->fcp_lun[2] = cdma->cmd.fcp_lun[2] =
+	    lobyte(fcp_ent_addr->ent_addr_0);
+	pkt->fcp_lun[3] = cdma->cmd.fcp_lun[3] =
+	    hibyte(fcp_ent_addr->ent_addr_0);
+	pkt->fcp_lun[0] = cdma->cmd.fcp_lun[0] =
+	    lobyte(fcp_ent_addr->ent_addr_1);
+	pkt->fcp_lun[1] = cdma->cmd.fcp_lun[1] =
+	    hibyte(fcp_ent_addr->ent_addr_1);
+	pkt->fcp_lun[6] = cdma->cmd.fcp_lun[6] =
+	    lobyte(fcp_ent_addr->ent_addr_2);
+	pkt->fcp_lun[7] = cdma->cmd.fcp_lun[7] =
+	    hibyte(fcp_ent_addr->ent_addr_2);
+	pkt->fcp_lun[4] = cdma->cmd.fcp_lun[4] =
+	    lobyte(fcp_ent_addr->ent_addr_3);
+	pkt->fcp_lun[5] = cdma->cmd.fcp_lun[5] =
+	    hibyte(fcp_ent_addr->ent_addr_3);
 
 	/* Set N_port handle */
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
 
 	/* Set target ID */
 	pkt->target_id[0] = tq->d_id.b.al_pa;
@@ -802,7 +879,7 @@
 
 	/* Set ISP command timeout. */
 	if (sp->isp_timeout < 0x1999) {
-		ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
+		ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
 		    sp->isp_timeout);
 	}
 
@@ -840,11 +917,11 @@
 	 * FCP_CMND Payload Data Segment
 	 */
 	cp = cmem->cookies;
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->cmnd_length,
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->cmnd_length,
 	    sizeof (fcp_cmnd_t));
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[0],
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->cmnd_address[0],
 	    cp->dmac_address);
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[1],
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->cmnd_address[1],
 	    cp->dmac_notused);
 
 	/* Set transfer direction. */
@@ -864,17 +941,17 @@
 	 * FCP_DATA Data Segment Descriptor.
 	 */
 	addr = cp->dmac_laddress + sizeof (fcp_cmnd_t);
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[0], LSD(addr));
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[1], MSD(addr));
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.address[0], LSD(addr));
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.address[1], MSD(addr));
 
 	/* Set data segment count. */
 	seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_length,
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.length,
 	    seg_cnt * 12 + 12);
 
 	/* Load total byte count. */
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->total_byte_count,
 	    fcp->fcp_data_len);
 	ddi_put32(cmem->acc_handle, &cdma->cmd.dl, (uint32_t)fcp->fcp_data_len);
 	ql_chg_endian((uint8_t *)&cdma->cmd.dl, 4);
@@ -892,7 +969,7 @@
 	/* Sync DMA buffer. */
 	(void) ddi_dma_sync(cmem->dma_handle, 0, 0, DDI_DMA_SYNC_FORDEV);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -902,7 +979,7 @@
  * Input:
  *	ha:		adapter state pointer.
  *	loop_id:	device loop ID
- *	lun:		device LUN
+ *	lq:		LUN queue pointer.
  *	type:		marker modifier
  *
  * Returns:
@@ -912,19 +989,21 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 int
-ql_marker(ql_adapter_state_t *ha, uint16_t loop_id, uint16_t lun,
+ql_marker(ql_adapter_state_t *ha, uint16_t loop_id, ql_lun_t *lq,
     uint8_t type)
 {
 	mrk_entry_t	*pkt;
 	int		rval;
+	ql_request_q_t	*req_q = ha->req_q[0];
+	fcp_ent_addr_t	*fcp_ent_addr;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	rval = ql_req_pkt(ha, (request_t **)&pkt);
+	rval = ql_req_pkt(ha, req_q, (request_t **)&pkt);
 	if (rval == QL_SUCCESS) {
 		pkt->entry_type = MARKER_TYPE;
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			marker_24xx_entry_t	*pkt24 =
 			    (marker_24xx_entry_t *)pkt;
 
@@ -931,20 +1010,39 @@
 			pkt24->modifier = type;
 
 			/* Set LUN number */
-			pkt24->fcp_lun[2] = LSB(lun);
-			pkt24->fcp_lun[3] = MSB(lun);
+			if (lq) {
+				fcp_ent_addr = (fcp_ent_addr_t *)&lq->lun_addr;
+				pkt24->fcp_lun[2] =
+				    lobyte(fcp_ent_addr->ent_addr_0);
+				pkt24->fcp_lun[3] =
+				    hibyte(fcp_ent_addr->ent_addr_0);
+				pkt24->fcp_lun[0] =
+				    lobyte(fcp_ent_addr->ent_addr_1);
+				pkt24->fcp_lun[1] =
+				    hibyte(fcp_ent_addr->ent_addr_1);
+				pkt24->fcp_lun[6] =
+				    lobyte(fcp_ent_addr->ent_addr_2);
+				pkt24->fcp_lun[7] =
+				    hibyte(fcp_ent_addr->ent_addr_2);
+				pkt24->fcp_lun[4] =
+				    lobyte(fcp_ent_addr->ent_addr_3);
+				pkt24->fcp_lun[5] =
+				    hibyte(fcp_ent_addr->ent_addr_3);
+			}
 
 			pkt24->vp_index = ha->vp_index;
 
 			/* Set N_port handle */
-			ddi_put16(ha->pha->hba_buf.acc_handle,
+			ddi_put16(req_q->req_ring.acc_handle,
 			    &pkt24->n_port_hdl, loop_id);
 
 		} else {
 			pkt->modifier = type;
 
-			pkt->lun_l = LSB(lun);
-			pkt->lun_h = MSB(lun);
+			if (lq) {
+				pkt->lun_l = LSB(lq->lun_no);
+				pkt->lun_h = MSB(lq->lun_no);
+			}
 
 			if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
 				pkt->target_l = LSB(loop_id);
@@ -955,7 +1053,7 @@
 		}
 
 		/* Issue command to ISP */
-		ql_isp_cmd(ha);
+		ql_isp_cmd(ha, req_q);
 	}
 
 	if (rval != QL_SUCCESS) {
@@ -962,7 +1060,7 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -972,15 +1070,17 @@
  *	Setup of name/management server IOCB.
  *
  * Input:
- *	ha = adapter state pointer.
- *	sp = srb structure pointer.
- *	arg = request queue packet.
+ *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
+ *	sp:	srb structure pointer.
+ *	arg:	request queue packet.
  *
  * Context:
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_ms_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_ms_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
+    void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32;
@@ -988,7 +1088,7 @@
 	ql_tgt_t		*tq = sp->lun_queue->target_queue;
 	ms_entry_t		*pkt = arg;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 	QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
 	/*
 	 * Build command packet.
@@ -1004,7 +1104,7 @@
 	}
 
 	/* Set ISP command timeout. */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
 
 	/* Set cmd data segment count. */
 	pkt->cmd_dseg_count_l = 1;
@@ -1011,29 +1111,29 @@
 
 	/* Set total data segment count */
 	seg_cnt = (uint16_t)(sp->pkt->pkt_resp_cookie_cnt + 1);
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->total_dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->total_dseg_count, seg_cnt);
 
 	/* Load ct cmd byte count. */
-	ddi_put32(ha->hba_buf.acc_handle, &pkt->cmd_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->cmd_byte_count,
 	    (uint32_t)sp->pkt->pkt_cmdlen);
 
 	/* Load ct rsp byte count. */
-	ddi_put32(ha->hba_buf.acc_handle, &pkt->resp_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->resp_byte_count,
 	    (uint32_t)sp->pkt->pkt_rsplen);
 
 	/* Load MS command data segments. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
+	ptr32 = (uint32_t *)&pkt->dseg;
 	cp = sp->pkt->pkt_cmd_cookie;
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
 	seg_cnt--;
 
 	/* Load MS response entry data segments. */
 	cp = sp->pkt->pkt_resp_cookie;
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
 	seg_cnt--;
 	cp++;
 
@@ -1041,10 +1141,10 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
+		ql_continuation_iocb(ha, req_q, cp, seg_cnt, B_TRUE);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -1053,6 +1153,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
  *	arg:	request queue packet.
  *
@@ -1060,7 +1161,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_ms_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_ms_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
+    void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32;
@@ -1069,7 +1171,7 @@
 	ct_passthru_entry_t	*pkt = arg;
 	ql_adapter_state_t	*pha = ha->pha;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 	QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
 	/*
 	 * Build command packet.
@@ -1077,41 +1179,41 @@
 	pkt->entry_type = CT_PASSTHRU_TYPE;
 
 	/* Set loop ID */
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
 
 	pkt->vp_index = ha->vp_index;
 
 	/* Set ISP command timeout. */
 	if (sp->isp_timeout < 0x1999) {
-		ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
+		ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
 		    sp->isp_timeout);
 	}
 
 	/* Set cmd/response data segment counts. */
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->cmd_dseg_count, 1);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->cmd_dseg_count, 1);
 	seg_cnt = (uint16_t)sp->pkt->pkt_resp_cookie_cnt;
-	ddi_put16(pha->hba_buf.acc_handle, &pkt->resp_dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->resp_dseg_count, seg_cnt);
 
 	/* Load ct cmd byte count. */
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->cmd_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->cmd_byte_count,
 	    (uint32_t)sp->pkt->pkt_cmdlen);
 
 	/* Load ct rsp byte count. */
-	ddi_put32(pha->hba_buf.acc_handle, &pkt->resp_byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->resp_byte_count,
 	    (uint32_t)sp->pkt->pkt_rsplen);
 
 	/* Load MS command entry data segments. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
+	ptr32 = (uint32_t *)&pkt->dseg;
 	cp = sp->pkt->pkt_cmd_cookie;
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
 
 	/* Load MS response entry data segments. */
 	cp = sp->pkt->pkt_resp_cookie;
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
 	seg_cnt--;
 	cp++;
 
@@ -1119,10 +1221,10 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
+		ql_continuation_iocb(pha, req_q, cp, seg_cnt, B_TRUE);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -1131,6 +1233,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
  *	arg:	request queue packet.
  *
@@ -1138,7 +1241,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_ip_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_ip_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
+    void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32, cnt;
@@ -1145,8 +1249,9 @@
 	uint16_t		seg_cnt;
 	ql_tgt_t		*tq = sp->lun_queue->target_queue;
 	ip_entry_t		*pkt = arg;
+	ip_a64_entry_t		*pkt64 = arg;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Set loop ID */
 	if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
@@ -1163,40 +1268,50 @@
 	}
 
 	/* Set ISP command timeout. */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
 
 	/* Set data segment count. */
 	seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
 	/* Load total byte count. */
-	ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
 	    (uint32_t)sp->pkt->pkt_cmdlen);
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
 
 	/*
 	 * Build command packet.
 	 */
+
+	/* Load command entry data segments. */
+	cp = sp->pkt->pkt_cmd_cookie;
+
 	if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
-		pkt->entry_type = IP_A64_TYPE;
+		pkt64->entry_type = IP_A64_TYPE;
 		cnt = IP_A64_DATA_SEGMENTS;
+		ptr32 = (uint32_t *)&pkt64->dseg;
+		while (cnt && seg_cnt) {
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    cp->dmac_address);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    cp->dmac_notused);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    (uint32_t)cp->dmac_size);
+			seg_cnt--;
+			cnt--;
+			cp++;
+		}
 	} else {
 		pkt->entry_type = IP_TYPE;
 		cnt = IP_DATA_SEGMENTS;
-	}
-
-	/* Load command entry data segments. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
-	cp = sp->pkt->pkt_cmd_cookie;
-	while (cnt && seg_cnt) {
-		ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-		if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
-			ddi_put32(ha->hba_buf.acc_handle, ptr32++,
-			    cp->dmac_notused);
+		ptr32 = (uint32_t *)&pkt->dseg;
+		while (cnt && seg_cnt) {
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    cp->dmac_address);
+			ddi_put32(req_q->req_ring.acc_handle, ptr32++,
+			    (uint32_t)cp->dmac_size);
+			seg_cnt--;
+			cnt--;
+			cp++;
 		}
-		ddi_put32(ha->hba_buf.acc_handle, ptr32++,
-		    (uint32_t)cp->dmac_size);
-		seg_cnt--;
-		cnt--;
-		cp++;
 	}
 
 	/*
@@ -1203,11 +1318,11 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(ha, cp, seg_cnt,
+		ql_continuation_iocb(ha, req_q, cp, seg_cnt,
 		    (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -1216,6 +1331,7 @@
  *
  * Input:
  *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
  *	sp:	srb structure pointer.
  *	arg:	request queue packet.
  *
@@ -1223,7 +1339,8 @@
  *	Interrupt or Kernel context, no mailbox commands allowed.
  */
 void
-ql_ip_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
+ql_ip_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
+    void *arg)
 {
 	ddi_dma_cookie_t	*cp;
 	uint32_t		*ptr32;
@@ -1233,14 +1350,14 @@
 
 	pkt->entry_type = IP_CMD_TYPE;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Set N_port handle */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->hdl_status, tq->loop_id);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->hdl_status, tq->loop_id);
 
 	/* Set ISP command timeout. */
 	if (sp->isp_timeout < 0x1999) {
-		ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout_hdl,
+		ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout_hdl,
 		    sp->isp_timeout);
 	}
 
@@ -1247,24 +1364,24 @@
 	/* Set data segment count. */
 	seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
 	/* Load total byte count. */
-	ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
+	ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
 	    (uint32_t)sp->pkt->pkt_cmdlen);
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
 
 	/* Set control flags */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->control_flags,
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->control_flags,
 	    (uint16_t)(BIT_0));
 
 	/* Set frame header control flags */
-	ddi_put16(ha->hba_buf.acc_handle, &pkt->frame_hdr_cntrl_flgs,
+	ddi_put16(req_q->req_ring.acc_handle, &pkt->frame_hdr_cntrl_flgs,
 	    (uint16_t)(IPCF_LAST_SEQ | IPCF_FIRST_SEQ));
 
 	/* Load command data segment. */
-	ptr32 = (uint32_t *)&pkt->dseg_0_address;
+	ptr32 = (uint32_t *)&pkt->dseg;
 	cp = sp->pkt->pkt_cmd_cookie;
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
-	ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
+	ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
 	seg_cnt--;
 	cp++;
 
@@ -1272,10 +1389,10 @@
 	 * Build continuation packets.
 	 */
 	if (seg_cnt) {
-		ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
+		ql_continuation_iocb(ha, req_q, cp, seg_cnt, B_TRUE);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -1300,12 +1417,12 @@
 	fc_unsol_buf_t	*ubp;
 	int		ring_updated = FALSE;
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		ql_isp24xx_rcvbuf(ha);
 		return;
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Acquire adapter state lock. */
 	ADAPTER_STATE_LOCK(ha);
@@ -1319,7 +1436,7 @@
 		} else {
 			index = index1;
 		}
-	} while (debounce_count --);
+	} while (debounce_count--);
 
 	if (debounce_count < 0) {
 		/* This should never happen */
@@ -1364,15 +1481,15 @@
 			/*
 			 * Build container.
 			 */
-			ddi_put32(ha->hba_buf.acc_handle,
+			ddi_put32(ha->rcv_ring.acc_handle,
 			    (uint32_t *)(void *)&container->bufp[0],
 			    sp->ub_buffer.cookie.dmac_address);
 
-			ddi_put32(ha->hba_buf.acc_handle,
+			ddi_put32(ha->rcv_ring.acc_handle,
 			    (uint32_t *)(void *)&container->bufp[1],
 			    sp->ub_buffer.cookie.dmac_notused);
 
-			ddi_put16(ha->hba_buf.acc_handle, &container->handle,
+			ddi_put16(ha->rcv_ring.acc_handle, &container->handle,
 			    LSW(sp->handle));
 
 			ha->ub_outcnt++;
@@ -1381,7 +1498,7 @@
 			ha->rcvbuf_ring_index++;
 			if (ha->rcvbuf_ring_index == RCVBUF_CONTAINER_CNT) {
 				ha->rcvbuf_ring_index = 0;
-				ha->rcvbuf_ring_ptr = ha->rcvbuf_ring_bp;
+				ha->rcvbuf_ring_ptr = ha->rcv_ring.bp;
 			} else {
 				ha->rcvbuf_ring_ptr++;
 			}
@@ -1393,9 +1510,8 @@
 
 	if (ring_updated) {
 		/* Sync queue. */
-		(void) ddi_dma_sync(ha->hba_buf.dma_handle,
-		    (off_t)RCVBUF_Q_BUFFER_OFFSET, (size_t)RCVBUF_QUEUE_SIZE,
-		    DDI_DMA_SYNC_FORDEV);
+		(void) ddi_dma_sync(ha->rcv_ring.dma_handle, 0,
+		    (size_t)RCVBUF_QUEUE_SIZE, DDI_DMA_SYNC_FORDEV);
 
 		/* Set chip new ring index. */
 		WRT16_IO_REG(ha, mailbox_in[8], ha->rcvbuf_ring_index);
@@ -1404,7 +1520,7 @@
 	/* Release adapter state lock. */
 	ADAPTER_STATE_UNLOCK(ha);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -1426,8 +1542,9 @@
 	fc_unsol_buf_t		*ubp;
 	int			rval;
 	ip_buf_pool_entry_t	*pkt = NULL;
+	ql_request_q_t		*req_q = ha->req_q[0];
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	for (;;) {
 		/* Locate a buffer to give. */
@@ -1455,7 +1572,7 @@
 
 		/* Get IOCB packet for buffers. */
 		if (pkt == NULL) {
-			rval = ql_req_pkt(ha, (request_t **)&pkt);
+			rval = ql_req_pkt(ha, req_q, (request_t **)&pkt);
 			if (rval != QL_SUCCESS) {
 				EL(ha, "failed, ql_req_pkt=%x\n", rval);
 				QL_UB_LOCK(ha);
@@ -1471,11 +1588,11 @@
 		/*
 		 * Build container.
 		 */
-		ddi_put32(ha->hba_buf.acc_handle, &container->bufp[0],
+		ddi_put32(req_q->req_ring.acc_handle, &container->bufp[0],
 		    sp->ub_buffer.cookie.dmac_address);
-		ddi_put32(ha->hba_buf.acc_handle, &container->bufp[1],
+		ddi_put32(req_q->req_ring.acc_handle, &container->bufp[1],
 		    sp->ub_buffer.cookie.dmac_notused);
-		ddi_put16(ha->hba_buf.acc_handle, &container->handle,
+		ddi_put16(req_q->req_ring.acc_handle, &container->handle,
 		    LSW(sp->handle));
 
 		pkt->buffer_count++;
@@ -1482,14 +1599,14 @@
 		container++;
 
 		if (pkt->buffer_count == IP_POOL_BUFFERS) {
-			ql_isp_cmd(ha);
+			ql_isp_cmd(ha, req_q);
 			pkt = NULL;
 		}
 	}
 
 	if (pkt != NULL) {
-		ql_isp_cmd(ha);
+		ql_isp_cmd(ha, req_q);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
