--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_ioctl.c	Mon Aug  5 17:28:43 2019
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_ioctl.c	Mon Aug  5 17:28:43 2019
@@ -19,13 +19,13 @@
  * CDDL HEADER END
  */
 
-/* Copyright 2010 QLogic Corporation */
+/* Copyright 2015 QLogic Corporation */
 
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"Copyright 2010 QLogic Corporation; ql_ioctl.c"
+#pragma ident	"Copyright 2015 QLogic Corporation; ql_ioctl.c"
 
 /*
  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
@@ -34,7 +34,7 @@
  * ***********************************************************************
  * *									**
  * *				NOTICE					**
- * *		COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION		**
+ * *		COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION		**
  * *			ALL RIGHTS RESERVED				**
  * *									**
  * ***********************************************************************
@@ -47,6 +47,7 @@
 #include <ql_init.h>
 #include <ql_ioctl.h>
 #include <ql_mbx.h>
+#include <ql_nx.h>
 #include <ql_xioctl.h>
 
 /*
@@ -68,6 +69,8 @@
 static int ql_adm_prop_update_int(ql_adapter_state_t *, ql_adm_op_t *, int);
 static int ql_adm_loop_reset(ql_adapter_state_t *);
 static int ql_adm_fw_dump(ql_adapter_state_t *, ql_adm_op_t *, void *, int);
+static int ql_adm_fw_t_dump(ql_adapter_state_t *);
+static int ql_adm_beacon(ql_adapter_state_t *, ql_adm_op_t *);
 static int ql_adm_nvram_dump(ql_adapter_state_t *, ql_adm_op_t *, int);
 static int ql_adm_nvram_load(ql_adapter_state_t *, ql_adm_op_t *, int);
 static int ql_adm_flash_load(ql_adapter_state_t *, ql_adm_op_t *, int);
@@ -106,16 +109,15 @@
 
 	ha = ddi_get_soft_state(ql_state, (int32_t)getminor(*dev_p));
 	if (ha == NULL) {
-		QL_PRINT_2(CE_CONT, "failed, no adapter\n");
+		QL_PRINT_2(NULL, "failed, no adapter\n");
 		return (ENXIO);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/* Allow only character opens */
 	if (otyp != OTYP_CHR) {
-		QL_PRINT_2(CE_CONT, "(%d): failed, open type\n",
-		    ha->instance);
+		QL_PRINT_2(ha, "failed, open type\n");
 		return (EINVAL);
 	}
 
@@ -132,7 +134,7 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -162,15 +164,14 @@
 
 	ha = ddi_get_soft_state(ql_state, (int32_t)getminor(dev));
 	if (ha == NULL) {
-		QL_PRINT_2(CE_CONT, "failed, no adapter\n");
+		QL_PRINT_2(ha, "failed, no adapter\n");
 		return (ENXIO);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (otyp != OTYP_CHR) {
-		QL_PRINT_2(CE_CONT, "(%d): failed, open type\n",
-		    ha->instance);
+		QL_PRINT_2(ha, "failed, open type\n");
 		return (EINVAL);
 	}
 
@@ -182,7 +183,7 @@
 		EL(ha, "failed, rval = %xh\n", rval);
 	} else {
 		/*EMPTY*/
-		QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_3(ha, "done\n");
 	}
 	return (rval);
 }
@@ -214,17 +215,17 @@
 	int			rval = 0;
 
 	if (ddi_in_panic()) {
-		QL_PRINT_2(CE_CONT, "ql_ioctl: ddi_in_panic exit\n");
+		QL_PRINT_2(NULL, "ql_ioctl: ddi_in_panic exit\n");
 		return (ENOPROTOOPT);
 	}
 
 	ha = ddi_get_soft_state(ql_state, (int32_t)getminor(dev));
 	if (ha == NULL)	{
-		QL_PRINT_2(CE_CONT, "failed, no adapter\n");
+		QL_PRINT_2(ha, "failed, no adapter\n");
 		return (ENXIO);
 	}
 
