--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_xioctl.c	Mon Aug  5 17:28:45 2019
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_xioctl.c	Mon Aug  5 17:28:45 2019
@@ -19,10 +19,10 @@
  * 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.
  */
 
 /*
@@ -29,7 +29,7 @@
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
 
-#pragma ident	"Copyright 2010 QLogic Corporation; ql_xioctl.c"
+#pragma ident	"Copyright 2015 QLogic Corporation; ql_xioctl.c"
 
 /*
  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
@@ -37,7 +37,7 @@
  * ***********************************************************************
  * *									**
  * *				NOTICE					**
- * *		COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION		**
+ * *		COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION		**
  * *			ALL RIGHTS RESERVED				**
  * *									**
  * ***********************************************************************
@@ -51,6 +51,7 @@
 #include <ql_iocb.h>
 #include <ql_ioctl.h>
 #include <ql_mbx.h>
+#include <ql_nx.h>
 #include <ql_xioctl.h>
 
 /*
@@ -96,7 +97,7 @@
 static int ql_report_lun(ql_adapter_state_t *, ql_tgt_t *);
 static int ql_inq_scan(ql_adapter_state_t *, ql_tgt_t *, int);
 static int ql_inq(ql_adapter_state_t *, ql_tgt_t *, int, ql_mbx_iocb_t *,
-    uint8_t);
+    uint32_t);
 static uint32_t	ql_get_buffer_data(caddr_t, caddr_t, uint32_t, int);
 static uint32_t ql_send_buffer_data(caddr_t, caddr_t, uint32_t, int);
 static int ql_24xx_flash_desc(ql_adapter_state_t *);
@@ -116,8 +117,8 @@
 static void ql_set_led_state(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_get_led_state(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_drive_led(ql_adapter_state_t *, uint32_t);
-static uint32_t ql_setup_led(ql_adapter_state_t *);
-static uint32_t ql_wrapup_led(ql_adapter_state_t *);
+static int ql_setup_led(ql_adapter_state_t *);
+static int ql_wrapup_led(ql_adapter_state_t *);
 static void ql_get_port_summary(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_get_target_id(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_get_sfp(ql_adapter_state_t *, EXT_IOCTL *, int);
@@ -152,7 +153,14 @@
 static void ql_get_fcf_list(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_get_resource_counts(ql_adapter_state_t *, EXT_IOCTL *, int);
 static void ql_qry_adapter_versions(ql_adapter_state_t *, EXT_IOCTL *, int);
-static int ql_set_loop_point(ql_adapter_state_t *, uint16_t);
+static void ql_get_temperature(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_dump_cmd(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_serdes_reg(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_serdes_reg_ex(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_els_passthru(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_flash_update_caps(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_get_bbcr_data(ql_adapter_state_t *, EXT_IOCTL *, int);
+static void ql_get_priv_stats(ql_adapter_state_t *, EXT_IOCTL *, int);
 
 /* ******************************************************************** */
 /*			External IOCTL support.				*/
