--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c	Mon Aug  5 17:28:44 2019
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c	Mon Aug  5 17:28:44 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.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"Copyright 2010 QLogic Corporation; ql_mbx.c"
+#pragma ident	"Copyright 2015 QLogic Corporation; ql_mbx.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				**
  * *									**
  * ***********************************************************************
@@ -46,6 +46,7 @@
 #include <ql_iocb.h>
 #include <ql_isr.h>
 #include <ql_mbx.h>
+#include <ql_nx.h>
 #include <ql_xioctl.h>
 
 /*
@@ -56,7 +57,7 @@
  * Local prototypes
  */
 static int ql_mailbox_command(ql_adapter_state_t *, mbx_cmd_t *);
-static int ql_task_mgmt_iocb(ql_adapter_state_t *, ql_tgt_t *, uint16_t,
+static int ql_task_mgmt_iocb(ql_adapter_state_t *, ql_tgt_t *, uint64_t,
     uint32_t, uint16_t);
 static int ql_abort_cmd_iocb(ql_adapter_state_t *, ql_srb_t *);
 static int ql_setup_mbox_dma_transfer(ql_adapter_state_t *, dma_mem_t *,
@@ -65,7 +66,8 @@
     uint32_t);
 static void ql_setup_mbox_dma_data(dma_mem_t *, caddr_t);
 static void ql_get_mbox_dma_data(dma_mem_t *, caddr_t);
-
+static int ql_init_req_q(ql_adapter_state_t *, ql_request_q_t *, uint16_t);
+static int ql_init_rsp_q(ql_adapter_state_t *, ql_response_q_t *, uint16_t);
 /*
  * ql_mailbox_command
  *	Issue mailbox command and waits for completion.
@@ -92,26 +94,25 @@
 	ql_adapter_state_t	*ha = vha->pha;
 	int			mbx_cmd = mcp->mb[0];
 
-	QL_PRINT_3(CE_CONT, "(%d): started, cmd=%xh\n", ha->instance, mbx_cmd);
+	QL_PRINT_3(ha, "started, cmd=%xh\n", mbx_cmd);
 
 	/* Acquire mailbox register lock. */
 	MBX_REGISTER_LOCK(ha);
 
 	/* Check for mailbox available, if not wait for signal. */
-	while (ha->mailbox_flags & MBX_BUSY_FLG ||
-	    (CFG_IST(ha, CFG_CTRL_8021) &&
-	    RD32_IO_REG(ha, nx_host_int) & NX_MBX_CMD)) {
-		ha->mailbox_flags = (uint8_t)
-		    (ha->mailbox_flags | MBX_WANT_FLG);
-
+	while (ha->mailbox_flags & MBX_BUSY_FLG) {
 		if (ha->task_daemon_flags & TASK_DAEMON_POWERING_DOWN) {
-			EL(vha, "failed availability cmd=%xh\n", mcp->mb[0]);
+			EL(vha, "powerdown availability cmd=%xh\n", mcp->mb[0]);
 			MBX_REGISTER_UNLOCK(ha);
 			return (QL_LOCK_TIMEOUT);
 		}
+		ha->mailbox_flags = (uint8_t)
+		    (ha->mailbox_flags | MBX_WANT_FLG);
 
 		/* Set timeout after command that is running. */
-		timer = (mcp->timeout + 20) * drv_usectohz(1000000);
+		timer = ha->mailbox_flags & MBX_BUSY_FLG ?
+		    (mcp->timeout + 20) : 2;
+		timer = timer * drv_usectohz(1000000);
 		cv_stat = cv_reltimedwait_sig(&ha->cv_mbx_wait,
 		    &ha->pha->mbx_mutex, timer, TR_CLOCK_TICK);
 		if (cv_stat == -1 || cv_stat == 0) {
@@ -153,9 +154,9 @@
 
 	/* Issue set host interrupt command. */
 	ha->mailbox_flags = (uint8_t)(ha->mailbox_flags & ~MBX_INTERRUPT);
-	if (CFG_IST(ha, CFG_CTRL_8021)) {
+	if (CFG_IST(ha, CFG_CTRL_82XX)) {
 		WRT32_IO_REG(ha, nx_host_int, NX_MBX_CMD);
-	} else if (CFG_IST(ha, CFG_CTRL_242581)) {
+	} else if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		WRT32_IO_REG(ha, hccr, HC24_SET_HOST_INT);
 	} else {
 		WRT16_IO_REG(ha, hccr, HC_SET_HOST_INT);
@@ -163,8 +164,7 @@
 
 	/* Wait for command to complete. */
 	if (ha->flags & INTERRUPTS_ENABLED &&
-	    !(ha->task_daemon_flags & (TASK_THREAD_CALLED |
-	    TASK_DAEMON_POWERING_DOWN)) &&
+	    !(ha->task_daemon_flags & TASK_DAEMON_POWERING_DOWN) &&
 	    !ddi_in_panic()) {
 		timer = mcp->timeout * drv_usectohz(1000000);
 		while (!(ha->mailbox_flags & (MBX_INTERRUPT | MBX_ABORT)) &&
@@ -177,6 +177,8 @@
 				 * reached without the condition
 				 * being signaled.
 				 */
+				EL(vha, "reltimedwait expired cmd=%xh\n",
+				    mcp->mb[0]);
 				MBX_REGISTER_UNLOCK(ha);
 				while (INTERRUPT_PENDING(ha)) {
 					(void) ql_isr((caddr_t)ha);
@@ -225,7 +227,7 @@
 	    ha->mailbox_flags & MBX_ABORT) {
 		rval = QL_ABORTED;
 	} else if ((ha->mailbox_flags & MBX_INTERRUPT) == 0) {
-		if (!CFG_IST(ha, CFG_CTRL_8021)) {
+		if (!CFG_IST(ha, CFG_CTRL_82XX)) {
 			if (CFG_IST(ha, CFG_DUMP_MAILBOX_TIMEOUT)) {
 				(void) ql_binary_fw_dump(ha, FALSE);
 			}
@@ -248,7 +250,7 @@
 	 * is on 2200 mailbox 4 and 5 affect the req and resp que indexes
 	 * so avoid writing them.
 	 */
-	if (ha->cfg_flags & CFG_CTRL_2200) {
+	if (CFG_IST(ha, CFG_CTRL_22XX)) {
 		data = ((mcp->out_mb & ~(MBX_4 | MBX_5)) >> 1);
 	} else {
 		data = (mcp->out_mb >> 1);
@@ -284,7 +286,7 @@
 		    mbx_cmd_text(mbx_cmd), rval, mcp->mb[0]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -427,16 +429,15 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, (CFG_CTRL_6322 | CFG_CTRL_258081)) ||
-	    ha->vp_index != 0) {
+	if (!CFG_IST(ha, CFG_FCIP_SUPPORT) || ha->vp_index != 0) {
 		ha->flags &= ~IP_INITIALIZED;
 		EL(ha, "HBA does not support IP\n");
 		return (QL_FUNCTION_FAILED);
 	}
 
-	ha->rcvbuf_ring_ptr = ha->rcvbuf_ring_bp;
+	ha->rcvbuf_ring_ptr = ha->rcv_ring.bp;
 	ha->rcvbuf_ring_index = 0;
 
 	/* Reset all sequence counts. */
@@ -472,7 +473,7 @@
 		ADAPTER_STATE_LOCK(ha);
 		ha->flags |= IP_INITIALIZED;
 		ADAPTER_STATE_UNLOCK(ha);
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	} else {
 		ha->flags &= ~IP_INITIALIZED;
 		EL(ha, "failed, rval = %xh\n", rval);
@@ -503,7 +504,7 @@
 	ql_srb_t	*sp;
 	uint16_t	index;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_UNLOAD_IP;
 	mcp->out_mb = MBX_0;
@@ -529,7 +530,7 @@
 
 	if (rval == QL_SUCCESS) {
 		/* EMPTY - no need to check return value of MBC_SHUTDOWN_IP */
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	} else {
 		EL(ha, "failed, rval = %xh\n", rval);
 	}
@@ -556,7 +557,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_ONLINE_SELF_TEST;
 	mcp->out_mb = MBX_0;
@@ -569,7 +570,7 @@
 		    rval, mcp->mb[1], mcp->mb[2], mcp->mb[3]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -598,7 +599,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK;
 	mcp->mb[1] = lb->options;
@@ -633,7 +634,7 @@
 		    rval, mcp->mb[1], mcp->mb[2], mcp->mb[3]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -645,7 +646,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK;
 	mcp->mb[1] = lb->options;
@@ -687,7 +688,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);
 }
@@ -716,7 +717,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_ECHO;			/* ECHO command */
 	mcp->mb[1] = echo_pt->options;		/* command options; 64 bit */
@@ -774,7 +775,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);
 }
@@ -800,7 +801,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_SEND_CHANGE_REQUEST;
 	mcp->mb[1] = fmt;
@@ -817,7 +818,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -845,7 +846,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* LFA_CB sz = 4 16bit words subcommand + 10 16bit words header. */
 	size = (uint16_t)((lfa->subcommand_length[0] + 10) << 1);
@@ -877,7 +878,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);
@@ -890,7 +891,7 @@
  * Input:
  *	ha:	adapter state pointer.
  *	tq:	target queue pointer.
- *	lun:	LUN.
+ *	lq:	LUN queue pointer.
  *
  * Returns:
  *	ql local function return status code.
@@ -899,16 +900,17 @@
  *	Kernel context.
  */
 int
-ql_clear_aca(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t lun)
+ql_clear_aca(ql_adapter_state_t *ha, ql_tgt_t *tq, ql_lun_t *lq)
 {
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		rval = ql_task_mgmt_iocb(ha, tq, lun, CF_CLEAR_ACA, 0);
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		rval = ql_task_mgmt_iocb(ha, tq, lq->lun_addr,
+		    CF_CLEAR_ACA, 0);
 	} else {
 		mcp->mb[0] = MBC_CLEAR_ACA;
 		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
@@ -916,7 +918,7 @@
 		} else {
 			mcp->mb[1] = (uint16_t)(tq->loop_id << 8);
 		}
-		mcp->mb[2] = lun;
+		mcp->mb[2] = lq->lun_no;
 		mcp->out_mb = MBX_2|MBX_1|MBX_0;
 		mcp->in_mb = MBX_0;
 		mcp->timeout = MAILBOX_TOV;
@@ -923,13 +925,13 @@
 		rval = ql_mailbox_command(ha, mcp);
 	}
 
-	(void) ql_marker(ha, tq->loop_id, lun, MK_SYNC_ID);
+	(void) ql_marker(ha, tq->loop_id, lq, MK_SYNC_ID);
 
 	if (rval != QL_SUCCESS) {
 		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);
@@ -954,14 +956,26 @@
 ql_target_reset(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t delay)
 {
 	ql_link_t	*link;
+	ql_srb_t	*sp;
 	uint16_t	index;
-	int		rval;
+	int		rval = QL_SUCCESS;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	ql_requeue_pending_cmds(ha, tq);
+	INTR_LOCK(ha);
+	for (index = 1; index < ha->pha->osc_max_cnt; index++) {
+		if ((sp = ha->pha->outstanding_cmds[index]) != NULL &&
+		    sp->lun_queue != NULL &&
+		    sp->lun_queue->target_queue == tq) {
+			sp->flags |= SRB_ABORTING;
+		}
+	}
+	INTR_UNLOCK(ha);
+
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		/* queue = NULL, all targets. */
 		if (tq == NULL) {
 			for (index = 0; index < DEVICE_HEAD_LIST_SIZE;
@@ -1032,7 +1046,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);
@@ -1056,13 +1070,26 @@
 int
 ql_abort_target(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t delay)
 {
+	ql_srb_t	*sp;
+	uint16_t	index;
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	ql_requeue_pending_cmds(ha, tq);
+	INTR_LOCK(ha);
+	for (index = 1; index < ha->pha->osc_max_cnt; index++) {
+		if ((sp = ha->pha->outstanding_cmds[index]) != NULL &&
+		    sp->lun_queue != NULL &&
+		    sp->lun_queue->target_queue == tq) {
+			sp->flags |= SRB_ABORTING;
+		}
+	}
+	INTR_UNLOCK(ha);
+
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		rval = ql_task_mgmt_iocb(ha, tq, 0,
 		    CF_DO_NOT_SEND | CF_TARGET_RESET, delay);
 	} else {
@@ -1088,7 +1115,7 @@
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -1100,7 +1127,7 @@
  * Input:
  *	ha:	adapter state pointer.
  *	tq:	target queue pointer.
- *	lun:	LUN.
+ *	lq:	LUN queue pointer.
  *
  * Returns:
  *	ql local function return status code.
@@ -1109,16 +1136,31 @@
  *	Kernel context.
  */
 int
-ql_lun_reset(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t lun)
+ql_lun_reset(ql_adapter_state_t *ha, ql_tgt_t *tq, ql_lun_t *lq)
 {
+	ql_srb_t	*sp;
+	uint16_t	index;
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		rval = ql_task_mgmt_iocb(ha, tq, lun, CF_LUN_RESET, 0);
+	ql_requeue_pending_cmds(ha, tq);
+	INTR_LOCK(ha);
+	for (index = 1; index < ha->pha->osc_max_cnt; index++) {
+		if ((sp = ha->pha->outstanding_cmds[index]) != NULL &&
+		    sp->lun_queue != NULL &&
+		    sp->lun_queue->target_queue == tq &&
+		    sp->lun_queue == lq) {
+			sp->flags |= SRB_ABORTING;
+		}
+	}
+	INTR_UNLOCK(ha);
+
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		rval = ql_task_mgmt_iocb(ha, tq, lq->lun_addr,
+		    CF_LUN_RESET, 0);
 	} else {
 		mcp->mb[0] = MBC_LUN_RESET;
 		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
@@ -1126,7 +1168,7 @@
 		} else {
 			mcp->mb[1] = (uint16_t)(tq->loop_id << 8);
 		}
-		mcp->mb[2] = lun;
+		mcp->mb[2] = lq->lun_no;
 		mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
 		mcp->in_mb = MBX_0;
 		mcp->timeout = MAILBOX_TOV;
@@ -1133,13 +1175,13 @@
 		rval = ql_mailbox_command(ha, mcp);
 	}
 
-	(void) ql_marker(ha, tq->loop_id, lun, MK_SYNC_ID);
+	(void) ql_marker(ha, tq->loop_id, lq, MK_SYNC_ID);
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -1151,7 +1193,7 @@
  * Input:
  *	ha:	adapter state pointer.
  *	tq:	target queue pointer.
- *	lun:	LUN.
+ *	lq:	LUN queue pointer.
  *
  * Returns:
  *	ql local function return status code.
@@ -1160,16 +1202,31 @@
  *	Kernel context.
  */
 int
-ql_clear_task_set(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t lun)
+ql_clear_task_set(ql_adapter_state_t *ha, ql_tgt_t *tq, ql_lun_t *lq)
 {
+	ql_srb_t	*sp;
+	uint16_t	index;
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		rval = ql_task_mgmt_iocb(ha, tq, lun, CF_CLEAR_TASK_SET, 0);
+	ql_requeue_pending_cmds(ha, tq);
+	INTR_LOCK(ha);
+	for (index = 1; index < ha->pha->osc_max_cnt; index++) {
+		if ((sp = ha->pha->outstanding_cmds[index]) != NULL &&
+		    sp->lun_queue != NULL &&
+		    sp->lun_queue->target_queue == tq &&
+		    sp->lun_queue == lq) {
+			sp->flags |= SRB_ABORTING;
+		}
+	}
+	INTR_UNLOCK(ha);
+
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		rval = ql_task_mgmt_iocb(ha, tq, lq->lun_addr,
+		    CF_CLEAR_TASK_SET, 0);
 	} else {
 		mcp->mb[0] = MBC_CLEAR_TASK_SET;
 		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
@@ -1177,7 +1234,7 @@
 		} else {
 			mcp->mb[1] = (uint16_t)(tq->loop_id << 8);
 		}
-		mcp->mb[2] = lun;
+		mcp->mb[2] = lq->lun_no;
 		mcp->out_mb = MBX_2|MBX_1|MBX_0;
 		mcp->in_mb = MBX_0;
 		mcp->timeout = MAILBOX_TOV;
@@ -1184,13 +1241,13 @@
 		rval = ql_mailbox_command(ha, mcp);
 	}
 
-	(void) ql_marker(ha, tq->loop_id, lun, MK_SYNC_ID);
+	(void) ql_marker(ha, tq->loop_id, lq, MK_SYNC_ID);
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1203,7 +1260,7 @@
  * Input:
  *	ha:	adapter state pointer.
  *	tq:	target queue pointer.
- *	lun:	LUN.
+ *	lq:	LUN queue pointer.
  *
  * Returns:
  *	ql local function return status code.
@@ -1212,16 +1269,31 @@
  *	Kernel context.
  */
 int
-ql_abort_task_set(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t lun)
+ql_abort_task_set(ql_adapter_state_t *ha, ql_tgt_t *tq, ql_lun_t *lq)
 {
+	ql_srb_t	*sp;
+	uint16_t	index;
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		rval = ql_task_mgmt_iocb(ha, tq, lun, CF_ABORT_TASK_SET, 0);
+	ql_requeue_pending_cmds(ha, tq);
+	INTR_LOCK(ha);
+	for (index = 1; index < ha->pha->osc_max_cnt; index++) {
+		if ((sp = ha->pha->outstanding_cmds[index]) != NULL &&
+		    sp->lun_queue != NULL &&
+		    sp->lun_queue->target_queue == tq &&
+		    sp->lun_queue == lq) {
+			sp->flags |= SRB_ABORTING;
+		}
+	}
+	INTR_UNLOCK(ha);
+
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		rval = ql_task_mgmt_iocb(ha, tq, lq->lun_addr,
+		    CF_ABORT_TASK_SET, 0);
 	} else {
 		mcp->mb[0] = MBC_ABORT_TASK_SET;
 		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
@@ -1229,7 +1301,7 @@
 		} else {
 			mcp->mb[1] = (uint16_t)(tq->loop_id << 8);
 		}
-		mcp->mb[2] = lun;
+		mcp->mb[2] = lq->lun_no;
 		mcp->out_mb = MBX_2|MBX_1|MBX_0;
 		mcp->in_mb = MBX_0;
 		mcp->timeout = MAILBOX_TOV;
@@ -1236,13 +1308,13 @@
 		rval = ql_mailbox_command(ha, mcp);
 	}
 
-	(void) ql_marker(ha, tq->loop_id, lun, MK_SYNC_ID);
+	(void) ql_marker(ha, tq->loop_id, lq, MK_SYNC_ID);
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1253,11 +1325,11 @@
  *	Function issues task management IOCB.
  *
  * Input:
- *	ha:	adapter state pointer.
- *	tq:	target queue pointer.
- *	lun:	LUN.
- *	flags:	control flags.
- *	delay:	seconds.
+ *	ha:		adapter state pointer.
+ *	tq:		target queue pointer.
+ *	lun_addr:	LUN.
+ *	flags:		control flags.
+ *	delay:		seconds.
  *
  * Returns:
  *	ql local function return status code.
@@ -1266,14 +1338,15 @@
  *	Kernel context
  */
 static int
-ql_task_mgmt_iocb(ql_adapter_state_t *ha, ql_tgt_t *tq, uint16_t lun,
+ql_task_mgmt_iocb(ql_adapter_state_t *ha, ql_tgt_t *tq, uint64_t lun_addr,
     uint32_t flags, uint16_t delay)
 {
 	ql_mbx_iocb_t	*pkt;
 	int		rval;
 	uint32_t	pkt_size;
+	fcp_ent_addr_t	*fcp_ent_addr;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	pkt_size = sizeof (ql_mbx_iocb_t);
 	pkt = kmem_zalloc(pkt_size, KM_SLEEP);
@@ -1288,8 +1361,17 @@
 	pkt->mgmt.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
 	pkt->mgmt.delay = (uint16_t)LE_16(delay);
 	pkt->mgmt.timeout = LE_16(MAILBOX_TOV);
-	pkt->mgmt.fcp_lun[2] = LSB(lun);
-	pkt->mgmt.fcp_lun[3] = MSB(lun);
+
+	fcp_ent_addr = (fcp_ent_addr_t *)&lun_addr;
+	pkt->mgmt.fcp_lun[2] = lobyte(fcp_ent_addr->ent_addr_0);
+	pkt->mgmt.fcp_lun[3] = hibyte(fcp_ent_addr->ent_addr_0);
+	pkt->mgmt.fcp_lun[0] = lobyte(fcp_ent_addr->ent_addr_1);
+	pkt->mgmt.fcp_lun[1] = hibyte(fcp_ent_addr->ent_addr_1);
+	pkt->mgmt.fcp_lun[6] = lobyte(fcp_ent_addr->ent_addr_2);
+	pkt->mgmt.fcp_lun[7] = hibyte(fcp_ent_addr->ent_addr_2);
+	pkt->mgmt.fcp_lun[4] = lobyte(fcp_ent_addr->ent_addr_3);
+	pkt->mgmt.fcp_lun[5] = hibyte(fcp_ent_addr->ent_addr_3);
+
 	pkt->mgmt.control_flags = LE_32(flags);
 	pkt->mgmt.target_id[0] = tq->d_id.b.al_pa;
 	pkt->mgmt.target_id[1] = tq->d_id.b.area;
@@ -1317,7 +1399,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);
@@ -1344,11 +1426,11 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_LOOP_PORT_BYPASS;
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[1] = tq->d_id.b.al_pa;
 	} else if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
 		mcp->mb[1] = tq->loop_id;
@@ -1365,7 +1447,7 @@
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1392,11 +1474,11 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_LOOP_PORT_ENABLE;
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[1] = tq->d_id.b.al_pa;
 	} else if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
 		mcp->mb[1] = tq->loop_id;
@@ -1412,7 +1494,7 @@
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1445,10 +1527,10 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started, d_id=%xh, loop_id=%xh\n",
+	QL_PRINT_3(ha, "started, d_id=%xh, loop_id=%xh\n",
 	    ha->instance, tq->d_id.b24, loop_id);
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		flags = CF_CMD_PLOGI;
 		if ((opt & LLF_PLOGI) == 0) {
 			flags = (uint16_t)(flags | CFO_COND_PLOGI);
@@ -1473,7 +1555,7 @@
 		    loop_id, rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1506,14 +1588,14 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started, d_id=%xh, loop_id=%xh\n",
+	QL_PRINT_3(ha, "started, d_id=%xh, loop_id=%xh\n",
 	    ha->instance, tq->d_id.b24, loop_id);
 
-	if ((tq->d_id.b24 & 0xffffff) == 0xfffffa) {
+	if ((tq->d_id.b24 & QL_PORT_ID_MASK) == FS_MANAGEMENT_SERVER) {
 		opt = (uint16_t)(opt | LFF_NO_PRLI);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		flags = CF_CMD_PLOGI;
 		if (opt & LFF_NO_PLOGI) {
 			flags = (uint16_t)(flags | CFO_COND_PLOGI);
@@ -1550,11 +1632,12 @@
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "d_id=%xh, loop_id=%xh, failed=%xh, mb1=%02xh, "
-		    "mb2=%04x\n", tq->d_id.b24, loop_id, rval, mr->mb[1],
-		    mr->mb[2]);
+		    "mb2=%04x\n", tq->d_id.b24, loop_id, rval,
+		    mr != NULL ? mr->mb[1] : mcp->mb[1],
+		    mr != NULL ? mr->mb[2] : mcp->mb[2]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1583,16 +1666,33 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started, loop_id=%xh d_id=%xh\n",
-	    ha->instance, tq->loop_id, tq->d_id.b24);
+	QL_PRINT_3(ha, "started, loop_id=%xh d_id=%xh\n",
+	    tq->loop_id, tq->d_id.b24);
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		flag = (uint16_t)(RESERVED_LOOP_ID(ha, tq->loop_id) ?
-		    CFO_EXPLICIT_LOGO |CF_CMD_LOGO | CFO_FREE_N_PORT_HANDLE :
-		    CFO_IMPLICIT_LOGO |CF_CMD_LOGO | CFO_FREE_N_PORT_HANDLE);
-		rval = ql_log_iocb(ha, tq, tq->loop_id, flag, &mr);
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		if ((ha->topology & QL_N_PORT) &&
+		    (tq->loop_id != 0x7fe) &&
+		    (tq->loop_id != 0x7ff)) {
+			flag = (uint16_t)(CFO_IMPLICIT_LOGO |
+			    CF_CMD_LOGO | CFO_FREE_N_PORT_HANDLE);
+
+			rval = ql_log_iocb(ha, tq, tq->loop_id, flag, &mr);
+		} else {
+			flag = (uint16_t)(RESERVED_LOOP_ID(ha, tq->loop_id) ?
+			    CFO_EXPLICIT_LOGO | CF_CMD_LOGO |
+			    CFO_FREE_N_PORT_HANDLE :
+			    CFO_IMPLICIT_LOGO | CF_CMD_LOGO |
+			    CFO_FREE_N_PORT_HANDLE);
+
+			rval = ql_log_iocb(ha, tq, tq->loop_id, flag, &mr);
+		}
+
+		if (rval == QL_SUCCESS) {
+			EL(ha, "tq=%ph, loop_id=%xh, d_id=%xh, flag=%xh\n",
+			    tq, tq->loop_id, tq->d_id.b24, flag);
+		}
 	} else {
-		flag = (uint16_t)(RESERVED_LOOP_ID(ha, tq->loop_id) ?  1 : 0);
+		flag = (uint16_t)(RESERVED_LOOP_ID(ha, tq->loop_id) ? 1 : 0);
 		mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
 		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
 			mcp->mb[1] = tq->loop_id;
@@ -1608,11 +1708,11 @@
 	}
 
 	if (rval != QL_SUCCESS) {
-		EL(ha, "d_id=%xh, loop_id=%xh, failed=%xh\n", rval,
+		EL(ha, "failed, rval=%xh, d_id=%xh, loop_id=%xh\n", rval,
 		    tq->d_id.b24, tq->loop_id);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1643,7 +1743,7 @@
 	int		rval;
 	uint32_t	pkt_size;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	pkt_size = sizeof (ql_mbx_iocb_t);
 	pkt = kmem_zalloc(pkt_size, KM_SLEEP);
@@ -1768,8 +1868,7 @@
 					break;
 				}
 			} else {
-				QL_PRINT_3(CE_CONT, "(%d): status=%xh\n",
-				    ha->instance, pkt->log.status);
+				QL_PRINT_3(ha, "status=%xh\n", pkt->log.status);
 
 				mr->mb[0] = MBS_COMMAND_COMPLETE;
 				mr->mb[1] = (uint16_t)
@@ -1787,10 +1886,11 @@
 	kmem_free(pkt, pkt_size);
 
 	if (rval != QL_SUCCESS) {
-		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
+		EL(ha, "failed, rval=%xh, d_id=%xh loop_id=%xh\n",
+		    rval, tq->d_id.b24, loop_id);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1821,7 +1921,7 @@
 	mbx_cmd_t		*mcp = &mc;
 	port_database_23_t	*pd23;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	pd23 = (port_database_23_t *)kmem_zalloc(PORT_DATABASE_SIZE, KM_SLEEP);
 	if (pd23 == NULL) {
@@ -1835,7 +1935,7 @@
 		return (QL_MEMORY_ALLOC_FAILED);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[0] = MBC_GET_PORT_DATABASE;
 		mcp->mb[1] = tq->loop_id;
 		mcp->mb[4] = CHAR_TO_SHORT(tq->d_id.b.al_pa, tq->d_id.b.area);
@@ -1873,7 +1973,7 @@
 	ql_free_dma_resource(ha, &mem_desc);
 
 	if (rval == QL_SUCCESS) {
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			port_database_24_t *pd24 = (port_database_24_t *)pd23;
 
 			tq->master_state = pd24->current_login_state;
@@ -1965,12 +2065,15 @@
 
 	kmem_free(pd23, PORT_DATABASE_SIZE);
 
-	if ((rval != QL_SUCCESS) && (rval != QL_PARAMETER_ERROR)) {
-		EL(ha, "d_id=%xh, loop_id=%xh, failed=%xh\n", tq->d_id.b24,
-		    tq->loop_id, rval);
+	/*
+	 * log the trace in any cases other than QL_SUCCESS.
+	 */
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh, d_id=%xh, loop_id=%xh\n",
+		    rval, tq->d_id.b24, tq->loop_id);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -1999,7 +2102,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2027,7 +2130,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2056,7 +2159,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_transfer(ha, &mem_desc, bufp,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2080,7 +2183,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);
@@ -2112,7 +2215,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2120,7 +2223,7 @@
 	}
 
 	mcp->mb[0] = MBC_SEND_RNID_ELS;
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[1] = loop_id;
 		mcp->mb[9] = ha->vp_index;
 		mcp->mb[10] = opt;
@@ -2151,7 +2254,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);
@@ -2180,7 +2283,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2207,7 +2310,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2240,7 +2343,7 @@
 	int		rval = QL_SUCCESS;
 	int		retry = 0;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	do {
 		if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
@@ -2250,7 +2353,7 @@
 		}
 
 		mcp->mb[0] = MBC_GET_LINK_STATUS;
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			if (loop_id == ha->loop_id) {
 				mcp->mb[0] = MBC_GET_STATUS_COUNTS;
 				mcp->mb[8] = (uint16_t)(size >> 2);
@@ -2306,7 +2409,7 @@
 		EL(ha, "failed=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2338,7 +2441,7 @@
 	mbx_cmd_t	*mcp = &mc;
 	int		rval = QL_SUCCESS;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2346,7 +2449,7 @@
 		return (QL_MEMORY_ALLOC_FAILED);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[0] = MBC_GET_STATUS_COUNTS;
 		mcp->mb[8] = (uint16_t)(size / 4);
 		mcp->out_mb = MBX_10|MBX_8;
@@ -2354,7 +2457,7 @@
 		mcp->mb[0] = MBC_GET_LINK_STATUS;
 
 		/* allows reporting when link is down */
-		if (CFG_IST(ha, CFG_CTRL_2200) == 0) {
+		if (CFG_IST(ha, CFG_CTRL_22XX) == 0) {
 			port_no = (uint8_t)(port_no | BIT_6);
 		}
 
@@ -2388,7 +2491,7 @@
 		    mcp->mb[1], mcp->mb[2]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2414,7 +2517,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_RESET_LINK_STATUS;
 	mcp->out_mb = MBX_0;
@@ -2426,7 +2529,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2450,7 +2553,7 @@
 {
 	int	rval;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (CFG_IST(ha, CFG_ENABLE_LIP_RESET)) {
 		rval = ql_lip_reset(ha, 0xff);
@@ -2466,7 +2569,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);
@@ -2492,12 +2595,16 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
+		ql_toggle_loop_state(ha);
+		QL_PRINT_3(ha, "8081 done\n");
+		return (QL_SUCCESS);
+	}
+	if (CFG_IST(ha, CFG_FC_TYPE_2)) {
 		mcp->mb[0] = MBC_LIP_FULL_LOGIN;
-		mcp->mb[1] = (uint16_t)(CFG_IST(ha, CFG_CTRL_8081) ?
-		    BIT_1 : BIT_4);
+		mcp->mb[1] = BIT_4;
 		mcp->mb[3] = ha->loop_reset_delay;
 		mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
 	} else {
@@ -2512,7 +2619,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);
@@ -2538,13 +2645,16 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
+		ql_toggle_loop_state(ha);
+		QL_PRINT_3(ha, "8081 done\n");
+		return (QL_SUCCESS);
+	}
 	mcp->mb[0] = MBC_LIP_FULL_LOGIN;
-	if (CFG_IST(ha, CFG_CTRL_2425)) {
+	if (CFG_IST(ha, CFG_FC_TYPE_2)) {
 		mcp->mb[1] = BIT_3;
-	} else if (CFG_IST(ha, CFG_CTRL_8081)) {
-		mcp->mb[1] = BIT_1;
 	}
 	mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
 	mcp->in_mb = MBX_0;
@@ -2555,7 +2665,7 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done", ha->instance);
+		QL_PRINT_3(ha, "done");
 	}
 
 	return (rval);
@@ -2582,12 +2692,17 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
+		ql_toggle_loop_state(ha);
+		QL_PRINT_3(ha, "8081 done\n");
+		return (QL_SUCCESS);
+	}
+
+	if (CFG_IST(ha, CFG_FC_TYPE_2)) {
 		mcp->mb[0] = MBC_LIP_FULL_LOGIN;
-		mcp->mb[1] = (uint16_t)(CFG_IST(ha, CFG_CTRL_8081) ?
-		    BIT_1 : BIT_6);
+		mcp->mb[1] = BIT_6;
 		mcp->mb[3] = ha->loop_reset_delay;
 		mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
 	} else {
@@ -2609,7 +2724,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);
@@ -2637,9 +2752,10 @@
 	mbx_cmd_t	*mcp = &mc;
 	ql_tgt_t	*tq = sp->lun_queue->target_queue;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	sp->flags |= SRB_ABORTING;
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		rval = ql_abort_cmd_iocb(ha, sp);
 	} else {
 		mcp->mb[0] = MBC_ABORT_COMMAND_IOCB;
@@ -2663,7 +2779,7 @@
 		    tq->d_id.b24, sp->handle);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2692,7 +2808,7 @@
 	uint16_t	comp_status;
 	ql_tgt_t	*tq = sp->lun_queue->target_queue;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	pkt_size = sizeof (ql_mbx_iocb_t);
 	if ((pkt = kmem_zalloc(pkt_size, KM_SLEEP)) == NULL) {
@@ -2703,7 +2819,7 @@
 	pkt->abo.entry_type = ABORT_CMD_TYPE;
 	pkt->abo.entry_count = 1;
 	pkt->abo.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
-	if (!CFG_IST(ha, CFG_CTRL_8021)) {
+	if (!CFG_IST(ha, CFG_CTRL_82XX)) {
 		pkt->abo.options = AF_NO_ABTS;
 	}
 	pkt->abo.cmd_handle = LE_32(sp->handle);
@@ -2715,7 +2831,7 @@
 	rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, pkt_size);
 
 	if (rval == QL_SUCCESS) {
-		if ((pkt->abo.entry_status  & 0x3c) != 0) {
+		if ((pkt->abo.entry_status & 0x3c) != 0) {
 			EL(ha, "failed, entry_status=%xh, d_id=%xh\n",
 			    pkt->abo.entry_status, tq->d_id.b24);
 			rval = QL_FUNCTION_PARAMETER_ERROR;
@@ -2735,7 +2851,7 @@
 		EL(ha, "failed=%xh, d_id=%xh\n", rval, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -2761,10 +2877,10 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_VERIFY_CHECKSUM;
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[1] = MSW(ha->risc_fw[0].addr);
 		mcp->mb[2] = LSW(ha->risc_fw[0].addr);
 	} else {
@@ -2779,7 +2895,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);
@@ -2810,7 +2926,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -2819,7 +2935,7 @@
 	}
 
 	mcp->mb[0] = MBC_GET_ID_LIST;
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[2] = MSW(LSD(mem_desc.cookie.dmac_laddress));
 		mcp->mb[3] = LSW(LSD(mem_desc.cookie.dmac_laddress));
 		mcp->mb[6] = MSW(MSD(mem_desc.cookie.dmac_laddress));
@@ -2854,7 +2970,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);
@@ -2884,28 +3000,26 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_242581)) {
+	mcp->mb[1] = LSW(risc_address);
+	mcp->mb[2] = MSW(LSD(bp));
+	mcp->mb[3] = LSW(LSD(bp));
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[0] = MBC_LOAD_RAM_EXTENDED;
 		mcp->mb[4] = MSW(word_count);
 		mcp->mb[5] = LSW(word_count);
-		mcp->mb[6] = MSW(MSD(bp));
-		mcp->mb[7] = LSW(MSD(bp));
 		mcp->mb[8] = MSW(risc_address);
-		mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|
-		    MBX_0;
+		mcp->out_mb = MBX_0_THRU_8;
 	} else {
-		mcp->mb[0] = MBC_LOAD_RAM;
+		mcp->mb[0] = MBC_LOAD_RISC_RAM;
 		mcp->mb[4] = LSW(word_count);
-		mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+		mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
 	}
-	mcp->mb[1] = LSW(risc_address);
-	mcp->mb[2] = MSW(LSD(bp));
-	mcp->mb[3] = LSW(LSD(bp));
+	mcp->mb[6] = MSW(MSD(bp));
+	mcp->mb[7] = LSW(MSD(bp));
 	mcp->in_mb = MBX_0;
 	mcp->timeout = MAILBOX_TOV;
-
 	rval = ql_mailbox_command(ha, mcp);
 
 	if (rval != QL_SUCCESS) {
@@ -2912,7 +3026,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);
@@ -2942,9 +3056,9 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_242581)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[0] = MBC_DUMP_RAM_EXTENDED;
 		mcp->mb[1] = LSW(risc_address);
 		mcp->mb[2] = MSW(LSD(bp));
@@ -2972,7 +3086,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);
@@ -3001,7 +3115,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_WRITE_RAM_EXTENDED;
 	mcp->mb[1] = LSW(risc_address);
@@ -3018,7 +3132,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);
@@ -3047,7 +3161,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_READ_RAM_EXTENDED;
 	mcp->mb[1] = LSW(risc_address);
@@ -3062,10 +3176,10 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		*data = mcp->mb[2];
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			*data |= mcp->mb[3] << 16;
 		}
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3094,7 +3208,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_transfer(ha, &mem_desc, bp, size)) !=
 	    QL_SUCCESS) {
@@ -3122,7 +3236,7 @@
 		EL(ha, "failed=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3149,10 +3263,18 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started cfg=0x%llx\n", ha->cfg_flags);
 
-	if (mr != NULL) {
-		mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
+	mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
+	if (mr == NULL) {
+		mcp->mb[1] = 0xAAAA;
+		mcp->mb[2] = 0x5555;
+		mcp->mb[3] = 0xAA55;
+		mcp->mb[4] = 0x55AA;
+		mcp->mb[5] = 0xA5A5;
+		mcp->mb[6] = 0x5A5A;
+		mcp->mb[7] = 0x2525;
+	} else {
 		mcp->mb[1] = mr->mb[1];
 		mcp->mb[2] = mr->mb[2];
 		mcp->mb[3] = mr->mb[3];
@@ -3160,21 +3282,34 @@
 		mcp->mb[5] = mr->mb[5];
 		mcp->mb[6] = mr->mb[6];
 		mcp->mb[7] = mr->mb[7];
-		mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
-		mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
-		mcp->timeout = MAILBOX_TOV;
-		rval = ql_mailbox_command(ha, mcp);
-		if (rval == QL_SUCCESS) {
-			mr->mb[1] = mcp->mb[1];
-			mr->mb[2] = mcp->mb[2];
-			mr->mb[3] = mcp->mb[3];
-			mr->mb[4] = mcp->mb[4];
-			mr->mb[5] = mcp->mb[5];
-			mr->mb[6] = mcp->mb[6];
-			mr->mb[7] = mcp->mb[7];
+	}
+	mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+	if (rval == QL_SUCCESS) {
+		if (mr == NULL) {
+			if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 ||
+			    mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) {
+				rval = QL_FUNCTION_FAILED;
+			}
+			if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A ||
+			    mcp->mb[7] != 0x2525) {
+				rval = QL_FUNCTION_FAILED;
+			}
+		} else {
+			if (mcp->mb[1] != mr->mb[1] ||
+			    mcp->mb[2] != mr->mb[2] ||
+			    mcp->mb[3] != mr->mb[3] ||
+			    mcp->mb[4] != mr->mb[4]) {
+				rval = QL_FUNCTION_FAILED;
+			}
+			if (mcp->mb[5] != mr->mb[5] ||
+			    mcp->mb[6] != mr->mb[6] ||
+			    mcp->mb[7] != mr->mb[7]) {
+				rval = QL_FUNCTION_FAILED;
+			}
 		}
-	} else {
-		rval = QL_FUNCTION_PARAMETER_ERROR;
 	}
 
 	if (rval != QL_SUCCESS) {
@@ -3181,7 +3316,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3207,14 +3342,14 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_8021)) {
+	if (CFG_IST(ha, CFG_CTRL_82XX)) {
 		return (QL_SUCCESS);
 	}
 
 	mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
-	if (CFG_IST(ha, CFG_CTRL_242581)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		mcp->mb[1] = MSW(ha->risc_fw[0].addr);
 		mcp->mb[2] = LSW(ha->risc_fw[0].addr);
 	} else {
@@ -3228,7 +3363,7 @@
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
-	if (CFG_IST(ha, CFG_CTRL_2200)) {
+	if (CFG_IST(ha, CFG_CTRL_22XX)) {
 		rval = QL_SUCCESS;
 	}
 
@@ -3236,7 +3371,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3263,7 +3398,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_FIRMWARE_OPTIONS;
 	mcp->out_mb = MBX_0;
@@ -3283,7 +3418,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	return (rval);
@@ -3310,7 +3445,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (mr != NULL) {
 		mcp->mb[0] = MBC_SET_FIRMWARE_OPTIONS;
@@ -3329,7 +3464,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3357,13 +3492,17 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_8021)) {
+	if (ha->flags & MULTI_QUEUE) {
+		WR32_MBAR_REG(ha, ha->req_q[0]->mbar_req_in, 0);
+		WR32_MBAR_REG(ha, ha->rsp_queues[0]->mbar_rsp_out, 0);
+	} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
+		ql_8021_wr_req_in(ha, 0);
 		WRT32_IO_REG(ha, req_out, 0);
 		WRT32_IO_REG(ha, resp_in, 0);
 		WRT32_IO_REG(ha, resp_out, 0);
-	} else if (CFG_IST(ha, CFG_CTRL_242581)) {
+	} else if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		WRT32_IO_REG(ha, req_in, 0);
 		WRT32_IO_REG(ha, resp_out, 0);
 		WRT32_IO_REG(ha, pri_req_in, 0);
@@ -3372,6 +3511,12 @@
 		WRT16_IO_REG(ha, req_in, 0);
 		WRT16_IO_REG(ha, resp_out, 0);
 	}
+	if (ha->req_q[0]->req_out_shadow_ptr) {
+		*ha->req_q[0]->req_out_shadow_ptr = 0;
+	}
+	if (ha->rsp_queues[0]->rsp_in_shadow_ptr) {
+		*ha->rsp_queues[0]->rsp_in_shadow_ptr = 0;
+	}
 
 	if ((rval = ql_setup_mbox_dma_transfer(ha, &mem_desc,
 	    (caddr_t)&ha->init_ctrl_blk, sizeof (ql_comb_init_cb_t))) !=
@@ -3384,7 +3529,7 @@
 	    MBC_INITIALIZE_MULTI_ID_FW : MBC_INITIALIZE_FIRMWARE);
 
 	if (CFG_IST(ha, CFG_SBUS_CARD)) {
-		mcp->mb[1] = (uint16_t)(CFG_IST(ha, CFG_CTRL_2200) ?
+		mcp->mb[1] = (uint16_t)(CFG_IST(ha, CFG_CTRL_22XX) ?
 		    0x204c : 0x52);
 	}
 
@@ -3392,7 +3537,7 @@
 	mcp->mb[3] = LSW(LSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[6] = MSW(MSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[7] = LSW(MSD(mem_desc.cookie.dmac_laddress));
-	if (CFG_IST(ha, CFG_CTRL_8081)) {
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
 		uint64_t		ofst, addr;
 		ql_init_24xx_cb_t	*icb = (ql_init_24xx_cb_t *)
 		    &ha->init_ctrl_blk.cb24;
@@ -3419,6 +3564,34 @@
 
 	if (rval == QL_SUCCESS) {
 		ha->sfp_stat = mcp->mb[2];
+		if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			(void) ql_8021_get_md_template(ha);
+		} else {
+			uint16_t	i, opt;
+
+			opt = ha->flags & NO_INTR_HANDSHAKE ?
+			    IMO_NONE : IMO_INTERRUPT_HANDSHAKE;
+			if (ha->flags & QUEUE_SHADOW_PTRS) {
+				opt |= IMO_QUEUE_POINTER_SHADOWING;
+			}
+			/* Initialize ha multi-response-queue request queue */
+			if (ha->rsp_queues_cnt > 1) {
+				rval = ql_init_req_q(ha, ha->req_q[1], opt);
+				if (rval != QL_SUCCESS) {
+					EL(ha, "ql_init_req_q=%xh\n", rval);
+					return (rval);
+				}
+			}
+			/* Initialize multi-response queues */
+			for (i = 1; i < ha->rsp_queues_cnt; i++) {
+				rval = ql_init_rsp_q(ha, ha->rsp_queues[i],
+				    opt);
+				if (rval != QL_SUCCESS) {
+					EL(ha, "ql_init_rsp_q=%xh\n", rval);
+					return (rval);
+				}
+			}
+		}
 	}
 	ql_free_dma_resource(ha, &mem_desc);
 
@@ -3426,7 +3599,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3453,14 +3626,22 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
 	mcp->out_mb = MBX_0;
-	mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0_THRU_6;
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
+	ha->fw_state[0] = mcp->mb[0];
+	ha->fw_state[1] = mcp->mb[1];
+	ha->fw_state[2] = mcp->mb[2];
+	ha->fw_state[3] = mcp->mb[3];
+	ha->fw_state[4] = mcp->mb[4];
+	ha->fw_state[5] = mcp->mb[5];
+	ha->fw_state[6] = mcp->mb[6];
+
 	/* Return mailbox data. */
 	if (mr != NULL) {
 		mr->mb[1] = mcp->mb[1];
@@ -3468,6 +3649,7 @@
 		mr->mb[3] = mcp->mb[3];
 		mr->mb[4] = mcp->mb[4];
 		mr->mb[5] = mcp->mb[5];
+		mr->mb[6] = mcp->mb[6];
 	}
 
 	ha->sfp_stat = mcp->mb[2];
@@ -3476,7 +3658,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3499,11 +3681,11 @@
 int
 ql_get_adapter_id(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
 {
-	int		rval;
+	int		i, rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_ID;
 	if (ha->flags & VP_ENABLED) {
@@ -3510,8 +3692,7 @@
 		mcp->mb[9] = ha->vp_index;
 	}
 	mcp->out_mb = MBX_9|MBX_0;
-	mcp->in_mb = MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|
-	    MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0_THRU_19;
 	mcp->timeout = MAILBOX_TOV;
 
 	rval = ql_mailbox_command(ha, mcp);
@@ -3518,19 +3699,9 @@
 
 	/* Return mailbox data. */
 	if (mr != NULL) {
-		mr->mb[1] = mcp->mb[1];
-		mr->mb[1] = (uint16_t)(CFG_IST(ha, CFG_CTRL_24258081) ?
-		    0xffff : mcp->mb[1]);
-		mr->mb[2] = mcp->mb[2];
-		mr->mb[3] = mcp->mb[3];
-		mr->mb[6] = mcp->mb[6];
-		mr->mb[7] = mcp->mb[7];
-		mr->mb[8] = mcp->mb[8];
-		mr->mb[9] = mcp->mb[9];
-		mr->mb[10] = mcp->mb[10];
-		mr->mb[11] = mcp->mb[11];
-		mr->mb[12] = mcp->mb[12];
-		mr->mb[13] = mcp->mb[13];
+		for (i = 0; i < 20; i++) {
+			mr->mb[i] = mcp->mb[i];
+		}
 	}
 
 	if (rval != QL_SUCCESS) {
@@ -3537,7 +3708,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3560,33 +3731,32 @@
 int
 ql_get_fw_version(ql_adapter_state_t *ha, ql_mbx_data_t *mr, uint16_t timeout)
 {
-	int		rval;
+	int		rval, i;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_ABOUT_FIRMWARE;
 	mcp->out_mb = MBX_0;
-	mcp->in_mb = MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_6|MBX_5|
-	    MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	if (CFG_IST(ha, CFG_CTRL_83XX)) {
+		mcp->in_mb = MBX_0_THRU_17;
+	} else if (CFG_IST(ha, CFG_CTRL_27XX)) {
+		mcp->in_mb = MBX_0_THRU_25;
+	} else {
+		mcp->in_mb = MBX_0_THRU_13;
+	}
 	mcp->timeout = timeout;
 	rval = ql_mailbox_command(ha, mcp);
 
 	/* Return mailbox data. */
 	if (mr != NULL) {
-		mr->mb[1] = mcp->mb[1];
-		mr->mb[2] = mcp->mb[2];
-		mr->mb[3] = mcp->mb[3];
-		mr->mb[4] = mcp->mb[4];
-		mr->mb[5] = mcp->mb[5];
-		mr->mb[6] = mcp->mb[6];
-		mr->mb[8] = mcp->mb[8];
-		mr->mb[9] = mcp->mb[9];
-		mr->mb[10] = mcp->mb[10];
-		mr->mb[11] = mcp->mb[11];
-		mr->mb[12] = mcp->mb[12];
-		mr->mb[13] = mcp->mb[13];
+		for (i = 0; i < ha->reg_off->mbox_cnt && mcp->in_mb; i++) {
+			if (mcp->in_mb & MBX_0) {
+				mr->mb[i] = mcp->mb[i];
+			}
+			mcp->in_mb >>= 1;
+		}
 	}
 
 	if (rval != QL_SUCCESS) {
@@ -3593,7 +3763,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3620,7 +3790,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (mr != NULL) {
 		mcp->mb[0] = MBC_DATA_RATE;
@@ -3627,7 +3797,7 @@
 		mcp->mb[1] = mr->mb[1];
 		mcp->mb[2] = mr->mb[2];
 		mcp->out_mb = MBX_2|MBX_1|MBX_0;
-		mcp->in_mb = MBX_2|MBX_1|MBX_0;
+		mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
 		mcp->timeout = MAILBOX_TOV;
 		rval = ql_mailbox_command(ha, mcp);
 
@@ -3634,6 +3804,7 @@
 		/* Return mailbox data. */
 		mr->mb[1] = mcp->mb[1];
 		mr->mb[2] = mcp->mb[2];
+		mr->mb[3] = mcp->mb[3];
 	} else {
 		rval = QL_FUNCTION_PARAMETER_ERROR;
 	}
@@ -3644,7 +3815,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3656,7 +3827,6 @@
  *
  * Input:
  *	ha:	adapter state pointer.
- *	findex:	FCF index.
  *	bp:	buffer pointer.
  *	size:	buffer size.
  *	opt:	command options.
@@ -3670,8 +3840,8 @@
  *	Kernel context.
  */
 int
-ql_diag_loopback(ql_adapter_state_t *ha, uint16_t findex, caddr_t bp,
-    uint32_t size, uint16_t opt, uint32_t it_cnt, ql_mbx_data_t *mr)
+ql_diag_loopback(ql_adapter_state_t *ha, caddr_t bp, uint32_t size,
+    uint16_t opt, uint32_t it_cnt, ql_mbx_data_t *mr)
 {
 	int		rval;
 	dma_mem_t	mem_desc;
@@ -3678,7 +3848,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_transfer(ha, &mem_desc, bp, size)) !=
 	    QL_SUCCESS) {
@@ -3688,7 +3858,7 @@
 
 	mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK;
 	mcp->mb[1] = opt;
-	mcp->mb[2] = findex;
+	mcp->mb[2] = ha->fcoe_fcf_idx;
 	mcp->mb[6] = LSW(MSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[7] = MSW(MSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[10] = LSW(size);
@@ -3730,7 +3900,7 @@
 		EL(ha, "failed=%xh, mb1=%xh\n", rval, mcp->mb[1]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3742,7 +3912,6 @@
  *
  * Input:
  *	ha:	adapter state pointer.
- *	findex:	FCF index.
  *	bp:	buffer pointer.
  *	size:	buffer size.
  *	opt:	command options.
@@ -3755,8 +3924,8 @@
  *	Kernel context.
  */
 int
-ql_diag_echo(ql_adapter_state_t *ha, uint16_t findex, caddr_t bp,
-    uint32_t size, uint16_t opt, ql_mbx_data_t *mr)
+ql_diag_echo(ql_adapter_state_t *ha, caddr_t bp, uint32_t size, uint16_t opt,
+    ql_mbx_data_t *mr)
 {
 	int		rval;
 	dma_mem_t	mem_desc;
@@ -3763,7 +3932,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_transfer(ha, &mem_desc, bp, size)) !=
 	    QL_SUCCESS) {
@@ -3773,7 +3942,7 @@
 
 	mcp->mb[0] = MBC_ECHO;
 	mcp->mb[1] = opt;
-	mcp->mb[2] = findex;
+	mcp->mb[2] = ha->fcoe_fcf_idx;
 	mcp->mb[6] = LSW(MSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[7] = MSW(MSD(mem_desc.cookie.dmac_laddress));
 	mcp->mb[10] = LSW(size);
@@ -3804,7 +3973,7 @@
 		    mcp->mb[1]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3811,6 +3980,54 @@
 }
 
 /*
+ * ql_diag_beacon
+ *      Enable/Disable beaconing via mailbox command.
+ *
+ * Input:
+ *      ha:     adapter state pointer.
+ *      mr:     pointer to mailbox in/out parameters.
+ *
+ * Returns:
+ *      ql local function return status code.
+ *
+ * Context:
+ *      Kernel context.
+ */
+int
+ql_diag_beacon(ql_adapter_state_t *ha, int cmd, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	mcp->mb[0] = MBC_SET_LED_CONFIG;
+	if (cmd == QL_BEACON_ENABLE) {
+		mcp->mb[7] = 0xE;
+	} else if (cmd == QL_BEACON_DISABLE) {
+		mcp->mb[7] = 0xD;
+	} else {
+		return (EIO);
+	}
+	mcp->out_mb = MBX_7|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return mailbox data. */
+	if (mr != NULL) {
+		mr->mb[0] = mcp->mb[0];
+	}
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh\n", rval);
+	}
+
+	return (rval);
+}
+
+
+/*
  * ql_serdes_param
  *	Set/Get serdes transmit parameters mailbox command.
  *
@@ -3831,7 +4048,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_SERDES_TRANSMIT_PARAMETERS;
 	mcp->mb[1] = mr->mb[1];
@@ -3844,18 +4061,16 @@
 	rval = ql_mailbox_command(ha, mcp);
 
 	/* Return mailbox data. */
-	if (mr != NULL) {
-		mr->mb[0] = mcp->mb[0];
-		mr->mb[2] = mcp->mb[2];
-		mr->mb[3] = mcp->mb[3];
-		mr->mb[4] = mcp->mb[4];
-	}
+	mr->mb[0] = mcp->mb[0];
+	mr->mb[2] = mcp->mb[2];
+	mr->mb[3] = mcp->mb[3];
+	mr->mb[4] = mcp->mb[4];
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3882,16 +4097,17 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_TIMEOUT_PARAMETERS;
-	mcp->out_mb = MBX_0;
+	mcp->mb[1] = ha->fcoe_fcf_idx;
+	mcp->out_mb = MBX_1|MBX_0;
 	mcp->in_mb = MBX_3|MBX_0;
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 	if (rval == QL_SUCCESS) {
 		/* Get 2 * R_A_TOV in seconds */
-		if (CFG_IST(ha, CFG_CTRL_2200) || mcp->mb[3] == 0) {
+		if (CFG_IST(ha, CFG_CTRL_22XX) || mcp->mb[3] == 0) {
 			*tov = R_A_TOV_DEFAULT;
 		} else {
 			*tov = (uint16_t)(mcp->mb[3] / 10);
@@ -3912,7 +4128,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3938,7 +4154,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_STOP_FIRMWARE;
 	mcp->out_mb = MBX_1|MBX_0;
@@ -3950,7 +4166,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -3964,7 +4180,7 @@
  *	ha:	adapter state pointer.
  *	mem:	pointer to dma memory object for command.
  *	dev:	Device address (A0h or A2h).
- *	addr:	Data address on SFP EEPROM (0–255).
+ *	addr:	Data address on SFP EEPROM (0-255).
  *
  * Returns:
  *	ql local function return status code.
@@ -3980,7 +4196,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_READ_SFP;
 	mcp->mb[1] = dev;
@@ -4002,7 +4218,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4034,7 +4250,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_PORT_PARAM;
 	mcp->mb[1] = loop_id;
@@ -4059,7 +4275,7 @@
 			*idma_rate = mcp->mb[3];
 		}
 
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4085,7 +4301,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_XMIT_PARM;
 	mcp->mb[1] = BIT_1;
@@ -4098,7 +4314,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -4111,6 +4327,7 @@
  *	ha:	adapter state pointer.
  *	mem:	pointer to dma memory object for command.
  *	opt:	options and opcode.
+ *	mr:	pointer to mailbox in/out parameters.
  *
  * Returns:
  *	ql local function return status code.
@@ -4119,7 +4336,8 @@
  *	Kernel context.
  */
 int
-ql_fw_etrace(ql_adapter_state_t *ha, dma_mem_t *mem, uint16_t opt)
+ql_fw_etrace(ql_adapter_state_t *ha, dma_mem_t *mem, uint16_t opt,
+    ql_mbx_data_t *mr)
 {
 	int		rval = QL_SUCCESS;
 	mbx_cmd_t	mc = {0};
@@ -4127,7 +4345,7 @@
 	uint16_t	op_code;
 	uint64_t	time;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* currently no supported options */
 	op_code = (uint16_t)(opt & ~0xFF00);
@@ -4194,11 +4412,25 @@
 		rval = ql_mailbox_command(ha, mcp);
 	}
 
+	/* Return mailbox data. */
+	if (mr != NULL) {
+		mr->mb[0] = mcp->mb[0];
+		mr->mb[1] = mcp->mb[1];
+		mr->mb[2] = mcp->mb[2];
+		mr->mb[3] = mcp->mb[3];
+		mr->mb[4] = mcp->mb[4];
+		mr->mb[5] = mcp->mb[5];
+		mr->mb[6] = mcp->mb[6];
+		mr->mb[7] = mcp->mb[7];
+		mr->mb[8] = mcp->mb[8];
+		mr->mb[9] = mcp->mb[9];
+	}
+
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4226,7 +4458,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_RESET_MENLO;
 	mcp->mb[1] = opt;
@@ -4245,7 +4477,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4272,7 +4504,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_RESTART_MPI;
 	mcp->out_mb = MBX_0;
@@ -4285,7 +4517,7 @@
 		EL(ha, "status=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4312,7 +4544,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_IDC_REQUEST;
 	mcp->mb[1] = mr->mb[1];
@@ -4328,10 +4560,8 @@
 	rval = ql_mailbox_command(ha, mcp);
 
 	if (rval == QL_SUCCESS) {
-		if (mr != NULL) {
-			mr->mb[2] = mcp->mb[2];
-		}
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		mr->mb[2] = mcp->mb[2];
+		QL_PRINT_3(ha, "done\n");
 	} else {
 		EL(ha, "status=%xh, mbx2=%xh\n", rval, mcp->mb[2]);
 	}
@@ -4359,7 +4589,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_IDC_ACK;
 	mcp->mb[1] = ha->idc_mb[1];
@@ -4374,7 +4604,7 @@
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (rval);
 }
@@ -4385,7 +4615,6 @@
  *
  * Input:
  *	ha:	adapter state pointer.
- *	mr:	pointer for mailbox data.
  *
  * Returns:
  *	ql local function return status code.
@@ -4394,23 +4623,28 @@
  *	Kernel context.
  */
 int
-ql_idc_time_extend(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+ql_idc_time_extend(ql_adapter_state_t *ha)
 {
 	int		rval;
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_IDC_TIME_EXTEND;
-	mcp->mb[1] = mr->mb[1];
-	mcp->mb[2] = mr->mb[2];
-	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->mb[1] = ha->idc_mb[1];
+	mcp->mb[2] = ha->idc_mb[2];
+	mcp->mb[3] = ha->idc_mb[3];
+	mcp->mb[4] = ha->idc_mb[4];
+	mcp->mb[5] = ha->idc_mb[5];
+	mcp->mb[6] = ha->idc_mb[6];
+	mcp->mb[7] = ha->idc_mb[7];
+	mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
 	mcp->in_mb = MBX_0;
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (rval);
 }
@@ -4435,7 +4669,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_PORT_RESET;
 	mcp->out_mb = MBX_0;
@@ -4443,7 +4677,7 @@
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (rval);
 }
@@ -4470,7 +4704,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_SET_PORT_CONFIG;
 	mcp->mb[1] = mrp->mb[1];
@@ -4482,7 +4716,7 @@
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (rval);
 }
@@ -4509,7 +4743,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_PORT_CONFIG;
 	mcp->out_mb = MBX_0;
@@ -4524,7 +4758,7 @@
 			mrp->mb[3] = mcp->mb[3];
 			mrp->mb[4] = mcp->mb[4];
 		}
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	} else {
 		EL(ha, "status=%xh, mbx1=%xh, mbx2=%xh, mbx3=%xh, mbx4=%xh\n",
 		    rval, mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[4]);
@@ -4559,14 +4793,10 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started, cmd=%xh\n", cmd);
 
 	mcp->mb[0] = MBC_FLASH_ACCESS;
-	if (cmd > 0 && cmd < 4) {
-		mcp->mb[1] = (uint16_t)(FAC_FORCE_SEMA_LOCK | cmd);
-	} else {
-		mcp->mb[1] = cmd;
-	}
+	mcp->mb[1] = cmd;
 	mcp->mb[2] = LSW(start);
 	mcp->mb[3] = MSW(start);
 	mcp->mb[4] = LSW(end);
@@ -4573,18 +4803,19 @@
 	mcp->mb[5] = MSW(end);
 
 	mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
-	mcp->in_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0_THRU_4;
 	mcp->timeout = MAILBOX_TOV;
 	rval = ql_mailbox_command(ha, mcp);
 
 	if (rval != QL_SUCCESS) {
-		EL(ha, "status=%xh, mbx1=%xh, mbx2=%xh\n", rval, mcp->mb[1],
-		    mcp->mb[2]);
+		EL(ha, "cmd=%xh, status=%xh, mbx1=%xh, mbx2=%xh, mbx3=%xh, "
+		    "mbx4=%xh\n", cmd, rval, mcp->mb[1], mcp->mb[2],
+		    mcp->mb[3], mcp->mb[4]);
 	} else {
 		if (dp != NULL) {
 			*dp = (uint32_t)mcp->mb[1];
 		}
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4613,7 +4844,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    (uint32_t)size)) != QL_SUCCESS) {
@@ -4642,7 +4873,7 @@
 		    mcp->mb[2]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4671,7 +4902,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc, size)) !=
 	    QL_SUCCESS) {
@@ -4701,7 +4932,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4731,7 +4962,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if ((rval = ql_setup_mbox_dma_resources(ha, &mem_desc,
 	    fcf_list->buffer_size)) !=
@@ -4765,7 +4996,7 @@
 		    mcp->mb[2]);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4793,10 +5024,10 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
-	mcp->out_mb = MBX_0;
+	mcp->out_mb = MBX_9|MBX_1|MBX_0;
 	mcp->in_mb = MBX_12|MBX_11|MBX_10|MBX_7|MBX_6|
 	    MBX_3|MBX_2|MBX_1|MBX_0;
 	mcp->timeout = MAILBOX_TOV;
@@ -4818,7 +5049,7 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
 	return (rval);
@@ -4845,7 +5076,7 @@
 	mbx_cmd_t	mc = {0};
 	mbx_cmd_t	*mcp = &mc;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	mcp->mb[0] = MBC_TOGGLE_INTERRUPT;
 	mcp->mb[1] = opt;
@@ -4858,8 +5089,616 @@
 		EL(ha, "failed=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 
+	return (rval);
+}
+
+/*
+ * ql_get_md_template
+ *	Issue request mini-dump template Mailbox command
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mem:	pointer to dma memory object for command.
+ *	mr:	pointer for return mailboxes.
+ *	ofst:	template offset.
+ *	opt:	request command code.
+ *		GTO_TEMPLATE_SIZE	= Request Template Size.
+ *		GTO_TEMPLATE		= Request Template.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_get_md_template(ql_adapter_state_t *ha, dma_mem_t *mem, ql_mbx_data_t *mr,
+    uint32_t ofst, uint16_t opt)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_GET_MD_TEMPLATE;
+	mcp->mb[2] = opt;
+	if (mem != NULL) {
+		mcp->mb[4] = LSW(mem->cookies->dmac_address);
+		mcp->mb[5] = MSW(mem->cookies->dmac_address);
+		mcp->mb[6] = LSW(mem->cookies->dmac_notused);
+		mcp->mb[7] = MSW(mem->cookies->dmac_notused);
+		mcp->mb[8] = LSW(mem->size);
+		mcp->mb[9] = MSW(mem->size);
+	}
+	if (ofst != 0) {
+		mcp->mb[10] = LSW(ofst);
+		mcp->mb[11] = MSW(ofst);
+	}
+	mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|
+	    MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_15|MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|
+	    MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return mailbox data. */
+	if (mr != NULL) {
+		mr->mb[0] = mcp->mb[0];
+		mr->mb[1] = mcp->mb[1];
+		mr->mb[2] = mcp->mb[2];
+		mr->mb[3] = mcp->mb[3];
+		mr->mb[4] = mcp->mb[4];
+		mr->mb[5] = mcp->mb[5];
+		mr->mb[6] = mcp->mb[6];
+		mr->mb[7] = mcp->mb[7];
+		mr->mb[8] = mcp->mb[8];
+		mr->mb[9] = mcp->mb[9];
+		mr->mb[10] = mcp->mb[10];
+		mr->mb[11] = mcp->mb[11];
+		mr->mb[12] = mcp->mb[12];
+		mr->mb[13] = mcp->mb[13];
+		mr->mb[12] = mcp->mb[14];
+		mr->mb[13] = mcp->mb[15];
+	}
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh\n", rval);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_init_req_q
+ *	 Initialize request queue.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	req_q:	request queue structure pointer.
+ *	opt:	Initialize Multiple Queue mailbox command options.
+ *
+ * Returns:
+ *	ql driver local function return status codes
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+ql_init_req_q(ql_adapter_state_t *ha, ql_request_q_t *req_q, uint16_t opt)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started, req_q_number=%d\n", req_q->req_q_number);
+
+	if (!(opt & IMO_QOS_UPDATE)) {
+		req_q->req_ring_ptr = req_q->req_ring.bp;
+		req_q->req_ring_index = 0;
+		req_q->req_q_cnt = (uint16_t)(req_q->req_entry_cnt - 1);
+		WR32_MBAR_REG(ha, req_q->mbar_req_in, 0);
+		if (req_q->req_out_shadow_ptr) {
+			*req_q->req_out_shadow_ptr = 0;
+		}
+	}
+
+	mcp->mb[0] = MBC_INIT_MULTIPLE_QUEUE;
+	mcp->mb[1] = (uint16_t)(opt | IMO_QUEUE_NOT_ASSOCIATED);
+	mcp->mb[2] = MSW(LSD(req_q->req_ring.cookie.dmac_laddress));
+	mcp->mb[3] = LSW(LSD(req_q->req_ring.cookie.dmac_laddress));
+	mcp->mb[4] = req_q->req_q_number;
+	mcp->mb[5] = req_q->req_entry_cnt;
+	mcp->mb[6] = MSW(MSD(req_q->req_ring.cookie.dmac_laddress));
+	mcp->mb[7] = LSW(MSD(req_q->req_ring.cookie.dmac_laddress));
+	mcp->mb[11] = ha->vp_index;
+	mcp->mb[12] = 0;
+	mcp->mb[14] = 1;
+	mcp->out_mb = MBX_0_THRU_14;
+	mcp->in_mb = MBX_0_THRU_1;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "status=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_init_rsp_q
+ *	 Initialize response queue.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	rsp_q:	response queue structure pointer.
+ *	opt:	Initialize Multiple Queue mailbox command options.
+ *
+ * Returns:
+ *	ql driver local function return status codes
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+ql_init_rsp_q(ql_adapter_state_t *ha, ql_response_q_t *rsp_q, uint16_t opt)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started, rsp_q_number=%d\n", rsp_q->rsp_q_number);
+
+	if (!(opt & IMO_DELETE_Q)) {
+		rsp_q->rsp_ring_ptr = rsp_q->rsp_ring.bp;
+		rsp_q->rsp_ring_index = 0;
+		WR32_MBAR_REG(ha, rsp_q->mbar_rsp_out, 0);
+		if (rsp_q->rsp_in_shadow_ptr) {
+			*rsp_q->rsp_in_shadow_ptr = 0;
+		}
+	}
+
+	mcp->mb[0] = MBC_INIT_MULTIPLE_QUEUE;
+	mcp->mb[1] = (uint16_t)(opt | IMO_QUEUE_NOT_ASSOCIATED |
+	    IMO_RESPONSE_Q_SERVICE);
+	mcp->mb[2] = MSW(LSD(rsp_q->rsp_ring.cookie.dmac_laddress));
+	mcp->mb[3] = LSW(LSD(rsp_q->rsp_ring.cookie.dmac_laddress));
+	mcp->mb[4] = rsp_q->rsp_q_number;
+	mcp->mb[5] = rsp_q->rsp_entry_cnt;
+	mcp->mb[6] = MSW(MSD(rsp_q->rsp_ring.cookie.dmac_laddress));
+	mcp->mb[7] = LSW(MSD(rsp_q->rsp_ring.cookie.dmac_laddress));
+	mcp->mb[14] = rsp_q->msi_x_vector;
+	mcp->out_mb = MBX_0_THRU_14;
+	mcp->in_mb = MBX_0_THRU_1;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "status=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_load_flash_image
+ *	Load Flash Firmware.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_load_flash_image(ql_adapter_state_t *ha)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_LOAD_FLASH_IMAGE;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_2|MBX_1|MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh, mbx1=%xh, mbx2=%xh\n",
+		    rval, mcp->mb[1], mcp->mb[2]);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_set_led_config
+ *	Set LED Configuration.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_set_led_config(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_SET_LED_CONFIG;
+	mcp->mb[1] = mr->mb[1];
+	mcp->mb[2] = mr->mb[2];
+	mcp->mb[3] = mr->mb[3];
+	mcp->mb[4] = mr->mb[4];
+	mcp->mb[5] = mr->mb[5];
+	mcp->mb[6] = mr->mb[6];
+	mcp->out_mb = MBX_0_THRU_6;
+	mcp->in_mb = MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh\n", rval);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+
+	return (rval);
+}
+/*
+ * ql_get_led_config
+ *	Get LED Configuration.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_get_led_config(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_GET_LED_CONFIG;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_0_THRU_6;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return config data. */
+	if (mr != NULL) {
+		mr->mb[1] = mcp->mb[1];
+		mr->mb[2] = mcp->mb[2];
+		mr->mb[3] = mcp->mb[3];
+		mr->mb[4] = mcp->mb[4];
+		mr->mb[5] = mcp->mb[5];
+		mr->mb[6] = mcp->mb[6];
+	}
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh\n", rval);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+
+	return (rval);
+}
+
+/*
+ * ql_led_config
+ *	Set/Get Fibre Channel LED Configuration command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	opt:	Options.
+ *	led0:	LED 0 configuration.
+ *	led1:	LED 1 configuration.
+ *	led2:	LED 2 configuration.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	qlc local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_led_config(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int			rval = QL_SUCCESS;
+	mbx_cmd_t		mc = {0};
+	mbx_cmd_t		*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_FC_LED_CONFIG;
+	mcp->mb[1] = mr->mb[1];
+	mcp->mb[2] = mr->mb[2];
+	mcp->mb[3] = mr->mb[3];
+	mcp->mb[4] = mr->mb[4];
+	mcp->out_mb = MBX_0_THRU_4;
+	mcp->in_mb = MBX_0_THRU_4;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return mailbox data. */
+	mr->mb[0] = mcp->mb[0];
+	mr->mb[1] = mcp->mb[1];
+	mr->mb[2] = mcp->mb[2];
+	mr->mb[3] = mcp->mb[3];
+	mr->mb[4] = mcp->mb[4];
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_write_remote_reg
+ *	Writes a register within another function.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	addr:	address.
+ *	data:	data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_write_remote_reg(ql_adapter_state_t *ha, uint32_t addr, uint32_t data)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_10(ha, "started, addr=%xh, data=%xh\n", addr, data);
+
+	mcp->mb[0] = MBC_WRITE_REMOTE_REG;
+	mcp->mb[1] = LSW(addr);
+	mcp->mb[2] = MSW(addr);
+	mcp->mb[3] = LSW(data);
+	mcp->mb[4] = MSW(data);
+	mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh, mbx1=%xh, addr=%xh, data=%xh\n", rval,
+		    mcp->mb[1], addr, data);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_10(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_read_remote_reg
+ *	Read a register within another function.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	addr:	address.
+ *	data:	data pointer.
+ *
+ * Returns:
+ *	qlc local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_read_remote_reg(ql_adapter_state_t *ha, uint32_t addr, uint32_t *dp)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_10(ha, "started, addr=%xh\n", addr);
+
+	mcp->mb[0] = MBC_READ_REMOTE_REG;
+	mcp->mb[1] = LSW(addr);
+	mcp->mb[2] = MSW(addr);
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed=%xh, mbx1=%xh, addr=%xh\n", rval, mcp->mb[1],
+		    addr);
+	} else {
+		*dp = SHORT_TO_LONG(mcp->mb[3], mcp->mb[4]);
+		QL_PRINT_10(ha, "done, addr=%xh, data=%xh\n", addr, *dp);
+	}
+	return (rval);
+}
+
+/*
+ * ql_get_temp
+ *	Issue get temperature mailbox command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_get_temp(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_GET_PARAMETERS;
+	mcp->mb[1] = READ_ASIC_TEMP << 8;
+	mcp->out_mb = MBX_0_THRU_1;
+	mcp->in_mb = MBX_0_THRU_1;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return config data. */
+	if (mr != NULL) {
+		mr->mb[1] = mcp->mb[1];
+	}
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh, mbx1=%xh\n", rval, mcp->mb[1]);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+	return (rval);
+}
+
+/*
+ * ql_write_serdes
+ *	Issue write FC serdes register mailbox command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_write_serdes(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_WRITE_SERDES_REG;
+	mcp->mb[1] = mr->mb[1];
+	mcp->mb[2] = mr->mb[2];
+	mcp->mb[3] = mr->mb[3];
+	mcp->mb[4] = mr->mb[4];
+	mcp->mb[5] = mr->mb[5];
+	mcp->mb[6] = mr->mb[6];
+	mcp->out_mb = MBX_0_THRU_6;
+	mcp->in_mb = MBX_0;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh\n", rval);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+
+	return (rval);
+}
+
+/*
+ * ql_read_serdes
+ *	Issue read FC serdes register mailbox command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	mr:	pointer for mailbox data.
+ *
+ * Returns:
+ *	ql local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+ql_read_serdes(ql_adapter_state_t *ha, ql_mbx_data_t *mr)
+{
+	int		rval;
+	mbx_cmd_t	mc = {0};
+	mbx_cmd_t	*mcp = &mc;
+
+	QL_PRINT_3(ha, "started\n");
+
+	mcp->mb[0] = MBC_READ_SERDES_REG;
+	mcp->mb[1] = mr->mb[1];
+	mcp->mb[2] = mr->mb[2];
+	mcp->mb[3] = mr->mb[3];
+	mcp->mb[4] = mr->mb[4];
+	mcp->mb[5] = mr->mb[5];
+	mcp->mb[6] = mr->mb[6];
+	mcp->out_mb = MBX_0_THRU_6;
+	mcp->in_mb = MBX_0_THRU_6;
+	mcp->timeout = MAILBOX_TOV;
+	rval = ql_mailbox_command(ha, mcp);
+
+	/* Return mailbox data. */
+	mr->mb[0] = mcp->mb[0];
+	mr->mb[1] = mcp->mb[1];
+	mr->mb[2] = mcp->mb[2];
+	mr->mb[3] = mcp->mb[3];
+	mr->mb[4] = mcp->mb[4];
+	mr->mb[4] = mcp->mb[5];
+	mr->mb[4] = mcp->mb[6];
+
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, rval=%xh", rval);
+	} else {
+		/*EMPTY*/
+		QL_PRINT_3(ha, "done\n");
+	}
+
 	return (rval);
 }