-	QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	/*
 	 * Quick clean exit for qla2x00 foapi calls which are
@@ -231,7 +232,7 @@
 	 * not supported in qlc.
 	 */
 	if (cmd >= QL_FOAPI_START && cmd <= QL_FOAPI_END) {
-		QL_PRINT_9(CE_CONT, "failed, fo api not supported\n");
+		QL_PRINT_9(ha, "failed, fo api not supported\n");
 		return (ENOTTY);
 	}
 
@@ -306,7 +307,7 @@
 		}
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 	return (rval);
 }
@@ -332,15 +333,17 @@
 		return (FC_SUCCESS);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	QL_PM_LOCK(ha);
-	ha->busy++;
+	ha->pm_busy++;
 	QL_PM_UNLOCK(ha);
 
 	if (pm_busy_component(ha->dip, 0) != DDI_SUCCESS) {
 		QL_PM_LOCK(ha);
-		ha->busy--;
+		if (ha->pm_busy) {
+			ha->pm_busy--;
+		}
 		QL_PM_UNLOCK(ha);
 
 		EL(ha, "pm_busy_component failed = %xh\n", FC_FAILURE);
@@ -352,7 +355,9 @@
 		QL_PM_UNLOCK(ha);
 		if (pm_raise_power(ha->dip, 0, 1) != DDI_SUCCESS) {
 			QL_PM_LOCK(ha);
-			ha->busy--;
+			if (ha->pm_busy) {
+				ha->pm_busy--;
+			}
 			QL_PM_UNLOCK(ha);
 			return (FC_FAILURE);
 		}
@@ -360,7 +365,7 @@
 		QL_PM_UNLOCK(ha);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (FC_SUCCESS);
 }
@@ -386,7 +391,7 @@
 		return (FC_SUCCESS);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (pm_idle_component(ha->dip, 0) != DDI_SUCCESS) {
 		EL(ha, "pm_idle_component failed = %xh\n", FC_FAILURE);
@@ -394,10 +399,12 @@
 	}
 
 	QL_PM_LOCK(ha);
-	ha->busy--;
+	if (ha->pm_busy) {
+		ha->pm_busy--;
+	}
 	QL_PM_UNLOCK(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (FC_SUCCESS);
 }
@@ -415,9 +422,9 @@
 	int			rval;
 	uint32_t		offset = offsetof(nvram_t, adapter_features);
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		EL(ha, "Not supported for 24xx\n");
 		return (EINVAL);
 	}
@@ -477,7 +484,7 @@
 
 	ql_release_nvram(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -496,9 +503,9 @@
 	uint8_t		csum;
 	uint32_t	start_addr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		EL(ha, "Not supported for 24xx\n");
 		return (EINVAL);
 	}