@@ -176,10 +184,10 @@
 {
 	ql_xioctl_t	*xp;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (ha->xioctl != NULL) {
-		QL_PRINT_9(CE_CONT, "(%d): already allocated done\n",
+		QL_PRINT_9(ha, "already allocated done\n",
 		    ha->instance);
 		return (0);
 	}
@@ -200,7 +208,7 @@
 		return (ENOMEM);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -220,10 +228,10 @@
 {
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (xp == NULL) {
-		QL_PRINT_9(CE_CONT, "(%d): already freed\n", ha->instance);
+		QL_PRINT_9(ha, "already freed\n");
 		return;
 	}
 
@@ -236,7 +244,7 @@
 	kmem_free(xp, sizeof (ql_xioctl_t));
 	ha->xioctl = NULL;
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -266,10 +274,10 @@
 {
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance, cmd);
+	QL_PRINT_9(ha, "started, cmd=%d\n", cmd);
 
 	if (ha->xioctl == NULL) {
-		QL_PRINT_9(CE_CONT, "(%d): no context\n", ha->instance);
+		QL_PRINT_9(ha, "no context\n");
 		return (ENXIO);
 	}
 
@@ -306,6 +314,14 @@
 	case EXT_CC_ACCESS_FLASH:
 	case EXT_CC_RESET_FW:
 	case EXT_CC_MENLO_MANAGE_INFO:
+	case EXT_CC_I2C_DATA:
+	case EXT_CC_DUMP:
+	case EXT_CC_SERDES_REG_OP:
+	case EXT_CC_VF_STATE:
+	case EXT_CC_SERDES_REG_OP_EX:
+	case EXT_CC_ELS_PASSTHRU_OS:
+	case EXT_CC_FLASH_UPDATE_CAPS_OS:
+	case EXT_CC_GET_BBCR_DATA_OS:
 		rval = ql_sdm_ioctl(ha, cmd, (void *)arg, mode);
 		break;
 	default:
@@ -314,7 +330,7 @@
 		rval = ENOPROTOOPT;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -348,7 +364,7 @@
 	int			rval;
 	ql_adapter_state_t	*vha;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Copy argument structure (EXT_IOCTL) from application land. */
 	if ((rval = ql_sdm_setup(ha, &cmd, arg, mode,
@@ -368,8 +384,7 @@
 	 */
 	if (ha->flags & VP_ENABLED) {
 		/* Check that it is within range. */
-		if (cmd->HbaSelect > (CFG_IST(ha, CFG_CTRL_2422) ?
-		    MAX_24_VIRTUAL_PORTS : MAX_25_VIRTUAL_PORTS)) {
+		if (cmd->HbaSelect > ha->max_vports) {
 			EL(ha, "Invalid HbaSelect vp index: %xh\n",
 			    cmd->HbaSelect);
 			cmd->Status = EXT_STATUS_INVALID_VPINDEX;
@@ -393,7 +408,7 @@
 			 * but it's not in the list. Currently this is all
 			 * we can say.
 			 */
-			if (vha == NULL) {
+			if (vha == NULL || !(vha->flags & VP_ENABLED)) {
 				cmd->Status = EXT_STATUS_INVALID_VPINDEX;
 				cmd->ResponseLen = 0;
 				return (EFAULT);
@@ -405,11 +420,14 @@
 	 * If driver is suspended, stalled, or powered down rtn BUSY
 	 */
 	if (ha->flags & ADAPTER_SUSPENDED ||
-	    ha->task_daemon_flags & DRIVER_STALL ||
+	    (ha->task_daemon_flags & (DRIVER_STALL | ISP_ABORT_NEEDED |
+	    ABORT_ISP_ACTIVE | LOOP_RESYNC_NEEDED | LOOP_RESYNC_ACTIVE)) ||
 	    ha->power_level != PM_LEVEL_D0) {
 		EL(ha, " %s\n", ha->flags & ADAPTER_SUSPENDED ?
 		    "driver suspended" :
-		    (ha->task_daemon_flags & DRIVER_STALL ? "driver stalled" :
+		    (ha->task_daemon_flags & (DRIVER_STALL | ISP_ABORT_NEEDED |
+		    ABORT_ISP_ACTIVE | LOOP_RESYNC_NEEDED |
+		    LOOP_RESYNC_ACTIVE) ? "driver stalled" :
 		    "FCA powered down"));
 		cmd->Status = EXT_STATUS_BUSY;
 		cmd->ResponseLen = 0;
@@ -525,6 +543,27 @@
 	case EXT_CC_RESET_FW_OS:
 		ql_reset_cmd(ha, cmd);
 		break;
+	case EXT_CC_I2C_DATA:
+		ql_get_temperature(ha, cmd, mode);
+		break;
+	case EXT_CC_DUMP_OS:
+		ql_dump_cmd(ha, cmd, mode);
+		break;
+	case EXT_CC_SERDES_REG_OP:
+		ql_serdes_reg(ha, cmd, mode);
+		break;
+	case EXT_CC_SERDES_REG_OP_EX:
+		ql_serdes_reg_ex(ha, cmd, mode);
+		break;
+	case EXT_CC_ELS_PASSTHRU_OS:
+		ql_els_passthru(ha, cmd, mode);
+		break;
+	case EXT_CC_FLASH_UPDATE_CAPS_OS:
+		ql_flash_update_caps(ha, cmd, mode);
+		break;
+	case EXT_CC_GET_BBCR_DATA_OS:
+		ql_get_bbcr_data(ha, cmd, mode);
+		break;
 	default:
 		/* function not supported. */
 		EL(ha, "failed, function not supported=%d\n", ioctl_code);
@@ -540,7 +579,7 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -572,7 +611,7 @@
 	int		rval;
 	EXT_IOCTL	*cmd;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Allocate local memory for EXT_IOCTL. */
 	*cmd_struct = NULL;
@@ -604,7 +643,7 @@
 	}
 
 	if (rval == 0) {
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 		*cmd_struct = cmd;
 		cmd->Status = EXT_STATUS_OK;
 		cmd->DetailStatus = 0;
@@ -640,7 +679,7 @@
 	 * to return any error status other than the errno.
 	 */
 	if (bcmp(&cmd_struct->Signature, "QLOGIC", 6) != 0) {
-		QL_PRINT_2(CE_CONT, "failed,\n");
+		QL_PRINT_2(NULL, "failed,\n");
 		return (B_FALSE);
 	}
 
@@ -672,7 +711,7 @@
 {
 	int	rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	rval |= ddi_copyout((void *)&cmd->ResponseLen,
 	    (void *)&(((EXT_IOCTL*)arg)->ResponseLen), sizeof (uint32_t),
@@ -693,7 +732,7 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -716,7 +755,7 @@
 static void
 ql_query(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, cmd=%d\n",
 	    cmd->SubCode);
 
 	/* case off on command subcode */
@@ -757,7 +796,7 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -782,7 +821,7 @@
 	uint_t		len;
 	caddr_t		bufp;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_HBA_NODE)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -819,7 +858,7 @@
 			    (uint16_t *)
 			    (ha->sbus_fpga_iobase + FPGA_REVISION));
 
-			tmpptr = (char *)&(tmp_node.DriverVersion[verlen+1]);
+			tmpptr = (char *)&(tmp_node.DriverVersion[verlen + 1]);
 			if (tmpptr == NULL) {
 				EL(ha, "Unable to insert fpga version str\n");
 			} else {
@@ -834,7 +873,7 @@
 	    ha->fw_major_version, ha->fw_minor_version,
 	    ha->fw_subminor_version);
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		switch (ha->fw_attributes) {
 		case FWATTRIB_EF:
 			(void) strcat((char *)(tmp_node.FWVersion), " EF");
@@ -879,6 +918,12 @@
 	tmp_node.PortCount = 1;
 	tmp_node.InterfaceType = EXT_DEF_FC_INTF_TYPE;
 
+	tmp_node.MpiVersion[0] = ha->mpi_fw_major_version;
+	tmp_node.MpiVersion[1] = ha->mpi_fw_minor_version;
+	tmp_node.MpiVersion[2] = ha->mpi_fw_subminor_version;
+	tmp_node.PepFwVersion[0] = ha->phy_fw_major_version;
+	tmp_node.PepFwVersion[1] = ha->phy_fw_minor_version;
+	tmp_node.PepFwVersion[2] = ha->phy_fw_subminor_version;
 	if (ddi_copyout((void *)&tmp_node,
 	    (void *)(uintptr_t)(cmd->ResponseAdr),
 	    sizeof (EXT_HBA_NODE), mode) != 0) {
@@ -887,7 +932,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_HBA_NODE);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -911,12 +956,12 @@
 {
 	ql_link_t	*link;
 	ql_tgt_t	*tq;
-	ql_mbx_data_t	mr;
+	ql_mbx_data_t	mr = {0};
 	EXT_HBA_PORT	tmp_port = {0};
 	int		rval;
 	uint16_t	port_cnt, tgt_cnt, index;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_HBA_PORT)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -976,6 +1021,12 @@
 		case IIDMA_RATE_10GB:
 			tmp_port.PortSpeed = EXT_DEF_PORTSPEED_10GBIT;
 			break;
+		case IIDMA_RATE_16GB:
+			tmp_port.PortSpeed = EXT_DEF_PORTSPEED_16GBIT;
+			break;
+		case IIDMA_RATE_32GB:
+			tmp_port.PortSpeed = EXT_DEF_PORTSPEED_32GBIT;
+			break;
 		default:
 			tmp_port.PortSpeed = EXT_DEF_PORTSPEED_UNKNOWN;
 			EL(ha, "failed, data rate=%xh\n", mr.mb[1]);
@@ -1013,23 +1064,39 @@
 			break;
 
 		}
-	} else if (CFG_IST(ha, CFG_CTRL_8081)) {
+	} else if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
 		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_10GBIT;
-	} else if (CFG_IST(ha, CFG_CTRL_2422)) {
+	} else if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		tmp_port.PortSupportedSpeed = (EXT_DEF_PORTSPEED_4GBIT |
 		    EXT_DEF_PORTSPEED_2GBIT | EXT_DEF_PORTSPEED_1GBIT);
-	} else if (CFG_IST(ha, CFG_CTRL_2300)) {
+	} else if (CFG_IST(ha, CFG_CTRL_23XX)) {
 		tmp_port.PortSupportedSpeed = (EXT_DEF_PORTSPEED_2GBIT |
 		    EXT_DEF_PORTSPEED_1GBIT);
-	} else if (CFG_IST(ha, CFG_CTRL_6322)) {
+	} else if (CFG_IST(ha, CFG_CTRL_63XX)) {
 		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_2GBIT;
-	} else if (CFG_IST(ha, CFG_CTRL_2200)) {
+	} else if (CFG_IST(ha, CFG_CTRL_22XX)) {
 		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_1GBIT;
+	} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
+		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_4GBIT |
+		    EXT_DEF_PORTSPEED_8GBIT | EXT_DEF_PORTSPEED_16GBIT;
+	} else if (CFG_IST(ha, CFG_CTRL_27XX)) {
+		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_4GBIT |
+		    EXT_DEF_PORTSPEED_8GBIT | EXT_DEF_PORTSPEED_16GBIT |
+		    EXT_DEF_PORTSPEED_32GBIT;
 	} else {
 		tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_UNKNOWN;
 		EL(ha, "unknown HBA type: %xh\n", ha->device_id);
 	}
+
+	if (ha->task_daemon_flags & LOOP_DOWN) {
+		(void) ql_get_firmware_state(ha, NULL);
+	}
+
+	tmp_port.LinkState1 = ha->fw_state[1];
 	tmp_port.LinkState2 = LSB(ha->sfp_stat);
+	tmp_port.LinkState3 = ha->fw_state[3];
+	tmp_port.LinkState6 = ha->fw_state[6];
+
 	port_cnt = 0;
 	tgt_cnt = 0;
 
@@ -1038,10 +1105,16 @@
 		    link = link->next) {
 			tq = link->base_address;
 
-			if (!VALID_TARGET_ID(ha, tq->loop_id)) {
+			if (!VALID_TARGET_ID(ha, tq->loop_id) ||
+			    tq->d_id.b24 == FS_MANAGEMENT_SERVER) {
 				continue;
 			}
 
+			if (tq->flags & (TQF_RSCN_RCVD | TQF_IIDMA_NEEDED |
+			    TQF_NEED_AUTHENTICATION | TQF_PLOGI_PROGRS)) {
+				continue;
+			}
+
 			port_cnt++;
 			if ((tq->flags & TQF_INITIATOR_DEVICE) == 0) {
 				tgt_cnt++;
@@ -1063,7 +1136,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_HBA_PORT);
-		QL_PRINT_9(CE_CONT, "(%d): done, ports=%d, targets=%d\n",
+		QL_PRINT_9(ha, "done, ports=%d, targets=%d\n",
 		    ha->instance, port_cnt, tgt_cnt);
 	}
 }
@@ -1094,7 +1167,7 @@
 	uint16_t	index;
 	uint16_t	inst = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_DISC_PORT)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -1111,9 +1184,16 @@
 		    link = link->next) {
 			tq = link->base_address;
 
-			if (!VALID_TARGET_ID(ha, tq->loop_id)) {
+			if (!VALID_TARGET_ID(ha, tq->loop_id) ||
+			    tq->d_id.b24 == FS_MANAGEMENT_SERVER) {
 				continue;
 			}
+
+			if (tq->flags & (TQF_RSCN_RCVD | TQF_IIDMA_NEEDED |
+			    TQF_NEED_AUTHENTICATION | TQF_PLOGI_PROGRS)) {
+				continue;
+			}
+
 			if (inst != cmd->Instance) {
 				inst++;
 				continue;
@@ -1171,7 +1251,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_DISC_PORT);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1201,7 +1281,7 @@
 	uint16_t	index;
 	uint16_t	inst = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started, target=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, target=%d\n",
 	    cmd->Instance);
 
 	if (cmd->ResponseLen < sizeof (EXT_DISC_TARGET)) {
@@ -1221,7 +1301,8 @@
 			tq = link->base_address;
 
 			if (!VALID_TARGET_ID(ha, tq->loop_id) ||
-			    tq->flags & TQF_INITIATOR_DEVICE) {
+			    tq->flags & TQF_INITIATOR_DEVICE ||
+			    tq->d_id.b24 == FS_MANAGEMENT_SERVER) {
 				continue;
 			}
 			if (inst != cmd->Instance) {
@@ -1283,7 +1364,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_DISC_TARGET);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1307,7 +1388,7 @@
 {
 	EXT_FW		fw_info = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_FW)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -1333,7 +1414,7 @@
 		return;
 	} else {
 		cmd->ResponseLen = sizeof (EXT_FW);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1356,8 +1437,9 @@
 ql_qry_chip(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
 	EXT_CHIP	chip = {0};
+	uint16_t	PciDevNumber;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_CHIP)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -1377,10 +1459,15 @@
 	chip.MemAddr = ql_pci_config_get32(ha, PCI_CONF_BASE1);
 	chip.MemAddrLen = 0x100;
 	chip.ChipRevID = ha->rev_id;
-	if (ha->flags & FUNCTION_1) {
-		chip.FuncNo = 1;
-	}
+	chip.FuncNo = ha->pci_function_number;
+	chip.PciBusNumber = (uint16_t)
+	    ((ha->pci_bus_addr & PCI_REG_BUS_M) >> PCI_REG_BUS_SHIFT);
 
+	PciDevNumber = (uint16_t)
+	    ((ha->pci_bus_addr & PCI_REG_DEV_M) >> PCI_REG_DEV_SHIFT);
+	chip.PciSlotNumber = (uint16_t)(((PciDevNumber << 3) & 0xF8) |
+	    (chip.FuncNo & 0x7));
+
 	if (ddi_copyout((void *)&chip,
 	    (void *)(uintptr_t)(cmd->ResponseAdr),
 	    sizeof (EXT_CHIP), mode) != 0) {
@@ -1389,7 +1476,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_CHIP);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1413,7 +1500,7 @@
 {
 	EXT_DRIVER	qd = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_DRIVER)) {
 		cmd->Status = EXT_STATUS_DATA_OVERRUN;
@@ -1427,7 +1514,7 @@
 	(void) strcpy((void *)&qd.Version[0], QL_VERSION);
 	qd.NumOfBus = 1;	/* Fixed for Solaris */
 	qd.TargetsPerBus = (uint16_t)
-	    (CFG_IST(ha, (CFG_CTRL_24258081 | CFG_EXT_FW_INTERFACE)) ?
+	    (CFG_IST(ha, (CFG_ISP_FW_TYPE_2 | CFG_EXT_FW_INTERFACE)) ?
 	    MAX_24_FIBRE_DEVICES : MAX_22_FIBRE_DEVICES);
 	qd.LunsPerTarget = 2030;
 	qd.MaxTransferLen = QL_DMA_MAX_XFER_SIZE;
@@ -1440,7 +1527,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_DRIVER);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1473,10 +1560,10 @@
 	ql_tgt_t		tq;
 	uint16_t		comp_status, loop_id;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Get CT argument structure. */
-	if ((ha->topology & QL_SNS_CONNECTION) == 0) {
+	if ((ha->topology & QL_FABRIC_CONNECTION) == 0) {
 		EL(ha, "failed, No switch\n");
 		cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
 		cmd->ResponseLen = 0;
@@ -1495,7 +1582,7 @@
 		tq.d_id.b.al_pa = 0xfa;
 		tq.d_id.b.area = 0xff;
 		tq.d_id.b.domain = 0xff;
-		tq.loop_id = (uint16_t)(CFG_IST(ha, CFG_CTRL_24258081) ?
+		tq.loop_id = (uint16_t)(CFG_IST(ha, CFG_ISP_FW_TYPE_2) ?
 		    MANAGEMENT_SERVER_24XX_LOOP_ID :
 		    MANAGEMENT_SERVER_LOOP_ID);
 		rval = ql_login_fport(ha, &tq, tq.loop_id, LFF_NO_PRLI, &mr);
@@ -1509,7 +1596,7 @@
 		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): cmd\n", ha->instance);
+	QL_PRINT_9(ha, "cmd\n");
 	QL_DUMP_9(cmd, 8, sizeof (EXT_IOCTL));
 
 	/* Allocate a DMA Memory Descriptor */
@@ -1551,8 +1638,8 @@
 	/* Get DMA memory for the IOCB */
 	if (ql_get_dma_mem(ha, dma_mem, pkt_size, LITTLE_ENDIAN_DMA,
 	    QL_DMA_RING_ALIGN) != QL_SUCCESS) {
-		cmn_err(CE_WARN, "%s(%d): DMA memory "
-		    "alloc failed", QL_NAME, ha->instance);
+		cmn_err(CE_WARN, "%sDMA memory "
+		    "alloc failed", QL_NAME);
 		kmem_free(pkt, pkt_size);
 		kmem_free(dma_mem, sizeof (dma_mem_t));
 		cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
@@ -1572,7 +1659,7 @@
 	 * Setup IOCB
 	 */
 	ct = (ql_ct_iu_preamble_t *)pld;
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		pkt->ms24.entry_type = CT_PASSTHRU_TYPE;
 		pkt->ms24.entry_count = 1;
 
@@ -1597,7 +1684,7 @@
 		/* Load ct rsp byte count. */
 		pkt->ms24.resp_byte_count = LE_32(cmd->ResponseLen);
 
-		long_ptr = (uint32_t *)&pkt->ms24.dseg_0_address;
+		long_ptr = (uint32_t *)&pkt->ms24.dseg;
 
 		/* Load MS command entry data segments. */
 		*long_ptr++ = (uint32_t)
@@ -1659,20 +1746,20 @@
 
 		/* Response total byte count. */
 		pkt->ms.resp_byte_count = LE_32(cmd->ResponseLen);
-		pkt->ms.dseg_1_length = LE_32(cmd->ResponseLen);
+		pkt->ms.dseg[1].length = LE_32(cmd->ResponseLen);
 
 		/* Command total byte count. */
 		pkt->ms.cmd_byte_count = LE_32(cmd->RequestLen);
-		pkt->ms.dseg_0_length = LE_32(cmd->RequestLen);
+		pkt->ms.dseg[0].length = LE_32(cmd->RequestLen);
 
 		/* Load command/response data segments. */
-		pkt->ms.dseg_0_address[0] = (uint32_t)
+		pkt->ms.dseg[0].address[0] = (uint32_t)
 		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-		pkt->ms.dseg_0_address[1] = (uint32_t)
+		pkt->ms.dseg[0].address[1] = (uint32_t)
 		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
-		pkt->ms.dseg_1_address[0] = (uint32_t)
+		pkt->ms.dseg[1].address[0] = (uint32_t)
 		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-		pkt->ms.dseg_1_address[1] = (uint32_t)
+		pkt->ms.dseg[1].address[1] = (uint32_t)
 		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
 
 		rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
@@ -1706,7 +1793,7 @@
 
 	/* Copy response payload from DMA buffer to application. */
 	if (cmd->ResponseLen != 0) {
-		QL_PRINT_9(CE_CONT, "(%d): ResponseLen=%d\n", ha->instance,
+		QL_PRINT_9(ha, "ResponseLen=%d\n",
 		    cmd->ResponseLen);
 		QL_DUMP_9(pld, 8, cmd->ResponseLen);
 
@@ -1724,7 +1811,7 @@
 	ql_free_dma_resource(ha, dma_mem);
 	kmem_free(dma_mem, sizeof (dma_mem_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -1749,7 +1836,7 @@
 	int		rval = 0;
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	rval = ddi_copyin((void*)(uintptr_t)cmd->RequestAdr, &reg_struct,
 	    cmd->RequestLen, mode);
@@ -1765,7 +1852,7 @@
 			xp->aen_q_tail = 0;
 			INTR_UNLOCK(ha);
 		}
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	} else {
 		cmd->Status = EXT_STATUS_COPY_ERR;
 		EL(ha, "failed, ddi_copyin\n");
@@ -1798,7 +1885,7 @@
 	uint8_t		request_cnt;
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Compute the number of events that can be returned */
 	request_cnt = (uint8_t)(cmd->ResponseLen / sizeof (EXT_ASYNC_EVENT));
@@ -1855,7 +1942,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = out_size;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -1879,11 +1966,11 @@
 	EXT_ASYNC_EVENT		*aen_queue;
 	ql_xioctl_t		*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started, event_code=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, event_code=%d\n",
 	    event_code);
 
 	if (xp == NULL) {
-		QL_PRINT_9(CE_CONT, "(%d): no context\n", ha->instance);
+		QL_PRINT_9(ha, "no context\n");
 		return;
 	}
 	aen_queue = (EXT_ASYNC_EVENT *)xp->aen_tracking_queue;
@@ -1949,7 +2036,7 @@
 		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -2013,7 +2100,7 @@
 		uint8_t		scsi_status_h;
 	} sts;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Verify Sub Code and set cnt to needed request size. */
 	if (cmd->SubCode == EXT_SC_SEND_SCSI_PASSTHRU) {
@@ -2069,7 +2156,7 @@
 
 		qlnt = QLNT_PORT;
 		name = (uint8_t *)&sp_req->TargetAddr.Target;
-		QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, Target=%lld\n",
+		QL_PRINT_9(ha, "SubCode=%xh, Target=%lld\n",
 		    ha->instance, cmd->SubCode, sp_req->TargetAddr.Target);
 		tq = ql_find_port(ha, name, qlnt);
 	} else {
@@ -2079,7 +2166,7 @@
 		if (fc_req->FCScsiAddr.DestType == EXT_DEF_DESTTYPE_WWPN) {
 			qlnt = QLNT_PORT;
 			name = &fc_req->FCScsiAddr.DestAddr.WWPN[0];
-			QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, "
+			QL_PRINT_9(ha, "SubCode=%xh, "
 			    "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 			    ha->instance, cmd->SubCode, name[0], name[1],
 			    name[2], name[3], name[4], name[5], name[6],
@@ -2089,7 +2176,7 @@
 		    EXT_DEF_DESTTYPE_WWNN) {
 			qlnt = QLNT_NODE;
 			name = &fc_req->FCScsiAddr.DestAddr.WWNN[0];
-			QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, "
+			QL_PRINT_9(ha, "SubCode=%xh, "
 			    "wwnn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 			    ha->instance, cmd->SubCode, name[0], name[1],
 			    name[2], name[3], name[4], name[5], name[6],
@@ -2099,8 +2186,8 @@
 		    EXT_DEF_DESTTYPE_PORTID) {
 			qlnt = QLNT_PID;
 			name = &fc_req->FCScsiAddr.DestAddr.Id[0];
-			QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, PID="
-			    "%02x%02x%02x\n", ha->instance, cmd->SubCode,
+			QL_PRINT_9(ha, "SubCode=%xh, PID="
+			    "%02x%02x%02x\n", cmd->SubCode,
 			    name[0], name[1], name[2]);
 			tq = ql_find_port(ha, name, qlnt);
 		} else {
@@ -2151,8 +2238,8 @@
 		/* Get DMA memory for the IOCB */
 		if (ql_get_dma_mem(ha, dma_mem, pld_size, LITTLE_ENDIAN_DMA,
 		    QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
-			cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
-			    "alloc failed", QL_NAME, ha->instance);
+			cmn_err(CE_WARN, "%srequest queue DMA memory "
+			    "alloc failed", QL_NAME);
 			kmem_free(pkt, pkt_size);
 			cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
 			cmd->ResponseLen = 0;
@@ -2161,11 +2248,11 @@
 
 		if (scsi_req.direction == EXT_DEF_SCSI_PASSTHRU_DATA_IN) {
 			scsi_req.direction = (uint8_t)
-			    (CFG_IST(ha, CFG_CTRL_24258081) ?
+			    (CFG_IST(ha, CFG_ISP_FW_TYPE_2) ?
 			    CF_RD : CF_DATA_IN | CF_STAG);
 		} else {
 			scsi_req.direction = (uint8_t)
-			    (CFG_IST(ha, CFG_CTRL_24258081) ?
+			    (CFG_IST(ha, CFG_ISP_FW_TYPE_2) ?
 			    CF_WR : CF_DATA_OUT | CF_STAG);
 			cmd->ResponseLen = 0;
 
@@ -2193,7 +2280,7 @@
 		}
 	} else {
 		scsi_req.direction = (uint8_t)
-		    (CFG_IST(ha, CFG_CTRL_24258081) ? 0 : CF_STAG);
+		    (CFG_IST(ha, CFG_ISP_FW_TYPE_2) ? 0 : CF_STAG);
 		cmd->ResponseLen = 0;
 
 		pkt_size = sizeof (ql_mbx_iocb_t);
@@ -2212,7 +2299,7 @@
 	cmd->Status = EXT_STATUS_OK;
 	cmd->DetailStatus = EXT_DSTATUS_NOADNL_INFO;
 
-	QL_PRINT_9(CE_CONT, "(%d): SCSI cdb\n", ha->instance);
+	QL_PRINT_9(ha, "SCSI cdb\n");
 	QL_DUMP_9(scsi_req.cdbp, 8, scsi_req.cdb_len);
 
 	do {
@@ -2221,14 +2308,34 @@
 			break;
 		}
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+			uint64_t		lun_addr = 0;
+			fcp_ent_addr_t		*fcp_ent_addr = 0;
+
 			pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
 			pkt->cmd24.entry_count = 1;
 
-			/* Set LUN number */
-			pkt->cmd24.fcp_lun[2] = LSB(scsi_req.lun);
-			pkt->cmd24.fcp_lun[3] = MSB(scsi_req.lun);
+			/* Set LUN number and address method */
+			lun_addr = ql_get_lun_addr(tq, scsi_req.lun);
+			fcp_ent_addr = (fcp_ent_addr_t *)&lun_addr;
 
+			pkt->cmd24.fcp_lun[2] =
+			    lobyte(fcp_ent_addr->ent_addr_0);
+			pkt->cmd24.fcp_lun[3] =
+			    hibyte(fcp_ent_addr->ent_addr_0);
+			pkt->cmd24.fcp_lun[0] =
+			    lobyte(fcp_ent_addr->ent_addr_1);
+			pkt->cmd24.fcp_lun[1] =
+			    hibyte(fcp_ent_addr->ent_addr_1);
+			pkt->cmd24.fcp_lun[6] =
+			    lobyte(fcp_ent_addr->ent_addr_2);
+			pkt->cmd24.fcp_lun[7] =
+			    hibyte(fcp_ent_addr->ent_addr_2);
+			pkt->cmd24.fcp_lun[4] =
+			    lobyte(fcp_ent_addr->ent_addr_3);
+			pkt->cmd24.fcp_lun[5] =
+			    hibyte(fcp_ent_addr->ent_addr_3);
+
 			/* Set N_port handle */
 			pkt->cmd24.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
 
@@ -2244,9 +2351,9 @@
 			pkt->cmd24.timeout = (uint16_t)LE_16(15);
 
 			/* Load SCSI CDB */
-			ddi_rep_put8(ha->hba_buf.acc_handle, scsi_req.cdbp,
-			    pkt->cmd24.scsi_cdb, scsi_req.cdb_len,
-			    DDI_DEV_AUTOINCR);
+			ddi_rep_put8(ha->req_q[0]->req_ring.acc_handle,
+			    scsi_req.cdbp, pkt->cmd24.scsi_cdb,
+			    scsi_req.cdb_len, DDI_DEV_AUTOINCR);
 			for (cnt = 0; cnt < MAX_CMDSZ;
 			    cnt = (uint16_t)(cnt + 4)) {
 				ql_chg_endian((uint8_t *)&pkt->cmd24.scsi_cdb
@@ -2267,11 +2374,11 @@
 				pkt->cmd24.total_byte_count = LE_32(pld_size);
 
 				/* Load data descriptor. */
-				pkt->cmd24.dseg_0_address[0] = (uint32_t)
+				pkt->cmd24.dseg.address[0] = (uint32_t)
 				    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-				pkt->cmd24.dseg_0_address[1] = (uint32_t)
+				pkt->cmd24.dseg.address[1] = (uint32_t)
 				    LE_32(MSD(dma_mem->cookie.dmac_laddress));
-				pkt->cmd24.dseg_0_length = LE_32(pld_size);
+				pkt->cmd24.dseg.length = LE_32(pld_size);
 			}
 		} else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
 			pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
@@ -2292,11 +2399,11 @@
 			if (pld_size) {
 				pkt->cmd3.dseg_count = LE_16(1);
 				pkt->cmd3.byte_count = LE_32(pld_size);
-				pkt->cmd3.dseg_0_address[0] = (uint32_t)
+				pkt->cmd3.dseg[0].address[0] = (uint32_t)
 				    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-				pkt->cmd3.dseg_0_address[1] = (uint32_t)
+				pkt->cmd3.dseg[0].address[1] = (uint32_t)
 				    LE_32(MSD(dma_mem->cookie.dmac_laddress));
-				pkt->cmd3.dseg_0_length = LE_32(pld_size);
+				pkt->cmd3.dseg[0].length = LE_32(pld_size);
 			}
 		} else {
 			pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
@@ -2317,13 +2424,13 @@
 			if (pld_size) {
 				pkt->cmd.dseg_count = LE_16(1);
 				pkt->cmd.byte_count = LE_32(pld_size);
-				pkt->cmd.dseg_0_address = (uint32_t)
+				pkt->cmd.dseg[0].address = (uint32_t)
 				    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-				pkt->cmd.dseg_0_length = LE_32(pld_size);
+				pkt->cmd.dseg[0].length = LE_32(pld_size);
 			}
 		}
 		/* Go issue command and wait for completion. */
-		QL_PRINT_9(CE_CONT, "(%d): request pkt\n", ha->instance);
+		QL_PRINT_9(ha, "request pkt\n");
 		QL_DUMP_9(pkt, 8, pkt_size);
 
 		status = ql_issue_mbx_iocb(ha, (caddr_t)pkt, pkt_size);
@@ -2338,7 +2445,7 @@
 			    DDI_DEV_AUTOINCR);
 		}
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			pkt->sts24.entry_status = (uint8_t)
 			    (pkt->sts24.entry_status & 0x3c);
 		} else {
@@ -2352,7 +2459,8 @@
 			status = QL_FUNCTION_PARAMETER_ERROR;
 		}
 
-		sts.comp_status = (uint16_t)(CFG_IST(ha, CFG_CTRL_24258081) ?
+		sts.comp_status = (uint16_t)
+		    (CFG_IST(ha, CFG_ISP_FW_TYPE_2) ?
 		    LE_16(pkt->sts24.comp_status) :
 		    LE_16(pkt->sts.comp_status));
 
@@ -2415,7 +2523,7 @@
 	}
 
 	/* Setup status. */
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		sts.scsi_status_l = pkt->sts24.scsi_status_l;
 		sts.scsi_status_h = pkt->sts24.scsi_status_h;
 
@@ -2490,7 +2598,7 @@
 		sts.req_sense_data = &pkt->sts.req_sense_data[0];
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): response pkt\n", ha->instance);
+	QL_PRINT_9(ha, "response pkt\n");
 	QL_DUMP_9(&pkt->sts, 8, sizeof (sts_entry_t));
 
 	switch (sts.comp_status) {
@@ -2554,11 +2662,11 @@
 	/* Correct ISP completion status */
 	if (sts.comp_status == CS_COMPLETE && sts.scsi_status_l == 0 &&
 	    (sts.scsi_status_h & FCP_RSP_MASK) == 0) {
-		QL_PRINT_9(CE_CONT, "(%d): Correct completion\n",
+		QL_PRINT_9(ha, "Correct completion\n",
 		    ha->instance);
 		scsi_req.resid = 0;
 	} else if (sts.comp_status == CS_DATA_UNDERRUN) {
-		QL_PRINT_9(CE_CONT, "(%d): Correct UNDERRUN\n",
+		QL_PRINT_9(ha, "Correct UNDERRUN\n",
 		    ha->instance);
 		scsi_req.resid = sts.residual_length;
 		if (sts.scsi_status_h & FCP_RESID_UNDER) {
@@ -2572,8 +2680,8 @@
 			cmd->ResponseLen = 0;
 		}
 	} else {
-		QL_PRINT_9(CE_CONT, "(%d): error d_id=%xh, comp_status=%xh, "
-		    "scsi_status_h=%xh, scsi_status_l=%xh\n", ha->instance,
+		QL_PRINT_9(ha, "error d_id=%xh, comp_status=%xh, "
+		    "scsi_status_h=%xh, scsi_status_l=%xh\n",
 		    tq->d_id.b24, sts.comp_status, sts.scsi_status_h,
 		    sts.scsi_status_l);
 
@@ -2638,8 +2746,8 @@
 	/* Copy response payload from DMA buffer to application. */
 	if (scsi_req.direction & (CF_RD | CF_DATA_IN) &&
 	    cmd->ResponseLen != 0) {
-		QL_PRINT_9(CE_CONT, "(%d): Data Return resid=%lu, "
-		    "byte_count=%u, ResponseLen=%xh\n", ha->instance,
+		QL_PRINT_9(ha, "Data Return resid=%lu, "
+		    "byte_count=%u, ResponseLen=%xh\n",
 		    scsi_req.resid, pld_size, cmd->ResponseLen);
 		QL_DUMP_9(pld, 8, cmd->ResponseLen);
 
@@ -2658,7 +2766,7 @@
 		    "d_id=%xh\n", cmd->Status, sts.comp_status, tq->d_id.b24);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done, ResponseLen=%d\n",
+		QL_PRINT_9(ha, "done, ResponseLen=%d\n",
 		    ha->instance, cmd->ResponseLen);
 	}
 
@@ -2686,7 +2794,7 @@
 	EXT_SCSI_ADDR	*tmp_addr;
 	ql_tgt_t	*tq;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->RequestLen != EXT_DEF_WWN_NAME_SIZE) {
 		/* Return error */
@@ -2724,7 +2832,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->Status = EXT_STATUS_OK;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -2748,7 +2856,7 @@
 {
 	uint16_t	idx;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (uint16_t)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -2767,7 +2875,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (uint16_t);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -2793,9 +2901,9 @@
 	char		drvname[] = QL_NAME;
 	uint32_t	qlnamelen;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	qlnamelen = (uint32_t)(strlen(QL_NAME)+1);
+	qlnamelen = (uint32_t)(strlen(QL_NAME) + 1);
 
 	if (cmd->ResponseLen < qlnamelen) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -2813,10 +2921,10 @@
 		cmd->ResponseLen = 0;
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
-		cmd->ResponseLen = qlnamelen-1;
+		cmd->ResponseLen = qlnamelen - 1;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -2838,7 +2946,7 @@
 ql_read_nvram(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < ha->nvram_cache->size) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -2857,7 +2965,7 @@
 		EL(ha, "failed, copy error\n");
 	} else {
 		cmd->ResponseLen = ha->nvram_cache->size;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -2880,7 +2988,7 @@
 ql_write_nvram(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->RequestLen < ha->nvram_cache->size) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -2897,7 +3005,7 @@
 		EL(ha, "failed, copy error\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -2919,11 +3027,11 @@
 static void
 ql_write_vpd(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	int32_t		rval = 0;
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		EL(ha, "failed, invalid request for HBA\n");
 		return;
@@ -2945,7 +3053,7 @@
 		EL(ha, "failed, errno=%x\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -2967,9 +3075,9 @@
 static void
 ql_read_vpd(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		EL(ha, "failed, invalid request for HBA\n");
 		return;
@@ -2990,7 +3098,7 @@
 		EL(ha, "failed,\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -3015,18 +3123,15 @@
 	uint32_t	bsize, boff, types, cpsize, hsize;
 	ql_fcache_t	*fptr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	CACHE_LOCK(ha);
-
 	if (ha->fcache == NULL) {
-		CACHE_UNLOCK(ha);
 		cmd->Status = EXT_STATUS_ERR;
 		EL(ha, "failed, adapter fcache not setup\n");
 		return;
 	}
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		bsize = 100;
 	} else {
 		bsize = 400;
@@ -3033,7 +3138,6 @@
 	}
 
 	if (cmd->ResponseLen < bsize) {
-		CACHE_UNLOCK(ha);
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
 		cmd->DetailStatus = bsize;
 		EL(ha, "failed, ResponseLen < %d, len passed=%xh\n",
@@ -3058,7 +3162,6 @@
 			if (ddi_copyout(fptr->buf,
 			    (void *)(uintptr_t)(cmd->ResponseAdr + boff),
 			    cpsize, mode) != 0) {
-				CACHE_UNLOCK(ha);
 				EL(ha, "ddicopy failed, done\n");
 				cmd->Status = EXT_STATUS_COPY_ERR;
 				cmd->DetailStatus = 0;
@@ -3079,7 +3182,6 @@
 
 		hsize = sizeof (pci_header_t) + sizeof (pci_data_t);
 		if (hsize > fptr->buflen) {
-			CACHE_UNLOCK(ha);
 			EL(ha, "header size (%xh) exceeds buflen (%xh)\n",
 			    hsize, fptr->buflen);
 			cmd->Status = EXT_STATUS_COPY_ERR;
@@ -3090,10 +3192,9 @@
 		cpsize = ((fptr->buflen - hsize) < 100 ?
 		    fptr->buflen - hsize : 100);
 
-		if (ddi_copyout(fptr->buf+hsize,
+		if (ddi_copyout(fptr->buf + hsize,
 		    (void *)(uintptr_t)(cmd->ResponseAdr + 300),
 		    cpsize, mode) != 0) {
-			CACHE_UNLOCK(ha);
 			EL(ha, "fw ddicopy failed, done\n");
 			cmd->Status = EXT_STATUS_COPY_ERR;
 			cmd->DetailStatus = 0;
@@ -3102,11 +3203,10 @@
 		bsize += 100;
 	}
 
-	CACHE_UNLOCK(ha);
 	cmd->Status = EXT_STATUS_OK;
 	cmd->DetailStatus = bsize;
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -3131,11 +3231,9 @@
 	uint32_t	boff = 0;
 	ql_fcache_t	*fptr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	CACHE_LOCK(ha);
 	if (ha->fcache == NULL) {
-		CACHE_UNLOCK(ha);
 		cmd->Status = EXT_STATUS_ERR;
 		EL(ha, "failed, adapter fcache not setup\n");
 		return;
@@ -3147,7 +3245,6 @@
 	}
 
 	if (cmd->ResponseLen < bsize) {
-		CACHE_UNLOCK(ha);
 		if (cmd->ResponseLen != 0) {
 			EL(ha, "failed, ResponseLen < %d, len passed=%xh\n",
 			    bsize, cmd->ResponseLen);
@@ -3165,7 +3262,6 @@
 		    (void *)(uintptr_t)(cmd->ResponseAdr + boff),
 		    (fptr->buflen < FBUFSIZE ? fptr->buflen : FBUFSIZE),
 		    mode) != 0) {
-			CACHE_UNLOCK(ha);
 			EL(ha, "failed, ddicopy at %xh, done\n", boff);
 			cmd->Status = EXT_STATUS_COPY_ERR;
 			cmd->DetailStatus = 0;
@@ -3175,11 +3271,10 @@
 		fptr = fptr->next;
 	}
 
-	CACHE_UNLOCK(ha);
 	cmd->Status = EXT_STATUS_OK;
 	cmd->DetailStatus = bsize;
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -3202,10 +3297,12 @@
 {
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1) &&
+	    ql_stall_driver(ha, 0) != QL_SUCCESS) {
 		EL(ha, "ql_stall_driver failed\n");
+		ql_restart_driver(ha);
 		cmd->Status = EXT_STATUS_BUSY;
 		cmd->DetailStatus = xp->fdesc.flash_size;
 		cmd->ResponseLen = 0;
@@ -3237,15 +3334,13 @@
 	}
 
 	/* Resume I/O */
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		ql_restart_driver(ha);
-	} else {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "isp_abort_needed for restart\n");
 		ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED,
 		    DRIVER_STALL);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -3268,10 +3363,12 @@
 {
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1) &&
+	    ql_stall_driver(ha, 0) != QL_SUCCESS) {
 		EL(ha, "ql_stall_driver failed\n");
+		ql_restart_driver(ha);
 		cmd->Status = EXT_STATUS_BUSY;
 		cmd->DetailStatus = xp->fdesc.flash_size;
 		cmd->ResponseLen = 0;
@@ -3288,7 +3385,7 @@
 		/* Load flash data. */
 		if (cmd->RequestLen > xp->fdesc.flash_size) {
 			cmd->Status = EXT_STATUS_ERR;
-			cmd->DetailStatus =  xp->fdesc.flash_size;
+			cmd->DetailStatus = xp->fdesc.flash_size;
 			EL(ha, "failed, RequestLen=%xh, flash size=%xh\n",
 			    cmd->RequestLen, xp->fdesc.flash_size);
 		} else if (ql_flash_fcode_load(ha,
@@ -3300,15 +3397,13 @@
 	}
 
 	/* Resume I/O */
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-		ql_restart_driver(ha);
-	} else {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "isp_abort_needed for restart\n");
 		ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED,
 		    DRIVER_STALL);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -3332,11 +3427,12 @@
 	EXT_LOOPBACK_REQ	plbreq;
 	EXT_LOOPBACK_RSP	plbrsp;
 	ql_mbx_data_t		mr;
-	uint32_t		rval;
-	caddr_t			bp;
+	uint32_t		rval, timer, bpsize;
+	caddr_t			bp, pld;
 	uint16_t		opt;
+	boolean_t		loop_up;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Get loop back request. */
 	if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
@@ -3347,14 +3443,11 @@
 		return;
 	}
 
-	opt = (uint16_t)(plbreq.Options & MBC_LOOPBACK_POINT_MASK);
-
 	/* Check transfer length fits in buffer. */
-	if (plbreq.BufferLength < plbreq.TransferCount &&
-	    plbreq.TransferCount < MAILBOX_BUFFER_SIZE) {
-		EL(ha, "failed, BufferLength=%d, xfercnt=%d, "
-		    "mailbox_buffer_size=%d\n", plbreq.BufferLength,
-		    plbreq.TransferCount, MAILBOX_BUFFER_SIZE);
+	if (plbreq.BufferLength < plbreq.TransferCount) {
+		EL(ha, "failed, BufferLength=%d, xfercnt=%d\n",
+
+		    plbreq.BufferLength, plbreq.TransferCount);
 		cmd->Status = EXT_STATUS_INVALID_PARAM;
 		cmd->ResponseLen = 0;
 		return;
@@ -3361,7 +3454,8 @@
 	}
 
 	/* Allocate command memory. */
-	bp = kmem_zalloc(plbreq.TransferCount, KM_SLEEP);
+	bpsize = plbreq.TransferCount + 4; /* Include opcode size */
+	bp = kmem_zalloc(bpsize, KM_SLEEP);
 	if (bp == NULL) {
 		EL(ha, "failed, kmem_zalloc\n");
 		cmd->Status = EXT_STATUS_NO_MEMORY;
@@ -3368,25 +3462,29 @@
 		cmd->ResponseLen = 0;
 		return;
 	}
+	pld = bp + 4;
+	*bp = 0x10;	/* opcode */
 
 	/* Get loopback data. */
 	if (ql_get_buffer_data((caddr_t)(uintptr_t)plbreq.BufferAddress,
-	    bp, plbreq.TransferCount, mode) != plbreq.TransferCount) {
+	    pld, plbreq.TransferCount, mode) != plbreq.TransferCount) {
 		EL(ha, "failed, ddi_copyin-2\n");
-		kmem_free(bp, plbreq.TransferCount);
+		kmem_free(bp, bpsize);
 		cmd->Status = EXT_STATUS_COPY_ERR;
 		cmd->ResponseLen = 0;
 		return;
 	}
 
-	if ((ha->task_daemon_flags & (QL_LOOP_TRANSITION | DRIVER_STALL)) ||
+	if (LOOP_RECONFIGURE(ha) ||
 	    ql_stall_driver(ha, 0) != QL_SUCCESS) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
-		kmem_free(bp, plbreq.TransferCount);
+		ql_restart_driver(ha);
+		kmem_free(bp, bpsize);
 		cmd->Status = EXT_STATUS_BUSY;
 		cmd->ResponseLen = 0;
 		return;
 	}
+	loop_up = ha->task_daemon_flags & LOOP_DOWN ? B_FALSE : B_TRUE;
 
 	/* Shutdown IP. */
 	if (ha->flags & IP_INITIALIZED) {
@@ -3396,49 +3494,76 @@
 	/* determine topology so we can send the loopback or the echo */
 	/* Echo is supported on 2300's only and above */
 
-	if (CFG_IST(ha, CFG_CTRL_8081)) {
-		if (!(ha->task_daemon_flags & LOOP_DOWN) && opt ==
-		    MBC_LOOPBACK_POINT_EXTERNAL) {
+	ADAPTER_STATE_LOCK(ha);
+	ha->flags |= LOOPBACK_ACTIVE;
+	ADAPTER_STATE_UNLOCK(ha);
+
+	opt = plbreq.Options;
+
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
+		opt = (uint16_t)(plbreq.Options & MBC_LOOPBACK_POINT_MASK);
+		if (loop_up && opt == MBC_LOOPBACK_POINT_EXTERNAL) {
 			if (plbreq.TransferCount > 252) {
 				EL(ha, "transfer count (%d) > 252\n",
 				    plbreq.TransferCount);
-				kmem_free(bp, plbreq.TransferCount);
+				ql_restart_driver(ha);
+				kmem_free(bp, bpsize);
 				cmd->Status = EXT_STATUS_INVALID_PARAM;
 				cmd->ResponseLen = 0;
 				return;
 			}
 			plbrsp.CommandSent = INT_DEF_LB_ECHO_CMD;
-			rval = ql_diag_echo(ha, 0, bp, plbreq.TransferCount,
+			rval = ql_diag_echo(ha, pld, plbreq.TransferCount,
 			    MBC_ECHO_ELS, &mr);
 		} else {
-			if (CFG_IST(ha, CFG_CTRL_81XX)) {
+			if (CFG_IST(ha, CFG_LOOP_POINT_SUPPORT)) {
 				(void) ql_set_loop_point(ha, opt);
 			}
 			plbrsp.CommandSent = INT_DEF_LB_LOOPBACK_CMD;
-			rval = ql_diag_loopback(ha, 0, bp, plbreq.TransferCount,
+			rval = ql_diag_loopback(ha, pld, plbreq.TransferCount,
 			    opt, plbreq.IterationCount, &mr);
-			if (CFG_IST(ha, CFG_CTRL_81XX)) {
+			if (mr.mb[0] == 0x4005 && mr.mb[1] == 0x17) {
+				(void) ql_abort_isp(ha);
+			}
+			if (CFG_IST(ha, CFG_LOOP_POINT_SUPPORT)) {
 				(void) ql_set_loop_point(ha, 0);
 			}
 		}
 	} else {
-		if (!(ha->task_daemon_flags & LOOP_DOWN) &&
-		    (ha->topology & QL_F_PORT) &&
-		    ha->device_id >= 0x2300) {
-			QL_PRINT_9(CE_CONT, "(%d): F_PORT topology -- using "
-			    "echo\n", ha->instance);
+		if (loop_up && (ha->topology & QL_F_PORT) &&
+		    CFG_IST(ha, CFG_LB_ECHO_SUPPORT)) {
+			QL_PRINT_9(ha, "F_PORT topology -- using "
+			    "echo\n");
 			plbrsp.CommandSent = INT_DEF_LB_ECHO_CMD;
-			rval = ql_diag_echo(ha, 0, bp, plbreq.TransferCount,
-			    (uint16_t)(CFG_IST(ha, CFG_CTRL_8081) ?
-			    MBC_ECHO_ELS : MBC_ECHO_64BIT), &mr);
+			if ((rval = ql_diag_echo(ha, bp, bpsize,
+			    (uint16_t)(CFG_IST(ha, CFG_ISP_FW_TYPE_1) ?
+			    MBC_ECHO_64BIT : MBC_ECHO_ELS), &mr)) !=
+			    QL_SUCCESS) {
+				rval = ql_diag_echo(ha, pld,
+				    plbreq.TransferCount,
+				    (uint16_t)(CFG_IST(ha, CFG_ISP_FW_TYPE_1) ?
+				    MBC_ECHO_64BIT : 0), &mr);
+			}
 		} else {
 			plbrsp.CommandSent = INT_DEF_LB_LOOPBACK_CMD;
-			rval = ql_diag_loopback(ha, 0, bp, plbreq.TransferCount,
+			if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
+				opt = (uint16_t)(opt | MBC_LOOPBACK_64BIT);
+			}
+			rval = ql_diag_loopback(ha, pld, plbreq.TransferCount,
 			    opt, plbreq.IterationCount, &mr);
 		}
 	}
+	ADAPTER_STATE_LOCK(ha);
+	ha->flags &= ~LOOPBACK_ACTIVE;
+	ADAPTER_STATE_UNLOCK(ha);
 
 	ql_restart_driver(ha);
+	if (loop_up && opt == MBC_LOOPBACK_POINT_INTERNAL) {
+		timer = 30;
+		do {
+			delay(100);
+		} while (timer-- && LOOP_NOT_READY(ha));
+	}
 
 	/* Restart IP if it was shutdown. */
 	if (ha->flags & IP_ENABLED && !(ha->flags & IP_INITIALIZED)) {
@@ -3448,7 +3573,7 @@
 
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed, diagnostic_loopback_mbx=%xh\n", rval);
-		kmem_free(bp, plbreq.TransferCount);
+		kmem_free(bp, bpsize);
 		cmd->Status = EXT_STATUS_MAILBOX;
 		cmd->DetailStatus = rval;
 		cmd->ResponseLen = 0;
@@ -3456,15 +3581,15 @@
 	}
 
 	/* Return loopback data. */
-	if (ql_send_buffer_data(bp, (caddr_t)(uintptr_t)plbreq.BufferAddress,
+	if (ql_send_buffer_data(pld, (caddr_t)(uintptr_t)plbreq.BufferAddress,
 	    plbreq.TransferCount, mode) != plbreq.TransferCount) {
 		EL(ha, "failed, ddi_copyout\n");
-		kmem_free(bp, plbreq.TransferCount);
+		kmem_free(bp, bpsize);
 		cmd->Status = EXT_STATUS_COPY_ERR;
 		cmd->ResponseLen = 0;
 		return;
 	}
-	kmem_free(bp, plbreq.TransferCount);
+	kmem_free(bp, bpsize);
 
 	/* Return loopback results. */
 	plbrsp.BufferAddress = plbreq.BufferAddress;
@@ -3480,7 +3605,8 @@
 		plbrsp.CrcErrorCount = mr.mb[1];
 		plbrsp.DisparityErrorCount = mr.mb[2];
 		plbrsp.FrameLengthErrorCount = mr.mb[3];
-		plbrsp.IterationCountLastError = (mr.mb[19] >> 16) | mr.mb[18];
+		plbrsp.IterationCountLastError =
+		    SHORT_TO_LONG(mr.mb[18], mr.mb[19]);
 	}
 
 	rval = ddi_copyout((void *)&plbrsp,
@@ -3494,7 +3620,7 @@
 	}
 	cmd->ResponseLen = sizeof (EXT_LOOPBACK_RSP);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -3511,7 +3637,7 @@
  * Context:
  *	Kernel context.
  */
-static int
+int
 ql_set_loop_point(ql_adapter_state_t *ha, uint16_t opt)
 {
 	ql_mbx_data_t	mr;
@@ -3518,7 +3644,7 @@
 	int		rval;
 	uint32_t	timer;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/*
 	 * We get the current port config, modify the loopback field and
@@ -3530,12 +3656,13 @@
 	}
 	/*
 	 * Set the loopback mode field while maintaining the others.
-	 * Currently only internal or none are supported.
 	 */
-	mr.mb[1] = (uint16_t)(mr.mb[1] &~LOOPBACK_MODE_FIELD_MASK);
+	mr.mb[1] = (uint16_t)(mr.mb[1] & ~LOOPBACK_MODE_FIELD_MASK);
 	if (opt == MBC_LOOPBACK_POINT_INTERNAL) {
-		mr.mb[1] = (uint16_t)(mr.mb[1] |
-		    LOOPBACK_MODE(LOOPBACK_MODE_INTERNAL));
+		mr.mb[1] = (uint16_t)(mr.mb[1] | LOOPBACK_MODE_INTERNAL);
+	} else if (CFG_IST(ha, CFG_CTRL_80XX) &&
+	    opt == MBC_LOOPBACK_POINT_EXTERNAL) {
+		mr.mb[1] = (uint16_t)(mr.mb[1] | LOOPBACK_MODE_EXTERNAL);
 	}
 	/*
 	 * Changing the port configuration will cause the port state to cycle
@@ -3558,7 +3685,7 @@
 		ql_delay(ha, 1000000);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -3585,13 +3712,13 @@
 	port_id_t	tmp_fcid;
 	caddr_t		tmp_buf, bptr;
 	uint32_t	copy_len;
-	ql_tgt_t	*tq;
+	ql_tgt_t	*tq = NULL;
 	EXT_RNID_DATA	rnid_data;
 	uint32_t	loop_ready_wait = 10 * 60 * 10;
 	int		rval = 0;
 	uint32_t	local_hba = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
@@ -3620,9 +3747,7 @@
 
 	/* Find loop ID of the device */
 	if (tmp_rnid.Addr.Type == EXT_DEF_TYPE_WWNN) {
-		bptr = CFG_IST(ha, CFG_CTRL_24258081) ?
-		    (caddr_t)&ha->init_ctrl_blk.cb24.node_name :
-		    (caddr_t)&ha->init_ctrl_blk.cb.node_name;
+		bptr = (caddr_t)ha->loginparams.node_ww_name.raw_wwn;
 		if (bcmp((void *)bptr, (void *)tmp_rnid.Addr.FcAddr.WWNN,
 		    EXT_DEF_WWN_NAME_SIZE) == 0) {
 			local_hba = 1;
@@ -3631,9 +3756,7 @@
 			    (uint8_t *)tmp_rnid.Addr.FcAddr.WWNN, QLNT_NODE);
 		}
 	} else if (tmp_rnid.Addr.Type == EXT_DEF_TYPE_WWPN) {
-		bptr = CFG_IST(ha, CFG_CTRL_24258081) ?
-		    (caddr_t)&ha->init_ctrl_blk.cb24.port_name :
-		    (caddr_t)&ha->init_ctrl_blk.cb.port_name;
+		bptr = (caddr_t)ha->loginparams.nport_ww_name.raw_wwn;
 		if (bcmp((void *)bptr, (void *)tmp_rnid.Addr.FcAddr.WWPN,
 		    EXT_DEF_WWN_NAME_SIZE) == 0) {
 			local_hba = 1;
@@ -3685,21 +3808,11 @@
 		tmp_buf[1] = (2 * EXT_DEF_WWN_NAME_SIZE);
 		tmp_buf[2] = 0;
 		tmp_buf[3] = sizeof (EXT_RNID_DATA);
-
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
-			bcopy(ha->init_ctrl_blk.cb24.port_name, &tmp_buf[4],
-			    EXT_DEF_WWN_NAME_SIZE);
-			bcopy(ha->init_ctrl_blk.cb24.node_name,
-			    &tmp_buf[4 + EXT_DEF_WWN_NAME_SIZE],
-			    EXT_DEF_WWN_NAME_SIZE);
-		} else {
-			bcopy(ha->init_ctrl_blk.cb.port_name, &tmp_buf[4],
-			    EXT_DEF_WWN_NAME_SIZE);
-			bcopy(ha->init_ctrl_blk.cb.node_name,
-			    &tmp_buf[4 + EXT_DEF_WWN_NAME_SIZE],
-			    EXT_DEF_WWN_NAME_SIZE);
-		}
-
+		bcopy(ha->loginparams.nport_ww_name.raw_wwn, &tmp_buf[4],
+		    EXT_DEF_WWN_NAME_SIZE);
+		bcopy(ha->loginparams.node_ww_name.raw_wwn,
+		    &tmp_buf[4 + EXT_DEF_WWN_NAME_SIZE],
+		    EXT_DEF_WWN_NAME_SIZE);
 		bcopy((uint8_t *)&rnid_data,
 		    &tmp_buf[4 + 2 * EXT_DEF_WWN_NAME_SIZE],
 		    sizeof (EXT_RNID_DATA));
@@ -3762,7 +3875,7 @@
 			EL(ha, "failed, EXT_STATUS_DATA_UNDERRUN\n");
 		} else {
 			cmd->Status = EXT_STATUS_OK;
-			QL_PRINT_9(CE_CONT, "(%d): done\n",
+			QL_PRINT_9(ha, "done\n",
 			    ha->instance);
 		}
 	}
@@ -3788,7 +3901,7 @@
 static void
 ql_set_host_data(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started, SubCode=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, SubCode=%d\n",
 	    cmd->SubCode);
 
 	/*
@@ -3827,7 +3940,7 @@
 		EL(ha, "failed, Status=%d\n", cmd->Status);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -3851,7 +3964,7 @@
 {
 	int	out_size = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started, SubCode=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, SubCode=%d\n",
 	    cmd->SubCode);
 
 	/* case off on command subcode */
@@ -3886,6 +3999,9 @@
 	case EXT_SC_GET_FCF_LIST:
 		out_size = sizeof (EXT_FCF_LIST);
 		break;
+	case EXT_SC_GET_PRIV_STATS:
+		out_size = cmd->ResponseLen;
+		break;
 	case EXT_SC_GET_SCSI_ADDR:
 	case EXT_SC_GET_ERR_DETECTIONS:
 	case EXT_SC_GET_BUS_MODE:
@@ -3950,6 +4066,9 @@
 	case EXT_SC_GET_RESOURCE_CNTS:
 		ql_get_resource_counts(ha, cmd, mode);
 		break;
+	case EXT_SC_GET_PRIV_STATS:
+		ql_get_priv_stats(ha, cmd, mode);
+		break;
 	}
 
 	if (cmd->Status != EXT_STATUS_OK) {
@@ -3956,7 +4075,7 @@
 		EL(ha, "failed, Status=%d\n", cmd->Status);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -3983,7 +4102,7 @@
 {
 	int	cnt;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Bypass LUNs that failed. */
 	cnt = ql_report_lun(ha, tq);
@@ -3991,7 +4110,7 @@
 		cnt = ql_inq_scan(ha, tq, ha->maximum_luns_per_target);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (cnt);
 }
@@ -4022,7 +4141,7 @@
 	uint16_t		comp_status;
 	uint8_t			scsi_status_h, scsi_status_l, *reqs;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
@@ -4040,7 +4159,7 @@
 	/* Get DMA memory for the IOCB */
 	if (ql_get_dma_mem(ha, &dma_mem, sizeof (ql_rpt_lun_lst_t),
 	    LITTLE_ENDIAN_DMA, QL_DMA_RING_ALIGN) != QL_SUCCESS) {
-		cmn_err(CE_WARN, "%s(%d): DMA memory "
+		cmn_err(CE_WARN, "%s(%d) DMA memory "
 		    "alloc failed", QL_NAME, ha->instance);
 		kmem_free(pkt, pkt_size);
 		return (0);
@@ -4047,7 +4166,7 @@
 	}
 
 	for (retries = 0; retries < 4; retries++) {
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
 			pkt->cmd24.entry_count = 1;
 
@@ -4091,13 +4210,13 @@
 
 			/* Load total byte count. */
 			/* Load data descriptor. */
-			pkt->cmd24.dseg_0_address[0] = (uint32_t)
+			pkt->cmd24.dseg.address[0] = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd24.dseg_0_address[1] = (uint32_t)
+			pkt->cmd24.dseg.address[1] = (uint32_t)
 			    LE_32(MSD(dma_mem.cookie.dmac_laddress));
 			pkt->cmd24.total_byte_count =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
-			pkt->cmd24.dseg_0_length =
+			pkt->cmd24.dseg.length =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
 		} else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
 			pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
@@ -4122,11 +4241,11 @@
 			    LSB(LSW(sizeof (ql_rpt_lun_lst_t)));
 			pkt->cmd3.byte_count =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
-			pkt->cmd3.dseg_0_address[0] = (uint32_t)
+			pkt->cmd3.dseg[0].address[0] = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd3.dseg_0_address[1] = (uint32_t)
+			pkt->cmd3.dseg[0].address[1] = (uint32_t)
 			    LE_32(MSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd3.dseg_0_length =
+			pkt->cmd3.dseg[0].length =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
 		} else {
 			pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
@@ -4151,9 +4270,9 @@
 			    LSB(LSW(sizeof (ql_rpt_lun_lst_t)));
 			pkt->cmd.byte_count =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
-			pkt->cmd.dseg_0_address = (uint32_t)
+			pkt->cmd.dseg[0].address = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd.dseg_0_length =
+			pkt->cmd.dseg[0].length =
 			    LE_32(sizeof (ql_rpt_lun_lst_t));
 		}
 
@@ -4167,7 +4286,7 @@
 		ddi_rep_get8(dma_mem.acc_handle, (uint8_t *)rpt,
 		    (uint8_t *)dma_mem.bp, dma_mem.size, DDI_DEV_AUTOINCR);
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			pkt->sts24.entry_status = (uint8_t)
 			    (pkt->sts24.entry_status & 0x3c);
 			comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
@@ -4235,7 +4354,7 @@
 		EL(ha, "failed=%xh\n", rval);
 		rval = 0;
 	} else {
-		QL_PRINT_9(CE_CONT, "(%d): LUN list\n", ha->instance);
+		QL_PRINT_9(ha, "LUN list\n");
 		QL_DUMP_9(rpt, 8, rpt->hdr.len + 8);
 		rval = (int)(BE_32(rpt->hdr.len) / 8);
 	}
@@ -4243,7 +4362,7 @@
 	kmem_free(pkt, pkt_size);
 	ql_free_dma_resource(ha, &dma_mem);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -4271,7 +4390,7 @@
 	uint8_t		*inq;
 	uint32_t	pkt_size;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	pkt_size = sizeof (ql_mbx_iocb_t) + INQ_DATA_SIZE;
 	pkt = kmem_zalloc(pkt_size, KM_SLEEP);
@@ -4308,9 +4427,9 @@
 				tq->flags |= TQF_TAPE_DEVICE;
 				break;
 			default:
-				QL_PRINT_9(CE_CONT, "(%d): failed, "
+				QL_PRINT_9(ha, "failed, "
 				    "unsupported device id=%xh, lun=%d, "
-				    "type=%xh\n", ha->instance, tq->loop_id,
+				    "type=%xh\n", tq->loop_id,
 				    lun, *inq);
 				break;
 			}
@@ -4326,7 +4445,7 @@
 
 	kmem_free(pkt, pkt_size);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (cnt);
 }
@@ -4350,7 +4469,7 @@
  */
 static int
 ql_inq(ql_adapter_state_t *ha, ql_tgt_t *tq, int lun, ql_mbx_iocb_t *pkt,
-    uint8_t inq_len)
+    uint32_t inq_len)
 {
 	dma_mem_t	dma_mem;
 	int		rval, retries;
@@ -4358,8 +4477,10 @@
 	uint16_t	comp_status;
 	uint8_t		scsi_status_h, scsi_status_l, *reqs;
 	caddr_t		inq_data;
+	uint64_t	lun_addr;
+	fcp_ent_addr_t	*fcp_ent_addr = (fcp_ent_addr_t *)&lun_addr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, loop down\n");
@@ -4374,19 +4495,35 @@
 	/* Get DMA memory for the IOCB */
 	if (ql_get_dma_mem(ha, &dma_mem, inq_len,
 	    LITTLE_ENDIAN_DMA, QL_DMA_RING_ALIGN) != QL_SUCCESS) {
-		cmn_err(CE_WARN, "%s(%d): DMA memory "
+		cmn_err(CE_WARN, "%s(%d) DMA memory "
 		    "alloc failed", QL_NAME, ha->instance);
 		return (0);
 	}
 
 	for (retries = 0; retries < 4; retries++) {
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
 			pkt->cmd24.entry_count = 1;
 
 			/* Set LUN number */
-			pkt->cmd24.fcp_lun[2] = LSB(lun);
-			pkt->cmd24.fcp_lun[3] = MSB(lun);
+			lun_addr = ql_get_lun_addr(tq, lun);
+			fcp_ent_addr = (fcp_ent_addr_t *)&lun_addr;
+			pkt->cmd24.fcp_lun[2] =
+			    lobyte(fcp_ent_addr->ent_addr_0);
+			pkt->cmd24.fcp_lun[3] =
+			    hibyte(fcp_ent_addr->ent_addr_0);
+			pkt->cmd24.fcp_lun[0] =
+			    lobyte(fcp_ent_addr->ent_addr_1);
+			pkt->cmd24.fcp_lun[1] =
+			    hibyte(fcp_ent_addr->ent_addr_1);
+			pkt->cmd24.fcp_lun[6] =
+			    lobyte(fcp_ent_addr->ent_addr_2);
+			pkt->cmd24.fcp_lun[7] =
+			    hibyte(fcp_ent_addr->ent_addr_2);
+			pkt->cmd24.fcp_lun[4] =
+			    lobyte(fcp_ent_addr->ent_addr_3);
+			pkt->cmd24.fcp_lun[5] =
+			    hibyte(fcp_ent_addr->ent_addr_3);
 
 			/* Set N_port handle */
 			pkt->cmd24.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
@@ -4404,7 +4541,7 @@
 
 			/* Load SCSI CDB */
 			pkt->cmd24.scsi_cdb[0] = SCMD_INQUIRY;
-			pkt->cmd24.scsi_cdb[4] = inq_len;
+			pkt->cmd24.scsi_cdb[4] = LSB(LSW(inq_len));
 			for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
 				ql_chg_endian((uint8_t *)&pkt->cmd24.scsi_cdb
 				    + cnt, 4);
@@ -4423,11 +4560,11 @@
 			pkt->cmd24.total_byte_count = LE_32(inq_len);
 
 			/* Load data descriptor. */
-			pkt->cmd24.dseg_0_address[0] = (uint32_t)
+			pkt->cmd24.dseg.address[0] = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd24.dseg_0_address[1] = (uint32_t)
+			pkt->cmd24.dseg.address[1] = (uint32_t)
 			    LE_32(MSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd24.dseg_0_length = LE_32(inq_len);
+			pkt->cmd24.dseg.length = LE_32(inq_len);
 		} else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
 			pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
 			cnt = CMD_TYPE_3_DATA_SEGMENTS;
@@ -4444,14 +4581,14 @@
 			pkt->cmd3.control_flags_l = CF_DATA_IN | CF_STAG;
 			pkt->cmd3.timeout = LE_16(15);
 			pkt->cmd3.scsi_cdb[0] = SCMD_INQUIRY;
-			pkt->cmd3.scsi_cdb[4] = inq_len;
+			pkt->cmd3.scsi_cdb[4] = LSB(LSW(inq_len));
 			pkt->cmd3.dseg_count = LE_16(1);
 			pkt->cmd3.byte_count = LE_32(inq_len);
-			pkt->cmd3.dseg_0_address[0] = (uint32_t)
+			pkt->cmd3.dseg[0].address[0] = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd3.dseg_0_address[1] = (uint32_t)
+			pkt->cmd3.dseg[0].address[1] = (uint32_t)
 			    LE_32(MSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd3.dseg_0_length = LE_32(inq_len);
+			pkt->cmd3.dseg[0].length = LE_32(inq_len);
 		} else {
 			pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
 			cnt = CMD_TYPE_2_DATA_SEGMENTS;
@@ -4468,12 +4605,12 @@
 			pkt->cmd.control_flags_l = CF_DATA_IN | CF_STAG;
 			pkt->cmd.timeout = LE_16(15);
 			pkt->cmd.scsi_cdb[0] = SCMD_INQUIRY;
-			pkt->cmd.scsi_cdb[4] = inq_len;
+			pkt->cmd.scsi_cdb[4] = LSB(LSW(inq_len));
 			pkt->cmd.dseg_count = LE_16(1);
 			pkt->cmd.byte_count = LE_32(inq_len);
-			pkt->cmd.dseg_0_address = (uint32_t)
+			pkt->cmd.dseg[0].address = (uint32_t)
 			    LE_32(LSD(dma_mem.cookie.dmac_laddress));
-			pkt->cmd.dseg_0_length = LE_32(inq_len);
+			pkt->cmd.dseg[0].length = LE_32(inq_len);
 		}
 
 /*		rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, pkt_size); */
@@ -4487,7 +4624,7 @@
 		ddi_rep_get8(dma_mem.acc_handle, (uint8_t *)inq_data,
 		    (uint8_t *)dma_mem.bp, dma_mem.size, DDI_DEV_AUTOINCR);
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			pkt->sts24.entry_status = (uint8_t)
 			    (pkt->sts24.entry_status & 0x3c);
 			comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
@@ -4542,7 +4679,7 @@
 	}
 	ql_free_dma_resource(ha, &dma_mem);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -4570,7 +4707,7 @@
 
 	for (cnt = 0; cnt < size; cnt++) {
 		if (ddi_copyin(src++, dst++, 1, mode) != 0) {
-			QL_PRINT_2(CE_CONT, "failed, ddi_copyin\n");
+			QL_PRINT_2(NULL, "failed, ddi_copyin\n");
 			break;
 		}
 	}
@@ -4601,7 +4738,7 @@
 
 	for (cnt = 0; cnt < size; cnt++) {
 		if (ddi_copyout(src++, dst++, 1, mode) != 0) {
-			QL_PRINT_2(CE_CONT, "failed, ddi_copyin\n");
+			QL_PRINT_2(NULL, "failed, ddi_copyin\n");
 			break;
 		}
 	}
@@ -4660,7 +4797,7 @@
 				}
 				break;
 			default:
-				EL(ha, "failed, invalid type=%d\n",  type);
+				EL(ha, "failed, invalid type=%d\n", type);
 				return (NULL);
 			}
 		}
@@ -4691,10 +4828,10 @@
 	flash_desc_t	*fdesc;
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (ha->flash_desc_addr == 0) {
-		QL_PRINT_9(CE_CONT, "(%d): desc ptr=0\n", ha->instance);
+		QL_PRINT_9(ha, "desc ptr=0\n");
 		return (QL_FUNCTION_FAILED);
 	}
 
@@ -4743,7 +4880,7 @@
 	bcopy(fdesc, &xp->fdesc, sizeof (flash_desc_t));
 	kmem_free(fdesc, sizeof (flash_desc_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (QL_SUCCESS);
 }
@@ -4772,16 +4909,18 @@
 		return (rval);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_2200) && !ha->subven_id) {
+	if (CFG_IST(ha, CFG_CTRL_22XX) && !ha->subven_id) {
 		return (QL_FUNCTION_FAILED);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_258081)) {
+	if (CFG_IST(ha, CFG_CTRL_252780818283)) {
 		/*
 		 * Temporarily set the ha->xioctl->fdesc.flash_size to
 		 * 25xx flash size to avoid failing of ql_dump_focde.
 		 */
-		if (CFG_IST(ha, CFG_CTRL_8021)) {
+		if (CFG_IST(ha, CFG_CTRL_278083)) {
+			ha->xioctl->fdesc.flash_size = 0x1000000;
+		} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
 			ha->xioctl->fdesc.flash_size = 0x800000;
 		} else if (CFG_IST(ha, CFG_CTRL_25XX)) {
 			ha->xioctl->fdesc.flash_size = 0x200000;
@@ -4793,15 +4932,15 @@
 			EL(ha, "flash desc table ok, exit\n");
 			return (rval);
 		}
-		if (CFG_IST(ha, CFG_CTRL_8021)) {
-			xp->fdesc.flash_manuf = WINBOND_FLASH;
-			xp->fdesc.flash_id = WINBOND_FLASHID;
+		if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			xp->fdesc.flash_manuf = MXIC_FLASH;
+			xp->fdesc.flash_id = MXIC_FLASHID_25LXX;
 			xp->fdesc.flash_len = 0x17;
 		} else {
 			(void) ql_24xx_flash_id(ha);
 		}
 
-	} else if (CFG_IST(ha, CFG_CTRL_2422)) {
+	} else if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		(void) ql_24xx_flash_id(ha);
 	} else {
 		ql_flash_enable(ha);
@@ -4837,7 +4976,7 @@
 	xp->fdesc.write_enable_bits = 0;
 	xp->fdesc.unprotect_sector_cmd = 0;
 	xp->fdesc.protect_sector_cmd = 0;
-	xp->fdesc.write_disable_bits = 0x9c;
+	xp->fdesc.write_disable_bits = 0xbc;
 	xp->fdesc.block_size = 0x10000;
 	xp->fdesc.erase_cmd = 0xd8;
 
@@ -4844,6 +4983,13 @@
 	switch (xp->fdesc.flash_manuf) {
 	case AMD_FLASH:
 		switch (xp->fdesc.flash_id) {
+		case SPAN_FLASHID_16384K:
+			if (xp->fdesc.flash_len == 0x18) {
+				xp->fdesc.flash_size = 0x1000000;
+			} else {
+				rval = QL_FUNCTION_FAILED;
+			}
+			break;
 		case SPAN_FLASHID_2048K:
 			xp->fdesc.flash_size = 0x200000;
 			break;
@@ -4884,6 +5030,13 @@
 				rval = QL_FUNCTION_FAILED;
 			}
 			break;
+		case ST_FLASHID_N25QXXX:
+			if (xp->fdesc.flash_len == 0x18) {
+				xp->fdesc.flash_size = 0x1000000;
+			} else {
+				rval = QL_FUNCTION_FAILED;
+			}
+			break;
 		default:
 			rval = QL_FUNCTION_FAILED;
 			break;
@@ -4920,10 +5073,17 @@
 			xp->fdesc.flash_size = 0x100000;
 			break;
 		case MXIC_FLASHID_25LXX:
+			xp->fdesc.write_disable_bits = 0xbc;
 			if (xp->fdesc.flash_len == 0x14) {
 				xp->fdesc.flash_size = 0x100000;
 			} else if (xp->fdesc.flash_len == 0x15) {
 				xp->fdesc.flash_size = 0x200000;
+			} else if (xp->fdesc.flash_len == 0x16) {
+				xp->fdesc.flash_size = 0x400000;
+			} else if (xp->fdesc.flash_len == 0x17) {
+				xp->fdesc.flash_size = 0x800000;
+			} else if (xp->fdesc.flash_len == 0x18) {
+				xp->fdesc.flash_size = 0x1000000;
 			} else {
 				rval = QL_FUNCTION_FAILED;
 			}
@@ -4955,6 +5115,8 @@
 				xp->fdesc.flash_size = 0x400000;
 			} else if (xp->fdesc.flash_len == 0x17) {
 				xp->fdesc.flash_size = 0x800000;
+			} else if (xp->fdesc.flash_len == 0x18) {
+				xp->fdesc.flash_size = 0x1000000;
 			} else {
 				rval = QL_FUNCTION_FAILED;
 			}
@@ -4982,6 +5144,20 @@
 			break;
 		}
 		break;
+	case EON_FLASH:
+		switch (xp->fdesc.flash_id) {
+		case EON_FLASHID_EN25QXXX:
+			if (xp->fdesc.flash_len == 0x18) {
+				xp->fdesc.flash_size = 0x1000000;
+			} else {
+				rval = QL_FUNCTION_FAILED;
+			}
+			break;
+		default:
+			rval = QL_FUNCTION_FAILED;
+			break;
+		}
+		break;
 	default:
 		rval = QL_FUNCTION_FAILED;
 		break;
@@ -4988,20 +5164,20 @@
 	}
 
 	/* Try flash table later. */
-	if (rval != QL_SUCCESS && CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (rval != QL_SUCCESS && CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		EL(ha, "no default id\n");
 		return (QL_SUCCESS);
 	}
 
 	/*
-	 * hack for non std 2312 and 6312 boards. hardware people need to
-	 * use either the 128k flash chip (original), or something larger.
-	 * For driver purposes, we'll treat it as a 128k flash chip.
+	 * hack for non std 2312/2322 and 6312/6322 boards. hardware people
+	 * need to use either the 128k flash chip (original), or something
+	 * larger. For driver purposes, we'll treat it as a 128k flash chip.
 	 */
 	if ((ha->device_id == 0x2312 || ha->device_id == 0x6312 ||
 	    ha->device_id == 0x2322 || ha->device_id == 0x6322) &&
 	    (xp->fdesc.flash_size > 0x20000) &&
-	    (CFG_IST(ha, CFG_SBUS_CARD) ==  0)) {
+	    (CFG_IST(ha, CFG_SBUS_CARD) == 0)) {
 		EL(ha, "chip exceeds max size: %xh, using 128k\n",
 		    xp->fdesc.flash_size);
 		xp->fdesc.flash_size = 0x20000;
@@ -5042,7 +5218,7 @@
 	ql_xioctl_t	*xp = ha->xioctl;
 	int		rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (bsize > xp->fdesc.flash_size) {
 		EL(ha, "failed, bufsize: %xh, flash size: %xh\n", bsize,
@@ -5053,7 +5229,7 @@
 	if ((bfp = (uint8_t *)kmem_zalloc(bsize, KM_SLEEP)) == NULL) {
 		EL(ha, "failed, kmem_zalloc\n");
 		rval = ENOMEM;
-	} else  {
+	} else {
 		if (ddi_copyin(bp, bfp, bsize, mode) != 0) {
 			EL(ha, "failed, ddi_copyin\n");
 			rval = EFAULT;
@@ -5068,7 +5244,7 @@
 		kmem_free(bfp, bsize);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -5095,11 +5271,11 @@
 	uint32_t	cnt;
 	int		rval;
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		return (ql_24xx_load_flash(ha, dp, size, addr));
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (CFG_IST(ha, CFG_SBUS_CARD)) {
 		/*
@@ -5141,7 +5317,7 @@
 		EL(ha, "failed, rval=%xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 	return (rval);
 }
@@ -5170,7 +5346,7 @@
 	int		rval;
 	ql_xioctl_t	*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* adjust max read size to flash size */
 	if (bsize > xp->fdesc.flash_size) {
@@ -5198,7 +5374,7 @@
 		kmem_free(bfp, bsize);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -5229,7 +5405,7 @@
 	int		fp_rval, rval = QL_SUCCESS;
 	dma_mem_t	mem;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* make sure startpos+size doesn't exceed flash */
 	if (size + startpos > ha->xioctl->fdesc.flash_size) {
@@ -5238,7 +5414,7 @@
 		return (QL_FUNCTION_PARAMETER_ERROR);
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		/* check start addr is 32 bit aligned for 24xx */
 		if ((startpos & 0x3) != 0) {
 			rval = ql_24xx_read_flash(ha,
@@ -5257,7 +5433,7 @@
 				size--;
 			}
 			if (size == 0) {
-				QL_PRINT_9(CE_CONT, "(%d): done2\n",
+				QL_PRINT_9(ha, "done2\n",
 				    ha->instance);
 				return (rval);
 			}
@@ -5270,7 +5446,7 @@
 	bzero(&mem, sizeof (dma_mem_t));
 	/* Check for Fast page is supported */
 	if ((ha->pha->task_daemon_flags & FIRMWARE_UP) &&
-	    (CFG_IST(ha, CFG_CTRL_2581))) {
+	    (CFG_IST(ha, CFG_FLASH_DMA_SUPPORT))) {
 		fp_rval = QL_SUCCESS;
 		/* Setup DMA buffer. */
 		rval = ql_get_dma_mem(ha, &mem, size,
@@ -5287,7 +5463,7 @@
 	GLOBAL_HW_LOCK();
 
 	/* Enable Flash Read/Write. */
-	if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		ql_flash_enable(ha);
 	}
 
@@ -5295,9 +5471,9 @@
 	while (size) {
 		/* Allow other system activity. */
 		if (size % 0x1000 == 0) {
-			ql_delay(ha, 100000);
+			ql_delay(ha, 10000);
 		}
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			if (fp_rval == QL_SUCCESS && (addr & 0x3f) == 0) {
 				cnt = (size + 3) >> 2;
 				fp_rval = ql_rd_risc_ram(ha, addr,
@@ -5328,7 +5504,7 @@
 		}
 	}
 
-	if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		ql_flash_disable(ha);
 	}
 
@@ -5342,7 +5518,7 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 	return (rval);
 }
@@ -5404,7 +5580,7 @@
 	EXT_RNID_DATA		*tmp_buf;
 	int			rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
@@ -5469,7 +5645,7 @@
 
 	kmem_free(tmp_buf, sizeof (EXT_RNID_DATA));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -5487,7 +5663,7 @@
 	EXT_RNID_DATA	*tmp_buf;
 	uint32_t	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
@@ -5525,7 +5701,7 @@
 		cmd->Status = EXT_STATUS_COPY_ERR;
 		cmd->ResponseLen = 0;
 	} else {
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 		cmd->ResponseLen = sizeof (EXT_RNID_DATA);
 	}
 
@@ -5552,7 +5728,7 @@
 	ql_xioctl_t		*xp = ha->xioctl;
 	int			rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (DRIVER_SUSPENDED(ha)) {
 		EL(ha, "failed, LOOP_NOT_READY\n");
@@ -5588,7 +5764,7 @@
 	xp->TotalInterrupts = 0;
 	INTR_UNLOCK(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -5617,7 +5793,7 @@
 	ql_xioctl_t		*xp = ha->xioctl;
 	int			retry = 10;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	while (ha->task_daemon_flags &
 	    (ABORT_ISP_ACTIVE | LOOP_RESYNC_ACTIVE | DRIVER_STALL)) {
@@ -5685,7 +5861,7 @@
 
 	kmem_free(ls, sizeof (ql_link_stats_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -5715,7 +5891,7 @@
 	ql_tgt_t		*tq = NULL;
 	int			retry = 10;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
 	    (void *)&pextdestaddr, sizeof (EXT_DEST_ADDR), mode) != 0) {
@@ -5728,7 +5904,7 @@
 	qlnt = QLNT_PORT;
 	name = pextdestaddr.DestAddr.WWPN;
 
-	QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
+	QL_PRINT_9(ha, "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 	    ha->instance, name[0], name[1], name[2], name[3], name[4],
 	    name[5], name[6], name[7]);
 
@@ -5742,7 +5918,7 @@
 	}
 
 	while (ha->task_daemon_flags &
-	    (ABORT_ISP_ACTIVE | LOOP_RESYNC_ACTIVE  | DRIVER_STALL)) {
+	    (ABORT_ISP_ACTIVE | LOOP_RESYNC_ACTIVE | DRIVER_STALL)) {
 		ql_delay(ha, 10000000);	/* 10 second delay */
 
 		retry--;
@@ -5795,7 +5971,7 @@
 
 	kmem_free(ls, sizeof (ql_link_stats_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -5820,7 +5996,7 @@
 	EXT_HBA_FC4STATISTICS	fc4stats = {0};
 	ql_xioctl_t		*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	fc4stats.InputRequests = xp->IOInputRequests;
 	fc4stats.OutputRequests = xp->IOOutputRequests;
@@ -5840,7 +6016,7 @@
 		cmd->ResponseLen = sizeof (EXT_HBA_FC4STATISTICS);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -5862,10 +6038,10 @@
 ql_set_led_state(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
 	EXT_BEACON_CONTROL	bstate;
-	uint32_t		rval;
-	ql_xioctl_t		*xp = ha->xioctl;
+	int			rval;
+	ql_mbx_data_t		mr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->RequestLen < sizeof (EXT_BEACON_CONTROL)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -5876,7 +6052,7 @@
 		return;
 	}
 
-	if (ha->device_id < 0x2300) {
+	if (!CFG_IST(ha, CFG_SET_LEDS_SUPPORT)) {
 		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
 		cmd->DetailStatus = 0;
 		EL(ha, "done - failed, Invalid function for HBA model\n");
@@ -5895,7 +6071,7 @@
 
 	switch (bstate.State) {
 	case EXT_DEF_GRN_BLINK_OFF:	/* turn beacon off */
-		if (xp->ledstate.BeaconState == BEACON_OFF) {
+		if (ha->ledstate.BeaconState == BEACON_OFF) {
 			/* not quite an error -- LED state is already off */
 			cmd->Status = EXT_STATUS_OK;
 			EL(ha, "LED off request -- LED is already off\n");
@@ -5902,9 +6078,25 @@
 			break;
 		}
 
-		xp->ledstate.BeaconState = BEACON_OFF;
-		xp->ledstate.LEDflags = LED_ALL_OFF;
+		if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			rval = ql_diag_beacon(ha, QL_BEACON_DISABLE,
+			    &mr);
 
+			if (rval == QL_SUCCESS) {
+				ha->ledstate.BeaconState = BEACON_OFF;
+				ha->ledstate.LEDflags = LED_ALL_OFF;
+				cmd->Status = EXT_STATUS_OK;
+			} else {
+				cmd->Status = EXT_STATUS_ERR;
+				EL(ha, "failed, disable beacon request %xh\n",
+				    bstate.State);
+			}
+			break;
+		}
+
+		ha->ledstate.BeaconState = BEACON_OFF;
+		ha->ledstate.LEDflags = LED_ALL_OFF;
+
 		if ((rval = ql_wrapup_led(ha)) != QL_SUCCESS) {
 			cmd->Status = EXT_STATUS_MAILBOX;
 		} else {
@@ -5913,7 +6105,7 @@
 		break;
 
 	case EXT_DEF_GRN_BLINK_ON:	/* turn beacon on */
-		if (xp->ledstate.BeaconState == BEACON_ON) {
+		if (ha->ledstate.BeaconState == BEACON_ON) {
 			/* not quite an error -- LED state is already on */
 			cmd->Status = EXT_STATUS_OK;
 			EL(ha, "LED on request  - LED is already on\n");
@@ -5920,17 +6112,33 @@
 			break;
 		}
 
+		if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			rval = ql_diag_beacon(ha, QL_BEACON_ENABLE,
+			    &mr);
+
+			if (rval == QL_SUCCESS) {
+				ha->ledstate.BeaconState = BEACON_ON;
+				ha->ledstate.LEDflags = LED_GREEN;
+				cmd->Status = EXT_STATUS_OK;
+			} else {
+				cmd->Status = EXT_STATUS_ERR;
+				EL(ha, "failed, enable beacon request %xh\n",
+				    bstate.State);
+			}
+			break;
+		}
+
 		if ((rval = ql_setup_led(ha)) != QL_SUCCESS) {
 			cmd->Status = EXT_STATUS_MAILBOX;
 			break;
 		}
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
-			xp->ledstate.LEDflags = LED_YELLOW_24 | LED_AMBER_24;
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+			ha->ledstate.LEDflags = LED_YELLOW_24 | LED_AMBER_24;
 		} else {
-			xp->ledstate.LEDflags = LED_GREEN;
+			ha->ledstate.LEDflags = LED_GREEN;
 		}
-		xp->ledstate.BeaconState = BEACON_ON;
+		ha->ledstate.BeaconState = BEACON_ON;
 
 		cmd->Status = EXT_STATUS_OK;
 		break;
@@ -5940,7 +6148,7 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -5963,9 +6171,8 @@
 {
 	EXT_BEACON_CONTROL	bstate = {0};
 	uint32_t		rval;
-	ql_xioctl_t		*xp = ha->xioctl;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (cmd->ResponseLen < sizeof (EXT_BEACON_CONTROL)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -5976,7 +6183,7 @@
 		return;
 	}
 
-	if (ha->device_id < 0x2300) {
+	if (!CFG_IST(ha, CFG_SET_LEDS_SUPPORT)) {
 		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
 		cmd->DetailStatus = 0;
 		EL(ha, "done - failed, Invalid function for HBA model\n");
@@ -5992,7 +6199,7 @@
 	}
 
 	/* inform the user of the current beacon state (off or on) */
-	bstate.State = xp->ledstate.BeaconState;
+	bstate.State = ha->ledstate.BeaconState;
 
 	rval = ddi_copyout((void *)&bstate,
 	    (void *)(uintptr_t)cmd->ResponseAdr,
@@ -6007,7 +6214,7 @@
 		cmd->ResponseLen = sizeof (EXT_BEACON_CONTROL);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -6023,26 +6230,79 @@
 void
 ql_blink_led(ql_adapter_state_t *ha)
 {
-	uint32_t		nextstate;
-	ql_xioctl_t		*xp = ha->xioctl;
+	uint32_t	nextstate;
+	ql_mbx_data_t	mr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (xp->ledstate.BeaconState == BEACON_ON) {
-		/* determine the next led state */
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
-			nextstate = (xp->ledstate.LEDflags) &
-			    (~(RD32_IO_REG(ha, gpiod)));
-		} else {
-			nextstate = (xp->ledstate.LEDflags) &
-			    (~(RD16_IO_REG(ha, gpiod)));
-		}
+	if (ha->ledstate.BeaconState == BEACON_ON) {
+		if (CFG_IST(ha, CFG_CTRL_2363 | CFG_CTRL_2425)) {
+			/* determine the next led state */
+			if (CFG_IST(ha, CFG_CTRL_2425)) {
+				nextstate = (ha->ledstate.LEDflags) &
+				    (~(RD32_IO_REG(ha, gpiod)));
+			} else {
+				nextstate = (ha->ledstate.LEDflags) &
+				    (~(RD16_IO_REG(ha, gpiod)));
+			}
 
-		/* turn the led on or off */
-		ql_drive_led(ha, nextstate);
+			/* turn the led on or off */
+			ql_drive_led(ha, nextstate);
+		} else if (CFG_IST(ha, CFG_CTRL_81XX)) {
+			if (ha->ledstate.flags & LED_ACTIVE) {
+				mr.mb[1] = 0x2000;
+				mr.mb[2] = 0x4000;
+				ha->ledstate.flags &= ~LED_ACTIVE;
+			} else {
+				mr.mb[1] = 0x4000;
+				mr.mb[2] = 0x2000;
+				ha->ledstate.flags |= LED_ACTIVE;
+			}
+			(void) ql_set_led_config(ha, &mr);
+		} else if (CFG_IST(ha, CFG_CTRL_80XX)) {
+			if (ha->ledstate.flags & LED_ACTIVE) {
+				mr.mb[1] = 0x4000;
+				mr.mb[2] = 0x2000;
+				mr.mb[3] = 0x4000;
+				mr.mb[4] = 0x4000;
+				mr.mb[5] = 0;
+				mr.mb[6] = 0x2000;
+				(void) ql_set_led_config(ha, &mr);
+				ha->ledstate.flags &= ~LED_ACTIVE;
+			} else {
+				mr.mb[1] = 0x4000;
+				mr.mb[2] = 0x4000;
+				mr.mb[3] = 0x4000;
+				mr.mb[4] = 0x2000;
+				mr.mb[5] = 0;
+				mr.mb[6] = 0x2000;
+				(void) ql_set_led_config(ha, &mr);
+				ha->ledstate.flags |= LED_ACTIVE;
+			}
+		} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
+			if (ha->ledstate.flags & LED_ACTIVE) {
+				(void) ql_write_remote_reg(ha,
+				    ha->ledstate.select,
+				    0x40004000);
+				(void) ql_write_remote_reg(ha,
+				    ha->ledstate.select + 4,
+				    0x40004000);
+				ha->ledstate.flags &= ~LED_ACTIVE;
+			} else {
+				(void) ql_write_remote_reg(ha,
+				    ha->ledstate.select,
+				    0x40002000);
+				(void) ql_write_remote_reg(ha,
+				    ha->ledstate.select + 4,
+				    0x40002000);
+				ha->ledstate.flags |= LED_ACTIVE;
+			}
+		} else if (!CFG_IST(ha, CFG_CTRL_27XX)) {
+			EL(ha, "unsupported HBA: %xh\n", ha->device_id);
+		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -6059,11 +6319,10 @@
 static void
 ql_drive_led(ql_adapter_state_t *ha, uint32_t LEDflags)
 {
+	QL_PRINT_9(ha, "started\n");
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	if (CFG_IST(ha, CFG_CTRL_2363)) {
 
-	if (CFG_IST(ha, (CFG_CTRL_2300 | CFG_CTRL_6322))) {
-
 		uint16_t	gpio_enable, gpio_data;
 
 		/* setup to send new data */
@@ -6081,8 +6340,7 @@
 		/* write out the new led data */
 		WRT16_IO_REG(ha, gpiod, gpio_data);
 
-	} else if (CFG_IST(ha, CFG_CTRL_24258081)) {
-
+	} else if (CFG_IST(ha, CFG_CTRL_2425)) {
 		uint32_t	gpio_data;
 
 		/* setup to send new data */
@@ -6101,10 +6359,10 @@
 		WRT32_IO_REG(ha, gpiod, gpio_data);
 
 	} else {
-		EL(ha, "unsupported HBA: %xh", ha->device_id);
+		EL(ha, "unsupported HBA: %xh\n", ha->device_id);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -6117,36 +6375,108 @@
  * Context:
  *	Kernel/Interrupt context.
  */
-static uint32_t
+static int
 ql_setup_led(ql_adapter_state_t *ha)
 {
-	uint32_t	rval;
+	int		rval = QL_SUCCESS;
 	ql_mbx_data_t	mr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	/* decouple the LED control from the fw */
-	rval = ql_get_firmware_option(ha, &mr);
-	if (rval != QL_SUCCESS) {
-		EL(ha, "failed, get_firmware_option=%xh\n", rval);
-		return (rval);
-	}
+	if (CFG_IST(ha, CFG_CTRL_2363 | CFG_CTRL_2425)) {
+		/* decouple the LED control from the fw */
+		rval = ql_get_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_firmware_option=%xh\n", rval);
+			return (rval);
+		}
 
-	/* set the appropriate options */
-	mr.mb[1] = (uint16_t)(mr.mb[1] | FO1_DISABLE_GPIO);
+		/* set the appropriate options */
+		mr.mb[1] = (uint16_t)(mr.mb[1] | FO1_DISABLE_GPIO);
 
-	/* send it back to the firmware */
-	rval = ql_set_firmware_option(ha, &mr);
-	if (rval != QL_SUCCESS) {
-		EL(ha, "failed, set_firmware_option=%xh\n", rval);
-		return (rval);
-	}
+		/* send it back to the firmware */
+		rval = ql_set_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, set_firmware_option=%xh\n", rval);
+			return (rval);
+		}
 
-	/* initally, turn the LED's off */
-	ql_drive_led(ha, LED_ALL_OFF);
+		/* initally, turn the LED's off */
+		ql_drive_led(ha, LED_ALL_OFF);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	} else if (CFG_IST(ha, CFG_CTRL_81XX)) {
+		(void) ql_get_led_config(ha, &ha->ledstate.cfg);
+		mr.mb[1] = 0x2000;
+		mr.mb[2] = 0x2000;
+		rval = ql_set_led_config(ha, &mr);
 
+	} else if (CFG_IST(ha, CFG_CTRL_80XX)) {
+		/* Save initial value */
+		rval = ql_get_led_config(ha, &ha->ledstate.cfg);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_led_config=%xh\n", rval);
+			return (rval);
+		}
+		mr.mb[1] = 0x4000;
+		mr.mb[2] = 0x4000;
+		mr.mb[3] = 0x4000;
+		mr.mb[4] = 0x2000;
+		mr.mb[5] = 0;
+		mr.mb[6] = 0x2000;
+		rval = ql_set_led_config(ha, &mr);
+
+	} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
+		rval = ql_get_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+		mr.mb[1] = (uint16_t)(mr.mb[1] | FO1_DISABLE_LEDS);
+
+		rval = ql_set_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, set_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+		(void) ql_write_remote_reg(ha, ha->ledstate.select,
+		    0x40002000);
+		(void) ql_write_remote_reg(ha, ha->ledstate.select + 4,
+		    0x40002000);
+
+	} else if (CFG_IST(ha, CFG_CTRL_27XX)) {
+		/* take control of LED */
+		rval = ql_get_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+		mr.mb[1] = (uint16_t)(mr.mb[1] | FO1_DISABLE_LEDS);
+
+		rval = ql_set_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, set_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+		mr.mb[1] = 0xf;
+		mr.mb[2] = 0x230;
+		mr.mb[3] = 0x230;
+		mr.mb[4] = 0x4000;
+		rval = ql_led_config(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, led_config=%xh\n", rval);
+			return (rval);
+		}
+	} else {
+		EL(ha, "unsupported HBA: %xh\n", ha->device_id);
+	}
+	ha->ledstate.flags |= LED_ACTIVE;
+
+	QL_PRINT_9(ha, "done\n");
+
 	return (rval);
 }
 
@@ -6160,45 +6490,67 @@
  * Context:
  *	Kernel/Interrupt context.
  */
-static uint32_t
+static int
 ql_wrapup_led(ql_adapter_state_t *ha)
 {
-	uint32_t	rval;
+	int		rval = QL_SUCCESS;
 	ql_mbx_data_t	mr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	/* Turn all LED's off */
-	ql_drive_led(ha, LED_ALL_OFF);
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
-
+	if (CFG_IST(ha, CFG_CTRL_2363 | CFG_CTRL_2425)) {
 		uint32_t	gpio_data;
 
-		/* disable the LED update mask */
-		gpio_data = RD32_IO_REG(ha, gpiod);
-		gpio_data &= ~LED_MASK_UPDATE_24;
+		/* Turn all LED's off */
+		ql_drive_led(ha, LED_ALL_OFF);
 
-		/* write out the data */
-		WRT32_IO_REG(ha, gpiod, gpio_data);
-	}
+		if (CFG_IST(ha, CFG_CTRL_2425)) {
+			/* disable the LED update mask */
+			gpio_data = RD32_IO_REG(ha, gpiod);
+			gpio_data &= ~LED_MASK_UPDATE_24;
 
-	/* give LED control back to the f/w */
-	rval = ql_get_firmware_option(ha, &mr);
-	if (rval != QL_SUCCESS) {
-		EL(ha, "failed, get_firmware_option=%xh\n", rval);
-		return (rval);
-	}
+			/* write out the data */
+			WRT32_IO_REG(ha, gpiod, gpio_data);
+			/* give LED control back to the f/w */
+		}
+		rval = ql_get_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_firmware_option=%xh\n", rval);
+			return (rval);
+		}
 
-	mr.mb[1] = (uint16_t)(mr.mb[1] & ~FO1_DISABLE_GPIO);
+		mr.mb[1] = (uint16_t)(mr.mb[1] & ~FO1_DISABLE_GPIO);
 
-	rval = ql_set_firmware_option(ha, &mr);
-	if (rval != QL_SUCCESS) {
-		EL(ha, "failed, set_firmware_option=%xh\n", rval);
-		return (rval);
+		rval = ql_set_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, set_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+	} else if (CFG_IST(ha, CFG_CTRL_8081)) {
+		rval = ql_set_led_config(ha, &ha->ledstate.cfg);
+
+	} else if (CFG_IST(ha, CFG_CTRL_2783)) {
+		/* give LED control back to the f/w */
+		rval = ql_get_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, get_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+		mr.mb[1] = (uint16_t)(mr.mb[1] & ~FO1_DISABLE_LEDS);
+
+		rval = ql_set_firmware_option(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, set_firmware_option=%xh\n", rval);
+			return (rval);
+		}
+
+	} else {
+		EL(ha, "unsupported HBA: %xh\n", ha->device_id);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -6232,7 +6584,7 @@
 	int			rval = 0;
 	EXT_DEVICEDATAENTRY	*uddep, *ddep;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	ddep = &dd.EntryList[0];
 
@@ -6291,7 +6643,8 @@
 		    link = link->next) {
 			tq = link->base_address;
 			if (tq->flags & TQF_INITIATOR_DEVICE ||
-			    !VALID_TARGET_ID(ha, tq->loop_id)) {
+			    !VALID_TARGET_ID(ha, tq->loop_id) ||
+			    tq->d_id.b24 == FS_MANAGEMENT_SERVER) {
 				continue;	/* Skip this one */
 			}
 
@@ -6309,7 +6662,7 @@
 
 			ddep->DeviceFlags = tq->flags;
 			ddep->LoopID = tq->loop_id;
-			QL_PRINT_9(CE_CONT, "(%d): Tgt=%lld, loop=%xh, "
+			QL_PRINT_9(ha, "Tgt=%lld, loop=%xh, "
 			    "wwnn=%02x%02x%02x%02x%02x%02x%02x%02x, "
 			    "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 			    ha->instance, ddep->TargetAddress.Target,
@@ -6345,7 +6698,7 @@
 		EL(ha, "failed, ddi_copyout-2\n");
 	} else {
 		cmd->ResponseLen += (uint32_t)sizeof (EXT_DEVICEDATAENTRY);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -6374,7 +6727,7 @@
 	uint8_t			wwpn[EXT_DEF_WWN_NAME_SIZE];
 	ql_tgt_t		*tq;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
 	    (void*)wwpn, sizeof (EXT_DEST_ADDR), mode) != 0) {
@@ -6386,7 +6739,7 @@
 
 	qlnt = QLNT_PORT;
 	name = wwpn;
-	QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
+	QL_PRINT_9(ha, "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 	    ha->instance, name[0], name[1], name[2], name[3], name[4],
 	    name[5], name[6], name[7]);
 
@@ -6408,7 +6761,7 @@
 		cmd->ResponseLen = 0;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -6438,13 +6791,10 @@
 	ql_fcache_t	*tail = NULL;
 	ql_fcache_t	*ftmp;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_10(ha, "started cfg=0x%llx\n", ha->cfg_flags);
 
-	CACHE_LOCK(ha);
-
 	/* If we already have populated it, rtn */
 	if (ha->fcache != NULL) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "buffer already populated\n");
 		return (QL_SUCCESS);
 	}
@@ -6452,7 +6802,6 @@
 	ql_flash_nvram_defaults(ha);
 
 	if ((rval = ql_setup_flash(ha)) != QL_SUCCESS) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "unable to setup flash; rval=%xh\n", rval);
 		return (rval);
 	}
@@ -6475,7 +6824,7 @@
 
 		/* Do the firmware node first for 24xx/25xx's */
 		if (fw_done == 0) {
-			if (CFG_IST(ha, CFG_CTRL_24258081)) {
+			if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 				freadpos = ha->flash_fw_addr << 2;
 			}
 			fw_done = 1;
@@ -6510,9 +6859,8 @@
 		EL(ha, "failed, done\n");
 	} else {
 		ha->fcache = head;
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_10(ha, "done\n");
 	}
-	CACHE_UNLOCK(ha);
 
 	return (rval);
 }
@@ -6543,7 +6891,7 @@
 	ql_fcache_t	*tail = NULL;
 	ql_fcache_t	*ftmp;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	while (freadpos != 0xffffffff) {
 
@@ -6565,7 +6913,7 @@
 
 		/* Do the firmware node first for 24xx's */
 		if (fw_done == 0) {
-			if (CFG_IST(ha, CFG_CTRL_24258081)) {
+			if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 				freadpos = ha->flash_fw_addr << 2;
 			}
 			fw_done = 1;
@@ -6572,13 +6920,13 @@
 		}
 
 		/* read in first FBUFSIZE bytes of this flash section */
-		if (freadpos+FBUFSIZE > bsize) {
+		if (freadpos + FBUFSIZE > bsize) {
 			EL(ha, "passed buffer too small; fr=%xh, bsize=%xh\n",
 			    freadpos, bsize);
 			rval = QL_FUNCTION_FAILED;
 			break;
 		}
-		bcopy(bfp+freadpos, ftmp->buf, FBUFSIZE);
+		bcopy(bfp + freadpos, ftmp->buf, FBUFSIZE);
 
 		/* checkout the pci data / format */
 		if (ql_check_pci(ha, ftmp, &freadpos)) {
@@ -6598,12 +6946,10 @@
 		/*
 		 * Release previous fcache resources and update with new
 		 */
-		CACHE_LOCK(ha);
 		ql_fcache_rel(ha->fcache);
 		ha->fcache = head;
-		CACHE_UNLOCK(ha);
 
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 }
 
@@ -6691,7 +7037,7 @@
 	ql_link_t		*link;
 	ql_adapter_state_t	*ha2;
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Get base path length. */
 	for (len = (uint32_t)strlen(ha->devpath); len; len--) {
@@ -6709,22 +7055,20 @@
 			continue;
 		}
 
-		CACHE_LOCK(ha2);
 		ql_fcache_rel(ha2->fcache);
 		ha2->fcache = NULL;
 
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			if (ha2->vcache != NULL) {
 				kmem_free(ha2->vcache, QL_24XX_VPD_SIZE);
 				ha2->vcache = NULL;
 			}
 		}
-		CACHE_UNLOCK(ha2);
 
 		(void) ql_setup_fcache(ha2);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 }
 
 /*
@@ -6784,7 +7128,7 @@
 	uint32_t	doff;
 	uint8_t		*pciinfo;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (fcache != NULL) {
 		pciinfo = fcache->buf;
@@ -6821,8 +7165,7 @@
 
 		*nextpos = 0xffffffff;
 
-		QL_PRINT_9(CE_CONT, "(%d): CFG_SBUS_CARD, done\n",
-		    ha->instance);
+		QL_PRINT_3(ha, "CFG_SBUS_CARD, done\n");
 
 		return (0);
 	}
@@ -6871,16 +7214,10 @@
 		    "%d.%02d.%02d", fcache->buf[19], fcache->buf[23],
 		    fcache->buf[27]);
 
-		if (CFG_IST(ha, CFG_CTRL_81XX)) {
-			*nextpos = 0x200000;
-		} else if (CFG_IST(ha, CFG_CTRL_8021)) {
-			*nextpos = 0x80000;
-		} else {
-			*nextpos = 0;
-		}
+		*nextpos = ha->boot_code_addr << 2;
 		kmem_free(buf, FBUFSIZE);
 
-		QL_PRINT_9(CE_CONT, "(%d): FTYPE_FW, done\n", ha->instance);
+		QL_PRINT_3(ha, "FTYPE_FW, done\n");
 
 		return (0);
 	}
@@ -6908,8 +7245,8 @@
 	}
 
 	if (pcid->indicator == PCI_IND_LAST_IMAGE) {
-		QL_PRINT_9(CE_CONT, "(%d): last image\n", ha->instance);
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		QL_PRINT_3(ha, "last image\n");
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			ql_flash_layout_table(ha, *nextpos +
 			    (pcid->imagelength[0] | (pcid->imagelength[1] <<
 			    8)) * PCI_SECTOR_SIZE);
@@ -6943,7 +7280,7 @@
 	(void) snprintf(fcache->verstr, FCHBA_OPTION_ROM_VERSION_LEN,
 	    "%d.%02d", pcid->revisionlevel[1], pcid->revisionlevel[0]);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (0);
 }
@@ -6968,7 +7305,7 @@
 	uint32_t	len, faddr, cnt;
 	uint16_t	chksum, w16;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Process flash layout table header */
 	len = sizeof (ql_flt_ptr_t);
@@ -6993,7 +7330,8 @@
 	}
 	if (chksum != 0 || fptr->sig[0] != 'Q' || fptr->sig[1] != 'F' ||
 	    fptr->sig[2] != 'L' || fptr->sig[3] != 'T') {
-		EL(ha, "ptr chksum=%xh, sig=%c%c%c%c\n", chksum, fptr->sig[0],
+		EL(ha, "ptr chksum=%xh, sig=%c%c%c%c \n",
+		    chksum, fptr->sig[0],
 		    fptr->sig[1], fptr->sig[2], fptr->sig[3]);
 		kmem_free(bp, len);
 		return;
@@ -7005,7 +7343,7 @@
 
 	ql_process_flt(ha, faddr);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7029,7 +7367,7 @@
 	uint32_t	len, cnt, fe_addr;
 	uint16_t	chksum, w16;
 
-	QL_PRINT_9(CE_CONT, "(%d): started faddr=%xh\n", ha->instance, faddr);
+	QL_PRINT_9(ha, "started faddr=%xh\n", faddr);
 
 	/* Process flash layout table header */
 	if ((bp = kmem_zalloc(FLASH_LAYOUT_TABLE_SIZE, KM_SLEEP)) == NULL) {
@@ -7067,7 +7405,7 @@
 
 	/* Process Function/Port Configuration Map. */
 	nv_rg = vpd_rg = 0;
-	if (CFG_IST(ha, CFG_CTRL_8021)) {
+	if (CFG_IST(ha, CFG_CTRL_82XX)) {
 		uint16_t	i;
 		uint8_t		*mbp = eaddr;
 		ql_fp_cfg_map_t	*cmp = (ql_fp_cfg_map_t *)mbp;
@@ -7090,7 +7428,7 @@
 		    cmp->hdr.Signature[2] != 'C' ||
 		    cmp->hdr.Signature[3] != 'M') {
 			EL(ha, "cfg_map chksum=%xh, version=%d, "
-			    "sig=%c%c%c%c\n", chksum, w16,
+			    "sig=%c%c%c%c \n", chksum, w16,
 			    cmp->hdr.Signature[0], cmp->hdr.Signature[1],
 			    cmp->hdr.Signature[2], cmp->hdr.Signature[3]);
 		} else {
@@ -7101,7 +7439,7 @@
 			for (i = 0; i < cnt; i++) {
 				if (cmp->cfg[i].FunctionType == FT_FC &&
 				    cmp->cfg[i].FunctionNumber[0] ==
-				    ha->function_number &&
+				    ha->pci_function_number &&
 				    cmp->cfg[i].FunctionNumber[1] == 0) {
 					nv_rg = cmp->cfg[i].ConfigRegion;
 					vpd_rg = cmp->cfg[i].VpdRegion;
@@ -7131,8 +7469,8 @@
 		case FLASH_8021_BOOTLOADER_REGION:
 			ha->bootloader_addr = faddr;
 			ha->bootloader_size = (fe_addr - faddr) + 1;
-			QL_PRINT_9(CE_CONT, "(%d): bootloader_addr=%xh, "
-			    "size=%xh\n", ha->instance, faddr,
+			QL_PRINT_9(ha, "bootloader_addr=%xh, "
+			    "size=%xh\n", faddr,
 			    ha->bootloader_size);
 			break;
 		case FLASH_FW_REGION:
@@ -7139,21 +7477,21 @@
 		case FLASH_8021_FW_REGION:
 			ha->flash_fw_addr = faddr;
 			ha->flash_fw_size = (fe_addr - faddr) + 1;
-			QL_PRINT_9(CE_CONT, "(%d): flash_fw_addr=%xh, "
-			    "size=%xh\n", ha->instance, faddr,
+			QL_PRINT_9(ha, "flash_fw_addr=%xh, "
+			    "size=%xh\n", faddr,
 			    ha->flash_fw_size);
 			break;
 		case FLASH_GOLDEN_FW_REGION:
 		case FLASH_8021_GOLDEN_FW_REGION:
 			ha->flash_golden_fw_addr = faddr;
-			QL_PRINT_9(CE_CONT, "(%d): flash_golden_fw_addr=%xh\n",
+			QL_PRINT_9(ha, "flash_golden_fw_addr=%xh\n",
 			    ha->instance, faddr);
 			break;
 		case FLASH_8021_VPD_REGION:
 			if (!vpd_rg || vpd_rg == FLASH_8021_VPD_REGION) {
 				ha->flash_vpd_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): 8021_flash_vpd_"
-				    "addr=%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "8021_flash_vpd_"
+				    "addr=%xh\n", faddr);
 			}
 			break;
 		case FLASH_VPD_0_REGION:
@@ -7160,15 +7498,15 @@
 			if (vpd_rg) {
 				if (vpd_rg == FLASH_VPD_0_REGION) {
 					ha->flash_vpd_addr = faddr;
-					QL_PRINT_9(CE_CONT, "(%d): vpd_rg  "
+					QL_PRINT_9(ha, "vpd_rg  "
 					    "flash_vpd_addr=%xh\n",
 					    ha->instance, faddr);
 				}
-			} else if (!(ha->flags & FUNCTION_1) &&
-			    !(CFG_IST(ha, CFG_CTRL_8021))) {
+			} else if (ha->function_number == 0 &&
+			    !(CFG_IST(ha, CFG_CTRL_82XX))) {
 				ha->flash_vpd_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_vpd_addr=%xh"
-				    "\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_vpd_addr=%xh"
+				    "\n", faddr);
 			}
 			break;
 		case FLASH_NVRAM_0_REGION:
@@ -7175,17 +7513,17 @@
 			if (nv_rg) {
 				if (nv_rg == FLASH_NVRAM_0_REGION) {
 					ADAPTER_STATE_LOCK(ha);
-					ha->flags &= ~FUNCTION_1;
+					ha->function_number = 0;
 					ADAPTER_STATE_UNLOCK(ha);
 					ha->flash_nvram_addr = faddr;
-					QL_PRINT_9(CE_CONT, "(%d): nv_rg "
+					QL_PRINT_9(ha, "nv_rg "
 					    "flash_nvram_addr=%xh\n",
 					    ha->instance, faddr);
 				}
-			} else if (!(ha->flags & FUNCTION_1)) {
+			} else if (ha->function_number == 0) {
 				ha->flash_nvram_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_nvram_addr="
-				    "%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_nvram_addr="
+				    "%xh\n", faddr);
 			}
 			break;
 		case FLASH_VPD_1_REGION:
@@ -7192,15 +7530,15 @@
 			if (vpd_rg) {
 				if (vpd_rg == FLASH_VPD_1_REGION) {
 					ha->flash_vpd_addr = faddr;
-					QL_PRINT_9(CE_CONT, "(%d): vpd_rg "
+					QL_PRINT_9(ha, "vpd_rg "
 					    "flash_vpd_addr=%xh\n",
 					    ha->instance, faddr);
 				}
-			} else if (ha->flags & FUNCTION_1 &&
-			    !(CFG_IST(ha, CFG_CTRL_8021))) {
+			} else if (ha->function_number &&
+			    !(CFG_IST(ha, CFG_CTRL_82XX))) {
 				ha->flash_vpd_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_vpd_addr=%xh"
-				    "\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_vpd_addr=%xh"
+				    "\n", faddr);
 			}
 			break;
 		case FLASH_NVRAM_1_REGION:
@@ -7207,38 +7545,38 @@
 			if (nv_rg) {
 				if (nv_rg == FLASH_NVRAM_1_REGION) {
 					ADAPTER_STATE_LOCK(ha);
-					ha->flags |= FUNCTION_1;
+					ha->function_number = 1;
 					ADAPTER_STATE_UNLOCK(ha);
 					ha->flash_nvram_addr = faddr;
-					QL_PRINT_9(CE_CONT, "(%d): nv_rg "
+					QL_PRINT_9(ha, "nv_rg "
 					    "flash_nvram_addr=%xh\n",
 					    ha->instance, faddr);
 				}
-			} else if (ha->flags & FUNCTION_1) {
+			} else if (ha->function_number) {
 				ha->flash_nvram_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_nvram_addr="
-				    "%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_nvram_addr="
+				    "%xh\n", faddr);
 			}
 			break;
 		case FLASH_DESC_TABLE_REGION:
-			if (!(CFG_IST(ha, CFG_CTRL_8021))) {
+			if (!(CFG_IST(ha, CFG_CTRL_82XX))) {
 				ha->flash_desc_addr = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_desc_addr="
-				    "%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_desc_addr="
+				    "%xh\n", faddr);
 			}
 			break;
 		case FLASH_ERROR_LOG_0_REGION:
-			if (!(ha->flags & FUNCTION_1)) {
+			if (ha->function_number == 0) {
 				ha->flash_errlog_start = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_errlog_addr="
-				    "%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_errlog_addr="
+				    "%xh\n", faddr);
 			}
 			break;
 		case FLASH_ERROR_LOG_1_REGION:
-			if (ha->flags & FUNCTION_1) {
+			if (ha->function_number) {
 				ha->flash_errlog_start = faddr;
-				QL_PRINT_9(CE_CONT, "(%d): flash_errlog_addr="
-				    "%xh\n", ha->instance, faddr);
+				QL_PRINT_9(ha, "flash_errlog_addr="
+				    "%xh\n", faddr);
 			}
 			break;
 		default:
@@ -7247,7 +7585,7 @@
 	}
 	kmem_free(bp, FLASH_LAYOUT_TABLE_SIZE);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7266,13 +7604,43 @@
 static void
 ql_flash_nvram_defaults(ql_adapter_state_t *ha)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_10(ha, "started\n");
 
-	if (ha->flags & FUNCTION_1) {
-		if (CFG_IST(ha, CFG_CTRL_2300)) {
+	if (ha->function_number == 3) {
+		if (CFG_IST(ha, CFG_CTRL_27XX)) {
+			ha->flash_nvram_addr = NVRAM_2700_FUNC3_ADDR;
+			ha->flash_vpd_addr = VPD_2700_FUNC3_ADDR;
+			ha->ledstate.select = BEACON_2700_FUNC3_ADDR;
+			ha->flash_data_addr = FLASH_2700_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_2700_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_2700_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_2700_FIRMWARE_SIZE;
+			ha->boot_code_addr = FLASH_2700_BOOT_CODE_ADDR;
+		} else {
+			EL(ha, "unassigned flash fn%d addr: %x\n",
+			    ha->function_number, ha->device_id);
+		}
+	} else if (ha->function_number == 2) {
+		if (CFG_IST(ha, CFG_CTRL_27XX)) {
+			ha->flash_nvram_addr = NVRAM_2700_FUNC2_ADDR;
+			ha->flash_vpd_addr = VPD_2700_FUNC2_ADDR;
+			ha->ledstate.select = BEACON_2700_FUNC2_ADDR;
+			ha->flash_data_addr = FLASH_2700_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_2700_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_2700_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_2700_FIRMWARE_SIZE;
+			ha->boot_code_addr = FLASH_2700_BOOT_CODE_ADDR;
+		} else {
+			EL(ha, "unassigned flash fn%d addr: %x\n",
+			    ha->function_number, ha->device_id);
+		}
+	} else if (ha->function_number == 1) {
+		if (CFG_IST(ha, CFG_CTRL_23XX) ||
+		    (CFG_IST(ha, CFG_CTRL_63XX))) {
 			ha->flash_nvram_addr = NVRAM_2300_FUNC1_ADDR;
 			ha->flash_fw_addr = FLASH_2300_FIRMWARE_ADDR;
-		} else if (CFG_IST(ha, CFG_CTRL_2422)) {
+			ha->boot_code_addr = FLASH_2300_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_24XX)) {
 			ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_2400_FUNC1_ADDR;
 			ha->flash_vpd_addr = VPD_2400_FUNC1_ADDR;
@@ -7279,6 +7647,7 @@
 			ha->flash_errlog_start = FLASH_2400_ERRLOG_START_ADDR_1;
 			ha->flash_desc_addr = FLASH_2400_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_2400_FIRMWARE_ADDR;
+			ha->boot_code_addr = FLASH_2400_BOOT_CODE_ADDR;
 		} else if (CFG_IST(ha, CFG_CTRL_25XX)) {
 			ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_2500_FUNC1_ADDR;
@@ -7286,6 +7655,7 @@
 			ha->flash_errlog_start = FLASH_2500_ERRLOG_START_ADDR_1;
 			ha->flash_desc_addr = FLASH_2500_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_2500_FIRMWARE_ADDR;
+			ha->boot_code_addr = FLASH_2500_BOOT_CODE_ADDR;
 		} else if (CFG_IST(ha, CFG_CTRL_81XX)) {
 			ha->flash_data_addr = FLASH_8100_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_8100_FUNC1_ADDR;
@@ -7293,7 +7663,8 @@
 			ha->flash_errlog_start = FLASH_8100_ERRLOG_START_ADDR_1;
 			ha->flash_desc_addr = FLASH_8100_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_8100_FIRMWARE_ADDR;
-		} else if (CFG_IST(ha, CFG_CTRL_8021)) {
+			ha->boot_code_addr = FLASH_8100_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
 			ha->flash_data_addr = 0;
 			ha->flash_nvram_addr = NVRAM_8021_FUNC1_ADDR;
 			ha->flash_vpd_addr = VPD_8021_FUNC1_ADDR;
@@ -7303,16 +7674,43 @@
 			ha->flash_fw_size = FLASH_8021_FIRMWARE_SIZE;
 			ha->bootloader_addr = FLASH_8021_BOOTLOADER_ADDR;
 			ha->bootloader_size = FLASH_8021_BOOTLOADER_SIZE;
+			ha->boot_code_addr = FLASH_8021_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
+			ha->flash_nvram_addr = NVRAM_8300_FC_FUNC1_ADDR;
+			ha->flash_vpd_addr = VPD_8300_FC_FUNC1_ADDR;
+			ha->ledstate.select = BEACON_8300_FC_FUNC1_ADDR;
+			ha->flash_errlog_start = FLASH_8300_ERRLOG_START_ADDR_1;
+			ha->flash_data_addr = FLASH_8300_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_8300_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_8300_FC_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_8300_FIRMWARE_SIZE;
+			ha->bootloader_addr = FLASH_8300_BOOTLOADER_ADDR;
+			ha->bootloader_size = FLASH_8300_BOOTLOADER_SIZE;
+			ha->boot_code_addr = FLASH_8300_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_27XX)) {
+			ha->flash_nvram_addr = NVRAM_2700_FUNC1_ADDR;
+			ha->flash_vpd_addr = VPD_2700_FUNC1_ADDR;
+			ha->ledstate.select = BEACON_2700_FUNC1_ADDR;
+			ha->flash_data_addr = FLASH_2700_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_2700_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_2700_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_2700_FIRMWARE_SIZE;
+			ha->boot_code_addr = FLASH_2700_BOOT_CODE_ADDR;
+		} else {
+			EL(ha, "unassigned flash fn%d addr: %x\n",
+			    ha->function_number, ha->device_id);
 		}
-	} else {
-		if (CFG_IST(ha, CFG_CTRL_2200)) {
+	} else if (ha->function_number == 0) {
+		if (CFG_IST(ha, CFG_CTRL_22XX)) {
 			ha->flash_nvram_addr = NVRAM_2200_FUNC0_ADDR;
 			ha->flash_fw_addr = FLASH_2200_FIRMWARE_ADDR;
-		} else if (CFG_IST(ha, CFG_CTRL_2300) ||
-		    (CFG_IST(ha, CFG_CTRL_6322))) {
+			ha->boot_code_addr = FLASH_2200_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_23XX) ||
+		    (CFG_IST(ha, CFG_CTRL_63XX))) {
 			ha->flash_nvram_addr = NVRAM_2300_FUNC0_ADDR;
 			ha->flash_fw_addr = FLASH_2300_FIRMWARE_ADDR;
-		} else if (CFG_IST(ha, CFG_CTRL_2422)) {
+			ha->boot_code_addr = FLASH_2300_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_24XX)) {
 			ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_2400_FUNC0_ADDR;
 			ha->flash_vpd_addr = VPD_2400_FUNC0_ADDR;
@@ -7319,6 +7717,7 @@
 			ha->flash_errlog_start = FLASH_2400_ERRLOG_START_ADDR_0;
 			ha->flash_desc_addr = FLASH_2400_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_2400_FIRMWARE_ADDR;
+			ha->boot_code_addr = FLASH_2400_BOOT_CODE_ADDR;
 		} else if (CFG_IST(ha, CFG_CTRL_25XX)) {
 			ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_2500_FUNC0_ADDR;
@@ -7326,6 +7725,7 @@
 			ha->flash_errlog_start = FLASH_2500_ERRLOG_START_ADDR_0;
 			ha->flash_desc_addr = FLASH_2500_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_2500_FIRMWARE_ADDR;
+			ha->boot_code_addr = FLASH_2500_BOOT_CODE_ADDR;
 		} else if (CFG_IST(ha, CFG_CTRL_81XX)) {
 			ha->flash_data_addr = FLASH_8100_DATA_ADDR;
 			ha->flash_nvram_addr = NVRAM_8100_FUNC0_ADDR;
@@ -7333,7 +7733,8 @@
 			ha->flash_errlog_start = FLASH_8100_ERRLOG_START_ADDR_0;
 			ha->flash_desc_addr = FLASH_8100_DESCRIPTOR_TABLE;
 			ha->flash_fw_addr = FLASH_8100_FIRMWARE_ADDR;
-		} else if (CFG_IST(ha, CFG_CTRL_8021)) {
+			ha->boot_code_addr = FLASH_8100_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_82XX)) {
 			ha->flash_data_addr = 0;
 			ha->flash_nvram_addr = NVRAM_8021_FUNC0_ADDR;
 			ha->flash_vpd_addr = VPD_8021_FUNC0_ADDR;
@@ -7343,12 +7744,37 @@
 			ha->flash_fw_size = FLASH_8021_FIRMWARE_SIZE;
 			ha->bootloader_addr = FLASH_8021_BOOTLOADER_ADDR;
 			ha->bootloader_size = FLASH_8021_BOOTLOADER_SIZE;
+			ha->boot_code_addr = FLASH_8021_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
+			ha->flash_nvram_addr = NVRAM_8300_FC_FUNC0_ADDR;
+			ha->flash_vpd_addr = VPD_8300_FC_FUNC0_ADDR;
+			ha->ledstate.select = BEACON_8300_FCOE_FUNC0_ADDR;
+			ha->flash_errlog_start = FLASH_8300_ERRLOG_START_ADDR_0;
+			ha->flash_data_addr = FLASH_8300_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_8300_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_8300_FC_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_8300_FIRMWARE_SIZE;
+			ha->bootloader_addr = FLASH_8300_BOOTLOADER_ADDR;
+			ha->bootloader_size = FLASH_8300_BOOTLOADER_SIZE;
+			ha->boot_code_addr = FLASH_8300_BOOT_CODE_ADDR;
+		} else if (CFG_IST(ha, CFG_CTRL_27XX)) {
+			ha->flash_nvram_addr = NVRAM_2700_FUNC0_ADDR;
+			ha->flash_vpd_addr = VPD_2700_FUNC0_ADDR;
+			ha->ledstate.select = BEACON_2700_FUNC0_ADDR;
+			ha->flash_data_addr = FLASH_2700_DATA_ADDR;
+			ha->flash_desc_addr = FLASH_2700_DESCRIPTOR_TABLE;
+			ha->flash_fw_addr = FLASH_2700_FIRMWARE_ADDR;
+			ha->flash_fw_size = FLASH_2700_FIRMWARE_SIZE;
+			ha->boot_code_addr = FLASH_2700_BOOT_CODE_ADDR;
 		} else {
-			EL(ha, "unassigned flash fn0 addr: %x\n",
-			    ha->device_id);
+			EL(ha, "unassigned flash fn%d addr: %x\n",
+			    ha->function_number, ha->device_id);
 		}
+	} else {
+		EL(ha, "known function=%d, device_id=%x\n",
+		    ha->function_number, ha->device_id);
 	}
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_10(ha, "done\n");
 }
 
 /*
@@ -7369,9 +7795,9 @@
 static void
 ql_get_sfp(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		EL(ha, "failed, invalid request for HBA\n");
 		return;
@@ -7394,7 +7820,7 @@
 		cmd->Status = EXT_STATUS_OK;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7419,7 +7845,7 @@
 	int		rval2, rval = 0;
 	uint32_t	dxfer;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Get memory for SFP. */
 
@@ -7454,7 +7880,7 @@
 
 	ql_free_phys(ha, &mem);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -7484,9 +7910,9 @@
 	uint32_t		rval = QL_SUCCESS;
 	uint32_t		idma_rate;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_242581) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "invalid request for this HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -7518,12 +7944,13 @@
 
 	name = port_param.FCScsiAddr.DestAddr.WWPN;
 
-	QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
+	QL_PRINT_9(ha, "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
 	    ha->instance, name[0], name[1], name[2], name[3], name[4],
 	    name[5], name[6], name[7]);
 
 	tq = ql_find_port(ha, name, (uint16_t)QLNT_PORT);
-	if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id)) {
+	if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id) ||
+	    tq->d_id.b24 == FS_MANAGEMENT_SERVER) {
 		EL(ha, "failed, fc_port not found\n");
 		cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
 		cmd->ResponseLen = 0;
@@ -7568,6 +7995,14 @@
 				port_param.Speed =
 				    EXT_DEF_PORTSPEED_10GBIT;
 				break;
+			case IIDMA_RATE_16GB:
+				port_param.Speed =
+				    EXT_DEF_PORTSPEED_16GBIT;
+				break;
+			case IIDMA_RATE_32GB:
+				port_param.Speed =
+				    EXT_DEF_PORTSPEED_32GBIT;
+				break;
 			default:
 				port_param.Speed =
 				    EXT_DEF_PORTSPEED_UNKNOWN;
@@ -7610,8 +8045,14 @@
 			idma_rate = IIDMA_RATE_8GB;
 			break;
 		case EXT_DEF_PORTSPEED_10GBIT:
-			port_param.Speed = IIDMA_RATE_10GB;
+			idma_rate = IIDMA_RATE_10GB;
 			break;
+		case EXT_DEF_PORTSPEED_16GBIT:
+			idma_rate = IIDMA_RATE_16GB;
+			break;
+		case EXT_DEF_PORTSPEED_32GBIT:
+			idma_rate = IIDMA_RATE_32GB;
+			break;
 		default:
 			EL(ha, "invalid set iidma rate: %x\n",
 			    port_param.Speed);
@@ -7640,7 +8081,7 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7664,9 +8105,9 @@
 	int	rval;
 	caddr_t	payload;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "invalid request for this HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -7691,7 +8132,8 @@
 	}
 
 	/* Time Stamp */
-	rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_INSERT_TIME_STAMP);
+	rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_INSERT_TIME_STAMP,
+	    NULL);
 	if (rval != QL_SUCCESS) {
 		EL(ha, "f/w extended trace insert"
 		    "time stamp failed: %xh\n", rval);
@@ -7701,7 +8143,8 @@
 	}
 
 	/* Disable Tracing */
-	rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_EXT_TRACE_DISABLE);
+	rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_EXT_TRACE_DISABLE,
+	    NULL);
 	if (rval != QL_SUCCESS) {
 		EL(ha, "f/w extended trace disable failed: %xh\n", rval);
 		cmd->Status = EXT_STATUS_ERR;
@@ -7739,7 +8182,7 @@
 
 	kmem_free(payload, FWEXTSIZE);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7760,12 +8203,16 @@
 static void
 ql_get_fwfcetrace(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	int	rval;
-	caddr_t	payload;
+	int			rval;
+	caddr_t			fce_trace_p;
+	ql_mbx_data_t		mr;
+	EXT_FW_FCE_TRACE	*fce_trace;
+	size_t			cnt;
+	uint32_t		*bp;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "invalid request for this HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -7790,7 +8237,7 @@
 	}
 
 	/* Disable Tracing */
-	rval = ql_fw_etrace(ha, &ha->fwfcetracebuf, FTO_FCE_TRACE_DISABLE);
+	rval = ql_fw_etrace(ha, &ha->fwfcetracebuf, FTO_FCE_TRACE_DISABLE, &mr);
 	if (rval != QL_SUCCESS) {
 		EL(ha, "f/w FCE trace disable failed: %xh\n", rval);
 		cmd->Status = EXT_STATUS_ERR;
@@ -7799,25 +8246,53 @@
 	}
 
 	/* Allocate payload buffer */
-	payload = kmem_zalloc(FWEXTSIZE, KM_SLEEP);
-	if (payload == NULL) {
+	fce_trace = kmem_zalloc(FWFCESIZE, KM_SLEEP);
+	if (fce_trace == NULL) {
 		EL(ha, "failed, kmem_zalloc\n");
 		cmd->Status = EXT_STATUS_NO_MEMORY;
 		cmd->ResponseLen = 0;
 		return;
 	}
+	fce_trace_p = (caddr_t)&fce_trace->TraceData[0];
 
+	/* Copy In Ponter and Base Pointer values */
+	fce_trace->Registers[0] = mr.mb[2];
+	fce_trace->Registers[1] = mr.mb[3];
+	fce_trace->Registers[2] = mr.mb[4];
+	fce_trace->Registers[3] = mr.mb[5];
+
+	fce_trace->Registers[4] = LSW(ha->fwexttracebuf.cookies->dmac_address);
+	fce_trace->Registers[5] = MSW(ha->fwexttracebuf.cookies->dmac_address);
+	fce_trace->Registers[6] = LSW(ha->fwexttracebuf.cookies->dmac_notused);
+	fce_trace->Registers[7] = MSW(ha->fwexttracebuf.cookies->dmac_notused);
+
+	/* Copy FCE Trace Enable Registers */
+	fce_trace->Registers[8] = ha->fw_fce_trace_enable.mb[0];
+	fce_trace->Registers[9] = ha->fw_fce_trace_enable.mb[2];
+	fce_trace->Registers[10] = ha->fw_fce_trace_enable.mb[3];
+	fce_trace->Registers[11] = ha->fw_fce_trace_enable.mb[4];
+	fce_trace->Registers[12] = ha->fw_fce_trace_enable.mb[5];
+	fce_trace->Registers[13] = ha->fw_fce_trace_enable.mb[6];
+
 	/* Sync DMA buffer. */
 	(void) ddi_dma_sync(ha->fwfcetracebuf.dma_handle, 0,
 	    FWFCESIZE, DDI_DMA_SYNC_FORKERNEL);
 
 	/* Copy trace buffer data. */
-	ddi_rep_get8(ha->fwfcetracebuf.acc_handle, (uint8_t *)payload,
+	ddi_rep_get8(ha->fwfcetracebuf.acc_handle, (uint8_t *)fce_trace_p,
 	    (uint8_t *)ha->fwfcetracebuf.bp, FWFCESIZE,
 	    DDI_DEV_AUTOINCR);
 
+	/* Swap bytes in buffer in case of Big Endian */
+	bp = (uint32_t *)&fce_trace->TraceData[0];
+	for (cnt = 0; cnt < (FWFCESIZE / sizeof (uint32_t)); cnt++) {
+		LITTLE_ENDIAN_32(bp);
+		bp++;
+	}
+
 	/* Send payload to application. */
-	if (ql_send_buffer_data(payload, (caddr_t)(uintptr_t)cmd->ResponseAdr,
+	if (ql_send_buffer_data((caddr_t)fce_trace,
+	    (caddr_t)(uintptr_t)cmd->ResponseAdr,
 	    cmd->ResponseLen, mode) != cmd->ResponseLen) {
 		EL(ha, "failed, send_buffer_data\n");
 		cmd->Status = EXT_STATUS_COPY_ERR;
@@ -7826,9 +8301,19 @@
 		cmd->Status = EXT_STATUS_OK;
 	}
 
-	kmem_free(payload, FWFCESIZE);
+	/* Re-enable Tracing */
+	bzero(ha->fwfcetracebuf.bp, ha->fwfcetracebuf.size);
+	if ((rval = ql_fw_etrace(ha, &ha->fwfcetracebuf,
+	    FTO_FCE_TRACE_ENABLE, &mr)) != QL_SUCCESS) {
+		EL(ha, "fcetrace enable failed: %xh\n", rval);
+	} else {
+		ha->fw_fce_trace_enable = mr;
+		EL(ha, "FCE Trace Re-Enabled\n");
+	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	kmem_free(fce_trace, FWFCESIZE);
+
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7854,7 +8339,7 @@
 	uint8_t		cap_id;
 	uint32_t	buf_size = 256;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/*
 	 * First check the "Capabilities List" bit of the status register.
@@ -7897,7 +8382,7 @@
 		cmd->DetailStatus = buf_size;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -7919,7 +8404,7 @@
 	uint32_t	pci_os;
 	uint32_t	*ptr32, *org_ptr32;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	ptr32 = kmem_zalloc(pci_size, KM_SLEEP);
 	if (ptr32 == NULL) {
@@ -7946,7 +8431,7 @@
 
 	kmem_free(org_ptr32, pci_size);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -7972,7 +8457,7 @@
 	ql_mbx_data_t	mr;
 	int		rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
 		EL(ha, "failed, invalid request for HBA\n");
@@ -8029,7 +8514,7 @@
 
 	ql_restart_hba(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8053,7 +8538,7 @@
 	ql_mbx_iocb_t			*pkt;
 	EXT_MENLO_GET_FW_VERSION	ver = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
 		EL(ha, "failed, invalid request for HBA\n");
@@ -8111,7 +8596,7 @@
 
 	kmem_free(pkt, sizeof (ql_mbx_iocb_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8137,7 +8622,7 @@
 	uint32_t		*ptr32;
 	int			rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
 		EL(ha, "failed, invalid request for HBA\n");
@@ -8200,8 +8685,8 @@
 	/* Get DMA memory for the IOCB */
 	if (ql_get_dma_mem(ha, dma_mem, fw.TotalByteCount, LITTLE_ENDIAN_DMA,
 	    QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
-		cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
-		    "alloc failed", QL_NAME, ha->instance);
+		cmn_err(CE_WARN, "%srequest queue DMA memory "
+		    "alloc failed", QL_NAME);
 		kmem_free(pkt, sizeof (ql_mbx_iocb_t));
 		kmem_free(dma_mem, sizeof (dma_mem_t));
 		ql_restart_hba(ha);
@@ -8235,11 +8720,11 @@
 	pkt->mvfy.fw_size = LE_32(fw.TotalByteCount);
 	pkt->mvfy.fw_sequence_size = LE_32(fw.TotalByteCount);
 	pkt->mvfy.dseg_count = LE_16(1);
-	pkt->mvfy.dseg_0_address[0] = (uint32_t)
+	pkt->mvfy.dseg.address[0] = (uint32_t)
 	    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-	pkt->mvfy.dseg_0_address[1] = (uint32_t)
+	pkt->mvfy.dseg.address[1] = (uint32_t)
 	    LE_32(MSD(dma_mem->cookie.dmac_laddress));
-	pkt->mvfy.dseg_0_length = LE_32(fw.TotalByteCount);
+	pkt->mvfy.dseg.length = LE_32(fw.TotalByteCount);
 
 	rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, sizeof (ql_mbx_iocb_t));
 	LITTLE_ENDIAN_16(&pkt->mvfy.options_status);
@@ -8262,7 +8747,7 @@
 	kmem_free(dma_mem, sizeof (dma_mem_t));
 	ql_restart_hba(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8287,18 +8772,17 @@
 	EXT_MENLO_MANAGE_INFO	info;
 	int			rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 
 	/* The call is only supported for Schultz right now */
-	if (CFG_IST(ha, CFG_CTRL_8081)) {
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
 		ql_get_xgmac_statistics(ha, cmd, mode);
-		QL_PRINT_9(CE_CONT, "(%d): CFG_CTRL_81XX done\n",
-		    ha->instance);
+		QL_PRINT_9(ha, "CFG_FCOE_SUPPORT done\n");
 		return;
 	}
 
-	if (!CFG_IST(ha, CFG_CTRL_8081) || !CFG_IST(ha, CFG_CTRL_MENLO)) {
+	if (!CFG_IST(ha, CFG_CTRL_MENLO)) {
 		EL(ha, "failed, invalid request for HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -8356,8 +8840,8 @@
 		}
 		if (ql_get_dma_mem(ha, dma_mem, info.TotalByteCount,
 		    LITTLE_ENDIAN_DMA, QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
-			cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
-			    "alloc failed", QL_NAME, ha->instance);
+			cmn_err(CE_WARN, "%srequest queue DMA memory "
+			    "alloc failed", QL_NAME);
 			kmem_free(dma_mem, sizeof (dma_mem_t));
 			kmem_free(pkt, sizeof (ql_mbx_iocb_t));
 			cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
@@ -8382,11 +8866,11 @@
 			    dma_mem->size, DDI_DMA_SYNC_FORDEV);
 		}
 		pkt->mdata.dseg_count = LE_16(1);
-		pkt->mdata.dseg_0_address[0] = (uint32_t)
+		pkt->mdata.dseg.address[0] = (uint32_t)
 		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
-		pkt->mdata.dseg_0_address[1] = (uint32_t)
+		pkt->mdata.dseg.address[1] = (uint32_t)
 		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
-		pkt->mdata.dseg_0_length = LE_32(info.TotalByteCount);
+		pkt->mdata.dseg.length = LE_32(info.TotalByteCount);
 	} else if (info.Operation & MENLO_OP_CHANGE_CONFIG) {
 		pkt->mdata.parameter_1 =
 		    LE_32(info.Parameters.ap.MenloConfig.ConfigParamID);
@@ -8430,7 +8914,7 @@
 	kmem_free(dma_mem, sizeof (dma_mem_t));
 	kmem_free(pkt, sizeof (ql_mbx_iocb_t));
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8525,7 +9009,7 @@
 	int			rval;
 	char			name[MAXPATHLEN];
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/*
 	 * To be backward compatible with older API
@@ -8553,7 +9037,8 @@
 		ptmp_vp->VpCnt++;
 		ptmp_vp->VpId[id] = vha->vp_index;
 		(void) ddi_pathname(vha->dip, name);
-		(void) strcpy((char *)ptmp_vp->vp_path[id], name);
+		(void) strncpy((char *)ptmp_vp->vp_path[id], name,
+		    (sizeof (ptmp_vp->vp_path[id]) -1));
 		ptmp_vp->VpDrvInst[id] = (int32_t)vha->instance;
 		id++;
 		vha = vha->vp_next;
@@ -8567,10 +9052,10 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_VPORT_ID_CNT);
-		QL_PRINT_9(CE_CONT, "(%d): done, vport_cnt=%d\n",
+		QL_PRINT_9(ha, "done, vport_cnt=%d\n",
 		    ha->instance, ptmp_vp->VpCnt);
 	}
-
+	kmem_free(ptmp_vp, sizeof (EXT_VPORT_ID_CNT));
 }
 
 /*
@@ -8591,7 +9076,7 @@
 static void
 ql_vp_ioctl(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance,
+	QL_PRINT_9(ha, "started, cmd=%d\n",
 	    cmd->SubCode);
 
 	/* case off on command subcode */
@@ -8607,7 +9092,7 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8630,9 +9115,8 @@
 {
 	ql_adapter_state_t	*tmp_vha;
 	EXT_VPORT_INFO		tmp_vport = {0};
-	int			max_vport;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", vha->instance);
+	QL_PRINT_9(vha, "started\n", vha->instance);
 
 	if (cmd->ResponseLen < sizeof (EXT_VPORT_INFO)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
@@ -8657,10 +9141,8 @@
 		tmp_vha = tmp_vha->vp_next;
 	}
 
-	max_vport = (CFG_IST(vha, CFG_CTRL_2422) ? MAX_24_VIRTUAL_PORTS :
-	    MAX_25_VIRTUAL_PORTS);
-	if (max_vport > tmp_vport.used) {
-		tmp_vport.free = max_vport - tmp_vport.used;
+	if (vha->max_vports > tmp_vport.used) {
+		tmp_vport.free = vha->max_vports - tmp_vport.used;
 	}
 
 	if (ddi_copyout((void *)&tmp_vport,
@@ -8671,7 +9153,7 @@
 		EL(vha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_VPORT_INFO);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", vha->instance);
+		QL_PRINT_9(vha, "done\n", vha->instance);
 	}
 }
 
@@ -8695,8 +9177,17 @@
 {
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1) &&
+	    ql_stall_driver(ha, 0) != QL_SUCCESS) {
+		EL(ha, "ql_stall_driver failed\n");
+		ql_restart_driver(ha);
+		cmd->Status = EXT_STATUS_BUSY;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
 	switch (cmd->SubCode) {
 	case EXT_SC_FLASH_READ:
 		if ((rval = ql_flash_fcode_dump(ha,
@@ -8727,7 +9218,14 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	/* Resume I/O */
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
+		EL(ha, "isp_abort_needed for restart\n");
+		ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED,
+		    DRIVER_STALL);
+	}
+
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8747,19 +9245,39 @@
 static void
 ql_reset_cmd(ql_adapter_state_t *ha, EXT_IOCTL *cmd)
 {
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	uint8_t	timer;
 
+	QL_PRINT_9(ha, "started\n");
+
 	switch (cmd->SubCode) {
 	case EXT_SC_RESET_FC_FW:
-		EL(ha, "isp_abort_needed\n");
-		ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
+		if (CFG_IST(ha, CFG_CTRL_82XX)) {
+			(void) ql_8021_reset_fw(ha);
+		} else {
+			EL(ha, "isp_abort_needed\n");
+			ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
+		}
+		for (timer = 180; timer; timer--) {
+			ql_awaken_task_daemon(ha, NULL, 0, 0);
+			/* Delay for 1 second. */
+			delay(100);
+			if (!(ha->task_daemon_flags & (ISP_ABORT_NEEDED |
+			    ABORT_ISP_ACTIVE | LOOP_RESYNC_NEEDED |
+			    LOOP_RESYNC_ACTIVE))) {
+				break;
+			}
+		}
 		break;
 	case EXT_SC_RESET_MPI_FW:
-		if (!(CFG_IST(ha, CFG_CTRL_81XX))) {
+		if (!(CFG_IST(ha, CFG_CTRL_8081))) {
 			EL(ha, "invalid request for HBA\n");
 			cmd->Status = EXT_STATUS_INVALID_REQUEST;
 			cmd->ResponseLen = 0;
 		} else {
+			ADAPTER_STATE_LOCK(ha);
+			ha->flags |= DISABLE_NIC_FW_DMP;
+			ADAPTER_STATE_UNLOCK(ha);
+
 			/* Wait for I/O to stop and daemon to stall. */
 			if (ql_suspend_hba(ha, 0) != QL_SUCCESS) {
 				EL(ha, "ql_suspend_hba failed\n");
@@ -8769,7 +9287,6 @@
 				cmd->Status = EXT_STATUS_ERR;
 				cmd->ResponseLen = 0;
 			} else {
-				uint8_t	timer;
 				/*
 				 * While the restart_mpi mailbox cmd may be
 				 * done the MPI is not. Wait at least 6 sec. or
@@ -8785,6 +9302,10 @@
 				}
 			}
 			ql_restart_hba(ha);
+
+			ADAPTER_STATE_LOCK(ha);
+			ha->flags &= ~DISABLE_NIC_FW_DMP;
+			ADAPTER_STATE_UNLOCK(ha);
 		}
 		break;
 	default:
@@ -8794,7 +9315,7 @@
 		break;
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -8812,9 +9333,9 @@
 	uint8_t		*tmp_buf;
 	int		rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (!(CFG_IST(ha, CFG_CTRL_8081))) {
+	if (!(CFG_IST(ha, CFG_FCOE_SUPPORT))) {
 		EL(ha, "invalid request for HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -8850,7 +9371,7 @@
 		cmd->ResponseLen = 0;
 	} else {
 		cmd->ResponseLen = EXT_DEF_DCBX_PARAM_BUF_SIZE;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 	kmem_free(tmp_buf, EXT_DEF_DCBX_PARAM_BUF_SIZE);
 
@@ -8876,9 +9397,9 @@
 {
 	EXT_CNA_PORT	cna_port = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (!(CFG_IST(ha, CFG_CTRL_8081))) {
+	if (!(CFG_IST(ha, CFG_FCOE_SUPPORT))) {
 		EL(ha, "invalid request for HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -8907,7 +9428,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_CNA_PORT);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 }
 
@@ -8934,7 +9455,7 @@
 	uint32_t			ver_len, transfer_size;
 	PEXT_ADAPTERREGIONVERSION	padapter_ver = NULL;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* 8142s do not have a EDC PHY firmware. */
 	mpi_cap = (uint8_t)(ha->mpi_capability_list >> 8);
@@ -9008,7 +9529,7 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = ver_len;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	kmem_free(padapter_ver, ver_len);
@@ -9037,7 +9558,7 @@
 	int8_t			*tmp_buf;
 	EXT_MENLO_MANAGE_INFO	info;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/*  Verify the size of request structure. */
 	if (cmd->RequestLen < sizeof (EXT_MENLO_MANAGE_INFO)) {
@@ -9104,10 +9625,10 @@
 		cmd->ResponseLen = 0;
 	} else {
 		cmd->ResponseLen = info.TotalByteCount;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 	kmem_free(tmp_buf, size);
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 }
 
 /*
@@ -9127,9 +9648,9 @@
 	EXT_FCF_LIST		fcf_list = {0};
 	ql_fcf_list_desc_t	mb_fcf_list = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (!(CFG_IST(ha, CFG_CTRL_81XX))) {
+	if (!(CFG_IST(ha, CFG_FCOE_SUPPORT))) {
 		EL(ha, "invalid request for HBA\n");
 		cmd->Status = EXT_STATUS_INVALID_REQUEST;
 		cmd->ResponseLen = 0;
@@ -9189,7 +9710,7 @@
 		cmd->ResponseLen = 0;
 	} else {
 		cmd->ResponseLen = mb_fcf_list.buffer_size;
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	kmem_free(tmp_buf, fcf_list.BufSize);
@@ -9211,15 +9732,8 @@
 	ql_mbx_data_t		mr;
 	EXT_RESOURCE_CNTS	tmp_rc_cnt = {0};
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (!(CFG_IST(ha, CFG_CTRL_242581))) {
-		EL(ha, "invalid request for HBA\n");
-		cmd->Status = EXT_STATUS_INVALID_REQUEST;
-		cmd->ResponseLen = 0;
-		return;
-	}
-
 	if (cmd->ResponseLen < sizeof (EXT_RESOURCE_CNTS)) {
 		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
 		cmd->DetailStatus = sizeof (EXT_RESOURCE_CNTS);
@@ -9243,8 +9757,12 @@
 	tmp_rc_cnt.OrgXchgCtrlCnt = (uint32_t)mr.mb[6];
 	tmp_rc_cnt.CurIocbBufCnt = (uint32_t)mr.mb[7];
 	tmp_rc_cnt.OrgIocbBufCnt = (uint32_t)mr.mb[10];
-	tmp_rc_cnt.NoOfSupVPs = (uint32_t)mr.mb[11];
-	tmp_rc_cnt.NoOfSupFCFs = (uint32_t)mr.mb[12];
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		tmp_rc_cnt.NoOfSupVPs = (uint32_t)mr.mb[11];
+	}
+	if (CFG_IST(ha, CFG_FCOE_SUPPORT)) {
+		tmp_rc_cnt.NoOfSupFCFs = (uint32_t)mr.mb[12];
+	}
 
 	rval = ddi_copyout((void *)&tmp_rc_cnt,
 	    (void *)(uintptr_t)(cmd->ResponseAdr),
@@ -9255,6 +9773,952 @@
 		EL(ha, "failed, ddi_copyout\n");
 	} else {
 		cmd->ResponseLen = sizeof (EXT_RESOURCE_CNTS);
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
+}
+
+/*
+ * ql_get_temperature
+ *	Get ASIC temperature data
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	EXT_IOCTL cmd struct pointer.
+ *	mode:	flags
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_get_temperature(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	ql_mbx_data_t	mr;
+	int		rval = 0;
+	EXT_BOARD_TEMP	board_temp = {0};
+
+	QL_PRINT_9(ha, "started\n");
+
+	if (!(ha->fw_ext_attributes & TEMP_SUPPORT_ISP)) {
+		EL(ha, "invalid request for HBA\n");
+		cmd->Status = EXT_STATUS_INVALID_REQUEST;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	if (cmd->ResponseLen < sizeof (EXT_BOARD_TEMP)) {
+		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+		cmd->DetailStatus = sizeof (EXT_BOARD_TEMP);
+		EL(ha, "failed, ResponseLen < EXT_BOARD_TEMP, "
+		    "Len=%xh \n", cmd->ResponseLen);
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	switch (cmd->SubCode) {
+	case EXT_SC_GET_BOARD_TEMP:
+		rval = ql_get_temp(ha, &mr);
+		if (rval != QL_SUCCESS) {
+			/* error */
+			EL(ha, "failed, get_temperature_mbx=%xh\n", rval);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			break;
+		}
+		board_temp.IntTemp = mr.mb[1];
+
+		rval = ddi_copyout((void *)&board_temp,
+		    (void *)(uintptr_t)(cmd->ResponseAdr),
+		    sizeof (EXT_BOARD_TEMP), mode);
+		if (rval != 0) {
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+			EL(ha, "failed, ddi_copyout\n");
+		} else {
+			cmd->ResponseLen = sizeof (EXT_BOARD_TEMP);
+		}
+		break;
+	default:
+		EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
+		cmd->Status = EXT_STATUS_ERR;
+		cmd->ResponseLen = 0;
+		break;
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_dump_cmd
+ *	Performs all EXT_CC_DUMP_OS functions.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	Local EXT_IOCTL cmd struct pointer.
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_dump_cmd(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	caddr_t		dump;
+	uint32_t	sdm_valid_dump = 0;
+	int		rval = 0;
+
+	QL_PRINT_9(ha, "started\n");
+
+	if (ha->ql_dump_state & QL_DUMP_VALID &&
+	    !(ha->ql_dump_state & QL_DUMP_UPLOADED) &&
+	    ha->ql_dump_state != NULL) {
+		sdm_valid_dump = 1;
+	} else {
+		EL(ha, "dump does not exist for instance %d (%x, %p)\n",
+		    ha->instance, ha->ql_dump_state, ha->ql_dump_ptr);
+	}
+
+	cmd->Status = EXT_STATUS_OK;
+	cmd->DetailStatus = 0;
+
+	switch (cmd->SubCode) {
+	case EXT_SC_DUMP_SIZE:
+		cmd->ResponseLen = 0;
+		if (sdm_valid_dump) {
+			cmd->DetailStatus = ha->risc_dump_size;
+		}
+		break;
+	case EXT_SC_DUMP_READ:
+		if (!sdm_valid_dump) {
+			cmd->Status = EXT_STATUS_INVALID_REQUEST;
+			cmd->ResponseLen = 0;
+			break;
+		}
+
+		if (cmd->ResponseLen < ha->risc_dump_size) {
+			cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+			cmd->DetailStatus = ha->risc_dump_size;
+			EL(ha, "failed, ResponseLen < %x, "
+			    "Len=%xh\n", ha->risc_dump_size,
+			    cmd->ResponseLen);
+			break;
+		}
+
+		ADAPTER_STATE_LOCK(ha);
+		ha->flags |= DISABLE_NIC_FW_DMP;
+		ADAPTER_STATE_UNLOCK(ha);
+
+		QL_DUMP_LOCK(ha);
+
+		dump = kmem_zalloc(ha->risc_dump_size, KM_SLEEP);
+		cmd->ResponseLen = (uint32_t)ql_ascii_fw_dump(ha, dump);
+
+		if ((rval = ddi_copyout((void *)dump,
+		    (void *)(uintptr_t)(cmd->ResponseAdr), cmd->ResponseLen,
+		    mode)) != 0) {
+			ha->ql_dump_state &= ~QL_DUMP_UPLOADED;
+			EL(ha, "failed, ddi_copyout\n");
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+		} else {
+			ha->ql_dump_state |= QL_DUMP_UPLOADED;
+		}
+
+		kmem_free(dump, ha->risc_dump_size);
+
+		QL_DUMP_UNLOCK(ha);
+
+		ADAPTER_STATE_LOCK(ha);
+		ha->flags &= ~DISABLE_NIC_FW_DMP;
+		ADAPTER_STATE_UNLOCK(ha);
+		break;
+	case EXT_SC_DUMP_TRIGGER:
+		cmd->ResponseLen = 0;
+
+		ADAPTER_STATE_LOCK(ha);
+		ha->flags |= DISABLE_NIC_FW_DMP;
+		ADAPTER_STATE_UNLOCK(ha);
+
+		if (sdm_valid_dump) {
+			cmd->Status = EXT_STATUS_INVALID_REQUEST;
+			EL(ha, "Existing dump file needs to be retrieved.\n");
+		} else {
+			rval = ql_dump_firmware(ha);
+
+			if (rval != QL_SUCCESS && rval != QL_DATA_EXISTS) {
+				cmd->Status = EXT_STATUS_ERR;
+			}
+		}
+
+		ADAPTER_STATE_LOCK(ha);
+		ha->flags &= ~DISABLE_NIC_FW_DMP;
+		ADAPTER_STATE_UNLOCK(ha);
+		break;
+	default:
+		EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
+		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
+		cmd->ResponseLen = 0;
+		break;
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_serdes_reg
+ *	Performs all EXT_CC_SERDES_REG_OP functions.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	EXT_IOCTL cmd struct pointer.
+ *	mode:	flags
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_serdes_reg(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	ql_mbx_data_t	mr = {0};
+	int		rval = 0;
+	EXT_SERDES_REG	serdes_reg = {0};
+
+	QL_PRINT_9(ha, "started\n");
+
+	/* Check if request valid for HBA */
+	if (!(CFG_IST(ha, CFG_SERDES_SUPPORT))) {
+		EL(ha, "invalid request for HBA\n");
+		cmd->Status = EXT_STATUS_INVALID_REQUEST;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Copy in the request structure. */
+	if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
+	    (void *)&serdes_reg, sizeof (EXT_SERDES_REG), mode) != 0) {
+		EL(ha, "failed, ddi_copyin\n");
+		cmd->Status = EXT_STATUS_COPY_ERR;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	switch (cmd->SubCode) {
+	case EXT_SC_WRITE_SERDES_REG:
+		mr.mb[1] = serdes_reg.addr;
+		mr.mb[2] = LSB(serdes_reg.val);
+		mr.mb[3] = 0;
+		mr.mb[4] = MSB(serdes_reg.val);
+		if ((rval = ql_write_serdes(ha, &mr)) != QL_SUCCESS) {
+			/* error */
+			EL(ha, "failed, write_serdes_mbx=%xh\n", rval);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			break;
+		} else {
+			cmd->Status = EXT_STATUS_OK;
+		}
+		break;
+	case EXT_SC_READ_SERDES_REG:
+		/* Verify the size of response structure. */
+		if (cmd->ResponseLen < sizeof (EXT_SERDES_REG)) {
+			cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+			cmd->DetailStatus = sizeof (EXT_SERDES_REG);
+			EL(ha, "failed, ResponseLen < EXT_SERDES_REG, "
+			    "Len=%xh \n", cmd->ResponseLen);
+			cmd->ResponseLen = 0;
+			break;
+		}
+		mr.mb[1] = serdes_reg.addr;
+		if ((rval = ql_read_serdes(ha, &mr)) != QL_SUCCESS) {
+			/* error */
+			EL(ha, "failed, read_serdes_mbx=%xh\n", rval);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			break;
+		}
+		serdes_reg.val = CHAR_TO_SHORT(LSB(mr.mb[1]), LSB(mr.mb[2]));
+		/* Copy back the response data */
+		if (ddi_copyout((void *)&serdes_reg,
+		    (void *)(uintptr_t)(cmd->ResponseAdr),
+		    sizeof (EXT_SERDES_REG), mode) != 0) {
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+			EL(ha, "failed, ddi_copyout\n");
+		} else {
+			cmd->Status = EXT_STATUS_OK;
+			cmd->ResponseLen = sizeof (EXT_SERDES_REG);
+		}
+		break;
+	default:
+		/* Subcode not supported. */
+		EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
+		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
+		cmd->ResponseLen = 0;
+		break;
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_serdes_reg_ex
+ *	Performs all EXT_CC_SERDES_REG_OP_EX functions.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	EXT_IOCTL cmd struct pointer.
+ *	mode:	flags
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_serdes_reg_ex(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	ql_mbx_data_t		mr = {0};
+	int			rval = 0;
+	EXT_SERDES_REG_EX	serdes_reg_ex = {0};
+
+	QL_PRINT_9(ha, "started\n");
+
+	/* Check if request valid for HBA */
+	if (!(CFG_IST(ha, CFG_SERDES_SUPPORT))) {
+		EL(ha, "invalid request for HBA\n");
+		cmd->Status = EXT_STATUS_INVALID_REQUEST;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Copy in the request structure. */
+	if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
+	    (void *)&serdes_reg_ex, sizeof (EXT_SERDES_REG_EX), mode) != 0) {
+		EL(ha, "failed, ddi_copyin\n");
+		cmd->Status = EXT_STATUS_COPY_ERR;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	switch (cmd->SubCode) {
+	case EXT_SC_WRITE_SERDES_REG:
+		mr.mb[3] = LSW(serdes_reg_ex.addr);
+		mr.mb[4] = MSW(serdes_reg_ex.addr);
+		mr.mb[5] = LSW(serdes_reg_ex.val);
+		mr.mb[6] = MSW(serdes_reg_ex.val);
+		if ((rval = ql_write_serdes(ha, &mr)) != QL_SUCCESS) {
+			/* error */
+			EL(ha, "failed, write_serdes_mbx=%xh\n", rval);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			break;
+		} else {
+			cmd->Status = EXT_STATUS_OK;
+		}
+		break;
+	case EXT_SC_READ_SERDES_REG:
+		/* Verify the size of response structure. */
+		if (cmd->ResponseLen < sizeof (EXT_SERDES_REG_EX)) {
+			cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+			cmd->DetailStatus = sizeof (EXT_SERDES_REG_EX);
+			EL(ha, "failed, ResponseLen < EXT_SERDES_REG_EX, "
+			    "Len=%xh\n", cmd->ResponseLen);
+			cmd->ResponseLen = 0;
+			break;
+		}
+		mr.mb[3] = LSW(serdes_reg_ex.addr);
+		mr.mb[4] = MSW(serdes_reg_ex.addr);
+		if ((rval = ql_read_serdes(ha, &mr)) != QL_SUCCESS) {
+			/* error */
+			EL(ha, "failed, read_serdes_mbx=%xh\n", rval);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			break;
+		}
+		serdes_reg_ex.val = SHORT_TO_LONG(mr.mb[1], mr.mb[2]);
+		/* Copy back the response data */
+		if (ddi_copyout((void *)&serdes_reg_ex,
+		    (void *)(uintptr_t)(cmd->ResponseAdr),
+		    sizeof (EXT_SERDES_REG_EX), mode) != 0) {
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+			EL(ha, "failed, ddi_copyout\n");
+		} else {
+			cmd->Status = EXT_STATUS_OK;
+			cmd->ResponseLen = sizeof (EXT_SERDES_REG_EX);
+		}
+		break;
+	default:
+		/* Subcode not supported. */
+		EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
+		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
+		cmd->ResponseLen = 0;
+		break;
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_els_passthru
+ *	IOCTL for extended link service passthru command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	User space CT arguments pointer.
+ *	mode:	flags.
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_els_passthru(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	ql_mbx_iocb_t		*pkt;
+	dma_mem_t		*dma_mem;
+	caddr_t			bp, pld;
+	uint32_t		pkt_size, pld_byte_cnt, cmd_size, *long_ptr;
+	EXT_ELS_PT_REQ		*pt_req;
+	boolean_t		local_hba = B_FALSE;
+	ql_tgt_t		*tq = NULL;
+	port_id_t		tmp_fcid;
+	int			rval;
+	uint16_t		comp_status;
+
+	QL_PRINT_9(ha, "started\n");
+
+	if (DRIVER_SUSPENDED(ha)) {
+		EL(ha, "failed, LOOP_NOT_READY\n");
+		cmd->Status = EXT_STATUS_BUSY;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	if (cmd->RequestLen < sizeof (EXT_ELS_PT_REQ)) {
+		/* parameter error */
+		EL(ha, "failed, RequestLen < EXT_ELS_PT_REQ, Len=%xh\n",
+		    cmd->RequestLen);
+		cmd->Status = EXT_STATUS_INVALID_PARAM;
+		cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Allocate memory for command. */
+	bp = kmem_zalloc(cmd->RequestLen, KM_SLEEP);
+
+	if (ddi_copyin((void*)(uintptr_t)cmd->RequestAdr,
+	    bp, cmd->RequestLen, mode) != 0) {
+		EL(ha, "failed, ddi_copyin\n");
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_COPY_ERR;
+		cmd->ResponseLen = 0;
+		return;
+	}
+	pt_req = (EXT_ELS_PT_REQ *)bp;
+
+	QL_PRINT_9(ha, "EXT_ELS_PT_REQ\n");
+	QL_DUMP_9((uint8_t *)pt_req, 8, sizeof (EXT_ELS_PT_REQ));
+
+	/* Find loop ID of the device */
+	if (pt_req->ValidMask & EXT_DEF_WWPN_VALID) {
+		if (bcmp(ha->loginparams.nport_ww_name.raw_wwn, pt_req->WWPN,
+		    EXT_DEF_WWN_NAME_SIZE) == 0) {
+			local_hba = B_TRUE;
+		} else {
+			tq = ql_find_port(ha, pt_req->WWPN, QLNT_PORT);
+		}
+	} else if (pt_req->ValidMask & EXT_DEF_PID_VALID) {
+		/*
+		 * Copy caller's d_id to tmp space.
+		 */
+		bcopy(&pt_req->Id[1], tmp_fcid.r.d_id,
+		    EXT_DEF_PORTID_SIZE_ACTUAL);
+		BIG_ENDIAN_24(&tmp_fcid.r.d_id[0]);
+
+		if (bcmp((void *)&ha->d_id, (void *)tmp_fcid.r.d_id,
+		    EXT_DEF_PORTID_SIZE_ACTUAL) == 0) {
+			local_hba = B_TRUE;
+		} else {
+			tq = ql_find_port(ha, (uint8_t *)tmp_fcid.r.d_id,
+			    QLNT_PID);
+		}
+	} else if (pt_req->ValidMask & EXT_DEF_WWNN_VALID) {
+		if (bcmp(ha->loginparams.node_ww_name.raw_wwn, pt_req->WWNN,
+		    EXT_DEF_WWN_NAME_SIZE) == 0) {
+			local_hba = B_TRUE;
+		} else {
+			tq = ql_find_port(ha, pt_req->WWNN, QLNT_NODE);
+		}
+	}
+
+	if (local_hba == B_TRUE) {
+		EL(ha, "failed, els to adapter\n");
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_ERR;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	if (tq == NULL) {
+		/* no matching device */
+		EL(ha, "failed, device not found\n");
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
+		cmd->DetailStatus = EXT_DSTATUS_TARGET;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Allocate a DMA Memory Descriptor */
+	dma_mem = (dma_mem_t *)kmem_zalloc(sizeof (dma_mem_t), KM_SLEEP);
+	if (dma_mem == NULL) {
+		EL(ha, "failed, kmem_zalloc\n");
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_NO_MEMORY;
+		cmd->ResponseLen = 0;
+		return;
+	}
+	/* Determine maximum buffer size. */
+	cmd_size = cmd->RequestLen - sizeof (EXT_ELS_PT_REQ);
+	pld_byte_cnt = cmd_size < cmd->ResponseLen ? cmd->ResponseLen :
+	    cmd_size;
+	pld = (caddr_t)(bp + sizeof (EXT_ELS_PT_REQ));
+
+	/* Allocate command block. */
+	pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t));
+	pkt = kmem_zalloc(pkt_size, KM_SLEEP);
+	if (pkt == NULL) {
+		EL(ha, "failed, kmem_zalloc\n");
+		kmem_free(dma_mem, sizeof (dma_mem_t));
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_NO_MEMORY;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Get DMA memory for the payload */
+	if (ql_get_dma_mem(ha, dma_mem, pld_byte_cnt, LITTLE_ENDIAN_DMA,
+	    QL_DMA_RING_ALIGN) != QL_SUCCESS) {
+		cmn_err(CE_WARN, "%sDMA memory alloc failed", QL_NAME);
+		kmem_free(pkt, pkt_size);
+		kmem_free(dma_mem, sizeof (dma_mem_t));
+		kmem_free(bp, cmd->RequestLen);
+		cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	/* Copy out going payload data to IOCB DMA buffer. */
+	ddi_rep_put8(dma_mem->acc_handle, (uint8_t *)pld,
+	    (uint8_t *)dma_mem->bp, cmd_size, DDI_DEV_AUTOINCR);
+
+	/* Sync IOCB DMA buffer. */
+	(void) ddi_dma_sync(dma_mem->dma_handle, 0, cmd_size,
+	    DDI_DMA_SYNC_FORDEV);
+
+	/*
+	 * Setup IOCB
+	 */
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
+		pkt->els.entry_type = ELS_PASSTHRU_TYPE;
+		pkt->els.entry_count = 1;
+
+		/* Set loop ID */
+		pkt->els.n_port_hdl = tq->loop_id;
+
+		/* Set cmd/response data segment counts. */
+		pkt->els.xmt_dseg_count = LE_16(1);
+		pkt->els.vp_index = ha->vp_index;
+		pkt->els.rcv_dseg_count = LE_16(1);
+
+		pkt->els.els_cmd_opcode = pld[0];
+
+		pkt->els.d_id_7_0 = tq->d_id.b.al_pa;
+		pkt->els.d_id_15_8 = tq->d_id.b.area;
+		pkt->els.d_id_23_16 = tq->d_id.b.domain;
+
+		pkt->els.s_id_7_0 = ha->d_id.b.al_pa;
+		pkt->els.s_id_15_8 = ha->d_id.b.area;
+		pkt->els.s_id_23_16 = ha->d_id.b.domain;
+
+		/* Load rsp byte count. */
+		pkt->els.rcv_payld_data_bcnt = LE_32(cmd->ResponseLen);
+
+		/* Load cmd byte count. */
+		pkt->els.xmt_payld_data_bcnt = LE_32(cmd_size);
+
+		long_ptr = (uint32_t *)&pkt->els.dseg;
+
+		/* Load MS command entry data segments. */
+		*long_ptr++ = (uint32_t)
+		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
+		*long_ptr++ = (uint32_t)
+		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
+		*long_ptr++ = LE_32(cmd_size);
+
+		/* Load MS response entry data segments. */
+		*long_ptr++ = (uint32_t)
+		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
+		*long_ptr++ = (uint32_t)
+		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
+		*long_ptr = LE_32(cmd->ResponseLen);
+
+		rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
+		    sizeof (ql_mbx_iocb_t));
+
+		comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
+		if (rval == QL_SUCCESS && comp_status == CS_DATA_UNDERRUN) {
+			comp_status = CS_COMPLETE;
+		}
+		if (rval != QL_SUCCESS ||
+		    (pkt->sts24.entry_status & 0x3c) != 0 ||
+		    comp_status != CS_COMPLETE) {
+			EL(ha, "failed, I/O timeout, cs=%xh, es=%xh, "
+			    "rval=%xh\n",
+			    comp_status, pkt->sts24.entry_status, rval);
+			ql_free_dma_resource(ha, dma_mem);
+			kmem_free(pkt, pkt_size);
+			kmem_free(dma_mem, sizeof (dma_mem_t));
+			kmem_free(bp, cmd->RequestLen);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			return;
+		}
+	} else {
+		pkt->ms.entry_type = MS_TYPE;
+		pkt->ms.entry_count = 1;
+
+		/* Set loop ID */
+		if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
+			pkt->ms.loop_id_l = LSB(tq->loop_id);
+			pkt->ms.loop_id_h = MSB(tq->loop_id);
+		} else {
+			pkt->ms.loop_id_h = LSB(tq->loop_id);
+		}
+
+		pkt->ms.control_flags_h = CF_ELS_PASSTHROUGH;
+
+		/* Set ISP command timeout. */
+		pkt->ms.timeout = LE_16(120);
+
+		/* Set data segment counts. */
+		pkt->ms.cmd_dseg_count_l = 1;
+		pkt->ms.total_dseg_count = LE_16(2);
+
+		/* Response total byte count. */
+		pkt->ms.resp_byte_count = LE_32(cmd->ResponseLen);
+		pkt->ms.dseg[1].length = LE_32(cmd->ResponseLen);
+
+		/* Command total byte count. */
+		pkt->ms.cmd_byte_count = LE_32(cmd_size);
+		pkt->ms.dseg[0].length = LE_32(cmd_size);
+
+		/* Load command/response data segments. */
+		pkt->ms.dseg[0].address[0] = (uint32_t)
+		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
+		pkt->ms.dseg[0].address[1] = (uint32_t)
+		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
+		pkt->ms.dseg[1].address[0] = (uint32_t)
+		    LE_32(LSD(dma_mem->cookie.dmac_laddress));
+		pkt->ms.dseg[1].address[1] = (uint32_t)
+		    LE_32(MSD(dma_mem->cookie.dmac_laddress));
+
+		rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
+		    sizeof (ql_mbx_iocb_t));
+
+		comp_status = (uint16_t)LE_16(pkt->sts.comp_status);
+		if (rval == QL_SUCCESS && comp_status == CS_DATA_UNDERRUN) {
+			comp_status = CS_COMPLETE;
+		}
+		if (rval != QL_SUCCESS ||
+		    (pkt->sts.entry_status & 0x7e) != 0 ||
+		    comp_status != CS_COMPLETE) {
+			EL(ha, "failed, I/O timeout, cs=%xh, es=%xh, "
+			    "rval=%xh\n",
+			    comp_status, pkt->sts.entry_status, rval);
+			ql_free_dma_resource(ha, dma_mem);
+			kmem_free(pkt, pkt_size);
+			kmem_free(dma_mem, sizeof (dma_mem_t));
+			kmem_free(bp, cmd->RequestLen);
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+			return;
+		}
+	}
+
+	/* Sync payload DMA buffer. */
+	(void) ddi_dma_sync(dma_mem->dma_handle, 0, cmd->ResponseLen,
+	    DDI_DMA_SYNC_FORKERNEL);
+
+	if (ql_send_buffer_data(dma_mem->bp,
+	    (caddr_t)(uintptr_t)cmd->ResponseAdr,
+	    cmd->ResponseLen, mode) != cmd->ResponseLen) {
+		cmd->Status = EXT_STATUS_COPY_ERR;
+		EL(ha, "failed, ddi_copyout\n");
+	} else {
+		QL_PRINT_9(ha, "els_rsp\n");
+		QL_DUMP_9(pld, 8, cmd->ResponseLen);
+		cmd->Status = EXT_STATUS_OK;
+		QL_PRINT_9(ha, "done\n");
+	}
+
+	ql_free_dma_resource(ha, dma_mem);
+	kmem_free(pkt, pkt_size);
+	kmem_free(dma_mem, sizeof (dma_mem_t));
+	kmem_free(bp, cmd->RequestLen);
+}
+
+/*
+ * ql_flash_update_caps
+ *	IOCTL for flash update capabilities command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	User space CT arguments pointer.
+ *	mode:	flags.
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_flash_update_caps(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	int			rval;
+	uint64_t		cb;
+	EXT_FLASH_UPDATE_CAPS	caps = {0};
+
+	QL_PRINT_9(ha, "started\n");
+
+	cb = LONG_TO_LLONG(ha->fw_attributes, ha->fw_ext_attributes);
+
+	switch (cmd->SubCode) {
+	case EXT_SC_GET_FLASH_UPDATE_CAPS:
+		if (cmd->ResponseLen < sizeof (EXT_FLASH_UPDATE_CAPS)) {
+			cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+			cmd->DetailStatus = sizeof (EXT_FLASH_UPDATE_CAPS);
+			EL(ha, "failed, ResponseLen < 0x%x, Len=0x%x\n",
+			    sizeof (EXT_FLASH_UPDATE_CAPS), cmd->ResponseLen);
+			cmd->ResponseLen = 0;
+			return;
+		}
+		caps.Capabilities = cb;
+		caps.OutageDuration = 300;	/* seconds */
+
+		rval = ddi_copyout((void *)&caps,
+		    (void *)(uintptr_t)(cmd->ResponseAdr),
+		    sizeof (EXT_FLASH_UPDATE_CAPS), mode);
+		if (rval != 0) {
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+			EL(ha, "failed, ddi_copyout\n");
+		} else {
+			cmd->ResponseLen = sizeof (EXT_FLASH_UPDATE_CAPS);
+		}
+		break;
+	case EXT_SC_SET_FLASH_UPDATE_CAPS:
+		if (cmd->RequestLen < sizeof (EXT_FLASH_UPDATE_CAPS)) {
+			/* parameter error */
+			EL(ha, "failed, RequestLen < EXT_FLASH_UPDATE_CAPS, "
+			    "Len=%xh\n", cmd->RequestLen);
+			cmd->Status = EXT_STATUS_INVALID_PARAM;
+			cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
+			cmd->ResponseLen = 0;
+			return;
+		}
+
+		/* Copy in the request structure. */
+		if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
+		    (void *)&caps, sizeof (EXT_FLASH_UPDATE_CAPS), mode) != 0) {
+			EL(ha, "failed, ddi_copyin\n");
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+			return;
+		}
+
+		if (cb != caps.Capabilities || caps.OutageDuration < 300) {
+			cmd->Status = EXT_STATUS_ERR;
+			cmd->ResponseLen = 0;
+		}
+		break;
+	default:
+		/* Subcode not supported. */
+		EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
+		cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
+		cmd->ResponseLen = 0;
+		break;
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_get_bbcr_data
+ *	IOCTL for get buffer to buffer credits command.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	User space CT arguments pointer.
+ *	mode:	flags.
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_get_bbcr_data(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	int		rval;
+	ql_mbx_data_t	mr;
+	EXT_BBCR_DATA	bb = {0};
+
+	QL_PRINT_9(ha, "started\n");
+
+	if (cmd->ResponseLen < sizeof (EXT_BBCR_DATA)) {
+		cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
+		cmd->DetailStatus = sizeof (EXT_BBCR_DATA);
+		EL(ha, "failed, ResponseLen < 0x%x, Len=0x%x\n",
+		    sizeof (EXT_BBCR_DATA), cmd->ResponseLen);
+		cmd->ResponseLen = 0;
+		return;
+	}
+
+	if (!(CFG_IST(ha, CFG_BBCR_SUPPORT))) {
+		EL(ha, "invalid request for HBA\n");
+		cmd->Status = EXT_STATUS_INVALID_REQUEST;
+		cmd->ResponseLen = 0;
+		return;
+	}
+	if (ha->task_daemon_flags & LOOP_DOWN) {
+		rval = ql_get_adapter_id(ha, &mr);
+		ha->bbcr_initial = LSB(mr.mb[15]);
+		ha->bbcr_runtime = MSB(mr.mb[15]);
+		bb.ConfiguredBBSCN = ha->bbcr_initial & BBCR_INITIAL_MASK;
+		bb.NegotiatedBBSCN = ha->bbcr_runtime & BBCR_RUNTIME_MASK;
+		bb.Status = EXT_DEF_BBCR_STATUS_UNKNOWN;
+		bb.State = EXT_DEF_BBCR_STATE_OFFLINE;
+		if (rval == 0x4005) {
+			bb.mbx1 = mr.mb[1];
+		}
+	} else {
+		bb.ConfiguredBBSCN = ha->bbcr_initial & BBCR_INITIAL_MASK;
+		bb.NegotiatedBBSCN = ha->bbcr_runtime & BBCR_RUNTIME_MASK;
+
+		if (bb.ConfiguredBBSCN) {
+			bb.Status = EXT_DEF_BBCR_STATUS_ENABLED;
+			if (bb.NegotiatedBBSCN &&
+			    !(ha->bbcr_runtime & BBCR_RUNTIME_REJECT)) {
+				bb.State = EXT_DEF_BBCR_STATE_ONLINE;
+			} else {
+				bb.State = EXT_DEF_BBCR_STATE_OFFLINE;
+				if (ha->bbcr_runtime & BBCR_RUNTIME_REJECT) {
+					bb.OfflineReasonCode =
+					    EXT_DEF_BBCR_REASON_LOGIN_REJECT;
+				} else {
+					bb.OfflineReasonCode =
+					    EXT_DEF_BBCR_REASON_SWITCH;
+				}
+			}
+		} else {
+			bb.Status = EXT_DEF_BBCR_STATUS_DISABLED;
+		}
+	}
+
+	rval = ddi_copyout((void *)&bb, (void *)(uintptr_t)(cmd->ResponseAdr),
+	    sizeof (EXT_BBCR_DATA), mode);
+	if (rval != 0) {
+		cmd->Status = EXT_STATUS_COPY_ERR;
+		cmd->ResponseLen = 0;
+		EL(ha, "failed, ddi_copyout\n");
+	} else {
+		cmd->ResponseLen = sizeof (EXT_BBCR_DATA);
+	}
+
+	QL_PRINT_9(ha, "done\n");
+}
+
+/*
+ * ql_get_priv_stats
+ *	Performs EXT_SC_GET_PRIV_STATS subcommand. of EXT_CC_GET_DATA.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	cmd:	Local EXT_IOCTL cmd struct pointer.
+ *	mode:	flags.
+ *
+ * Returns:
+ *	None, request status indicated in cmd->Status.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+ql_get_priv_stats(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
+{
+	uint8_t	*ls;
+	int	rval;
+	int	retry = 10;
+
+	QL_PRINT_9(ha, "started\n");
+
+	while (ha->task_daemon_flags & (DRIVER_STALL | ABORT_ISP_ACTIVE |
+	    LOOP_RESYNC_ACTIVE)) {
+		ql_delay(ha, 10000000);	/* 10 second delay */
+
+		retry--;
+
+		if (retry == 0) { /* effectively 100 seconds */
+			EL(ha, "failed, LOOP_NOT_READY\n");
+			cmd->Status = EXT_STATUS_BUSY;
+			cmd->ResponseLen = 0;
+			return;
+		}
+	}
+
+	/* Allocate memory for command. */
+	ls = kmem_zalloc(cmd->ResponseLen, KM_SLEEP);
+
+	/*
+	 * I think these are supposed to be port statistics
+	 * the loop ID or port ID should be in cmd->Instance.
+	 */
+	rval = ql_get_status_counts(ha,
+	    ha->task_daemon_flags & LOOP_DOWN ? 0xFF : ha->loop_id,
+	    cmd->ResponseLen, (caddr_t)ls, 0);
+	if (rval != QL_SUCCESS) {
+		EL(ha, "failed, get_link_status=%xh, id=%xh\n", rval,
+		    ha->loop_id);
+		cmd->Status = EXT_STATUS_MAILBOX;
+		cmd->DetailStatus = rval;
+		cmd->ResponseLen = 0;
+	} else {
+		rval = ddi_copyout((void *)&ls,
+		    (void *)(uintptr_t)cmd->ResponseAdr, cmd->ResponseLen,
+		    mode);
+		if (rval != 0) {
+			EL(ha, "failed, ddi_copyout\n");
+			cmd->Status = EXT_STATUS_COPY_ERR;
+			cmd->ResponseLen = 0;
+		}
+	}
+
+	kmem_free(ls, cmd->ResponseLen);
+
+	QL_PRINT_9(ha, "done\n");
 }