@@ -581,7 +588,7 @@
 	kmem_free(nv, sizeof (*nv));
 	ql_release_nvram(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -596,7 +603,7 @@
 	uint32_t	count;
 	uint32_t	start_addr;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	rval = ql_lock_nvram(ha, &start_addr, LNF_NVRAM_DATA);
 	if (rval != QL_SUCCESS) {
@@ -605,7 +612,7 @@
 	}
 	rval = 0;
 
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		nvram_24xx_t	*nv;
 		uint32_t	*longptr;
 		uint32_t	csum = 0;
@@ -645,7 +652,8 @@
 		 */
 		longptr = (uint32_t *)nv;
 		csum = 0;
-		for (count = 0; count < (sizeof (nvram_24xx_t)/4)-1; count++) {
+		for (count = 0; count < (sizeof (nvram_24xx_t) / 4) - 1;
+		    count++) {
 			csum += *longptr;
 			longptr++;
 		}
@@ -759,7 +767,7 @@
 	}
 	ql_release_nvram(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -877,7 +885,7 @@
 	int	rval;
 
 	/* Enable flash write. */
-	if (!(CFG_IST(ha, CFG_CTRL_8081))) {
+	if (!(CFG_IST(ha, CFG_FCOE_SUPPORT))) {
 		WRT32_IO_REG(ha, ctrl_status,
 		    RD32_IO_REG(ha, ctrl_status) | ISP_FLASH_ENABLE);
 		RD32_IO_REG(ha, ctrl_status);	/* PCI Posting. */
@@ -884,7 +892,7 @@
 	}
 
 	/* Disable NVRAM write-protection. */
-	if (CFG_IST(ha, CFG_CTRL_2422)) {
+	if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		(void) ql_24xx_write_flash(ha, NVRAM_CONF_ADDR | 0x101, 0);
 	} else {
 		if ((rval = ql_24xx_unprotect_flash(ha)) != QL_SUCCESS) {
@@ -897,7 +905,7 @@
 	rval = ql_24xx_write_flash(ha, addr, value);
 
 	/* Enable NVRAM write-protection. */
-	if (CFG_IST(ha, CFG_CTRL_2422)) {
+	if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		/* TODO: Check if 0x8c is correct -- sb: 0x9c ? */
 		(void) ql_24xx_write_flash(ha, NVRAM_CONF_ADDR | 0x101, 0x8c);
 	} else {
@@ -938,7 +946,7 @@
 	nvram_t		*nptr;
 	int		rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if ((nv = kmem_zalloc(ha->nvram_cache->size, KM_SLEEP)) == NULL) {
 		EL(ha, "failed, kmem_zalloc\n");
@@ -976,7 +984,7 @@
 	}
 
 	/* Load NVRAM. */
-	if (CFG_IST(ha, CFG_CTRL_258081)) {
+	if (CFG_IST(ha, CFG_CTRL_252780818283)) {
 		GLOBAL_HW_UNLOCK();
 		start_addr &= ~ha->flash_data_addr;
 		start_addr <<= 2;
@@ -985,7 +993,7 @@
 			EL(ha, "nvram load failed, rval = %0xh\n", rval);
 		}
 		GLOBAL_HW_LOCK();
-	} else if (CFG_IST(ha, CFG_CTRL_2422)) {
+	} else if (CFG_IST(ha, CFG_CTRL_24XX)) {
 		lptr = (uint32_t *)nv;
 		for (cnt = 0; cnt < ha->nvram_cache->size / 4; cnt++) {
 			data32 = *lptr++;
@@ -1006,17 +1014,13 @@
 		}
 	}
 	/* switch to the new one */
-	NVRAM_CACHE_LOCK(ha);
-
 	kmem_free(ha->nvram_cache->cache, ha->nvram_cache->size);
 	ha->nvram_cache->cache = (void *)nptr;
 
-	NVRAM_CACHE_UNLOCK(ha);
-
 	ql_release_nvram(ha);
 	ql_restart_driver(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	if (rval == QL_SUCCESS) {
 		return (0);
@@ -1044,7 +1048,7 @@
 	uint32_t	start_addr;
 	int		rval2, rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (ha->nvram_cache == NULL ||
 	    ha->nvram_cache->size == NULL ||
@@ -1065,8 +1069,6 @@
 			ql_restart_driver(ha);
 			return (EIO);
 		}
-		NVRAM_CACHE_LOCK(ha);
-
 		rval2 = ql_get_nvram(ha, ha->nvram_cache->cache,
 		    start_addr, ha->nvram_cache->size);
 		if (rval2 != QL_SUCCESS) {
@@ -1076,8 +1078,6 @@
 			EL(ha, "nvram cache now valid.");
 		}
 
-		NVRAM_CACHE_UNLOCK(ha);
-
 		ql_release_nvram(ha);
 		ql_restart_driver(ha);
 
@@ -1093,7 +1093,7 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -1105,7 +1105,7 @@
 	int rval = QL_SUCCESS;
 	int cnt;
 	/* Dump NVRAM. */
-	if (CFG_IST(ha, CFG_CTRL_24258081)) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 		uint32_t	*lptr = (uint32_t *)dest_addr;
 
 		for (cnt = 0; cnt < size / 4; cnt++) {
@@ -1153,9 +1153,9 @@
 	uint32_t	start_addr, vpd_size, *lptr, data32;
 	int		rval;
 
-	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, "unsupported adapter feature\n");
 		return (ENOTSUP);
 	}
@@ -1209,7 +1209,7 @@
 	}
 
 	/* Load VPD. */
-	if (CFG_IST(ha, CFG_CTRL_258081)) {
+	if (CFG_IST(ha, CFG_CTRL_252780818283)) {
 		GLOBAL_HW_UNLOCK();
 		start_addr &= ~ha->flash_data_addr;
 		start_addr <<= 2;
@@ -1235,8 +1235,6 @@
 	kmem_free(vpd, vpd_size);
 
 	/* Update the vcache */
-	CACHE_LOCK(ha);
-
 	if (rval != QL_SUCCESS) {
 		EL(ha, "failed, load\n");
 	} else if ((ha->vcache == NULL) && ((ha->vcache =
@@ -1248,12 +1246,10 @@
 		ha->vcache = NULL;
 	}
 
-	CACHE_UNLOCK(ha);
-
 	ql_release_nvram(ha);
 	ql_restart_driver(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	if (rval == QL_SUCCESS) {
 		return (0);
@@ -1283,9 +1279,9 @@
 	uint32_t	start_addr, vpd_size, *lptr;
 	int		rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		EL(ha, "unsupported adapter feature\n");
 		return (EACCES);
 	}
@@ -1292,8 +1288,6 @@
 
 	vpd_size = QL_24XX_VPD_SIZE;
 
-	CACHE_LOCK(ha);
-
 	if (ha->vcache != NULL) {
 		/* copy back the vpd cache data */
 		if (ddi_copyout(ha->vcache, bp, vpd_size, mode) != 0) {
@@ -1300,12 +1294,10 @@
 			EL(ha, "Buffer copy failed\n");
 			rval = EFAULT;
 		}
-		CACHE_UNLOCK(ha);
 		return (rval);
 	}
 
 	if ((vpd = kmem_zalloc(vpd_size, KM_SLEEP)) == NULL) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "failed, kmem_zalloc\n");
 		return (ENOMEM);
 	}
@@ -1312,7 +1304,6 @@
 
 	/* Quiesce I/O */
 	if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "ql_stall_driver failed\n");
 		kmem_free(vpd, vpd_size);
 		return (EBUSY);
@@ -1320,7 +1311,6 @@
 
 	rval = ql_lock_nvram(ha, &start_addr, LNF_VPD_DATA);
 	if (rval != QL_SUCCESS) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "failed, ql_lock_nvram=%xh\n", rval);
 		kmem_free(vpd, vpd_size);
 		ql_restart_driver(ha);
@@ -1345,7 +1335,6 @@
 	ql_restart_driver(ha);
 
 	if (ddi_copyout(vpd, bp, vpd_size, mode) != 0) {
-		CACHE_UNLOCK(ha);
 		EL(ha, "Buffer copy failed\n");
 		kmem_free(vpd, vpd_size);
 		return (EFAULT);
@@ -1353,10 +1342,8 @@
 
 	ha->vcache = vpd;
 
-	CACHE_UNLOCK(ha);
+	QL_PRINT_3(ha, "done\n");
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
-
 	if (rval != QL_SUCCESS) {
 		return (EFAULT);
 	} else {
@@ -1387,7 +1374,7 @@
 	uint8_t		*end = vpdbuf + QL_24XX_VPD_SIZE;
 	uint32_t	found = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (vpdbuf == NULL || opcode == NULL) {
 		EL(ha, "null parameter passed!\n");
@@ -1427,7 +1414,7 @@
 		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (found == 1 ? vpd : NULL);
 }
@@ -1462,7 +1449,7 @@
 	uint8_t		*vpdbuf;
 	int32_t		len = -1;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_3(ha, "started\n");
 
 	if (opcode == NULL || bp == NULL || bplen < 1) {
 		EL(ha, "invalid parameter passed: opcode=%ph, "
@@ -1470,7 +1457,7 @@
 		return (len);
 	}
 
-	if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
+	if (CFG_IST(ha, CFG_ISP_FW_TYPE_1)) {
 		return (len);
 	}
 
@@ -1509,7 +1496,7 @@
 		 * make sure that the vpd len doesn't exceed the
 		 * vpd end
 		 */
-		if (vpd+len > vpdbuf + QL_24XX_VPD_SIZE) {
+		if (vpd + len > vpdbuf + QL_24XX_VPD_SIZE) {
 			EL(ha, "vpd tag len (%xh) exceeds vpd buffer "
 			    "length\n", len);
 			len = -1;
@@ -1521,11 +1508,11 @@
 		 * make sure we don't exceed callers buffer space len
 		 */
 		if (len > bplen) {
-			len = bplen-1;
+			len = bplen - 1;
 		}
 
 		/* copy the data back */
-		(void) strncpy((int8_t *)bp, (int8_t *)(vpd+3), (int64_t)len);
+		(void) strncpy((int8_t *)bp, (int8_t *)(vpd + 3), (int64_t)len);
 		bp[len] = NULL;
 	} else {
 		/* error -- couldn't find tag */
@@ -1539,7 +1526,7 @@
 
 	kmem_free(vpdbuf, QL_24XX_VPD_SIZE);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_3(ha, "done\n");
 
 	return (len);
 }
@@ -1569,8 +1556,8 @@
 	uint32_t	xfer, bsize, saddr, ofst;
 	int		rval = 0;
 
-	QL_PRINT_9(CE_CONT, "(%d): started, dp=%ph, faddr=%xh, bc=%xh\n",
-	    ha->instance, (void *)dp, faddr, bc);
+	QL_PRINT_9(ha, "started, dp=%ph, faddr=%xh, bc=%xh\n",
+	    (void *)dp, faddr, bc);
 
 	bsize = ha->xioctl->fdesc.block_size;
 	saddr = faddr & ~(bsize - 1);
@@ -1586,8 +1573,8 @@
 		if (ofst + xfer > bsize) {
 			xfer = bsize - ofst;
 		}
-		QL_PRINT_9(CE_CONT, "(%d): dp=%ph, saddr=%xh, bc=%xh, "
-		    "ofst=%xh, xfer=%xh\n", ha->instance, (void *)dp, saddr,
+		QL_PRINT_9(ha, "dp=%ph, saddr=%xh, bc=%xh, "
+		    "ofst=%xh, xfer=%xh\n", (void *)dp, saddr,
 		    bc, ofst, xfer);
 
 		if (ofst || xfer < bsize) {
@@ -1622,7 +1609,7 @@
 
 	kmem_free(bp, bsize);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -1652,8 +1639,8 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): started, cmd=%xh, buffer=%llx,"
-	    " length=%xh, option=%xh\n", ha->instance, dop.cmd, dop.buffer,
+	QL_PRINT_9(ha, "started, cmd=%xh, buffer=%llx,"
+	    " length=%xh, option=%xh\n", dop.cmd, dop.buffer,
 	    dop.length, dop.option);
 
 	switch (dop.cmd) {
@@ -1685,6 +1672,15 @@
 		rval = ql_adm_fw_dump(ha, &dop, arg, mode);
 		break;
 
+	case QL_FW_DUMP_TRIGGER:
+		rval = ql_adm_fw_t_dump(ha);
+		break;
+
+	case QL_BEACON_ENABLE:
+	case QL_BEACON_DISABLE:
+		rval = ql_adm_beacon(ha, &dop);
+		break;
+
 	case QL_NVRAM_LOAD:
 		rval = ql_adm_nvram_load(ha, &dop, mode);
 		break;
@@ -1718,7 +1714,7 @@
 		return (EINVAL);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -1745,19 +1741,17 @@
 	uint32_t		length;
 	int			rval, i;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	hba.device_id = ha->device_id;
 
-	dp = CFG_IST(ha, CFG_CTRL_24258081) ?
-	    &ha->init_ctrl_blk.cb24.port_name[0] :
-	    &ha->init_ctrl_blk.cb.port_name[0];
+	dp = ha->loginparams.nport_ww_name.raw_wwn;
 	bcopy(dp, hba.wwpn, 8);
 
 	hba.d_id = ha->d_id.b24;
 
 	if (ha->xioctl->fdesc.flash_size == 0 &&
-	    !(CFG_IST(ha, CFG_CTRL_2200) && !ha->subven_id)) {
+	    !(CFG_IST(ha, CFG_CTRL_22XX) && !ha->subven_id)) {
 		if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
 			EL(ha, "ql_stall_driver failed\n");
 			return (EBUSY);
@@ -1772,7 +1766,7 @@
 		}
 
 		/* Resume I/O */
-		if (CFG_IST(ha, CFG_CTRL_24258081)) {
+		if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
 			ql_restart_driver(ha);
 		} else {
 			EL(ha, "isp_abort_needed for restart\n");
@@ -1809,7 +1803,7 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -1833,7 +1827,7 @@
 	char	prop_name[MAX_PROP_LENGTH];
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	(void) sprintf(prop_name, "hba%d-extended-logging", ha->instance);
 
@@ -1849,7 +1843,7 @@
 		    (ha->cfg_flags &= ~CFG_ENABLE_EXTENDED_LOGGING);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -1871,16 +1865,25 @@
 {
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
-	if (ha->task_daemon_flags & LOOP_DOWN) {
-		(void) ql_full_login_lip(ha);
-	} else if ((rval = ql_full_login_lip(ha)) != QL_SUCCESS) {
-		EL(ha, "failed, ql_initiate_lip=%xh\n", rval);
-		return (EIO);
+	if (CFG_IST(ha, CFG_CTRL_82XX)) {
+		rval = ql_8021_fw_reload(ha);
+		ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
+		if (rval != QL_SUCCESS) {
+			EL(ha, "failed, ql_8021_fw_reload=%xh\n", rval);
+			return (EIO);
+		}
+	} else {
+		if (ha->task_daemon_flags & LOOP_DOWN) {
+			(void) ql_full_login_lip(ha);
+		} else if ((rval = ql_full_login_lip(ha)) != QL_SUCCESS) {
+			EL(ha, "failed, ql_initiate_lip=%xh\n", rval);
+			return (EIO);
+		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -1907,7 +1910,7 @@
 	ql_tgt_t		*tq;
 	uint32_t		index, cnt;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	cnt = 0;
 	dev.address = 0xffffffff;
@@ -1947,7 +1950,7 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -1970,7 +1973,7 @@
 	ql_comb_init_cb_t	init_ctrl_blk;
 	ql_comb_ip_init_cb_t	ip_init_ctrl_blk;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* Stall driver instance. */
 	(void) ql_stall_driver(ha, 0);
@@ -2007,7 +2010,7 @@
 	/* Restart driver instance. */
 	ql_restart_driver(ha);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -2032,7 +2035,7 @@
 	char	*prop_name;
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	prop_name = kmem_zalloc(dop->length, KM_SLEEP);
 	if (prop_name == NULL) {
@@ -2057,7 +2060,7 @@
 
 	kmem_free(prop_name, dop->length);
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -2082,7 +2085,7 @@
 {
 	caddr_t	dmp;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (dop->length < ha->risc_dump_size) {
 		EL(ha, "failed, incorrect length=%xh, size=%xh\n",
@@ -2118,12 +2121,78 @@
 		return (EFAULT);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
 
 /*
+ * ql_adm_fw_t_dump
+ *	Performs qladm QL_FW_DUMP_TRIGGER command
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *
+ * Returns:
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+ql_adm_fw_t_dump(ql_adapter_state_t *ha)
+{
+	int	rval;
+
+	QL_PRINT_9(ha, "started\n");
+
+	if (ha->ql_dump_state & QL_DUMP_VALID) {
+		EL(ha, "Already contains a dump file\n");
+		return (EINVAL);
+	}
+	rval = ql_dump_firmware(ha);
+
+	QL_PRINT_9(ha, "done\n");
+
+	if (rval == QL_SUCCESS || rval == QL_DATA_EXISTS) {
+		return (0);
+	}
+	return (EFAULT);
+}
+
+/*
+ * ql_adm_beacon
+ *      Performs qladm QL_BEACON_ENABLE/DISABLE command
+ *
+ * Input:
+ *      ha:     adapter state pointer.
+ *	dop:	ql_adm_op_t structure pointer.
+ *
+ * Returns:
+ *
+ * Context:
+ *      Kernel context.
+ */
+static int
+ql_adm_beacon(ql_adapter_state_t *ha, ql_adm_op_t *dop)
+{
+	int		rval;
+	ql_mbx_data_t	mr;
+
+	if (!CFG_IST(ha, CFG_CTRL_82XX)) {
+		return (EIO);
+	}
+
+	rval = ql_diag_beacon(ha, dop->cmd, &mr);
+
+	if (rval == QL_SUCCESS) {
+		return (0);
+	}
+
+	return (rval);
+}
+
+
+/*
  * ql_adm_nvram_dump
  *	Performs qladm QL_NVRAM_DUMP command
  *
@@ -2142,7 +2211,7 @@
 {
 	int		rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (dop->length < ha->nvram_cache->size) {
 		EL(ha, "failed, length=%xh, size=%xh\n", dop->length,
@@ -2155,7 +2224,7 @@
 		EL(ha, "failed, ql_nv_util_dump\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	return (rval);
@@ -2180,7 +2249,7 @@
 {
 	int		rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if (dop->length < ha->nvram_cache->size) {
 		EL(ha, "failed, length=%xh, size=%xh\n", dop->length,
@@ -2193,7 +2262,7 @@
 		EL(ha, "failed, ql_nv_util_dump\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	return (rval);
@@ -2219,7 +2288,7 @@
 	uint8_t	*dp;
 	int	rval;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	if ((dp = kmem_zalloc(dop->length, KM_SLEEP)) == NULL) {
 		EL(ha, "failed, kmem_zalloc\n");
@@ -2239,7 +2308,7 @@
 		return (EBUSY);
 	}
 
-	rval = (CFG_IST(ha, CFG_CTRL_24258081) ?
+	rval = (CFG_IST(ha, CFG_ISP_FW_TYPE_2) ?
 	    ql_24xx_load_flash(ha, dp, dop->length, dop->option) :
 	    ql_load_flash(ha, dp, dop->length));
 
@@ -2252,7 +2321,7 @@
 		return (EIO);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (0);
 }
@@ -2276,9 +2345,9 @@
 {
 	int		rval;
 
-	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, "hba does not support VPD\n");
 		return (EINVAL);
 	}
@@ -2294,7 +2363,7 @@
 		EL(ha, "failed, ql_vpd_dump\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	return (rval);
@@ -2319,9 +2388,9 @@
 {
 	int		rval;
 
-	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, "hba does not support VPD\n");
 		return (EINVAL);
 	}
@@ -2337,7 +2406,7 @@
 		EL(ha, "failed, ql_vpd_dump\n");
 	} else {
 		/*EMPTY*/
-		QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+		QL_PRINT_9(ha, "done\n");
 	}
 
 	return (rval);
@@ -2363,9 +2432,9 @@
 	int		rval = 0;
 	uint8_t		*lbuf;
 
-	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, "hba does not support VPD\n");
 		return (EINVAL);
 	}
@@ -2386,7 +2455,7 @@
 			EL(ha, "failed vpd_lookup\n");
 		} else {
 			if (ddi_copyout(lbuf, (void *)(uintptr_t)dop->buffer,
-			    strlen((int8_t *)lbuf)+1, mode) != 0) {
+			    strlen((int8_t *)lbuf) + 1, mode) != 0) {
 				EL(ha, "failed, ddi_copyout\n");
 				rval = EFAULT;
 			} else {
@@ -2396,7 +2465,7 @@
 		kmem_free(lbuf, dop->length);
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
@@ -2424,7 +2493,7 @@
 	ql_adapter_state_t	*ha2 = NULL;
 	uint16_t		fw_class = (uint16_t)dop->option;
 
-	QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
+	QL_PRINT_9(ha, "started\n");
 
 	/* zero the firmware module reference count */
 	for (link = ql_hba.first; link != NULL; link = link->next) {
@@ -2462,7 +2531,7 @@
 		}
 	}
 
-	QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
+	QL_PRINT_9(ha, "done\n");
 
 	return (rval);
 }
