xref: /onnv-gate/usr/src/cmd/mdb/common/modules/qlc/qlc.c (revision 12279:f13874aa8143)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM 
22*12279SDaniel.Beauregard@Sun.COM /* Copyright 2010 QLogic Corporation */
237836SJohn.Forte@Sun.COM 
247836SJohn.Forte@Sun.COM /*
257836SJohn.Forte@Sun.COM  * ISP2xxx Solaris Fibre Channel Adapter (FCA) qlc mdb source file.
267836SJohn.Forte@Sun.COM  *
277836SJohn.Forte@Sun.COM  * ***********************************************************************
287836SJohn.Forte@Sun.COM  * *									**
297836SJohn.Forte@Sun.COM  * *				NOTICE					**
3011924SDaniel.Beauregard@Sun.COM  * *		COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION		**
317836SJohn.Forte@Sun.COM  * *			ALL RIGHTS RESERVED				**
327836SJohn.Forte@Sun.COM  * *									**
337836SJohn.Forte@Sun.COM  * ***********************************************************************
347836SJohn.Forte@Sun.COM  *
357836SJohn.Forte@Sun.COM  */
367836SJohn.Forte@Sun.COM 
3711924SDaniel.Beauregard@Sun.COM #pragma ident	"Copyright 2010 QLogic Corporation; ql_mdb.c"
387836SJohn.Forte@Sun.COM 
397836SJohn.Forte@Sun.COM #include <sys/mdb_modapi.h>
409156SDaniel.Beauregard@Sun.COM #include <ql_apps.h>
419156SDaniel.Beauregard@Sun.COM #include <ql_api.h>
429156SDaniel.Beauregard@Sun.COM #include <ql_init.h>
439156SDaniel.Beauregard@Sun.COM #include <ql_debug.h>
447836SJohn.Forte@Sun.COM 
457836SJohn.Forte@Sun.COM /*
467836SJohn.Forte@Sun.COM  * local prototypes
477836SJohn.Forte@Sun.COM  */
487836SJohn.Forte@Sun.COM static int32_t ql_doprint(uintptr_t, int8_t *);
497836SJohn.Forte@Sun.COM static void ql_dump_flags(uint64_t, int8_t **);
507836SJohn.Forte@Sun.COM static int qlclinks_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
517836SJohn.Forte@Sun.COM static int qlcstate_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
527836SJohn.Forte@Sun.COM static int qlc_osc_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
539156SDaniel.Beauregard@Sun.COM static int qlc_wdog_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
549156SDaniel.Beauregard@Sun.COM static int qlc_getdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
559156SDaniel.Beauregard@Sun.COM static int qlc_gettrace_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
569156SDaniel.Beauregard@Sun.COM #if 0
579156SDaniel.Beauregard@Sun.COM static int qlc_triggerdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
589156SDaniel.Beauregard@Sun.COM #endif
597836SJohn.Forte@Sun.COM static int qlcver_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
607836SJohn.Forte@Sun.COM static int qlstates_walk_init(mdb_walk_state_t *);
617836SJohn.Forte@Sun.COM static int qlstates_walk_step(mdb_walk_state_t *);
627836SJohn.Forte@Sun.COM static void qlstates_walk_fini(mdb_walk_state_t *);
637836SJohn.Forte@Sun.COM static int qlsrb_walk_init(mdb_walk_state_t *);
647836SJohn.Forte@Sun.COM static int qlsrb_walk_step(mdb_walk_state_t *);
657836SJohn.Forte@Sun.COM static void qlsrb_walk_fini(mdb_walk_state_t *);
667836SJohn.Forte@Sun.COM static int get_next_link(ql_link_t *);
677836SJohn.Forte@Sun.COM static int get_first_link(ql_head_t *, ql_link_t *);
687836SJohn.Forte@Sun.COM 
697836SJohn.Forte@Sun.COM static int ql_24xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
707836SJohn.Forte@Sun.COM     const mdb_arg_t *);
717836SJohn.Forte@Sun.COM static int ql_23xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
727836SJohn.Forte@Sun.COM     const mdb_arg_t *);
737836SJohn.Forte@Sun.COM static int ql_25xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
747836SJohn.Forte@Sun.COM     const mdb_arg_t *);
7510736SDaniel.Beauregard@Sun.COM static int ql_81xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
7610736SDaniel.Beauregard@Sun.COM     const mdb_arg_t *);
777836SJohn.Forte@Sun.COM static void ql_elog_common(ql_adapter_state_t *, boolean_t);
787836SJohn.Forte@Sun.COM 
797836SJohn.Forte@Sun.COM /*
807836SJohn.Forte@Sun.COM  * local adapter state flags strings
817836SJohn.Forte@Sun.COM  */
827836SJohn.Forte@Sun.COM int8_t *adapter_state_flags[] = {
837836SJohn.Forte@Sun.COM 	"FCA_BOUND",
847836SJohn.Forte@Sun.COM 	"QL_OPENED",
857836SJohn.Forte@Sun.COM 	"ONLINE",
867836SJohn.Forte@Sun.COM 	"INTERRUPTS_ENABLED",
879156SDaniel.Beauregard@Sun.COM 	"ABORT_CMDS_LOOP_DOWN_TMO",
887836SJohn.Forte@Sun.COM 	"POINT_TO_POINT",
897836SJohn.Forte@Sun.COM 	"IP_ENABLED",
907836SJohn.Forte@Sun.COM 	"IP_INITIALIZED",
919446SDaniel.Beauregard@Sun.COM 	"MENLO_LOGIN_OPERATIONAL",
927836SJohn.Forte@Sun.COM 	"ADAPTER_SUSPENDED",
937836SJohn.Forte@Sun.COM 	"ADAPTER_TIMER_BUSY",
947836SJohn.Forte@Sun.COM 	"PARITY_ERROR",
957836SJohn.Forte@Sun.COM 	"FLASH_ERRLOG_MARKER",
967836SJohn.Forte@Sun.COM 	"VP_ENABLED",
977836SJohn.Forte@Sun.COM 	"FDISC_ENABLED",
989446SDaniel.Beauregard@Sun.COM 	"FUNCTION_1",
999611SDaniel.Beauregard@Sun.COM 	"MPI_RESET_NEEDED",
1007836SJohn.Forte@Sun.COM 	NULL
1017836SJohn.Forte@Sun.COM };
1027836SJohn.Forte@Sun.COM 
1037836SJohn.Forte@Sun.COM int8_t *adapter_config_flags[] = {
1047836SJohn.Forte@Sun.COM 	"ENABLE_HARD_ADDRESS",
1057836SJohn.Forte@Sun.COM 	"ENABLE_64BIT_ADDRESSING",
1067836SJohn.Forte@Sun.COM 	"ENABLE_LIP_RESET",
1077836SJohn.Forte@Sun.COM 	"ENABLE_FULL_LIP_LOGIN",
1087836SJohn.Forte@Sun.COM 	"ENABLE_TARGET_RESET",
1097836SJohn.Forte@Sun.COM 	"ENABLE_LINK_DOWN_REPORTING",
1109446SDaniel.Beauregard@Sun.COM 	"DISABLE_EXTENDED_LOGGING_TRACE",
1117836SJohn.Forte@Sun.COM 	"ENABLE_FCP_2_SUPPORT",
1127836SJohn.Forte@Sun.COM 	"MULTI_CHIP_ADAPTER",
1137836SJohn.Forte@Sun.COM 	"SBUS_CARD",
1147836SJohn.Forte@Sun.COM 	"CTRL_2300",
1157836SJohn.Forte@Sun.COM 	"CTRL_6322",
1167836SJohn.Forte@Sun.COM 	"CTRL_2200",
1177836SJohn.Forte@Sun.COM 	"CTRL_2422",
1187836SJohn.Forte@Sun.COM 	"CTRL_25XX",
1197836SJohn.Forte@Sun.COM 	"ENABLE_EXTENDED_LOGGING",
1207836SJohn.Forte@Sun.COM 	"DISABLE_RISC_CODE_LOAD",
1217836SJohn.Forte@Sun.COM 	"SET_CACHE_LINE_SIZE_1",
1229446SDaniel.Beauregard@Sun.COM 	"CTRL_MENLO",
1237836SJohn.Forte@Sun.COM 	"EXT_FW_INTERFACE",
1247836SJohn.Forte@Sun.COM 	"LOAD_FLASH_FW",
1257836SJohn.Forte@Sun.COM 	"DUMP_MAILBOX_TIMEOUT",
1267836SJohn.Forte@Sun.COM 	"DUMP_ISP_SYSTEM_ERROR",
1277836SJohn.Forte@Sun.COM 	"DUMP_DRIVER_COMMAND_TIMEOUT",
1287836SJohn.Forte@Sun.COM 	"DUMP_LOOP_OFFLINE_TIMEOUT",
1297836SJohn.Forte@Sun.COM 	"ENABLE_FWEXTTRACE",
1307836SJohn.Forte@Sun.COM 	"ENABLE_FWFCETRACE",
1317836SJohn.Forte@Sun.COM 	"FW_MISMATCH",
1329446SDaniel.Beauregard@Sun.COM 	"CTRL_81XX",
13311924SDaniel.Beauregard@Sun.COM 	"CTRL_8021",
13411924SDaniel.Beauregard@Sun.COM 	"ENABLE_FAST_TIMEOUT",
13511924SDaniel.Beauregard@Sun.COM 	"LR_SUPPORT",
1367836SJohn.Forte@Sun.COM 	NULL
1377836SJohn.Forte@Sun.COM };
1387836SJohn.Forte@Sun.COM 
1397836SJohn.Forte@Sun.COM /*
1407836SJohn.Forte@Sun.COM  * local task daemon flags strings
1417836SJohn.Forte@Sun.COM  */
1427836SJohn.Forte@Sun.COM int8_t *task_daemon_flags[] = {
1437836SJohn.Forte@Sun.COM 	"TASK_DAEMON_STOP_FLG",
1447836SJohn.Forte@Sun.COM 	"TASK_DAEMON_SLEEPING_FLG",
1457836SJohn.Forte@Sun.COM 	"TASK_DAEMON_ALIVE_FLG",
1467836SJohn.Forte@Sun.COM 	"TASK_DAEMON_IDLE_CHK_FLG",
1477836SJohn.Forte@Sun.COM 	"SUSPENDED_WAKEUP_FLG",
1487836SJohn.Forte@Sun.COM 	"FC_STATE_CHANGE",
1497836SJohn.Forte@Sun.COM 	"NEED_UNSOLICITED_BUFFERS",
1507836SJohn.Forte@Sun.COM 	"RESET_MARKER_NEEDED",
1517836SJohn.Forte@Sun.COM 	"RESET_ACTIVE",
1527836SJohn.Forte@Sun.COM 	"ISP_ABORT_NEEDED",
1537836SJohn.Forte@Sun.COM 	"ABORT_ISP_ACTIVE",
1547836SJohn.Forte@Sun.COM 	"LOOP_RESYNC_NEEDED",
1557836SJohn.Forte@Sun.COM 	"LOOP_RESYNC_ACTIVE",
1567836SJohn.Forte@Sun.COM 	"LOOP_DOWN",
1577836SJohn.Forte@Sun.COM 	"DRIVER_STALL",
1587836SJohn.Forte@Sun.COM 	"COMMAND_WAIT_NEEDED",
1597836SJohn.Forte@Sun.COM 	"COMMAND_WAIT_ACTIVE",
1607836SJohn.Forte@Sun.COM 	"STATE_ONLINE",
1617836SJohn.Forte@Sun.COM 	"ABORT_QUEUES_NEEDED",
1627836SJohn.Forte@Sun.COM 	"TASK_DAEMON_STALLED_FLG",
1637836SJohn.Forte@Sun.COM 	"TASK_THREAD_CALLED",
1647836SJohn.Forte@Sun.COM 	"FIRMWARE_UP",
1657836SJohn.Forte@Sun.COM 	"LIP_RESET_PENDING",
1667836SJohn.Forte@Sun.COM 	"FIRMWARE_LOADED",
1677836SJohn.Forte@Sun.COM 	"RSCN_UPDATE_NEEDED",
1687836SJohn.Forte@Sun.COM 	"HANDLE_PORT_BYPASS_CHANGE",
1697836SJohn.Forte@Sun.COM 	"PORT_RETRY_NEEDED",
1707836SJohn.Forte@Sun.COM 	"TASK_DAEMON_POWERING_DOWN",
1717836SJohn.Forte@Sun.COM 	"TD_IIDMA_NEEDED",
1729446SDaniel.Beauregard@Sun.COM 	"SEND_PLOGI",
173*12279SDaniel.Beauregard@Sun.COM 	"IDC_EVENT",
1747836SJohn.Forte@Sun.COM 	NULL
1757836SJohn.Forte@Sun.COM };
1767836SJohn.Forte@Sun.COM 
1777836SJohn.Forte@Sun.COM /*
1787836SJohn.Forte@Sun.COM  * local interrupt aif flags
1797836SJohn.Forte@Sun.COM  */
1807836SJohn.Forte@Sun.COM int8_t *aif_flags[] = {
1817836SJohn.Forte@Sun.COM 	"IFLG_INTR_LEGACY",
1829446SDaniel.Beauregard@Sun.COM 	"IFLG_INTR_FIXED",
1837836SJohn.Forte@Sun.COM 	"IFLG_INTR_MSI",
1849446SDaniel.Beauregard@Sun.COM 	"IFLG_INTR_MSIX",
1857836SJohn.Forte@Sun.COM 	NULL
1867836SJohn.Forte@Sun.COM };
1877836SJohn.Forte@Sun.COM 
1887836SJohn.Forte@Sun.COM int8_t *qlsrb_flags[] = {
1897836SJohn.Forte@Sun.COM 	"SRB_ISP_STARTED",
1907836SJohn.Forte@Sun.COM 	"SRB_ISP_COMPLETED",
1917836SJohn.Forte@Sun.COM 	"SRB_RETRY",
1927836SJohn.Forte@Sun.COM 	"SRB_POLL",
1937836SJohn.Forte@Sun.COM 	"SRB_WATCHDOG_ENABLED",
1947836SJohn.Forte@Sun.COM 	"SRB_ABORT",
1957836SJohn.Forte@Sun.COM 	"SRB_UB_IN_FCA",
1967836SJohn.Forte@Sun.COM 	"SRB_UB_IN_ISP",
1977836SJohn.Forte@Sun.COM 	"SRB_UB_CALLBACK",
1987836SJohn.Forte@Sun.COM 	"SRB_UB_RSCN",
1997836SJohn.Forte@Sun.COM 	"SRB_UB_FCP",
2007836SJohn.Forte@Sun.COM 	"SRB_FCP_CMD_PKT",
2017836SJohn.Forte@Sun.COM 	"SRB_FCP_DATA_PKT",
2027836SJohn.Forte@Sun.COM 	"SRB_FCP_RSP_PKT",
2037836SJohn.Forte@Sun.COM 	"SRB_IP_PKT",
2047836SJohn.Forte@Sun.COM 	"SRB_GENERIC_SERVICES_PKT",
2057836SJohn.Forte@Sun.COM 	"SRB_COMMAND_TIMEOUT",
2067836SJohn.Forte@Sun.COM 	"SRB_ABORTING",
2077836SJohn.Forte@Sun.COM 	"SRB_IN_DEVICE_QUEUE",
2087836SJohn.Forte@Sun.COM 	"SRB_IN_TOKEN_ARRAY",
2097836SJohn.Forte@Sun.COM 	"SRB_UB_FREE_REQUESTED",
2107836SJohn.Forte@Sun.COM 	"SRB_UB_ACQUIRED",
2117836SJohn.Forte@Sun.COM 	"SRB_MS_PKT",
2127836SJohn.Forte@Sun.COM 	NULL
2137836SJohn.Forte@Sun.COM };
2147836SJohn.Forte@Sun.COM 
2157836SJohn.Forte@Sun.COM int8_t *qllun_flags[] = {
2167836SJohn.Forte@Sun.COM 	"LQF_UNTAGGED_PENDING",
2177836SJohn.Forte@Sun.COM 	NULL
2187836SJohn.Forte@Sun.COM };
2197836SJohn.Forte@Sun.COM 
2207836SJohn.Forte@Sun.COM int8_t *qltgt_flags[] = {
2217836SJohn.Forte@Sun.COM 	"TQF_TAPE_DEVICE",
2227836SJohn.Forte@Sun.COM 	"TQF_QUEUE_SUSPENDED",
2237836SJohn.Forte@Sun.COM 	"TQF_FABRIC_DEVICE",
2247836SJohn.Forte@Sun.COM 	"TQF_INITIATOR_DEVICE",
2257836SJohn.Forte@Sun.COM 	"TQF_RSCN_RCVD",
2267836SJohn.Forte@Sun.COM 	"TQF_NEED_AUTHENTICATION",
2277836SJohn.Forte@Sun.COM 	"TQF_PLOGI_PROGRS",
2287836SJohn.Forte@Sun.COM 	"TQF_IIDMA_NEEDED",
2297836SJohn.Forte@Sun.COM 	NULL
2307836SJohn.Forte@Sun.COM };
2317836SJohn.Forte@Sun.COM 
2329156SDaniel.Beauregard@Sun.COM int8_t *qldump_flags[] = {
2339156SDaniel.Beauregard@Sun.COM 	"QL_DUMPING",
2349156SDaniel.Beauregard@Sun.COM 	"QL_DUMP_VALID",
2359156SDaniel.Beauregard@Sun.COM 	"QL_DUMP_UPLOADED",
2369156SDaniel.Beauregard@Sun.COM 	NULL
2379156SDaniel.Beauregard@Sun.COM };
2389156SDaniel.Beauregard@Sun.COM 
2397836SJohn.Forte@Sun.COM /*
2407836SJohn.Forte@Sun.COM  * qlclinks_dcmd
2417836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the ql_hba pointers
2427836SJohn.Forte@Sun.COM  *
2437836SJohn.Forte@Sun.COM  * Input:
2447836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
2457836SJohn.Forte@Sun.COM  *	flags = mdb flags.
2467836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
2477836SJohn.Forte@Sun.COM  *	argv  = Arg array.
2487836SJohn.Forte@Sun.COM  *
2497836SJohn.Forte@Sun.COM  * Returns:
2507836SJohn.Forte@Sun.COM  *	DCMD_ERR, DCMD_USAGE, or DCMD_OK
2517836SJohn.Forte@Sun.COM  *
2527836SJohn.Forte@Sun.COM  * Context:
2537836SJohn.Forte@Sun.COM  *	User context.
2547836SJohn.Forte@Sun.COM  *
2557836SJohn.Forte@Sun.COM  */
2567836SJohn.Forte@Sun.COM /*ARGSUSED*/
2577836SJohn.Forte@Sun.COM static int
qlclinks_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2587836SJohn.Forte@Sun.COM qlclinks_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2597836SJohn.Forte@Sun.COM {
2607836SJohn.Forte@Sun.COM 	ql_head_t		ql_hba;
2617836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
2627836SJohn.Forte@Sun.COM 	uintptr_t		hbaptr = NULL;
2637836SJohn.Forte@Sun.COM 
2647836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
2657836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
2667836SJohn.Forte@Sun.COM 	}
2677836SJohn.Forte@Sun.COM 
2687836SJohn.Forte@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
2697836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure");
2707836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2717836SJohn.Forte@Sun.COM 	}
2727836SJohn.Forte@Sun.COM 
2737836SJohn.Forte@Sun.COM 	if (&ql_hba == NULL) {
2747836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
2757836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2767836SJohn.Forte@Sun.COM 	}
2777836SJohn.Forte@Sun.COM 
2787836SJohn.Forte@Sun.COM 	mdb_printf("\nqlc adapter state linkages (f=0x%llx, l=0x%llx)\n\n",
2797836SJohn.Forte@Sun.COM 	    ql_hba.first, ql_hba.last);
2807836SJohn.Forte@Sun.COM 
2817836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
2827836SJohn.Forte@Sun.COM 	    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
2837836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
2847836SJohn.Forte@Sun.COM 		return (DCMD_OK);
2857836SJohn.Forte@Sun.COM 	}
2867836SJohn.Forte@Sun.COM 
2877836SJohn.Forte@Sun.COM 	(void) mdb_inc_indent((ulong_t)4);
2887836SJohn.Forte@Sun.COM 	mdb_printf("%<u>%-?s\t%-45s%</u>\n\n", "baseaddr", "instance");
2897836SJohn.Forte@Sun.COM 
2907836SJohn.Forte@Sun.COM 	hbaptr = (uintptr_t)ql_hba.first;
2917836SJohn.Forte@Sun.COM 	while (hbaptr != NULL) {
2927836SJohn.Forte@Sun.COM 
2937836SJohn.Forte@Sun.COM 		if (mdb_vread(qlstate, sizeof (ql_adapter_state_t),
2947836SJohn.Forte@Sun.COM 		    hbaptr) == -1) {
2957836SJohn.Forte@Sun.COM 			mdb_free(qlstate, sizeof (ql_adapter_state_t));
2967836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_adapter_state at %p",
2977836SJohn.Forte@Sun.COM 			    hbaptr);
2987836SJohn.Forte@Sun.COM 			return (DCMD_OK);
2997836SJohn.Forte@Sun.COM 		}
3007836SJohn.Forte@Sun.COM 
3017836SJohn.Forte@Sun.COM 		mdb_printf("%<b>0x%016p%t%d%</b>\n",
3027836SJohn.Forte@Sun.COM 		    qlstate->hba.base_address, qlstate->instance);
3037836SJohn.Forte@Sun.COM 
3047836SJohn.Forte@Sun.COM 		/*
3057836SJohn.Forte@Sun.COM 		 * If vp exists, loop through those
3067836SJohn.Forte@Sun.COM 		 */
3077836SJohn.Forte@Sun.COM 
3087836SJohn.Forte@Sun.COM 		if ((qlstate->flags & VP_ENABLED) &&
3097836SJohn.Forte@Sun.COM 		    (qlstate->vp_next != NULL)) {
3107836SJohn.Forte@Sun.COM 
3117836SJohn.Forte@Sun.COM 			ql_adapter_state_t	*vqlstate;
3127836SJohn.Forte@Sun.COM 			uintptr_t		vhbaptr = NULL;
3137836SJohn.Forte@Sun.COM 
3147836SJohn.Forte@Sun.COM 			vhbaptr = (uintptr_t)qlstate->vp_next;
3157836SJohn.Forte@Sun.COM 
3167836SJohn.Forte@Sun.COM 			if ((vqlstate = (ql_adapter_state_t *)mdb_alloc(
3177836SJohn.Forte@Sun.COM 			    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
3187836SJohn.Forte@Sun.COM 				mdb_warn("Unable to allocate memory for "
3197836SJohn.Forte@Sun.COM 				    "ql_adapter_state vp\n");
3207836SJohn.Forte@Sun.COM 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
3217836SJohn.Forte@Sun.COM 				return (DCMD_OK);
3227836SJohn.Forte@Sun.COM 			}
3237836SJohn.Forte@Sun.COM 
3247836SJohn.Forte@Sun.COM 			(void) mdb_inc_indent((ulong_t)30);
3257836SJohn.Forte@Sun.COM 
3267836SJohn.Forte@Sun.COM 			mdb_printf("%<u>vp baseaddr\t\tvp index%</u>\n");
3277836SJohn.Forte@Sun.COM 
3287836SJohn.Forte@Sun.COM 			while (vhbaptr != NULL) {
3297836SJohn.Forte@Sun.COM 
3307836SJohn.Forte@Sun.COM 				if (mdb_vread(vqlstate,
3319156SDaniel.Beauregard@Sun.COM 				    sizeof (ql_adapter_state_t), vhbaptr) ==
3329156SDaniel.Beauregard@Sun.COM 				    -1) {
3337836SJohn.Forte@Sun.COM 					mdb_free(vqlstate,
3347836SJohn.Forte@Sun.COM 					    sizeof (ql_adapter_state_t));
3357836SJohn.Forte@Sun.COM 					mdb_free(qlstate,
3367836SJohn.Forte@Sun.COM 					    sizeof (ql_adapter_state_t));
3377836SJohn.Forte@Sun.COM 					mdb_warn("failed to read vp "
3387836SJohn.Forte@Sun.COM 					    "ql_adapter_state at %p", vhbaptr);
3397836SJohn.Forte@Sun.COM 					return (DCMD_OK);
3407836SJohn.Forte@Sun.COM 				}
3417836SJohn.Forte@Sun.COM 
3427836SJohn.Forte@Sun.COM 				mdb_printf("%<b>0x%016p%t%d%</b>\n",
3437836SJohn.Forte@Sun.COM 				    vqlstate->hba.base_address,
3447836SJohn.Forte@Sun.COM 				    vqlstate->vp_index);
3457836SJohn.Forte@Sun.COM 
3467836SJohn.Forte@Sun.COM 				vhbaptr = (uintptr_t)vqlstate->vp_next;
3477836SJohn.Forte@Sun.COM 			}
3487836SJohn.Forte@Sun.COM 
3497836SJohn.Forte@Sun.COM 			mdb_free(vqlstate, sizeof (ql_adapter_state_t));
3507836SJohn.Forte@Sun.COM 
3517836SJohn.Forte@Sun.COM 			(void) mdb_dec_indent((ulong_t)30);
3527836SJohn.Forte@Sun.COM 
3537836SJohn.Forte@Sun.COM 			mdb_printf("\n");
3547836SJohn.Forte@Sun.COM 		}
3557836SJohn.Forte@Sun.COM 
3567836SJohn.Forte@Sun.COM 		hbaptr = (uintptr_t)qlstate->hba.next;
3577836SJohn.Forte@Sun.COM 	}
3587836SJohn.Forte@Sun.COM 
3597836SJohn.Forte@Sun.COM 	(void) mdb_dec_indent((ulong_t)4);
3607836SJohn.Forte@Sun.COM 
3617836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
3627836SJohn.Forte@Sun.COM 
3637836SJohn.Forte@Sun.COM 	return (DCMD_OK);
3647836SJohn.Forte@Sun.COM }
3657836SJohn.Forte@Sun.COM 
3667836SJohn.Forte@Sun.COM /*
3677836SJohn.Forte@Sun.COM  * qlcver_dcmd
3687836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the qlc driver version the mdb
3697836SJohn.Forte@Sun.COM  *	module was compiled with, and the verison of qlc which is
3707836SJohn.Forte@Sun.COM  *	currently loaded on the machine.
3717836SJohn.Forte@Sun.COM  *
3727836SJohn.Forte@Sun.COM  * Input:
3737836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
3747836SJohn.Forte@Sun.COM  *	flags = mdb flags.
3757836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
3767836SJohn.Forte@Sun.COM  *	argv  = Arg array.
3777836SJohn.Forte@Sun.COM  *
3787836SJohn.Forte@Sun.COM  * Returns:
3797836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
3807836SJohn.Forte@Sun.COM  *
3817836SJohn.Forte@Sun.COM  * Context:
3827836SJohn.Forte@Sun.COM  *	User context.
3837836SJohn.Forte@Sun.COM  *
3847836SJohn.Forte@Sun.COM  */
3857836SJohn.Forte@Sun.COM /*ARGSUSED*/
3867836SJohn.Forte@Sun.COM static int
qlcver_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)3877836SJohn.Forte@Sun.COM qlcver_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3887836SJohn.Forte@Sun.COM {
3899156SDaniel.Beauregard@Sun.COM 	int8_t		qlcversion[100];
3909156SDaniel.Beauregard@Sun.COM 	struct fw_table	fw_table[10], *fwt = NULL;
3919156SDaniel.Beauregard@Sun.COM 	uint8_t		*fwverptr = NULL;
3929156SDaniel.Beauregard@Sun.COM 	ql_head_t	ql_hba;
3939156SDaniel.Beauregard@Sun.COM 	uint32_t	found = 0;
3947836SJohn.Forte@Sun.COM 
3957836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
3967836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
3977836SJohn.Forte@Sun.COM 	}
3987836SJohn.Forte@Sun.COM 
3997836SJohn.Forte@Sun.COM 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
4007836SJohn.Forte@Sun.COM 		mdb_warn("unable to read qlc driver version\n");
4017836SJohn.Forte@Sun.COM 	} else {
4029156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n%s version currently loaded is: %s\n",
4037836SJohn.Forte@Sun.COM 		    QL_NAME, qlcversion);
4047836SJohn.Forte@Sun.COM 	}
4057836SJohn.Forte@Sun.COM 
4069156SDaniel.Beauregard@Sun.COM 	mdb_printf("qlc mdb library compiled with %s version: %s\n",
4079156SDaniel.Beauregard@Sun.COM 	    QL_NAME, QL_VERSION);
4089156SDaniel.Beauregard@Sun.COM 
4099156SDaniel.Beauregard@Sun.COM 	if ((fwverptr = (uint8_t *)(mdb_alloc(50, UM_SLEEP))) == NULL) {
4109156SDaniel.Beauregard@Sun.COM 		mdb_warn("unable to alloc fwverptr\n");
4119156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
4129156SDaniel.Beauregard@Sun.COM 	}
4139156SDaniel.Beauregard@Sun.COM 
4149156SDaniel.Beauregard@Sun.COM 	if (mdb_readvar(&fw_table, "fw_table") == -1) {
4159156SDaniel.Beauregard@Sun.COM 		mdb_warn("unable to read firmware table\n");
4169156SDaniel.Beauregard@Sun.COM 	} else {
4179156SDaniel.Beauregard@Sun.COM 		ql_adapter_state_t	*qlstate;
4189156SDaniel.Beauregard@Sun.COM 		uintptr_t		hbaptr = NULL;
4199156SDaniel.Beauregard@Sun.COM 
4209156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
4219156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
4229156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
4239156SDaniel.Beauregard@Sun.COM 		}
4249156SDaniel.Beauregard@Sun.COM 
4259156SDaniel.Beauregard@Sun.COM 		if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
4269156SDaniel.Beauregard@Sun.COM 		    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
4279156SDaniel.Beauregard@Sun.COM 			mdb_warn("Unable to allocate memory for "
4289156SDaniel.Beauregard@Sun.COM 			    "ql_adapter_state\n");
4299156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
4309156SDaniel.Beauregard@Sun.COM 		}
4319156SDaniel.Beauregard@Sun.COM 
4329156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n%-8s%-11s%s\n", "f/w", "compiled", "loaded");
4339156SDaniel.Beauregard@Sun.COM 		mdb_printf("%<u>%-8s%-11s%-13s%s%</u>\n\n", "class", "version",
4349156SDaniel.Beauregard@Sun.COM 		    "version", "instance list");
4359156SDaniel.Beauregard@Sun.COM 
4369156SDaniel.Beauregard@Sun.COM 		for (fwt = &fw_table[0]; fwt->fw_class; fwt++) {
4379156SDaniel.Beauregard@Sun.COM 
4389156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(fwverptr, sizeof (void *),
4399156SDaniel.Beauregard@Sun.COM 			    (uintptr_t)fwt->fw_version) == -1) {
4409156SDaniel.Beauregard@Sun.COM 				mdb_warn("unable to read fwverptr\n");
4419156SDaniel.Beauregard@Sun.COM 				mdb_free(fwverptr, sizeof (void *));
4429156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
4439156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
4449156SDaniel.Beauregard@Sun.COM 			}
4459156SDaniel.Beauregard@Sun.COM 
4469156SDaniel.Beauregard@Sun.COM 			mdb_printf("%x\t%-11s", fwt->fw_class, fwverptr);
4479156SDaniel.Beauregard@Sun.COM 
4489156SDaniel.Beauregard@Sun.COM 			if (&ql_hba == NULL) {
4499156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read ql_hba structure");
4509156SDaniel.Beauregard@Sun.COM 				hbaptr = NULL;
4519156SDaniel.Beauregard@Sun.COM 			} else {
4529156SDaniel.Beauregard@Sun.COM 				hbaptr = (uintptr_t)ql_hba.first;
4539156SDaniel.Beauregard@Sun.COM 			}
4549156SDaniel.Beauregard@Sun.COM 
4559156SDaniel.Beauregard@Sun.COM 			found = 0;
4569156SDaniel.Beauregard@Sun.COM 			while (hbaptr != NULL) {
4579156SDaniel.Beauregard@Sun.COM 
4589156SDaniel.Beauregard@Sun.COM 				if (mdb_vread(qlstate,
4599156SDaniel.Beauregard@Sun.COM 				    sizeof (ql_adapter_state_t), hbaptr) ==
4609156SDaniel.Beauregard@Sun.COM 				    -1) {
4619156SDaniel.Beauregard@Sun.COM 					mdb_warn("failed to read "
4629156SDaniel.Beauregard@Sun.COM 					    "ql_adapter_state at %p", hbaptr);
4639156SDaniel.Beauregard@Sun.COM 					break;
4649156SDaniel.Beauregard@Sun.COM 				}
4659156SDaniel.Beauregard@Sun.COM 
4669156SDaniel.Beauregard@Sun.COM 				if (qlstate->fw_class == fwt->fw_class) {
4679156SDaniel.Beauregard@Sun.COM 					if (found == 0) {
4689156SDaniel.Beauregard@Sun.COM 						mdb_printf("%x.%02x.%02x\t",
4699156SDaniel.Beauregard@Sun.COM 						    qlstate->fw_major_version,
4709156SDaniel.Beauregard@Sun.COM 						    qlstate->fw_minor_version,
4719156SDaniel.Beauregard@Sun.COM 						    qlstate->
4729156SDaniel.Beauregard@Sun.COM 						    fw_subminor_version);
4739156SDaniel.Beauregard@Sun.COM 						mdb_printf("%d",
4749156SDaniel.Beauregard@Sun.COM 						    qlstate->instance);
4759156SDaniel.Beauregard@Sun.COM 					} else {
4769156SDaniel.Beauregard@Sun.COM 						mdb_printf(", %d",
4779156SDaniel.Beauregard@Sun.COM 						    qlstate->instance);
4789156SDaniel.Beauregard@Sun.COM 					}
4799156SDaniel.Beauregard@Sun.COM 					found = 1;
4809156SDaniel.Beauregard@Sun.COM 				}
4819156SDaniel.Beauregard@Sun.COM 
4829156SDaniel.Beauregard@Sun.COM 				hbaptr = (uintptr_t)qlstate->hba.next;
4839156SDaniel.Beauregard@Sun.COM 			}
4849156SDaniel.Beauregard@Sun.COM 
4859156SDaniel.Beauregard@Sun.COM 			if (found == 1) {
4869156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n");
4879156SDaniel.Beauregard@Sun.COM 			} else {
4889156SDaniel.Beauregard@Sun.COM 				mdb_printf("not loaded\n");
4899156SDaniel.Beauregard@Sun.COM 			}
4909156SDaniel.Beauregard@Sun.COM 		}
4919156SDaniel.Beauregard@Sun.COM 
4929156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
4939156SDaniel.Beauregard@Sun.COM 		mdb_free(fwverptr, sizeof (void *));
4949156SDaniel.Beauregard@Sun.COM 	}
4959156SDaniel.Beauregard@Sun.COM 
4967836SJohn.Forte@Sun.COM 	return (DCMD_OK);
4977836SJohn.Forte@Sun.COM }
4987836SJohn.Forte@Sun.COM 
4997836SJohn.Forte@Sun.COM /*
5007836SJohn.Forte@Sun.COM  * qlc_el_dcmd
5017836SJohn.Forte@Sun.COM  *	mdb dcmd which turns the extended logging bit on or off
5027836SJohn.Forte@Sun.COM  *	for the specificed qlc instance(s).
5037836SJohn.Forte@Sun.COM  *
5047836SJohn.Forte@Sun.COM  * Input:
5057836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
5067836SJohn.Forte@Sun.COM  *	flags = mdb flags.
5077836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
5087836SJohn.Forte@Sun.COM  *	argv  = Arg array.
5097836SJohn.Forte@Sun.COM  *
5107836SJohn.Forte@Sun.COM  * Returns:
5117836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
5127836SJohn.Forte@Sun.COM  *
5137836SJohn.Forte@Sun.COM  * Context:
5147836SJohn.Forte@Sun.COM  *	User context.
5157836SJohn.Forte@Sun.COM  *
5167836SJohn.Forte@Sun.COM  */
5177836SJohn.Forte@Sun.COM /*ARGSUSED*/
5187836SJohn.Forte@Sun.COM static int
qlc_el_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)5197836SJohn.Forte@Sun.COM qlc_el_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5207836SJohn.Forte@Sun.COM {
5217836SJohn.Forte@Sun.COM 	int8_t			qlcversion[100];
5227836SJohn.Forte@Sun.COM 	boolean_t		elswitch;
5237836SJohn.Forte@Sun.COM 	uint32_t		argcnt;
5247836SJohn.Forte@Sun.COM 	int			mdbs;
5257836SJohn.Forte@Sun.COM 	uint32_t		instance;
5267836SJohn.Forte@Sun.COM 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
5277836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
5287836SJohn.Forte@Sun.COM 	uintptr_t		hbaptr = NULL;
5297836SJohn.Forte@Sun.COM 	ql_head_t		ql_hba;
5307836SJohn.Forte@Sun.COM 
5317836SJohn.Forte@Sun.COM 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
5327836SJohn.Forte@Sun.COM 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
5337836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5347836SJohn.Forte@Sun.COM 	}
5357836SJohn.Forte@Sun.COM 
5367836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc < 2) {
5377836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
5387836SJohn.Forte@Sun.COM 	}
5397836SJohn.Forte@Sun.COM 
5407836SJohn.Forte@Sun.COM 	/*
5417836SJohn.Forte@Sun.COM 	 * Check and make sure the driver version and the mdb versions
5427836SJohn.Forte@Sun.COM 	 * match so all the structures and flags line up
5437836SJohn.Forte@Sun.COM 	 */
5447836SJohn.Forte@Sun.COM 
5457836SJohn.Forte@Sun.COM 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
5467836SJohn.Forte@Sun.COM 		mdb_warn("unable to read qlc driver version\n");
5477836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5487836SJohn.Forte@Sun.COM 	}
5497836SJohn.Forte@Sun.COM 
5507836SJohn.Forte@Sun.COM 	if ((strcmp(QL_VERSION, (const char *)&qlcversion)) != 0) {
5517836SJohn.Forte@Sun.COM 		mdb_warn("Error: qlc driver/qlc mdb version mismatch\n");
5527836SJohn.Forte@Sun.COM 		mdb_printf("\tqlc mdb library compiled version is: %s\n",
5537836SJohn.Forte@Sun.COM 		    QL_VERSION);
5547836SJohn.Forte@Sun.COM 		mdb_printf("\tqlc driver version is: %s\n", qlcversion);
5557836SJohn.Forte@Sun.COM 
5567836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5577836SJohn.Forte@Sun.COM 	}
5587836SJohn.Forte@Sun.COM 
5597836SJohn.Forte@Sun.COM 	if ((strcasecmp(argv[0].a_un.a_str, "on")) == 0) {
5607836SJohn.Forte@Sun.COM 		elswitch = TRUE;
5617836SJohn.Forte@Sun.COM 	} else if ((strcasecmp(argv[0].a_un.a_str, "off")) == 0) {
5627836SJohn.Forte@Sun.COM 		elswitch = FALSE;
5637836SJohn.Forte@Sun.COM 	} else {
5647836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
5657836SJohn.Forte@Sun.COM 	}
5667836SJohn.Forte@Sun.COM 
5677836SJohn.Forte@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
5687836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure");
5697836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
5707836SJohn.Forte@Sun.COM 	}
5717836SJohn.Forte@Sun.COM 
5727836SJohn.Forte@Sun.COM 	if (&ql_hba == NULL) {
5737836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure - is qlc loaded?");
5747836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
5757836SJohn.Forte@Sun.COM 	}
5767836SJohn.Forte@Sun.COM 
5777836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
5787836SJohn.Forte@Sun.COM 	    UM_SLEEP)) == NULL) {
5797836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for "
5807836SJohn.Forte@Sun.COM 		    "ql_adapter_state\n");
5817836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5827836SJohn.Forte@Sun.COM 	}
5837836SJohn.Forte@Sun.COM 
5847836SJohn.Forte@Sun.COM 	if ((strcasecmp(argv[1].a_un.a_str, "all")) == 0) {
5857836SJohn.Forte@Sun.COM 
5867836SJohn.Forte@Sun.COM 		if (argc != 2) {
5877836SJohn.Forte@Sun.COM 			mdb_free(qlstate, qlsize);
5887836SJohn.Forte@Sun.COM 			return (DCMD_USAGE);
5897836SJohn.Forte@Sun.COM 		}
5907836SJohn.Forte@Sun.COM 
5917836SJohn.Forte@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
5927836SJohn.Forte@Sun.COM 
5937836SJohn.Forte@Sun.COM 		while (hbaptr != NULL) {
5947836SJohn.Forte@Sun.COM 
5957836SJohn.Forte@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
5967836SJohn.Forte@Sun.COM 				mdb_free(qlstate, qlsize);
5977836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_adapter_state "
5987836SJohn.Forte@Sun.COM 				    "at %p", hbaptr);
5997836SJohn.Forte@Sun.COM 				return (DCMD_OK);
6007836SJohn.Forte@Sun.COM 			}
6017836SJohn.Forte@Sun.COM 
6027836SJohn.Forte@Sun.COM 			ql_elog_common(qlstate, elswitch);
6037836SJohn.Forte@Sun.COM 
6047836SJohn.Forte@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
6057836SJohn.Forte@Sun.COM 		}
6067836SJohn.Forte@Sun.COM 	} else {
6077836SJohn.Forte@Sun.COM 		for (argcnt = 1; argcnt < argc; argcnt++) {
6087836SJohn.Forte@Sun.COM 
6097836SJohn.Forte@Sun.COM 			instance = (uint32_t)mdb_strtoull(
6107836SJohn.Forte@Sun.COM 			    argv[argcnt].a_un.a_str);
6117836SJohn.Forte@Sun.COM 
6127836SJohn.Forte@Sun.COM 			/* find the correct instance to change */
6137836SJohn.Forte@Sun.COM 			hbaptr = (uintptr_t)ql_hba.first;
6147836SJohn.Forte@Sun.COM 			while (hbaptr != NULL) {
6157836SJohn.Forte@Sun.COM 
6167836SJohn.Forte@Sun.COM 				if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
6177836SJohn.Forte@Sun.COM 					mdb_free(qlstate, qlsize);
6189156SDaniel.Beauregard@Sun.COM 					mdb_warn("failed to read "
6199156SDaniel.Beauregard@Sun.COM 					    "ql_adapter_state at %p", hbaptr);
6207836SJohn.Forte@Sun.COM 					return (DCMD_OK);
6217836SJohn.Forte@Sun.COM 				}
6227836SJohn.Forte@Sun.COM 
6237836SJohn.Forte@Sun.COM 				if (qlstate->instance == instance) {
6247836SJohn.Forte@Sun.COM 					break;
6257836SJohn.Forte@Sun.COM 				}
6267836SJohn.Forte@Sun.COM 
6277836SJohn.Forte@Sun.COM 				hbaptr = (uintptr_t)qlstate->hba.next;
6287836SJohn.Forte@Sun.COM 			}
6297836SJohn.Forte@Sun.COM 
6307836SJohn.Forte@Sun.COM 			if (hbaptr == NULL) {
6317836SJohn.Forte@Sun.COM 				mdb_printf("instance %d is not loaded",
6327836SJohn.Forte@Sun.COM 				    instance);
6337836SJohn.Forte@Sun.COM 				continue;
6347836SJohn.Forte@Sun.COM 			}
6357836SJohn.Forte@Sun.COM 
6367836SJohn.Forte@Sun.COM 			ql_elog_common(qlstate, elswitch);
6377836SJohn.Forte@Sun.COM 		}
6387836SJohn.Forte@Sun.COM 	}
6397836SJohn.Forte@Sun.COM 
6407836SJohn.Forte@Sun.COM 	mdb_free(qlstate, qlsize);
6417836SJohn.Forte@Sun.COM 
6427836SJohn.Forte@Sun.COM 	return (DCMD_OK);
6437836SJohn.Forte@Sun.COM }
6447836SJohn.Forte@Sun.COM 
6457836SJohn.Forte@Sun.COM /*
6467836SJohn.Forte@Sun.COM  * qlc_elog_common
6477836SJohn.Forte@Sun.COM  *	mdb helper function which set/resets the extended logging bit
6487836SJohn.Forte@Sun.COM  *
6497836SJohn.Forte@Sun.COM  * Input:
6507836SJohn.Forte@Sun.COM  *	qlstate  = adapter state structure
6517836SJohn.Forte@Sun.COM  *	elswitch = boolean which specifies to reset (0) or set (1) the
6527836SJohn.Forte@Sun.COM  *		   extended logging bit.
6537836SJohn.Forte@Sun.COM  *
6547836SJohn.Forte@Sun.COM  * Returns:
6557836SJohn.Forte@Sun.COM  *
6567836SJohn.Forte@Sun.COM  * Context:
6577836SJohn.Forte@Sun.COM  *	User context.
6587836SJohn.Forte@Sun.COM  *
6597836SJohn.Forte@Sun.COM  */
6607836SJohn.Forte@Sun.COM static void
ql_elog_common(ql_adapter_state_t * qlstate,boolean_t elswitch)6617836SJohn.Forte@Sun.COM ql_elog_common(ql_adapter_state_t *qlstate, boolean_t elswitch)
6627836SJohn.Forte@Sun.COM {
6637836SJohn.Forte@Sun.COM 	uintptr_t	hbaptr = (uintptr_t)qlstate->hba.base_address;
6647836SJohn.Forte@Sun.COM 	size_t		qlsize = sizeof (ql_adapter_state_t);
6657836SJohn.Forte@Sun.COM 
6667836SJohn.Forte@Sun.COM 	if (elswitch) {
6677836SJohn.Forte@Sun.COM 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) == 0) {
6687836SJohn.Forte@Sun.COM 
6697836SJohn.Forte@Sun.COM 			qlstate->cfg_flags |= CFG_ENABLE_EXTENDED_LOGGING;
6707836SJohn.Forte@Sun.COM 
6717836SJohn.Forte@Sun.COM 			if ((mdb_vwrite((const void *)qlstate, qlsize,
6727836SJohn.Forte@Sun.COM 			    hbaptr)) != (ssize_t)qlsize) {
6737836SJohn.Forte@Sun.COM 				mdb_warn("instance %d - unable to update",
6747836SJohn.Forte@Sun.COM 				    qlstate->instance);
6757836SJohn.Forte@Sun.COM 			} else {
6767836SJohn.Forte@Sun.COM 				mdb_printf("instance %d extended logging is "
6777836SJohn.Forte@Sun.COM 				    "now on\n", qlstate->instance);
6787836SJohn.Forte@Sun.COM 			}
6797836SJohn.Forte@Sun.COM 		} else {
6807836SJohn.Forte@Sun.COM 			mdb_printf("instance %d extended logging is "
6817836SJohn.Forte@Sun.COM 			    "already on\n", qlstate->instance);
6827836SJohn.Forte@Sun.COM 		}
6837836SJohn.Forte@Sun.COM 	} else {
6847836SJohn.Forte@Sun.COM 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) != 0) {
6857836SJohn.Forte@Sun.COM 
6867836SJohn.Forte@Sun.COM 			qlstate->cfg_flags &= ~CFG_ENABLE_EXTENDED_LOGGING;
6877836SJohn.Forte@Sun.COM 
6887836SJohn.Forte@Sun.COM 			if ((mdb_vwrite((const void *)qlstate, qlsize,
6897836SJohn.Forte@Sun.COM 			    hbaptr)) != (ssize_t)qlsize) {
6907836SJohn.Forte@Sun.COM 				mdb_warn("instance %d - unable to update",
6917836SJohn.Forte@Sun.COM 				    qlstate->instance);
6927836SJohn.Forte@Sun.COM 			} else {
6937836SJohn.Forte@Sun.COM 				mdb_printf("instance %d extended logging is "
6947836SJohn.Forte@Sun.COM 				    "now off\n", qlstate->instance);
6957836SJohn.Forte@Sun.COM 			}
6967836SJohn.Forte@Sun.COM 		} else {
6977836SJohn.Forte@Sun.COM 			mdb_printf("instance %d extended logging is "
6987836SJohn.Forte@Sun.COM 			    "already off\n", qlstate->instance);
6997836SJohn.Forte@Sun.COM 		}
7007836SJohn.Forte@Sun.COM 	}
7017836SJohn.Forte@Sun.COM }
7027836SJohn.Forte@Sun.COM 
7037836SJohn.Forte@Sun.COM /*
7047836SJohn.Forte@Sun.COM  * qlc_ocs_dcmd
7057836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the outstanding command array using
7067836SJohn.Forte@Sun.COM  *	caller supplied address (which sb the ha structure).
7077836SJohn.Forte@Sun.COM  *
7087836SJohn.Forte@Sun.COM  * Input:
7097836SJohn.Forte@Sun.COM  *	addr  = User supplied ha address.
7107836SJohn.Forte@Sun.COM  *	flags = mdb flags.
7117836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
7127836SJohn.Forte@Sun.COM  *	argv  = Arg array.
7137836SJohn.Forte@Sun.COM  *
7147836SJohn.Forte@Sun.COM  * Returns:
7157836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
7167836SJohn.Forte@Sun.COM  *
7177836SJohn.Forte@Sun.COM  * Context:
7187836SJohn.Forte@Sun.COM  *	User context.
7197836SJohn.Forte@Sun.COM  *
7207836SJohn.Forte@Sun.COM  *
7217836SJohn.Forte@Sun.COM  */
7227836SJohn.Forte@Sun.COM static int
7237836SJohn.Forte@Sun.COM /*ARGSUSED*/
qlc_osc_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)7247836SJohn.Forte@Sun.COM qlc_osc_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
7257836SJohn.Forte@Sun.COM {
7267836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
7277836SJohn.Forte@Sun.COM 	uintptr_t		qlosc, ptr1;
7287836SJohn.Forte@Sun.COM 	uint32_t		indx, found = 0;
7297836SJohn.Forte@Sun.COM 	ql_srb_t		*qlsrb;
7307836SJohn.Forte@Sun.COM 
7317836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
7327836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
7337836SJohn.Forte@Sun.COM 	}
7347836SJohn.Forte@Sun.COM 
7357836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
7367836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
7377836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
7387836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7397836SJohn.Forte@Sun.COM 	}
7407836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
7417836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
7427836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
7437836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7447836SJohn.Forte@Sun.COM 	}
7457836SJohn.Forte@Sun.COM 
7467836SJohn.Forte@Sun.COM 	qlosc = (uintptr_t)qlstate->outstanding_cmds;
7477836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx, osc base = %p\n",
7487836SJohn.Forte@Sun.COM 	    qlstate->instance, qlstate->hba.base_address, qlosc);
7497836SJohn.Forte@Sun.COM 
7507836SJohn.Forte@Sun.COM 	if ((qlsrb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP)) ==
7517836SJohn.Forte@Sun.COM 	    NULL) {
7527836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
7537836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate space for srb_t\n");
7547836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7557836SJohn.Forte@Sun.COM 	}
7567836SJohn.Forte@Sun.COM 	for (indx = 0; indx < MAX_OUTSTANDING_COMMANDS; indx++, qlosc += 8) {
7577836SJohn.Forte@Sun.COM 		if (mdb_vread(&ptr1, 8, qlosc) == -1) {
7587836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ptr1, indx=%d", indx);
7597836SJohn.Forte@Sun.COM 			break;
7607836SJohn.Forte@Sun.COM 		}
7617836SJohn.Forte@Sun.COM 		if (ptr1 == 0) {
7627836SJohn.Forte@Sun.COM 			continue;
7637836SJohn.Forte@Sun.COM 		}
7647836SJohn.Forte@Sun.COM 
7657836SJohn.Forte@Sun.COM 		mdb_printf("osc ptr = %p, indx = %xh\n", ptr1, indx);
7667836SJohn.Forte@Sun.COM 
7677836SJohn.Forte@Sun.COM 		if (mdb_vread(qlsrb, sizeof (ql_srb_t), ptr1) == -1) {
7687836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_srb_t at %p", ptr1);
7697836SJohn.Forte@Sun.COM 			break;
7707836SJohn.Forte@Sun.COM 		}
7717836SJohn.Forte@Sun.COM 		(void) ql_doprint(ptr1, "struct ql_srb");
7727836SJohn.Forte@Sun.COM 		found++;
7737836SJohn.Forte@Sun.COM 	}
7747836SJohn.Forte@Sun.COM 
7757836SJohn.Forte@Sun.COM 	mdb_free(qlsrb, sizeof (ql_srb_t));
7767836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
7777836SJohn.Forte@Sun.COM 
7787836SJohn.Forte@Sun.COM 	mdb_printf("number of outstanding command srb's is: %d\n", found);
7797836SJohn.Forte@Sun.COM 
7807836SJohn.Forte@Sun.COM 	return (DCMD_OK);
7817836SJohn.Forte@Sun.COM }
7827836SJohn.Forte@Sun.COM 
7837836SJohn.Forte@Sun.COM /*
7847836SJohn.Forte@Sun.COM  * qlc_wdog_dcmd
7857836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the commands which are linked
7867836SJohn.Forte@Sun.COM  *	on the watchdog linked list. Caller supplied address (which
7877836SJohn.Forte@Sun.COM  *	sb the ha structure).
7887836SJohn.Forte@Sun.COM  *
7897836SJohn.Forte@Sun.COM  * Input:
7907836SJohn.Forte@Sun.COM  *	addr  = User supplied ha address.
7917836SJohn.Forte@Sun.COM  *	flags = mdb flags.
7927836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
7937836SJohn.Forte@Sun.COM  *	argv  = Arg array.
7947836SJohn.Forte@Sun.COM  *
7957836SJohn.Forte@Sun.COM  * Returns:
7967836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
7977836SJohn.Forte@Sun.COM  *
7987836SJohn.Forte@Sun.COM  * Context:
7997836SJohn.Forte@Sun.COM  *	User context.
8007836SJohn.Forte@Sun.COM  *
8017836SJohn.Forte@Sun.COM  *
8027836SJohn.Forte@Sun.COM  */
8037836SJohn.Forte@Sun.COM static int
8047836SJohn.Forte@Sun.COM /*ARGSUSED*/
qlc_wdog_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)8057836SJohn.Forte@Sun.COM qlc_wdog_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
8067836SJohn.Forte@Sun.COM {
8077836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
8087836SJohn.Forte@Sun.COM 	uint16_t		index, count;
8097836SJohn.Forte@Sun.COM 	ql_head_t		*dev;
8107836SJohn.Forte@Sun.COM 	ql_srb_t		*srb;
8117836SJohn.Forte@Sun.COM 	ql_tgt_t		*tq;
8127836SJohn.Forte@Sun.COM 	ql_lun_t		*lq;
8137836SJohn.Forte@Sun.COM 	ql_link_t		*tqlink, *srblink, *lqlink;
8147836SJohn.Forte@Sun.COM 	int			nextlink;
8157836SJohn.Forte@Sun.COM 
8167836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
8177836SJohn.Forte@Sun.COM 		mdb_warn("Address required\n", addr);
8187836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
8197836SJohn.Forte@Sun.COM 	}
8207836SJohn.Forte@Sun.COM 
8217836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
8227836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
8237836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
8247836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8257836SJohn.Forte@Sun.COM 	}
8267836SJohn.Forte@Sun.COM 
8277836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
8287836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
8297836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
8307836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8317836SJohn.Forte@Sun.COM 	}
8327836SJohn.Forte@Sun.COM 
8337836SJohn.Forte@Sun.COM 	/*
8347836SJohn.Forte@Sun.COM 	 * Read in the device array
8357836SJohn.Forte@Sun.COM 	 */
8367836SJohn.Forte@Sun.COM 	dev = (ql_head_t *)
8377836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
8387836SJohn.Forte@Sun.COM 
8397836SJohn.Forte@Sun.COM 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
8407836SJohn.Forte@Sun.COM 	    (uintptr_t)qlstate->dev) == -1) {
8417836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_head_t (dev) at %p", qlstate->dev);
8427836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
8437836SJohn.Forte@Sun.COM 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
8447836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8457836SJohn.Forte@Sun.COM 	}
8467836SJohn.Forte@Sun.COM 
8477836SJohn.Forte@Sun.COM 	tqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8487836SJohn.Forte@Sun.COM 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
8497836SJohn.Forte@Sun.COM 	lqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8507836SJohn.Forte@Sun.COM 	lq = (ql_lun_t *)mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
8517836SJohn.Forte@Sun.COM 	srblink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8527836SJohn.Forte@Sun.COM 	srb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
8537836SJohn.Forte@Sun.COM 
8547836SJohn.Forte@Sun.COM 	/*
8557836SJohn.Forte@Sun.COM 	 * Validate the devices watchdog queue
8567836SJohn.Forte@Sun.COM 	 */
8577836SJohn.Forte@Sun.COM 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
8587836SJohn.Forte@Sun.COM 
8597836SJohn.Forte@Sun.COM 		/* Skip empty ones */
8607836SJohn.Forte@Sun.COM 		if (dev[index].first == NULL) {
8617836SJohn.Forte@Sun.COM 			continue;
8627836SJohn.Forte@Sun.COM 		}
8637836SJohn.Forte@Sun.COM 
8647836SJohn.Forte@Sun.COM 		mdb_printf("dev array index = %x\n", index);
8657836SJohn.Forte@Sun.COM 
8667836SJohn.Forte@Sun.COM 		/* Loop through targets on device linked list */
8677836SJohn.Forte@Sun.COM 		/* get the first link */
8687836SJohn.Forte@Sun.COM 
8697836SJohn.Forte@Sun.COM 		nextlink = get_first_link(&dev[index], tqlink);
8707836SJohn.Forte@Sun.COM 
8717836SJohn.Forte@Sun.COM 		/*
8727836SJohn.Forte@Sun.COM 		 * traverse the targets linked list at this device array index.
8737836SJohn.Forte@Sun.COM 		 */
8747836SJohn.Forte@Sun.COM 		while (nextlink == DCMD_OK) {
8757836SJohn.Forte@Sun.COM 			/* Get the target */
8767836SJohn.Forte@Sun.COM 			if (mdb_vread(tq, sizeof (ql_tgt_t),
8777836SJohn.Forte@Sun.COM 			    (uintptr_t)(tqlink->base_address)) == -1) {
8787836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_tgt at %p",
8797836SJohn.Forte@Sun.COM 				    tqlink->base_address);
8807836SJohn.Forte@Sun.COM 				break;
8817836SJohn.Forte@Sun.COM 			}
8827836SJohn.Forte@Sun.COM 			mdb_printf("tgt q base = %llx, ",
8837836SJohn.Forte@Sun.COM 			    tqlink->base_address);
8847836SJohn.Forte@Sun.COM 
8857836SJohn.Forte@Sun.COM 			mdb_printf("flags: (%xh)", tq->flags);
8867836SJohn.Forte@Sun.COM 
8877836SJohn.Forte@Sun.COM 			if (tq->flags) {
8887836SJohn.Forte@Sun.COM 				ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
8897836SJohn.Forte@Sun.COM 			}
8907836SJohn.Forte@Sun.COM 
8917836SJohn.Forte@Sun.COM 			mdb_printf("tgt: %02x%02x%02x%02x%02x%02x%02x%02x ",
8927836SJohn.Forte@Sun.COM 			    tq->node_name[0], tq->node_name[1],
8937836SJohn.Forte@Sun.COM 			    tq->node_name[2], tq->node_name[3],
8947836SJohn.Forte@Sun.COM 			    tq->node_name[4], tq->node_name[5],
8957836SJohn.Forte@Sun.COM 			    tq->node_name[6], tq->node_name[7]);
8967836SJohn.Forte@Sun.COM 
8977836SJohn.Forte@Sun.COM 			/*
8987836SJohn.Forte@Sun.COM 			 * Loop through commands on this targets watchdog queue.
8997836SJohn.Forte@Sun.COM 			 */
9007836SJohn.Forte@Sun.COM 
9017836SJohn.Forte@Sun.COM 			/* Get the first link on the targets cmd wdg q. */
9027836SJohn.Forte@Sun.COM 			if (tq->wdg.first == NULL) {
9037836SJohn.Forte@Sun.COM 				mdb_printf(" watchdog list empty ");
9047836SJohn.Forte@Sun.COM 				break;
9057836SJohn.Forte@Sun.COM 			} else {
9067836SJohn.Forte@Sun.COM 				if (mdb_vread(srblink, sizeof (ql_link_t),
9077836SJohn.Forte@Sun.COM 				    (uintptr_t)tq->wdg.first) == -1) {
9087836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_link_t"
9097836SJohn.Forte@Sun.COM 					    " at %p", tq->wdg.first);
9107836SJohn.Forte@Sun.COM 					break;
9117836SJohn.Forte@Sun.COM 				}
9127836SJohn.Forte@Sun.COM 				/* There is aleast one. */
9137836SJohn.Forte@Sun.COM 				count = 1;
9147836SJohn.Forte@Sun.COM 				/*
9157836SJohn.Forte@Sun.COM 				 * Count the remaining items in the
9167836SJohn.Forte@Sun.COM 				 * cmd watchdog list.
9177836SJohn.Forte@Sun.COM 				 */
9187836SJohn.Forte@Sun.COM 				while (srblink->next != NULL) {
9197836SJohn.Forte@Sun.COM 					/* Read in the next ql_link_t header */
9207836SJohn.Forte@Sun.COM 					if (mdb_vread(srblink,
9217836SJohn.Forte@Sun.COM 					    sizeof (ql_link_t),
9227836SJohn.Forte@Sun.COM 					    (uintptr_t)srblink->next) == -1) {
9237836SJohn.Forte@Sun.COM 						mdb_warn("failed to read"
9247836SJohn.Forte@Sun.COM 						    " ql_link_t next at %p",
9257836SJohn.Forte@Sun.COM 						    srblink->next);
9267836SJohn.Forte@Sun.COM 						break;
9277836SJohn.Forte@Sun.COM 					}
9287836SJohn.Forte@Sun.COM 					count = (uint16_t)(count + 1);
9297836SJohn.Forte@Sun.COM 				}
9307836SJohn.Forte@Sun.COM 				mdb_printf(" watchdog list: %d entries\n",
9317836SJohn.Forte@Sun.COM 				    count);
9327836SJohn.Forte@Sun.COM 				/* get the first one again */
9337836SJohn.Forte@Sun.COM 				if (mdb_vread(srblink, sizeof (ql_link_t),
9347836SJohn.Forte@Sun.COM 				    (uintptr_t)tq->wdg.first) == -1) {
9357836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_link_t"
9367836SJohn.Forte@Sun.COM 					    " at %p", tq->wdg.first);
9377836SJohn.Forte@Sun.COM 					break;
9387836SJohn.Forte@Sun.COM 				}
9397836SJohn.Forte@Sun.COM 			}
9407836SJohn.Forte@Sun.COM 			/*
9417836SJohn.Forte@Sun.COM 			 * Traverse the targets cmd watchdog linked list
9427836SJohn.Forte@Sun.COM 			 * verifying srb's from the list are on a lun cmd list.
9437836SJohn.Forte@Sun.COM 			 */
9447836SJohn.Forte@Sun.COM 			while (nextlink == DCMD_OK) {
9457836SJohn.Forte@Sun.COM 				int	found = 0;
9467836SJohn.Forte@Sun.COM 				/* get the srb */
9477836SJohn.Forte@Sun.COM 				if (mdb_vread(srb, sizeof (ql_srb_t),
9487836SJohn.Forte@Sun.COM 				    (uintptr_t)srblink->base_address) == -1) {
9497836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_srb_t"
9507836SJohn.Forte@Sun.COM 					" at %p", srblink->base_address);
9517836SJohn.Forte@Sun.COM 					break;
9527836SJohn.Forte@Sun.COM 				}
9537836SJohn.Forte@Sun.COM 				mdb_printf("ql_srb %llx ",
9547836SJohn.Forte@Sun.COM 				    srblink->base_address);
9557836SJohn.Forte@Sun.COM 
9567836SJohn.Forte@Sun.COM 				/*
9577836SJohn.Forte@Sun.COM 				 * Get the lun q the srb is on
9587836SJohn.Forte@Sun.COM 				 */
9597836SJohn.Forte@Sun.COM 				if (mdb_vread(lq, sizeof (ql_lun_t),
9607836SJohn.Forte@Sun.COM 				    (uintptr_t)srb->lun_queue) == -1) {
9617836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_srb_t"
9627836SJohn.Forte@Sun.COM 					    " at %p", srb->lun_queue);
9637836SJohn.Forte@Sun.COM 					break;
9647836SJohn.Forte@Sun.COM 				}
9657836SJohn.Forte@Sun.COM 				nextlink = get_first_link(&lq->cmd, lqlink);
9667836SJohn.Forte@Sun.COM 				/*
9677836SJohn.Forte@Sun.COM 				 * traverse the lun cmd linked list looking
9687836SJohn.Forte@Sun.COM 				 * for the srb from the targets watchdog list
9697836SJohn.Forte@Sun.COM 				 */
9707836SJohn.Forte@Sun.COM 				while (nextlink == DCMD_OK) {
9717836SJohn.Forte@Sun.COM 					if (srblink->base_address ==
9727836SJohn.Forte@Sun.COM 					    lqlink->base_address) {
9737836SJohn.Forte@Sun.COM 						mdb_printf("on lun %d cmd q\n",
9747836SJohn.Forte@Sun.COM 						    lq->lun_no);
9757836SJohn.Forte@Sun.COM 						found = 1;
9767836SJohn.Forte@Sun.COM 						break;
9777836SJohn.Forte@Sun.COM 					}
9787836SJohn.Forte@Sun.COM 					/* get next item on lun cmd list */
9797836SJohn.Forte@Sun.COM 					nextlink = get_next_link(lqlink);
9807836SJohn.Forte@Sun.COM 				}
9817836SJohn.Forte@Sun.COM 				if (!found) {
9827836SJohn.Forte@Sun.COM 					mdb_printf("not found on lun cmd q\n");
9837836SJohn.Forte@Sun.COM 				}
9847836SJohn.Forte@Sun.COM 				/* get next item in the watchdog list */
9857836SJohn.Forte@Sun.COM 				nextlink = get_next_link(srblink);
9867836SJohn.Forte@Sun.COM 			} /* End targets command watchdog list */
9877836SJohn.Forte@Sun.COM 			/* get next item in this target list */
9887836SJohn.Forte@Sun.COM 			nextlink = get_next_link(tqlink);
9897836SJohn.Forte@Sun.COM 		} /* End traverse the device targets linked list */
9907836SJohn.Forte@Sun.COM 		mdb_printf("\n");
9917836SJohn.Forte@Sun.COM 	} /* End device array */
9927836SJohn.Forte@Sun.COM 
9937836SJohn.Forte@Sun.COM 	mdb_free(tq, sizeof (ql_tgt_t));
9947836SJohn.Forte@Sun.COM 	mdb_free(lq, sizeof (ql_lun_t));
9957836SJohn.Forte@Sun.COM 	mdb_free(srb, sizeof (ql_srb_t));
9967836SJohn.Forte@Sun.COM 	mdb_free(tqlink, sizeof (ql_link_t));
9977836SJohn.Forte@Sun.COM 	mdb_free(srblink, sizeof (ql_link_t));
9987836SJohn.Forte@Sun.COM 	mdb_free(lqlink, sizeof (ql_link_t));
9997836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
10007836SJohn.Forte@Sun.COM 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
10017836SJohn.Forte@Sun.COM 
10027836SJohn.Forte@Sun.COM 	return (DCMD_OK);
10037836SJohn.Forte@Sun.COM }
10047836SJohn.Forte@Sun.COM 
10057836SJohn.Forte@Sun.COM /*
10067836SJohn.Forte@Sun.COM  * get_first_link
10077836SJohn.Forte@Sun.COM  *	Gets the first ql_link_t header on ql_head.
10087836SJohn.Forte@Sun.COM  *
10097836SJohn.Forte@Sun.COM  * Input:
10107836SJohn.Forte@Sun.COM  *	ql_head  = pointer to a ql_head_t structure.
10117836SJohn.Forte@Sun.COM  *	ql_link  = pointer to a ql_link_t structure.
10127836SJohn.Forte@Sun.COM  *
10137836SJohn.Forte@Sun.COM  * Returns:
10147836SJohn.Forte@Sun.COM  *	DCMD_ABORT, or DCMD_OK
10157836SJohn.Forte@Sun.COM  *
10167836SJohn.Forte@Sun.COM  * Context:
10177836SJohn.Forte@Sun.COM  *	User context.
10187836SJohn.Forte@Sun.COM  *
10197836SJohn.Forte@Sun.COM  */
10207836SJohn.Forte@Sun.COM static int
get_first_link(ql_head_t * qlhead,ql_link_t * qllink)10217836SJohn.Forte@Sun.COM get_first_link(ql_head_t *qlhead, ql_link_t *qllink)
10227836SJohn.Forte@Sun.COM {
10237836SJohn.Forte@Sun.COM 	int	rval = DCMD_ABORT;
10247836SJohn.Forte@Sun.COM 
10257836SJohn.Forte@Sun.COM 	if (qlhead != NULL) {
10267836SJohn.Forte@Sun.COM 		if (qlhead->first != NULL) {
10277836SJohn.Forte@Sun.COM 			/* Read in the first ql_link_t header */
10287836SJohn.Forte@Sun.COM 			if (mdb_vread(qllink, sizeof (ql_link_t),
10297836SJohn.Forte@Sun.COM 			    (uintptr_t)(qlhead->first)) == -1) {
10307836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_link_t "
10317836SJohn.Forte@Sun.COM 				    "next at %p", qlhead->first);
10327836SJohn.Forte@Sun.COM 			} else {
10337836SJohn.Forte@Sun.COM 				rval = DCMD_OK;
10347836SJohn.Forte@Sun.COM 			}
10357836SJohn.Forte@Sun.COM 		}
10367836SJohn.Forte@Sun.COM 	}
10377836SJohn.Forte@Sun.COM 	return (rval);
10387836SJohn.Forte@Sun.COM }
10397836SJohn.Forte@Sun.COM 
10407836SJohn.Forte@Sun.COM /*
10417836SJohn.Forte@Sun.COM  * get_next_link
10427836SJohn.Forte@Sun.COM  *	Gets the next ql_link_t structure.
10437836SJohn.Forte@Sun.COM  *
10447836SJohn.Forte@Sun.COM  * Input:
10457836SJohn.Forte@Sun.COM  *	ql_link  = pointer to a ql_link_t structure.
10467836SJohn.Forte@Sun.COM  *
10477836SJohn.Forte@Sun.COM  * Returns:
10487836SJohn.Forte@Sun.COM  *	DCMD_ABORT, or DCMD_OK
10497836SJohn.Forte@Sun.COM  *
10507836SJohn.Forte@Sun.COM  * Context:
10517836SJohn.Forte@Sun.COM  *	User context.
10527836SJohn.Forte@Sun.COM  *
10537836SJohn.Forte@Sun.COM  */
10547836SJohn.Forte@Sun.COM static int
get_next_link(ql_link_t * qllink)10557836SJohn.Forte@Sun.COM get_next_link(ql_link_t *qllink)
10567836SJohn.Forte@Sun.COM {
10577836SJohn.Forte@Sun.COM 	int	rval = DCMD_ABORT;
10587836SJohn.Forte@Sun.COM 
10597836SJohn.Forte@Sun.COM 	if (qllink != NULL) {
10607836SJohn.Forte@Sun.COM 		if (qllink->next != NULL) {
10617836SJohn.Forte@Sun.COM 			/* Read in the next ql_link_t header */
10627836SJohn.Forte@Sun.COM 			if (mdb_vread(qllink, sizeof (ql_link_t),
10637836SJohn.Forte@Sun.COM 			    (uintptr_t)(qllink->next)) == -1) {
10647836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_link_t "
10657836SJohn.Forte@Sun.COM 				    "next at %p", qllink->next);
10667836SJohn.Forte@Sun.COM 			} else {
10677836SJohn.Forte@Sun.COM 				rval = DCMD_OK;
10687836SJohn.Forte@Sun.COM 			}
10697836SJohn.Forte@Sun.COM 		}
10707836SJohn.Forte@Sun.COM 	}
10717836SJohn.Forte@Sun.COM 	return (rval);
10727836SJohn.Forte@Sun.COM }
10737836SJohn.Forte@Sun.COM 
10747836SJohn.Forte@Sun.COM /*
10757836SJohn.Forte@Sun.COM  * qlcstate_dcmd
10767836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the ql_state info using
10777836SJohn.Forte@Sun.COM  *	caller supplied address.
10787836SJohn.Forte@Sun.COM  *
10797836SJohn.Forte@Sun.COM  * Input:
10807836SJohn.Forte@Sun.COM  *	addr  = User supplied address.
10817836SJohn.Forte@Sun.COM  *	flags = mdb flags.
10827836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
10837836SJohn.Forte@Sun.COM  *	argv  = Arg array.
10847836SJohn.Forte@Sun.COM  *
10857836SJohn.Forte@Sun.COM  * Returns:
10867836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
10877836SJohn.Forte@Sun.COM  *
10887836SJohn.Forte@Sun.COM  * Context:
10897836SJohn.Forte@Sun.COM  *	User context.
10907836SJohn.Forte@Sun.COM  *
10917836SJohn.Forte@Sun.COM  */
10927836SJohn.Forte@Sun.COM static int
qlcstate_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)10937836SJohn.Forte@Sun.COM qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
10947836SJohn.Forte@Sun.COM {
10957836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
10967836SJohn.Forte@Sun.COM 	int			verbose = 0;
10977836SJohn.Forte@Sun.COM 
10987836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
10997836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
11007836SJohn.Forte@Sun.COM 	}
11017836SJohn.Forte@Sun.COM 
11027836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
11037836SJohn.Forte@Sun.COM 	    argc) {
11047836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
11057836SJohn.Forte@Sun.COM 	}
11067836SJohn.Forte@Sun.COM 
11077836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
11087836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
11097836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
11107836SJohn.Forte@Sun.COM 		return (DCMD_OK);
11117836SJohn.Forte@Sun.COM 	}
11127836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
11137836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
11147836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
11157836SJohn.Forte@Sun.COM 		return (DCMD_OK);
11167836SJohn.Forte@Sun.COM 	}
11177836SJohn.Forte@Sun.COM 
11187836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx\n", qlstate->instance,
11197836SJohn.Forte@Sun.COM 	    addr);
11207836SJohn.Forte@Sun.COM 
11217836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state flags:\n");
11227836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
11237836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter cfg flags:\n");
11247836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
11257836SJohn.Forte@Sun.COM 	mdb_printf("\ntask daemon state flags:\n");
11267836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
11277836SJohn.Forte@Sun.COM 	    task_daemon_flags);
11287836SJohn.Forte@Sun.COM 
11297836SJohn.Forte@Sun.COM 	if (verbose) {
11307836SJohn.Forte@Sun.COM 		(void) ql_doprint(addr, "struct ql_adapter_state");
11317836SJohn.Forte@Sun.COM 	}
11327836SJohn.Forte@Sun.COM 
11337836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
11347836SJohn.Forte@Sun.COM 
11357836SJohn.Forte@Sun.COM 	return (DCMD_OK);
11367836SJohn.Forte@Sun.COM }
11377836SJohn.Forte@Sun.COM 
11387836SJohn.Forte@Sun.COM /*
11397836SJohn.Forte@Sun.COM  * qlcstates_walk_init
11407836SJohn.Forte@Sun.COM  *	mdb walker init which prints out all qlc states info.
11417836SJohn.Forte@Sun.COM  *
11427836SJohn.Forte@Sun.COM  * Input:
11437836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
11447836SJohn.Forte@Sun.COM  *
11457836SJohn.Forte@Sun.COM  * Returns:
11467836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
11477836SJohn.Forte@Sun.COM  *
11487836SJohn.Forte@Sun.COM  * Context:
11497836SJohn.Forte@Sun.COM  *	User context.
11507836SJohn.Forte@Sun.COM  *
11517836SJohn.Forte@Sun.COM  */
11527836SJohn.Forte@Sun.COM static int
qlstates_walk_init(mdb_walk_state_t * wsp)11537836SJohn.Forte@Sun.COM qlstates_walk_init(mdb_walk_state_t *wsp)
11547836SJohn.Forte@Sun.COM {
11557836SJohn.Forte@Sun.COM 	ql_head_t	ql_hba;
11567836SJohn.Forte@Sun.COM 
11577836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
11587836SJohn.Forte@Sun.COM 		if ((mdb_readvar(&ql_hba, "ql_hba") == -1) ||
11597836SJohn.Forte@Sun.COM 		    (&ql_hba == NULL)) {
11607836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_hba structure");
11617836SJohn.Forte@Sun.COM 			return (WALK_ERR);
11627836SJohn.Forte@Sun.COM 		}
11637836SJohn.Forte@Sun.COM 
11647836SJohn.Forte@Sun.COM 		wsp->walk_addr = (uintptr_t)ql_hba.first;
11657836SJohn.Forte@Sun.COM 		wsp->walk_data = mdb_alloc(sizeof (ql_adapter_state_t),
11667836SJohn.Forte@Sun.COM 		    UM_SLEEP);
11677836SJohn.Forte@Sun.COM 		return (WALK_NEXT);
11687836SJohn.Forte@Sun.COM 	} else {
11697836SJohn.Forte@Sun.COM 		return (ql_doprint(wsp->walk_addr, "struct ql_adapter_state"));
11707836SJohn.Forte@Sun.COM 	}
11717836SJohn.Forte@Sun.COM }
11727836SJohn.Forte@Sun.COM 
11737836SJohn.Forte@Sun.COM /*
11747836SJohn.Forte@Sun.COM  * qlstates_walk_step
11757836SJohn.Forte@Sun.COM  *	mdb walker step which prints out all qlc states info.
11767836SJohn.Forte@Sun.COM  *
11777836SJohn.Forte@Sun.COM  * Input:
11787836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
11797836SJohn.Forte@Sun.COM  *
11807836SJohn.Forte@Sun.COM  * Returns:
11817836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
11827836SJohn.Forte@Sun.COM  *
11837836SJohn.Forte@Sun.COM  * Context:
11847836SJohn.Forte@Sun.COM  *	User context.
11857836SJohn.Forte@Sun.COM  *
11867836SJohn.Forte@Sun.COM  */
11877836SJohn.Forte@Sun.COM static int
qlstates_walk_step(mdb_walk_state_t * wsp)11887836SJohn.Forte@Sun.COM qlstates_walk_step(mdb_walk_state_t *wsp)
11897836SJohn.Forte@Sun.COM {
11907836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
11917836SJohn.Forte@Sun.COM 
11927836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
11937836SJohn.Forte@Sun.COM 		return (WALK_DONE);
11947836SJohn.Forte@Sun.COM 	}
11957836SJohn.Forte@Sun.COM 
11967836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_adapter_state_t),
11977836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
11987836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p",
11997836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
12007836SJohn.Forte@Sun.COM 		return (WALK_DONE);
12017836SJohn.Forte@Sun.COM 	}
12027836SJohn.Forte@Sun.COM 
12037836SJohn.Forte@Sun.COM 	qlstate = (ql_adapter_state_t *)(wsp->walk_data);
12047836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx\n",
12057836SJohn.Forte@Sun.COM 	    qlstate->instance, wsp->walk_addr);
12067836SJohn.Forte@Sun.COM 
12077836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state flags:\n");
12087836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
12097836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter cfg flags:\n");
12107836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
12117836SJohn.Forte@Sun.COM 	mdb_printf("\ntask daemon state flags:\n");
12127836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
12137836SJohn.Forte@Sun.COM 	    task_daemon_flags);
12147836SJohn.Forte@Sun.COM 
12157836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state:\n");
12167836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_adapter_state");
12177836SJohn.Forte@Sun.COM 
12187836SJohn.Forte@Sun.COM 	mdb_printf("\n");
12197836SJohn.Forte@Sun.COM 
12207836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)
12217836SJohn.Forte@Sun.COM 	    (((ql_adapter_state_t *)wsp->walk_data)->hba.next);
12227836SJohn.Forte@Sun.COM 
12237836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
12247836SJohn.Forte@Sun.COM }
12257836SJohn.Forte@Sun.COM 
12267836SJohn.Forte@Sun.COM /*
12277836SJohn.Forte@Sun.COM  * qlstates_walk_fini
12287836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
12297836SJohn.Forte@Sun.COM  *
12307836SJohn.Forte@Sun.COM  * Input:
12317836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
12327836SJohn.Forte@Sun.COM  *
12337836SJohn.Forte@Sun.COM  * Returns:
12347836SJohn.Forte@Sun.COM  *
12357836SJohn.Forte@Sun.COM  * Context:
12367836SJohn.Forte@Sun.COM  *	User context.
12377836SJohn.Forte@Sun.COM  *
12387836SJohn.Forte@Sun.COM  */
12397836SJohn.Forte@Sun.COM static void
qlstates_walk_fini(mdb_walk_state_t * wsp)12407836SJohn.Forte@Sun.COM qlstates_walk_fini(mdb_walk_state_t *wsp)
12417836SJohn.Forte@Sun.COM {
12427836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_adapter_state_t));
12437836SJohn.Forte@Sun.COM }
12447836SJohn.Forte@Sun.COM 
12457836SJohn.Forte@Sun.COM /*
12467836SJohn.Forte@Sun.COM  * qlsrb_walk_init
12477836SJohn.Forte@Sun.COM  *	mdb walker init which prints out linked srb's
12487836SJohn.Forte@Sun.COM  *
12497836SJohn.Forte@Sun.COM  * Input:
12507836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker ql_srb struct
12517836SJohn.Forte@Sun.COM  *
12527836SJohn.Forte@Sun.COM  * Returns:
12537836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
12547836SJohn.Forte@Sun.COM  *
12557836SJohn.Forte@Sun.COM  * Context:
12567836SJohn.Forte@Sun.COM  *	User context.
12577836SJohn.Forte@Sun.COM  *
12587836SJohn.Forte@Sun.COM  */
12597836SJohn.Forte@Sun.COM static int
qlsrb_walk_init(mdb_walk_state_t * wsp)12607836SJohn.Forte@Sun.COM qlsrb_walk_init(mdb_walk_state_t *wsp)
12617836SJohn.Forte@Sun.COM {
12627836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
12637836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_srb addr at %p",
12647836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
12657836SJohn.Forte@Sun.COM 		return (WALK_ERR);
12667836SJohn.Forte@Sun.COM 	}
12677836SJohn.Forte@Sun.COM 
12687836SJohn.Forte@Sun.COM 	wsp->walk_data = mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
12697836SJohn.Forte@Sun.COM 
12707836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
12717836SJohn.Forte@Sun.COM }
12727836SJohn.Forte@Sun.COM 
12737836SJohn.Forte@Sun.COM /*
12747836SJohn.Forte@Sun.COM  * qlcsrb_walk_step
12757836SJohn.Forte@Sun.COM  *	mdb walker step which prints out linked ql_srb structures
12767836SJohn.Forte@Sun.COM  *
12777836SJohn.Forte@Sun.COM  * Input:
12787836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker srb struct
12797836SJohn.Forte@Sun.COM  *
12807836SJohn.Forte@Sun.COM  * Returns:
12817836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
12827836SJohn.Forte@Sun.COM  *
12837836SJohn.Forte@Sun.COM  * Context:
12847836SJohn.Forte@Sun.COM  *	User context.
12857836SJohn.Forte@Sun.COM  *
12867836SJohn.Forte@Sun.COM  */
12877836SJohn.Forte@Sun.COM static int
qlsrb_walk_step(mdb_walk_state_t * wsp)12887836SJohn.Forte@Sun.COM qlsrb_walk_step(mdb_walk_state_t *wsp)
12897836SJohn.Forte@Sun.COM {
12907836SJohn.Forte@Sun.COM 	ql_srb_t	*qlsrb;
12917836SJohn.Forte@Sun.COM 
12927836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
12937836SJohn.Forte@Sun.COM 		return (WALK_DONE);
12947836SJohn.Forte@Sun.COM 
12957836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_srb_t),
12967836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
12977836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_srb at %p", wsp->walk_addr);
12987836SJohn.Forte@Sun.COM 		return (WALK_DONE);
12997836SJohn.Forte@Sun.COM 	}
13007836SJohn.Forte@Sun.COM 
13017836SJohn.Forte@Sun.COM 	qlsrb = (ql_srb_t *)(wsp->walk_data);
13027836SJohn.Forte@Sun.COM 	mdb_printf("ql_srb base addr = %llx\n", wsp->walk_addr);
13037836SJohn.Forte@Sun.COM 
13047836SJohn.Forte@Sun.COM 	mdb_printf("\nql_srb flags:\n");
13057836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlsrb->flags, qlsrb_flags);
13067836SJohn.Forte@Sun.COM 
13077836SJohn.Forte@Sun.COM 	mdb_printf("\nql_srb:\n");
13087836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_srb");
13097836SJohn.Forte@Sun.COM 
13107836SJohn.Forte@Sun.COM 	mdb_printf("\n");
13117836SJohn.Forte@Sun.COM 
13127836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)
13137836SJohn.Forte@Sun.COM 	    (((ql_srb_t *)wsp->walk_data)->cmd.next);
13147836SJohn.Forte@Sun.COM 
13157836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
13167836SJohn.Forte@Sun.COM }
13177836SJohn.Forte@Sun.COM 
13187836SJohn.Forte@Sun.COM /*
13197836SJohn.Forte@Sun.COM  * qlsrb_walk_fini
13207836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
13217836SJohn.Forte@Sun.COM  *
13227836SJohn.Forte@Sun.COM  * Input:
13237836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
13247836SJohn.Forte@Sun.COM  *
13257836SJohn.Forte@Sun.COM  * Returns:
13267836SJohn.Forte@Sun.COM  *
13277836SJohn.Forte@Sun.COM  * Context:
13287836SJohn.Forte@Sun.COM  *	User context.
13297836SJohn.Forte@Sun.COM  *
13307836SJohn.Forte@Sun.COM  */
13317836SJohn.Forte@Sun.COM static void
qlsrb_walk_fini(mdb_walk_state_t * wsp)13327836SJohn.Forte@Sun.COM qlsrb_walk_fini(mdb_walk_state_t *wsp)
13337836SJohn.Forte@Sun.COM {
13347836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_srb_t));
13357836SJohn.Forte@Sun.COM }
13367836SJohn.Forte@Sun.COM 
13377836SJohn.Forte@Sun.COM /*
13387836SJohn.Forte@Sun.COM  * qllunq_dcmd
13397836SJohn.Forte@Sun.COM  *	mdb walker which prints out lun q's
13407836SJohn.Forte@Sun.COM  *
13417836SJohn.Forte@Sun.COM  * Input:
13427836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker ql_lun struct
13437836SJohn.Forte@Sun.COM  *
13447836SJohn.Forte@Sun.COM  * Returns:
13457836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
13467836SJohn.Forte@Sun.COM  *
13477836SJohn.Forte@Sun.COM  * Context:
13487836SJohn.Forte@Sun.COM  *	User context.
13497836SJohn.Forte@Sun.COM  *
13507836SJohn.Forte@Sun.COM  */
13517836SJohn.Forte@Sun.COM static int
qllunq_walk_init(mdb_walk_state_t * wsp)13527836SJohn.Forte@Sun.COM qllunq_walk_init(mdb_walk_state_t *wsp)
13537836SJohn.Forte@Sun.COM {
13547836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
13557836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_lun addr at %p",
13567836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
13577836SJohn.Forte@Sun.COM 		return (WALK_ERR);
13587836SJohn.Forte@Sun.COM 	}
13597836SJohn.Forte@Sun.COM 
13607836SJohn.Forte@Sun.COM 	wsp->walk_data = mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
13617836SJohn.Forte@Sun.COM 
13627836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
13637836SJohn.Forte@Sun.COM }
13647836SJohn.Forte@Sun.COM 
13657836SJohn.Forte@Sun.COM /*
13667836SJohn.Forte@Sun.COM  * qlclunq_walk_step
13677836SJohn.Forte@Sun.COM  *	mdb walker step which prints out linked ql_lun structures
13687836SJohn.Forte@Sun.COM  *
13697836SJohn.Forte@Sun.COM  * Input:
13707836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker srb struct
13717836SJohn.Forte@Sun.COM  *
13727836SJohn.Forte@Sun.COM  * Returns:
13737836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
13747836SJohn.Forte@Sun.COM  *
13757836SJohn.Forte@Sun.COM  * Context:
13767836SJohn.Forte@Sun.COM  *	User context.
13777836SJohn.Forte@Sun.COM  *
13787836SJohn.Forte@Sun.COM  */
13797836SJohn.Forte@Sun.COM static int
qllunq_walk_step(mdb_walk_state_t * wsp)13807836SJohn.Forte@Sun.COM qllunq_walk_step(mdb_walk_state_t *wsp)
13817836SJohn.Forte@Sun.COM {
13827836SJohn.Forte@Sun.COM 	ql_lun_t	*qllun;
13837836SJohn.Forte@Sun.COM 	ql_link_t	ql_link;
13847836SJohn.Forte@Sun.COM 	ql_link_t	*qllink;
13857836SJohn.Forte@Sun.COM 
13867836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
13877836SJohn.Forte@Sun.COM 		return (WALK_DONE);
13887836SJohn.Forte@Sun.COM 
13897836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_lun_t),
13907836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
13917836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_lun at %p", wsp->walk_addr);
13927836SJohn.Forte@Sun.COM 		return (WALK_DONE);
13937836SJohn.Forte@Sun.COM 	}
13947836SJohn.Forte@Sun.COM 
13957836SJohn.Forte@Sun.COM 	qllun = (ql_lun_t *)(wsp->walk_data);
13967836SJohn.Forte@Sun.COM 	mdb_printf("ql_lun base addr = %llx\n", wsp->walk_addr);
13977836SJohn.Forte@Sun.COM 
13987836SJohn.Forte@Sun.COM 	mdb_printf("\nql_lun flags:\n");
13997836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qllun->flags, qllun_flags);
14007836SJohn.Forte@Sun.COM 
14017836SJohn.Forte@Sun.COM 	mdb_printf("\nql_lun:\n");
14027836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_lun");
14037836SJohn.Forte@Sun.COM 
14047836SJohn.Forte@Sun.COM 	mdb_printf("\n");
14057836SJohn.Forte@Sun.COM 
14067836SJohn.Forte@Sun.COM 	qllink = (ql_link_t *)
14077836SJohn.Forte@Sun.COM 	    (((ql_lun_t *)wsp->walk_data)->link.next);
14087836SJohn.Forte@Sun.COM 
14097836SJohn.Forte@Sun.COM 	if (qllink == NULL) {
14107836SJohn.Forte@Sun.COM 		return (WALK_DONE);
14117836SJohn.Forte@Sun.COM 	} else {
14127836SJohn.Forte@Sun.COM 		/*
14137836SJohn.Forte@Sun.COM 		 * Read in the next link_t header
14147836SJohn.Forte@Sun.COM 		 */
14157836SJohn.Forte@Sun.COM 		if (mdb_vread(&ql_link, sizeof (ql_link_t),
14167836SJohn.Forte@Sun.COM 		    (uintptr_t)qllink) == -1) {
14177836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_link_t "
14187836SJohn.Forte@Sun.COM 			    "next at %p", qllink->next);
14197836SJohn.Forte@Sun.COM 			return (WALK_DONE);
14207836SJohn.Forte@Sun.COM 		}
14217836SJohn.Forte@Sun.COM 		qllink = &ql_link;
14227836SJohn.Forte@Sun.COM 	}
14237836SJohn.Forte@Sun.COM 
14247836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)qllink->base_address;
14257836SJohn.Forte@Sun.COM 
14267836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
14277836SJohn.Forte@Sun.COM }
14287836SJohn.Forte@Sun.COM 
14297836SJohn.Forte@Sun.COM /*
14307836SJohn.Forte@Sun.COM  * qllunq_walk_fini
14317836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
14327836SJohn.Forte@Sun.COM  *
14337836SJohn.Forte@Sun.COM  * Input:
14347836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
14357836SJohn.Forte@Sun.COM  *
14367836SJohn.Forte@Sun.COM  * Returns:
14377836SJohn.Forte@Sun.COM  *
14387836SJohn.Forte@Sun.COM  * Context:
14397836SJohn.Forte@Sun.COM  *	User context.
14407836SJohn.Forte@Sun.COM  *
14417836SJohn.Forte@Sun.COM  */
14427836SJohn.Forte@Sun.COM static void
qllunq_walk_fini(mdb_walk_state_t * wsp)14437836SJohn.Forte@Sun.COM qllunq_walk_fini(mdb_walk_state_t *wsp)
14447836SJohn.Forte@Sun.COM {
14457836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_lun_t));
14467836SJohn.Forte@Sun.COM }
14477836SJohn.Forte@Sun.COM 
14487836SJohn.Forte@Sun.COM /*
14497836SJohn.Forte@Sun.COM  * qltgtq_dcmd
14507836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out an hs's tq struct info.
14517836SJohn.Forte@Sun.COM  *
14527836SJohn.Forte@Sun.COM  * Input:
14537836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
14547836SJohn.Forte@Sun.COM  *	flags = mdb flags.
14557836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
14567836SJohn.Forte@Sun.COM  *	argv  = Arg array.
14577836SJohn.Forte@Sun.COM  *
14587836SJohn.Forte@Sun.COM  * Returns:
14597836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
14607836SJohn.Forte@Sun.COM  *
14617836SJohn.Forte@Sun.COM  * Context:
14627836SJohn.Forte@Sun.COM  *	User context.
14637836SJohn.Forte@Sun.COM  *
14647836SJohn.Forte@Sun.COM  */
14657836SJohn.Forte@Sun.COM /*ARGSUSED*/
14667836SJohn.Forte@Sun.COM static int
qltgtq_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)14677836SJohn.Forte@Sun.COM qltgtq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
14687836SJohn.Forte@Sun.COM {
14697836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*ha;
14707836SJohn.Forte@Sun.COM 	ql_link_t		*link;
14717836SJohn.Forte@Sun.COM 	ql_tgt_t		*tq;
14727836SJohn.Forte@Sun.COM 	uint32_t		index;
14737836SJohn.Forte@Sun.COM 	ql_head_t		*dev;
14747836SJohn.Forte@Sun.COM 
14757836SJohn.Forte@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
14767836SJohn.Forte@Sun.COM 		mdb_warn("ql_hba structure addr is required");
14777836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
14787836SJohn.Forte@Sun.COM 	}
14797836SJohn.Forte@Sun.COM 
14807836SJohn.Forte@Sun.COM 	/*
14817836SJohn.Forte@Sun.COM 	 * Get the adapter state struct which was passed
14827836SJohn.Forte@Sun.COM 	 */
14837836SJohn.Forte@Sun.COM 
14847836SJohn.Forte@Sun.COM 	ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
14857836SJohn.Forte@Sun.COM 	    UM_SLEEP);
14867836SJohn.Forte@Sun.COM 
14877836SJohn.Forte@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
14887836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
14897836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
14907836SJohn.Forte@Sun.COM 		return (DCMD_OK);
14917836SJohn.Forte@Sun.COM 	}
14927836SJohn.Forte@Sun.COM 
14937836SJohn.Forte@Sun.COM 	if (ha->dev == NULL) {
14947836SJohn.Forte@Sun.COM 		mdb_warn("dev ptr is NULL for ha: %p", addr);
14957836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
14967836SJohn.Forte@Sun.COM 		return (DCMD_OK);
14977836SJohn.Forte@Sun.COM 	}
14987836SJohn.Forte@Sun.COM 
14997836SJohn.Forte@Sun.COM 	/*
15007836SJohn.Forte@Sun.COM 	 * Read in the device array
15017836SJohn.Forte@Sun.COM 	 */
15027836SJohn.Forte@Sun.COM 	dev = (ql_head_t *)
15037836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
15047836SJohn.Forte@Sun.COM 
15057836SJohn.Forte@Sun.COM 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
15067836SJohn.Forte@Sun.COM 	    (uintptr_t)ha->dev) == -1) {
15077836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_head_t (dev) at %p", ha->dev);
15087836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
15097836SJohn.Forte@Sun.COM 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
15107836SJohn.Forte@Sun.COM 	}
15117836SJohn.Forte@Sun.COM 
15127836SJohn.Forte@Sun.COM 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
15137836SJohn.Forte@Sun.COM 	link = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
15147836SJohn.Forte@Sun.COM 
15157836SJohn.Forte@Sun.COM 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
15167836SJohn.Forte@Sun.COM 
15177836SJohn.Forte@Sun.COM 		if (dev[index].first == NULL) {
15187836SJohn.Forte@Sun.COM 			continue;
15197836SJohn.Forte@Sun.COM 		}
15207836SJohn.Forte@Sun.COM 
15217836SJohn.Forte@Sun.COM 		if (mdb_vread(link, sizeof (ql_link_t),
15227836SJohn.Forte@Sun.COM 		    (uintptr_t)dev[index].first) == -1) {
15237836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_link_t at %p",
15247836SJohn.Forte@Sun.COM 			    dev[index].first);
15257836SJohn.Forte@Sun.COM 			break;
15267836SJohn.Forte@Sun.COM 		}
15277836SJohn.Forte@Sun.COM 
15287836SJohn.Forte@Sun.COM 		while (link != NULL) {
15297836SJohn.Forte@Sun.COM 			if (mdb_vread(tq, sizeof (ql_tgt_t),
15307836SJohn.Forte@Sun.COM 			    (uintptr_t)(link->base_address)) == -1) {
15317836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_tgt at %p",
15327836SJohn.Forte@Sun.COM 				    link->base_address);
15337836SJohn.Forte@Sun.COM 				break;
15347836SJohn.Forte@Sun.COM 			}
15357836SJohn.Forte@Sun.COM 
15367836SJohn.Forte@Sun.COM 			mdb_printf("tgt queue base addr = %llx\n",
15377836SJohn.Forte@Sun.COM 			    link->base_address);
15387836SJohn.Forte@Sun.COM 
15397836SJohn.Forte@Sun.COM 			mdb_printf("\ntgt queue flags: (%xh)\n", tq->flags);
15407836SJohn.Forte@Sun.COM 			ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
15417836SJohn.Forte@Sun.COM 
15427836SJohn.Forte@Sun.COM 			mdb_printf("\ntgt queue:\n");
15437836SJohn.Forte@Sun.COM 
15447836SJohn.Forte@Sun.COM 			(void) ql_doprint((uintptr_t)link->base_address,
15457836SJohn.Forte@Sun.COM 			    "struct ql_target");
15467836SJohn.Forte@Sun.COM 
15477836SJohn.Forte@Sun.COM 			mdb_printf("\n");
15487836SJohn.Forte@Sun.COM 
15497836SJohn.Forte@Sun.COM 			if (get_next_link(link) != DCMD_OK) {
15507836SJohn.Forte@Sun.COM 				break;
15517836SJohn.Forte@Sun.COM 			}
15527836SJohn.Forte@Sun.COM 		}
15537836SJohn.Forte@Sun.COM 	}
15547836SJohn.Forte@Sun.COM 
15557836SJohn.Forte@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
15567836SJohn.Forte@Sun.COM 	mdb_free(tq, sizeof (ql_tgt_t));
15577836SJohn.Forte@Sun.COM 	mdb_free(link, sizeof (ql_link_t));
15587836SJohn.Forte@Sun.COM 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
15597836SJohn.Forte@Sun.COM 
15607836SJohn.Forte@Sun.COM 	return (DCMD_OK);
15617836SJohn.Forte@Sun.COM }
15627836SJohn.Forte@Sun.COM 
15637836SJohn.Forte@Sun.COM /*
15649156SDaniel.Beauregard@Sun.COM  * ql_triggerdump_dcmd
15659156SDaniel.Beauregard@Sun.COM  *	Triggers the driver to take a firmware dump
15669156SDaniel.Beauregard@Sun.COM  *
15679156SDaniel.Beauregard@Sun.COM  * Input:
15689156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address (optional)
15699156SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
15709156SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
15719156SDaniel.Beauregard@Sun.COM  *	argv  = Arg array (instance #, optional).
15729156SDaniel.Beauregard@Sun.COM  *
15739156SDaniel.Beauregard@Sun.COM  * Returns:
15749156SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
15759156SDaniel.Beauregard@Sun.COM  *
15769156SDaniel.Beauregard@Sun.COM  * Context:
15779156SDaniel.Beauregard@Sun.COM  *	User context.
15789156SDaniel.Beauregard@Sun.COM  *
15799156SDaniel.Beauregard@Sun.COM  */
15809156SDaniel.Beauregard@Sun.COM 
15819156SDaniel.Beauregard@Sun.COM #if 0
15829156SDaniel.Beauregard@Sun.COM 
15839156SDaniel.Beauregard@Sun.COM /*ARGSUSED*/
15849156SDaniel.Beauregard@Sun.COM static int
15859156SDaniel.Beauregard@Sun.COM qlc_triggerdump_dcmd(uintptr_t addr, uint_t flags, int argc,
15869156SDaniel.Beauregard@Sun.COM     const mdb_arg_t *argv)
15879156SDaniel.Beauregard@Sun.COM {
15889156SDaniel.Beauregard@Sun.COM 	ql_adapter_state_t	*qlstate;
15899156SDaniel.Beauregard@Sun.COM 	uintptr_t		hbaptr = NULL;
15909156SDaniel.Beauregard@Sun.COM 	ql_head_t		ql_hba;
15919156SDaniel.Beauregard@Sun.COM 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
15929156SDaniel.Beauregard@Sun.COM 	int			mdbs;
15939156SDaniel.Beauregard@Sun.COM 
15949156SDaniel.Beauregard@Sun.COM 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
15959156SDaniel.Beauregard@Sun.COM 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
15969156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
15979156SDaniel.Beauregard@Sun.COM 	}
15989156SDaniel.Beauregard@Sun.COM 
15999156SDaniel.Beauregard@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
16009156SDaniel.Beauregard@Sun.COM 	    UM_SLEEP)) == NULL) {
16019156SDaniel.Beauregard@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
16029156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
16039156SDaniel.Beauregard@Sun.COM 	}
16049156SDaniel.Beauregard@Sun.COM 
16059156SDaniel.Beauregard@Sun.COM 	if (addr == NULL) {
16069156SDaniel.Beauregard@Sun.COM 		char		*tptr;
16079156SDaniel.Beauregard@Sun.COM 		uint32_t	instance;
16089156SDaniel.Beauregard@Sun.COM 
16099156SDaniel.Beauregard@Sun.COM 		if (argc == 0) {
16109156SDaniel.Beauregard@Sun.COM 			mdb_warn("must specify either the ha addr or "
16119156SDaniel.Beauregard@Sun.COM 			    "the instance number\n");
16129156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16139156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
16149156SDaniel.Beauregard@Sun.COM 		}
16159156SDaniel.Beauregard@Sun.COM 
16169156SDaniel.Beauregard@Sun.COM 		/*
16179156SDaniel.Beauregard@Sun.COM 		 * find the specified instance in the ha list
16189156SDaniel.Beauregard@Sun.COM 		 */
16199156SDaniel.Beauregard@Sun.COM 
16209156SDaniel.Beauregard@Sun.COM 		instance = (uint32_t)strtol(argv[1].a_un.a_str, &tptr, 16);
16219156SDaniel.Beauregard@Sun.COM 		if (tptr == argv[1].a_un.a_str) {
16229156SDaniel.Beauregard@Sun.COM 			mdb_printf("instance # is illegal: '%s'\n",
16239156SDaniel.Beauregard@Sun.COM 			    argv[1].a_un.a_str);
16249156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16259156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
16269156SDaniel.Beauregard@Sun.COM 		}
16279156SDaniel.Beauregard@Sun.COM 
16289156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
16299156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
16309156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16319156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16329156SDaniel.Beauregard@Sun.COM 		}
16339156SDaniel.Beauregard@Sun.COM 
16349156SDaniel.Beauregard@Sun.COM 		if (&ql_hba == NULL) {
16359156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure - "
16369156SDaniel.Beauregard@Sun.COM 			    "is qlc loaded?");
16379156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16389156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16399156SDaniel.Beauregard@Sun.COM 		}
16409156SDaniel.Beauregard@Sun.COM 
16419156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
16429156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
16439156SDaniel.Beauregard@Sun.COM 
16449156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
16459156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, qlsize);
16469156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read "
16479156SDaniel.Beauregard@Sun.COM 				    "ql_adapter_state at %p", hbaptr);
16489156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
16499156SDaniel.Beauregard@Sun.COM 			}
16509156SDaniel.Beauregard@Sun.COM 
16519156SDaniel.Beauregard@Sun.COM 			if (qlstate->instance == instance) {
16529156SDaniel.Beauregard@Sun.COM 				break;
16539156SDaniel.Beauregard@Sun.COM 			}
16549156SDaniel.Beauregard@Sun.COM 
16559156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
16569156SDaniel.Beauregard@Sun.COM 		}
16579156SDaniel.Beauregard@Sun.COM 	} else {
16589156SDaniel.Beauregard@Sun.COM 
16599156SDaniel.Beauregard@Sun.COM 		/*
16609156SDaniel.Beauregard@Sun.COM 		 * verify the addr specified
16619156SDaniel.Beauregard@Sun.COM 		 */
16629156SDaniel.Beauregard@Sun.COM 
16639156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
16649156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
16659156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16669156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16679156SDaniel.Beauregard@Sun.COM 		}
16689156SDaniel.Beauregard@Sun.COM 
16699156SDaniel.Beauregard@Sun.COM 		if (&ql_hba == NULL) {
16709156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure - "
16719156SDaniel.Beauregard@Sun.COM 			    "is qlc loaded?");
16729156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16739156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16749156SDaniel.Beauregard@Sun.COM 		}
16759156SDaniel.Beauregard@Sun.COM 
16769156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
16779156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
16789156SDaniel.Beauregard@Sun.COM 
16799156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
16809156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, qlsize);
16819156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read "
16829156SDaniel.Beauregard@Sun.COM 				    "ql_adapter_state at %p", hbaptr);
16839156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
16849156SDaniel.Beauregard@Sun.COM 			}
16859156SDaniel.Beauregard@Sun.COM 
16869156SDaniel.Beauregard@Sun.COM 			if (hbaptr == addr) {
16879156SDaniel.Beauregard@Sun.COM 				break;
16889156SDaniel.Beauregard@Sun.COM 			}
16899156SDaniel.Beauregard@Sun.COM 
16909156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
16919156SDaniel.Beauregard@Sun.COM 		}
16929156SDaniel.Beauregard@Sun.COM 	}
16939156SDaniel.Beauregard@Sun.COM 
16949156SDaniel.Beauregard@Sun.COM 	if (hbaptr == NULL) {
16959156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, qlsize);
16969156SDaniel.Beauregard@Sun.COM 		if (argc == 0) {
16979156SDaniel.Beauregard@Sun.COM 			mdb_warn("addr specified is not in the hba list\n");
16989156SDaniel.Beauregard@Sun.COM 		} else {
16999156SDaniel.Beauregard@Sun.COM 			mdb_warn("instance specified does not exist\n");
17009156SDaniel.Beauregard@Sun.COM 		}
17019156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
17029156SDaniel.Beauregard@Sun.COM 	}
17039156SDaniel.Beauregard@Sun.COM 
17049156SDaniel.Beauregard@Sun.COM 	if (((qlstate->ql_dump_state & QL_DUMP_VALID) != 0) ||
17059156SDaniel.Beauregard@Sun.COM 	    (qlstate->ql_dump_ptr != NULL)) {
17069156SDaniel.Beauregard@Sun.COM 		mdb_warn("instance %d already has a valid dump\n",
17079156SDaniel.Beauregard@Sun.COM 		    qlstate->instance);
17089156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, qlsize);
17099156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
17109156SDaniel.Beauregard@Sun.COM 	}
17119156SDaniel.Beauregard@Sun.COM }
17129156SDaniel.Beauregard@Sun.COM #endif
17139156SDaniel.Beauregard@Sun.COM 
17149156SDaniel.Beauregard@Sun.COM /*
17159156SDaniel.Beauregard@Sun.COM  * ql_getdump_dcmd
17167836SJohn.Forte@Sun.COM  *	prints out the firmware dump buffer
17177836SJohn.Forte@Sun.COM  *
17187836SJohn.Forte@Sun.COM  * Input:
17199156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: must be an ha)
17207836SJohn.Forte@Sun.COM  *	flags = mdb flags.
17217836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
17227836SJohn.Forte@Sun.COM  *	argv  = Arg array.
17237836SJohn.Forte@Sun.COM  *
17247836SJohn.Forte@Sun.COM  * Returns:
17257836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
17267836SJohn.Forte@Sun.COM  *
17277836SJohn.Forte@Sun.COM  * Context:
17287836SJohn.Forte@Sun.COM  *	User context.
17297836SJohn.Forte@Sun.COM  *
17307836SJohn.Forte@Sun.COM  */
17317836SJohn.Forte@Sun.COM static int
qlc_getdump_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)17329156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
17337836SJohn.Forte@Sun.COM {
17347836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*ha;
17359156SDaniel.Beauregard@Sun.COM 	ql_head_t		ql_hba;
17369156SDaniel.Beauregard@Sun.COM 	uintptr_t		hbaptr = NULL;
17379156SDaniel.Beauregard@Sun.COM 	int			verbose = 0;
17387836SJohn.Forte@Sun.COM 
17397836SJohn.Forte@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
17407836SJohn.Forte@Sun.COM 		mdb_warn("ql_adapter_state structure addr is required");
17417836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
17427836SJohn.Forte@Sun.COM 	}
17437836SJohn.Forte@Sun.COM 
17449156SDaniel.Beauregard@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
17459156SDaniel.Beauregard@Sun.COM 	    argc) {
17469156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
17479156SDaniel.Beauregard@Sun.COM 	}
17489156SDaniel.Beauregard@Sun.COM 
17497836SJohn.Forte@Sun.COM 	/*
17507836SJohn.Forte@Sun.COM 	 * Get the adapter state struct which was passed
17517836SJohn.Forte@Sun.COM 	 */
17527836SJohn.Forte@Sun.COM 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
17537836SJohn.Forte@Sun.COM 	    UM_SLEEP)) == NULL) {
17547836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
17557836SJohn.Forte@Sun.COM 		return (DCMD_OK);
17567836SJohn.Forte@Sun.COM 	}
17577836SJohn.Forte@Sun.COM 
17589156SDaniel.Beauregard@Sun.COM 	/*
17599156SDaniel.Beauregard@Sun.COM 	 * show user which instances have valid f/w dumps available if
17609156SDaniel.Beauregard@Sun.COM 	 * user has specified verbose option
17619156SDaniel.Beauregard@Sun.COM 	 */
17629156SDaniel.Beauregard@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
17639156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_hba structure");
17649156SDaniel.Beauregard@Sun.COM 	} else if (&ql_hba == NULL) {
17659156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
17669156SDaniel.Beauregard@Sun.COM 	} else if (verbose) {
17679156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
17689156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
17699156SDaniel.Beauregard@Sun.COM 
17709156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(ha, sizeof (ql_adapter_state_t),
17719156SDaniel.Beauregard@Sun.COM 			    hbaptr) == -1) {
17729156SDaniel.Beauregard@Sun.COM 				mdb_free(ha, sizeof (ql_adapter_state_t));
17739156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed read ql_adapter_state at %p",
17749156SDaniel.Beauregard@Sun.COM 				    hbaptr);
17759156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
17769156SDaniel.Beauregard@Sun.COM 			}
17779156SDaniel.Beauregard@Sun.COM 
17789156SDaniel.Beauregard@Sun.COM 			mdb_printf("instance %d:\n", ha->instance);
17799156SDaniel.Beauregard@Sun.COM 			(void) mdb_inc_indent((ulong_t)4);
17809156SDaniel.Beauregard@Sun.COM 
17819156SDaniel.Beauregard@Sun.COM 			if (ha->ql_dump_state == 0) {
17829156SDaniel.Beauregard@Sun.COM 				mdb_printf("no dump flags\n");
17839156SDaniel.Beauregard@Sun.COM 			} else {
17849156SDaniel.Beauregard@Sun.COM 				ql_dump_flags((uint64_t)ha->ql_dump_state,
17859156SDaniel.Beauregard@Sun.COM 				    qldump_flags);
17869156SDaniel.Beauregard@Sun.COM 			}
17879156SDaniel.Beauregard@Sun.COM 
17889156SDaniel.Beauregard@Sun.COM 			if (ha->ql_dump_ptr == NULL) {
17899156SDaniel.Beauregard@Sun.COM 				mdb_printf("no dump address\n");
17909156SDaniel.Beauregard@Sun.COM 			} else {
17919156SDaniel.Beauregard@Sun.COM 				mdb_printf("dump address is: %p\n",
17929156SDaniel.Beauregard@Sun.COM 				    ha->ql_dump_ptr);
17939156SDaniel.Beauregard@Sun.COM 			}
17949156SDaniel.Beauregard@Sun.COM 
17959156SDaniel.Beauregard@Sun.COM 			(void) mdb_dec_indent((ulong_t)4);
17969156SDaniel.Beauregard@Sun.COM 
17979156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)ha->hba.next;
17989156SDaniel.Beauregard@Sun.COM 		}
17999156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n");
18009156SDaniel.Beauregard@Sun.COM 	}
18019156SDaniel.Beauregard@Sun.COM 
18027836SJohn.Forte@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
18037836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
18047836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
18057836SJohn.Forte@Sun.COM 		return (DCMD_OK);
18067836SJohn.Forte@Sun.COM 	}
18077836SJohn.Forte@Sun.COM 
18089156SDaniel.Beauregard@Sun.COM 	/*
18099156SDaniel.Beauregard@Sun.COM 	 * If its not a valid dump or there's not a f/w dump binary (???)
18109156SDaniel.Beauregard@Sun.COM 	 * then bail out
18119156SDaniel.Beauregard@Sun.COM 	 */
18129156SDaniel.Beauregard@Sun.COM 	if (((ha->ql_dump_state & QL_DUMP_VALID) == 0) ||
18139156SDaniel.Beauregard@Sun.COM 	    (ha->ql_dump_ptr == NULL)) {
18149156SDaniel.Beauregard@Sun.COM 		mdb_warn("dump does not exist for instance %d (%x, %p)\n",
18159156SDaniel.Beauregard@Sun.COM 		    ha->instance, ha->ql_dump_state, ha->ql_dump_ptr);
18169156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
18179156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
18189156SDaniel.Beauregard@Sun.COM 	}
18199156SDaniel.Beauregard@Sun.COM 
18207836SJohn.Forte@Sun.COM 	if (CFG_IST(ha, CFG_CTRL_2422)) {
18217836SJohn.Forte@Sun.COM 		(void) ql_24xx_dump_dcmd(ha, flags, argc, argv);
182210736SDaniel.Beauregard@Sun.COM 	} else if (CFG_IST(ha, CFG_CTRL_25XX))  {
18237836SJohn.Forte@Sun.COM 		(void) ql_25xx_dump_dcmd(ha, flags, argc, argv);
182410736SDaniel.Beauregard@Sun.COM 	} else if (CFG_IST(ha, CFG_CTRL_81XX))  {
182510736SDaniel.Beauregard@Sun.COM 		(void) ql_81xx_dump_dcmd(ha, flags, argc, argv);
182611924SDaniel.Beauregard@Sun.COM 	} else if (!(CFG_IST(ha, CFG_CTRL_8021)))  {
18277836SJohn.Forte@Sun.COM 		(void) ql_23xx_dump_dcmd(ha, flags, argc, argv);
18287836SJohn.Forte@Sun.COM 	}
18297836SJohn.Forte@Sun.COM 
18307836SJohn.Forte@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
18317836SJohn.Forte@Sun.COM 
18327836SJohn.Forte@Sun.COM 	return (DCMD_OK);
18337836SJohn.Forte@Sun.COM }
18347836SJohn.Forte@Sun.COM 
18357836SJohn.Forte@Sun.COM /*
18367836SJohn.Forte@Sun.COM  * ql_23xx_dump_dcmd
18377836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
18387836SJohn.Forte@Sun.COM  *
18397836SJohn.Forte@Sun.COM  * Input:
18407836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
18417836SJohn.Forte@Sun.COM  *	flags = mdb flags.
18427836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
18437836SJohn.Forte@Sun.COM  *	argv  = Arg array.
18447836SJohn.Forte@Sun.COM  *
18457836SJohn.Forte@Sun.COM  * Returns:
18467836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
18477836SJohn.Forte@Sun.COM  *
18487836SJohn.Forte@Sun.COM  * Context:
18497836SJohn.Forte@Sun.COM  *	User context.
18507836SJohn.Forte@Sun.COM  *
18517836SJohn.Forte@Sun.COM  */
18527836SJohn.Forte@Sun.COM /*ARGSUSED*/
18537836SJohn.Forte@Sun.COM static int
ql_23xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)18547836SJohn.Forte@Sun.COM ql_23xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
18557836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
18567836SJohn.Forte@Sun.COM {
18577836SJohn.Forte@Sun.COM 	ql_fw_dump_t	*fw;
18587836SJohn.Forte@Sun.COM 	uint32_t	cnt = 0;
18597836SJohn.Forte@Sun.COM 	int		mbox_cnt;
18607836SJohn.Forte@Sun.COM 
18619156SDaniel.Beauregard@Sun.COM 	fw = (ql_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
18629156SDaniel.Beauregard@Sun.COM 
18639156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
18649156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
18657836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
18669156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
18677836SJohn.Forte@Sun.COM 		return (DCMD_OK);
18687836SJohn.Forte@Sun.COM 	}
18697836SJohn.Forte@Sun.COM 
18707836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & CFG_CTRL_2300) {
18717836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 2300IP ");
18727836SJohn.Forte@Sun.COM 	} else if (ha->cfg_flags & CFG_CTRL_6322) {
18737836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 6322FLX ");
18747836SJohn.Forte@Sun.COM 	} else {
18757836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 2200IP ");
18767836SJohn.Forte@Sun.COM 	}
18777836SJohn.Forte@Sun.COM 
18787836SJohn.Forte@Sun.COM 	mdb_printf("Firmware Version %d.%d.%d\n",
18797836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
18807836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version);
18817836SJohn.Forte@Sun.COM 
18827836SJohn.Forte@Sun.COM 	mdb_printf("\nPBIU Registers:");
18837836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
18847836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
18857836SJohn.Forte@Sun.COM 			mdb_printf("\n");
18867836SJohn.Forte@Sun.COM 		}
18877836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->pbiu_reg[cnt]);
18887836SJohn.Forte@Sun.COM 	}
18897836SJohn.Forte@Sun.COM 
18907836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
18917836SJohn.Forte@Sun.COM 		mdb_printf("\n\nReqQ-RspQ-Risc2Host Status registers:");
18927836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
18937836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
18947836SJohn.Forte@Sun.COM 				mdb_printf("\n");
18957836SJohn.Forte@Sun.COM 			}
18967836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_host_reg[cnt]);
18977836SJohn.Forte@Sun.COM 		}
18987836SJohn.Forte@Sun.COM 	}
18997836SJohn.Forte@Sun.COM 
19007836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers:");
19017836SJohn.Forte@Sun.COM 	mbox_cnt = (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) ? 16 : 8;
19027836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < mbox_cnt; cnt++) {
19037836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19047836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19057836SJohn.Forte@Sun.COM 		}
19067836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->mailbox_reg[cnt]);
19077836SJohn.Forte@Sun.COM 	}
19087836SJohn.Forte@Sun.COM 
19097836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
19107836SJohn.Forte@Sun.COM 		mdb_printf("\n\nAuto Request Response DMA Registers:");
19117836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
19127836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
19137836SJohn.Forte@Sun.COM 				mdb_printf("\n");
19147836SJohn.Forte@Sun.COM 			}
19157836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->resp_dma_reg[cnt]);
19167836SJohn.Forte@Sun.COM 		}
19177836SJohn.Forte@Sun.COM 	}
19187836SJohn.Forte@Sun.COM 
19197836SJohn.Forte@Sun.COM 	mdb_printf("\n\nDMA Registers:");
19207836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
19217836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19227836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19237836SJohn.Forte@Sun.COM 		}
19247836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->dma_reg[cnt]);
19257836SJohn.Forte@Sun.COM 	}
19267836SJohn.Forte@Sun.COM 
19277836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC Hardware Registers:");
19287836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
19297836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19307836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19317836SJohn.Forte@Sun.COM 		}
19327836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_hdw_reg[cnt]);
19337836SJohn.Forte@Sun.COM 	}
19347836SJohn.Forte@Sun.COM 
19357836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP0 Registers:");
19367836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
19377836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19387836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19397836SJohn.Forte@Sun.COM 		}
19407836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp0_reg[cnt]);
19417836SJohn.Forte@Sun.COM 	}
19427836SJohn.Forte@Sun.COM 
19437836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP1 Registers:");
19447836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
19457836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19467836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19477836SJohn.Forte@Sun.COM 		}
19487836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp1_reg[cnt]);
19497836SJohn.Forte@Sun.COM 	}
19507836SJohn.Forte@Sun.COM 
19517836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP2 Registers:");
19527836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
19537836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19547836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19557836SJohn.Forte@Sun.COM 		}
19567836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp2_reg[cnt]);
19577836SJohn.Forte@Sun.COM 	}
19587836SJohn.Forte@Sun.COM 
19597836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP3 Registers:");
19607836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
19617836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19627836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19637836SJohn.Forte@Sun.COM 		}
19647836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp3_reg[cnt]);
19657836SJohn.Forte@Sun.COM 	}
19667836SJohn.Forte@Sun.COM 
19677836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP4 Registers:");
19687836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
19697836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19707836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19717836SJohn.Forte@Sun.COM 		}
19727836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp4_reg[cnt]);
19737836SJohn.Forte@Sun.COM 	}
19747836SJohn.Forte@Sun.COM 
19757836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP5 Registers:");
19767836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
19777836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19787836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19797836SJohn.Forte@Sun.COM 		}
19807836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp5_reg[cnt]);
19817836SJohn.Forte@Sun.COM 	}
19827836SJohn.Forte@Sun.COM 
19837836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP6 Registers:");
19847836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
19857836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19867836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19877836SJohn.Forte@Sun.COM 		}
19887836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp6_reg[cnt]);
19897836SJohn.Forte@Sun.COM 	}
19907836SJohn.Forte@Sun.COM 
19917836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP7 Registers:");
19927836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
19937836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19947836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19957836SJohn.Forte@Sun.COM 		}
19967836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp7_reg[cnt]);
19977836SJohn.Forte@Sun.COM 	}
19987836SJohn.Forte@Sun.COM 
19997836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFrame Buffer Hardware Registers:");
20007836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
20017836SJohn.Forte@Sun.COM 		if ((cnt == 16) &&
20027836SJohn.Forte@Sun.COM 		    ((ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) == 0)) {
20037836SJohn.Forte@Sun.COM 			break;
20047836SJohn.Forte@Sun.COM 		}
20057836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20067836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20077836SJohn.Forte@Sun.COM 		}
20087836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->frame_buf_hdw_reg[cnt]);
20097836SJohn.Forte@Sun.COM 	}
20107836SJohn.Forte@Sun.COM 
20117836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM B0 Registers:");
20127836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
20137836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20147836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20157836SJohn.Forte@Sun.COM 		}
20167836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->fpm_b0_reg[cnt]);
20177836SJohn.Forte@Sun.COM 	}
20187836SJohn.Forte@Sun.COM 
20197836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM B1 Registers:");
20207836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
20217836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20227836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20237836SJohn.Forte@Sun.COM 		}
20247836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->fpm_b1_reg[cnt]);
20257836SJohn.Forte@Sun.COM 	}
20267836SJohn.Forte@Sun.COM 
20277836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
20287836SJohn.Forte@Sun.COM 		mdb_printf("\n\nCode RAM Dump:");
20297836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
20307836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20317836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x0800);
20327836SJohn.Forte@Sun.COM 			}
20337836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
20347836SJohn.Forte@Sun.COM 		}
20357836SJohn.Forte@Sun.COM 
20367836SJohn.Forte@Sun.COM 		mdb_printf("\n\nStack RAM Dump:");
20377836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
20387836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20397836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x010000);
20407836SJohn.Forte@Sun.COM 			}
20417836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->stack_ram[cnt]);
20427836SJohn.Forte@Sun.COM 		}
20437836SJohn.Forte@Sun.COM 
20447836SJohn.Forte@Sun.COM 		mdb_printf("\n\nData RAM Dump:");
20457836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) {
20467836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20477836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x010800);
20487836SJohn.Forte@Sun.COM 			}
20497836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->data_ram[cnt]);
20507836SJohn.Forte@Sun.COM 		}
20517836SJohn.Forte@Sun.COM 
20527836SJohn.Forte@Sun.COM 		mdb_printf("\n\n[<==END] ISP Debug Dump.\n");
20539156SDaniel.Beauregard@Sun.COM 
20549156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nRequest Queue");
20559156SDaniel.Beauregard@Sun.COM 
20569156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
20579156SDaniel.Beauregard@Sun.COM 			if (cnt % 8 == 0) {
20589156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", cnt);
20599156SDaniel.Beauregard@Sun.COM 			}
20609156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->req_q[cnt]);
20619156SDaniel.Beauregard@Sun.COM 		}
20629156SDaniel.Beauregard@Sun.COM 
20639156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nResponse Queue");
20649156SDaniel.Beauregard@Sun.COM 
20659156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
20669156SDaniel.Beauregard@Sun.COM 			if (cnt % 8 == 0) {
20679156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", cnt);
20689156SDaniel.Beauregard@Sun.COM 			}
20699156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->rsp_q[cnt]);
20709156SDaniel.Beauregard@Sun.COM 		}
20719156SDaniel.Beauregard@Sun.COM 
20729156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n");
20739156SDaniel.Beauregard@Sun.COM 
20747836SJohn.Forte@Sun.COM 	} else {
20757836SJohn.Forte@Sun.COM 		mdb_printf("\n\nRISC SRAM:");
20767836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < 0xf000; cnt++) {
20777836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20787836SJohn.Forte@Sun.COM 				mdb_printf("\n%04x: ", cnt + 0x1000);
20797836SJohn.Forte@Sun.COM 			}
20807836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
20817836SJohn.Forte@Sun.COM 		}
20827836SJohn.Forte@Sun.COM 	}
20837836SJohn.Forte@Sun.COM 
20849156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
20859156SDaniel.Beauregard@Sun.COM 
20867836SJohn.Forte@Sun.COM 	return (DCMD_OK);
20877836SJohn.Forte@Sun.COM }
20887836SJohn.Forte@Sun.COM 
20897836SJohn.Forte@Sun.COM /*
20907836SJohn.Forte@Sun.COM  * ql_24xx_dump_dcmd
20917836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
20927836SJohn.Forte@Sun.COM  *
20937836SJohn.Forte@Sun.COM  * Input:
20947836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
20957836SJohn.Forte@Sun.COM  *	flags = mdb flags.
20967836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
20977836SJohn.Forte@Sun.COM  *	argv  = Arg array.
20987836SJohn.Forte@Sun.COM  *
20997836SJohn.Forte@Sun.COM  * Returns:
21007836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
21017836SJohn.Forte@Sun.COM  *
21027836SJohn.Forte@Sun.COM  * Context:
21037836SJohn.Forte@Sun.COM  *	User context.
21047836SJohn.Forte@Sun.COM  *
21057836SJohn.Forte@Sun.COM  */
21067836SJohn.Forte@Sun.COM /*ARGSUSED*/
21077836SJohn.Forte@Sun.COM static int
ql_24xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)21087836SJohn.Forte@Sun.COM ql_24xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
21097836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
21107836SJohn.Forte@Sun.COM {
21117836SJohn.Forte@Sun.COM 	ql_24xx_fw_dump_t	*fw;
21127836SJohn.Forte@Sun.COM 	uint32_t		cnt = 0;
21137836SJohn.Forte@Sun.COM 
21149156SDaniel.Beauregard@Sun.COM 	fw = (ql_24xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
21159156SDaniel.Beauregard@Sun.COM 
21169156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
21179156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
21187836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
21199156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
21207836SJohn.Forte@Sun.COM 		return (DCMD_OK);
21217836SJohn.Forte@Sun.COM 	}
21227836SJohn.Forte@Sun.COM 
21237836SJohn.Forte@Sun.COM 	mdb_printf("ISP FW Version %d.%02d.%02d Attributes %X\n",
21247836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
21257836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
21267836SJohn.Forte@Sun.COM 
21277836SJohn.Forte@Sun.COM 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
21287836SJohn.Forte@Sun.COM 
21297836SJohn.Forte@Sun.COM 	mdb_printf("\nHost Interface Registers");
21307836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
21317836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21327836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21337836SJohn.Forte@Sun.COM 		}
21347836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
21357836SJohn.Forte@Sun.COM 	}
21367836SJohn.Forte@Sun.COM 
21377836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers");
21387836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
21397836SJohn.Forte@Sun.COM 		if (cnt % 16 == 0) {
21407836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21417836SJohn.Forte@Sun.COM 		}
21427836SJohn.Forte@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
21437836SJohn.Forte@Sun.COM 	}
21447836SJohn.Forte@Sun.COM 
21457836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
21467836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
21477836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21487836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21497836SJohn.Forte@Sun.COM 		}
21507836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
21517836SJohn.Forte@Sun.COM 	}
21527836SJohn.Forte@Sun.COM 
21537836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
21547836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
21557836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21567836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21577836SJohn.Forte@Sun.COM 		}
21587836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
21597836SJohn.Forte@Sun.COM 	}
21607836SJohn.Forte@Sun.COM 
21617836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
21627836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
21637836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21647836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21657836SJohn.Forte@Sun.COM 		}
21667836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
21677836SJohn.Forte@Sun.COM 	}
21687836SJohn.Forte@Sun.COM 
21697836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
21707836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
21717836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21727836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21737836SJohn.Forte@Sun.COM 		}
21747836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
21757836SJohn.Forte@Sun.COM 	}
21767836SJohn.Forte@Sun.COM 
21777836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
21787836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
21797836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21807836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21817836SJohn.Forte@Sun.COM 		}
21827836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
21837836SJohn.Forte@Sun.COM 	}
21847836SJohn.Forte@Sun.COM 
21857836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
21867836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
21877836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21887836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21897836SJohn.Forte@Sun.COM 		}
21907836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
21917836SJohn.Forte@Sun.COM 	}
21927836SJohn.Forte@Sun.COM 
21937836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
21947836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
21957836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21967836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21977836SJohn.Forte@Sun.COM 		}
21987836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
21997836SJohn.Forte@Sun.COM 	}
22007836SJohn.Forte@Sun.COM 
22017836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
22027836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
22037836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22047836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22057836SJohn.Forte@Sun.COM 		}
22067836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
22077836SJohn.Forte@Sun.COM 	}
22087836SJohn.Forte@Sun.COM 
22097836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
22107836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
22117836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22127836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22137836SJohn.Forte@Sun.COM 		}
22147836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
22157836SJohn.Forte@Sun.COM 	}
22167836SJohn.Forte@Sun.COM 
22177836SJohn.Forte@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
22187836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
22197836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22207836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22217836SJohn.Forte@Sun.COM 		}
22227836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
22237836SJohn.Forte@Sun.COM 	}
22247836SJohn.Forte@Sun.COM 
22257836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
22267836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
22277836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22287836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22297836SJohn.Forte@Sun.COM 		}
22307836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
22317836SJohn.Forte@Sun.COM 	}
22327836SJohn.Forte@Sun.COM 
22337836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
22347836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
22357836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22367836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22377836SJohn.Forte@Sun.COM 		}
22387836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
22397836SJohn.Forte@Sun.COM 	}
22407836SJohn.Forte@Sun.COM 
22417836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
22427836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
22437836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22447836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22457836SJohn.Forte@Sun.COM 		}
22467836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
22477836SJohn.Forte@Sun.COM 	}
22487836SJohn.Forte@Sun.COM 
22497836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
22507836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
22517836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22527836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22537836SJohn.Forte@Sun.COM 		}
22547836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
22557836SJohn.Forte@Sun.COM 	}
22567836SJohn.Forte@Sun.COM 
22577836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
22587836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
22597836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22607836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22617836SJohn.Forte@Sun.COM 		}
22627836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
22637836SJohn.Forte@Sun.COM 	}
22647836SJohn.Forte@Sun.COM 
22657836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
22667836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
22677836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22687836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22697836SJohn.Forte@Sun.COM 		}
22707836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
22717836SJohn.Forte@Sun.COM 	}
22727836SJohn.Forte@Sun.COM 
22737836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
22747836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
22757836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22767836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22777836SJohn.Forte@Sun.COM 		}
22787836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
22797836SJohn.Forte@Sun.COM 	}
22807836SJohn.Forte@Sun.COM 
22817836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
22827836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
22837836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22847836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22857836SJohn.Forte@Sun.COM 		}
22867836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
22877836SJohn.Forte@Sun.COM 	}
22887836SJohn.Forte@Sun.COM 
22897836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
22907836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
22917836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22927836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22937836SJohn.Forte@Sun.COM 		}
22947836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
22957836SJohn.Forte@Sun.COM 	}
22967836SJohn.Forte@Sun.COM 
22977836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
22987836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
22997836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23007836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23017836SJohn.Forte@Sun.COM 		}
23027836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
23037836SJohn.Forte@Sun.COM 	}
23047836SJohn.Forte@Sun.COM 
23057836SJohn.Forte@Sun.COM 	mdb_printf("\n\nShadow Registers");
23067836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
23077836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23087836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23097836SJohn.Forte@Sun.COM 		}
23107836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
23117836SJohn.Forte@Sun.COM 	}
23127836SJohn.Forte@Sun.COM 
23137836SJohn.Forte@Sun.COM 	mdb_printf("\n\nLMC Registers");
23147836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
23157836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23167836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23177836SJohn.Forte@Sun.COM 		}
23187836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
23197836SJohn.Forte@Sun.COM 	}
23207836SJohn.Forte@Sun.COM 
23217836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
23227836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
23237836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23247836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23257836SJohn.Forte@Sun.COM 		}
23267836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
23277836SJohn.Forte@Sun.COM 	}
23287836SJohn.Forte@Sun.COM 
23297836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
23307836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
23317836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23327836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23337836SJohn.Forte@Sun.COM 		}
23347836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
23357836SJohn.Forte@Sun.COM 	}
23367836SJohn.Forte@Sun.COM 
23377836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCode RAM");
23387836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
23397836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23407836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
23417836SJohn.Forte@Sun.COM 		}
23427836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
23437836SJohn.Forte@Sun.COM 	}
23447836SJohn.Forte@Sun.COM 
23457836SJohn.Forte@Sun.COM 	mdb_printf("\n\nExternal Memory");
23467836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
23477836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23487836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
23497836SJohn.Forte@Sun.COM 		}
23507836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
23517836SJohn.Forte@Sun.COM 	}
23527836SJohn.Forte@Sun.COM 
23537836SJohn.Forte@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
23547836SJohn.Forte@Sun.COM 
23559156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
23569156SDaniel.Beauregard@Sun.COM 
23579156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
23589156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
23599156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
23609156SDaniel.Beauregard@Sun.COM 		}
23619156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
23629156SDaniel.Beauregard@Sun.COM 	}
23639156SDaniel.Beauregard@Sun.COM 
23649156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
23659156SDaniel.Beauregard@Sun.COM 
23669156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
23679156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
23689156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
23699156SDaniel.Beauregard@Sun.COM 		}
23709156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
23719156SDaniel.Beauregard@Sun.COM 	}
23729156SDaniel.Beauregard@Sun.COM 
23739156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
23749156SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
23759156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
23769156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
23779156SDaniel.Beauregard@Sun.COM 
23789156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
23799156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
23809156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
23819156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
23829156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
23839156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
23849156SDaniel.Beauregard@Sun.COM 			}
23859156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
23869156SDaniel.Beauregard@Sun.COM 		}
23879156SDaniel.Beauregard@Sun.COM 	}
23889156SDaniel.Beauregard@Sun.COM 
23899156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
23909156SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
23919156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
23929156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
23939156SDaniel.Beauregard@Sun.COM 
23949156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
23959156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
23969156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
23979156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
23989156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
23999156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
24009156SDaniel.Beauregard@Sun.COM 			}
24019156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
24029156SDaniel.Beauregard@Sun.COM 		}
24039156SDaniel.Beauregard@Sun.COM 	}
24049156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
24057836SJohn.Forte@Sun.COM 
24067836SJohn.Forte@Sun.COM 	return (DCMD_OK);
24077836SJohn.Forte@Sun.COM }
24087836SJohn.Forte@Sun.COM 
24097836SJohn.Forte@Sun.COM /*
24107836SJohn.Forte@Sun.COM  * ql_25xx_dump_dcmd
24117836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
24127836SJohn.Forte@Sun.COM  *
24137836SJohn.Forte@Sun.COM  * Input:
24147836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
24157836SJohn.Forte@Sun.COM  *	flags = mdb flags.
24167836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
24177836SJohn.Forte@Sun.COM  *	argv  = Arg array.
24187836SJohn.Forte@Sun.COM  *
24197836SJohn.Forte@Sun.COM  * Returns:
24207836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
24217836SJohn.Forte@Sun.COM  *
24227836SJohn.Forte@Sun.COM  * Context:
24237836SJohn.Forte@Sun.COM  *	User context.
24247836SJohn.Forte@Sun.COM  *
24257836SJohn.Forte@Sun.COM  */
24267836SJohn.Forte@Sun.COM /*ARGSUSED*/
24277836SJohn.Forte@Sun.COM static int
ql_25xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)24287836SJohn.Forte@Sun.COM ql_25xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
24297836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
24307836SJohn.Forte@Sun.COM {
24317836SJohn.Forte@Sun.COM 	ql_25xx_fw_dump_t	*fw;
24327836SJohn.Forte@Sun.COM 	uint32_t		cnt = 0;
24337836SJohn.Forte@Sun.COM 
24349156SDaniel.Beauregard@Sun.COM 	fw = (ql_25xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
24359156SDaniel.Beauregard@Sun.COM 
24369156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
24379156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
24387836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
24399156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
24407836SJohn.Forte@Sun.COM 		return (DCMD_OK);
24417836SJohn.Forte@Sun.COM 	}
24427836SJohn.Forte@Sun.COM 
24439156SDaniel.Beauregard@Sun.COM 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
24447836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
24457836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
24467836SJohn.Forte@Sun.COM 
24477836SJohn.Forte@Sun.COM 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
24487836SJohn.Forte@Sun.COM 
24499156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHostRisc Registers");
24507836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
24517836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24527836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24537836SJohn.Forte@Sun.COM 		}
24547836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
24557836SJohn.Forte@Sun.COM 	}
24567836SJohn.Forte@Sun.COM 
24579156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nPCIe Registers");
24587836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
24597836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24607836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24617836SJohn.Forte@Sun.COM 		}
24627836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
24637836SJohn.Forte@Sun.COM 	}
24647836SJohn.Forte@Sun.COM 
24659156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHost Interface Registers");
24667836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
24677836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24687836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24697836SJohn.Forte@Sun.COM 		}
24707836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
24717836SJohn.Forte@Sun.COM 	}
24727836SJohn.Forte@Sun.COM 
24739156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nShadow Registers");
24749156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
24759156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
24769156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
24779156SDaniel.Beauregard@Sun.COM 		}
24789156SDaniel.Beauregard@Sun.COM 
24799156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
24809156SDaniel.Beauregard@Sun.COM 	}
24819156SDaniel.Beauregard@Sun.COM 
24827836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers");
24837836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
24847836SJohn.Forte@Sun.COM 		if (cnt % 16 == 0) {
24857836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24867836SJohn.Forte@Sun.COM 		}
24877836SJohn.Forte@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
24887836SJohn.Forte@Sun.COM 	}
24897836SJohn.Forte@Sun.COM 
24907836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
24917836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
24927836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24937836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24947836SJohn.Forte@Sun.COM 		}
24957836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
24967836SJohn.Forte@Sun.COM 	}
24977836SJohn.Forte@Sun.COM 
24987836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
24997836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
25007836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25017836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25027836SJohn.Forte@Sun.COM 		}
25037836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
25047836SJohn.Forte@Sun.COM 	}
25057836SJohn.Forte@Sun.COM 
25067836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
25077836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
25087836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25097836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25107836SJohn.Forte@Sun.COM 		}
25117836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
25127836SJohn.Forte@Sun.COM 	}
25137836SJohn.Forte@Sun.COM 
25147836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
25157836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
25167836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25177836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25187836SJohn.Forte@Sun.COM 		}
25197836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
25207836SJohn.Forte@Sun.COM 	}
25217836SJohn.Forte@Sun.COM 
25227836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
25237836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
25247836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25257836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25267836SJohn.Forte@Sun.COM 		}
25277836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
25287836SJohn.Forte@Sun.COM 	}
25297836SJohn.Forte@Sun.COM 
25307836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
25317836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
25327836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25337836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25347836SJohn.Forte@Sun.COM 		}
25357836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
25367836SJohn.Forte@Sun.COM 	}
25377836SJohn.Forte@Sun.COM 
25387836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
25397836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
25407836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25417836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25427836SJohn.Forte@Sun.COM 		}
25437836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
25447836SJohn.Forte@Sun.COM 	}
25457836SJohn.Forte@Sun.COM 
25467836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ GP Registers");
25477836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
25487836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25497836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25507836SJohn.Forte@Sun.COM 		}
25517836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
25527836SJohn.Forte@Sun.COM 	}
25537836SJohn.Forte@Sun.COM 
25547836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-0 GP Registers");
25557836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
25567836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25577836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25587836SJohn.Forte@Sun.COM 		}
25597836SJohn.Forte@Sun.COM 
25607836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
25617836SJohn.Forte@Sun.COM 	}
25627836SJohn.Forte@Sun.COM 
25637836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-1 GP Registers");
25647836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
25657836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25667836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25677836SJohn.Forte@Sun.COM 		}
25687836SJohn.Forte@Sun.COM 
25697836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
25707836SJohn.Forte@Sun.COM 	}
25717836SJohn.Forte@Sun.COM 
25727836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-2 GP Registers");
25737836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
25747836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25757836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25767836SJohn.Forte@Sun.COM 		}
25777836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
25787836SJohn.Forte@Sun.COM 	}
25797836SJohn.Forte@Sun.COM 
25807836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
25817836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
25827836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25837836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25847836SJohn.Forte@Sun.COM 		}
25857836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
25867836SJohn.Forte@Sun.COM 	}
25877836SJohn.Forte@Sun.COM 
25887836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
25897836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
25907836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25917836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25927836SJohn.Forte@Sun.COM 		}
25937836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
25947836SJohn.Forte@Sun.COM 	}
25957836SJohn.Forte@Sun.COM 
25967836SJohn.Forte@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
25977836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
25987836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25997836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26007836SJohn.Forte@Sun.COM 		}
26017836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
26027836SJohn.Forte@Sun.COM 	}
26037836SJohn.Forte@Sun.COM 
26047836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
26057836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
26067836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26077836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26087836SJohn.Forte@Sun.COM 		}
26097836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
26107836SJohn.Forte@Sun.COM 	}
26117836SJohn.Forte@Sun.COM 
26127836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
26137836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
26147836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26157836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26167836SJohn.Forte@Sun.COM 		}
26177836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
26187836SJohn.Forte@Sun.COM 	}
26197836SJohn.Forte@Sun.COM 
26207836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
26217836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
26227836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26237836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26247836SJohn.Forte@Sun.COM 		}
26257836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
26267836SJohn.Forte@Sun.COM 	}
26277836SJohn.Forte@Sun.COM 
26287836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
26297836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
26307836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26317836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26327836SJohn.Forte@Sun.COM 		}
26337836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
26347836SJohn.Forte@Sun.COM 	}
26357836SJohn.Forte@Sun.COM 
26367836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
26377836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
26387836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26397836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26407836SJohn.Forte@Sun.COM 		}
26417836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
26427836SJohn.Forte@Sun.COM 	}
26437836SJohn.Forte@Sun.COM 
26447836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
26457836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
26467836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26477836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26487836SJohn.Forte@Sun.COM 		}
26497836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
26507836SJohn.Forte@Sun.COM 	}
26517836SJohn.Forte@Sun.COM 
26527836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
26537836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
26547836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26557836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26567836SJohn.Forte@Sun.COM 		}
26577836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
26587836SJohn.Forte@Sun.COM 	}
26597836SJohn.Forte@Sun.COM 
26607836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
26617836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
26627836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26637836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26647836SJohn.Forte@Sun.COM 		}
26657836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
26667836SJohn.Forte@Sun.COM 	}
26677836SJohn.Forte@Sun.COM 
26687836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
26697836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
26707836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26717836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26727836SJohn.Forte@Sun.COM 		}
26737836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
26747836SJohn.Forte@Sun.COM 	}
26757836SJohn.Forte@Sun.COM 
26767836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
26777836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
26787836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26797836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26807836SJohn.Forte@Sun.COM 		}
26817836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
26827836SJohn.Forte@Sun.COM 	}
26837836SJohn.Forte@Sun.COM 
26847836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
26857836SJohn.Forte@Sun.COM 
26867836SJohn.Forte@Sun.COM 	mdb_printf("\n\nLMC Registers");
26877836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
26887836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26897836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26907836SJohn.Forte@Sun.COM 		}
26917836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
26927836SJohn.Forte@Sun.COM 	}
26937836SJohn.Forte@Sun.COM 
26947836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
26957836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
26967836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26977836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26987836SJohn.Forte@Sun.COM 		}
26997836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
27007836SJohn.Forte@Sun.COM 	}
27017836SJohn.Forte@Sun.COM 
27027836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
27037836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
27047836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27057836SJohn.Forte@Sun.COM 			mdb_printf("\n");
27067836SJohn.Forte@Sun.COM 		}
27077836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
27087836SJohn.Forte@Sun.COM 	}
27097836SJohn.Forte@Sun.COM 
27107836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCode RAM");
27117836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
27127836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27137836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
27147836SJohn.Forte@Sun.COM 		}
27157836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
27167836SJohn.Forte@Sun.COM 	}
27177836SJohn.Forte@Sun.COM 
27187836SJohn.Forte@Sun.COM 	mdb_printf("\n\nExternal Memory");
27197836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
27207836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27217836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
27227836SJohn.Forte@Sun.COM 		}
27237836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
27247836SJohn.Forte@Sun.COM 	}
27257836SJohn.Forte@Sun.COM 
27267836SJohn.Forte@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
27277836SJohn.Forte@Sun.COM 
27289156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
27299156SDaniel.Beauregard@Sun.COM 
27309156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
27319156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
27329156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
27339156SDaniel.Beauregard@Sun.COM 		}
27349156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
27359156SDaniel.Beauregard@Sun.COM 	}
27369156SDaniel.Beauregard@Sun.COM 
27379156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
27389156SDaniel.Beauregard@Sun.COM 
27399156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
27409156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
27419156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
27429156SDaniel.Beauregard@Sun.COM 		}
27439156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
27449156SDaniel.Beauregard@Sun.COM 	}
27459156SDaniel.Beauregard@Sun.COM 
27469156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
27479156SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
27489156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
27499156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
27509156SDaniel.Beauregard@Sun.COM 
27519156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
27529156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
27539156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
27549156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
27559156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
27569156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
27579156SDaniel.Beauregard@Sun.COM 			}
27589156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
27599156SDaniel.Beauregard@Sun.COM 		}
27609156SDaniel.Beauregard@Sun.COM 	}
27619156SDaniel.Beauregard@Sun.COM 
27629156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
27639156SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
27649156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
27659156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
27669156SDaniel.Beauregard@Sun.COM 
27679156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
27689156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
27699156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
27709156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
27719156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
27729156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
27739156SDaniel.Beauregard@Sun.COM 			}
27749156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
27759156SDaniel.Beauregard@Sun.COM 		}
27769156SDaniel.Beauregard@Sun.COM 	}
27779156SDaniel.Beauregard@Sun.COM 
27789156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
27799156SDaniel.Beauregard@Sun.COM 
27809156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nreturn exit\n");
27817836SJohn.Forte@Sun.COM 
27827836SJohn.Forte@Sun.COM 	return (DCMD_OK);
27837836SJohn.Forte@Sun.COM }
27847836SJohn.Forte@Sun.COM 
27857836SJohn.Forte@Sun.COM /*
278610736SDaniel.Beauregard@Sun.COM  * ql_81xx_dump_dcmd
278710736SDaniel.Beauregard@Sun.COM  *	prints out a firmware dump buffer
278810736SDaniel.Beauregard@Sun.COM  *
278910736SDaniel.Beauregard@Sun.COM  * Input:
279010736SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
279110736SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
279210736SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
279310736SDaniel.Beauregard@Sun.COM  *	argv  = Arg array.
279410736SDaniel.Beauregard@Sun.COM  *
279510736SDaniel.Beauregard@Sun.COM  * Returns:
279610736SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
279710736SDaniel.Beauregard@Sun.COM  *
279810736SDaniel.Beauregard@Sun.COM  * Context:
279910736SDaniel.Beauregard@Sun.COM  *	User context.
280010736SDaniel.Beauregard@Sun.COM  *
280110736SDaniel.Beauregard@Sun.COM  */
280210736SDaniel.Beauregard@Sun.COM /*ARGSUSED*/
280310736SDaniel.Beauregard@Sun.COM static int
ql_81xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)280410736SDaniel.Beauregard@Sun.COM ql_81xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
280510736SDaniel.Beauregard@Sun.COM     const mdb_arg_t *argv)
280610736SDaniel.Beauregard@Sun.COM {
280710736SDaniel.Beauregard@Sun.COM 	ql_81xx_fw_dump_t	*fw;
280810736SDaniel.Beauregard@Sun.COM 	uint32_t		cnt = 0;
280910736SDaniel.Beauregard@Sun.COM 
281010736SDaniel.Beauregard@Sun.COM 	fw = (ql_81xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
281110736SDaniel.Beauregard@Sun.COM 
281210736SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
281310736SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
281410736SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
281510736SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
281610736SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
281710736SDaniel.Beauregard@Sun.COM 	}
281810736SDaniel.Beauregard@Sun.COM 
281910736SDaniel.Beauregard@Sun.COM 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
282010736SDaniel.Beauregard@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
282110736SDaniel.Beauregard@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
282210736SDaniel.Beauregard@Sun.COM 
282310736SDaniel.Beauregard@Sun.COM 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
282410736SDaniel.Beauregard@Sun.COM 
282510736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHostRisc Registers");
282610736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
282710736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
282810736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
282910736SDaniel.Beauregard@Sun.COM 		}
283010736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
283110736SDaniel.Beauregard@Sun.COM 	}
283210736SDaniel.Beauregard@Sun.COM 
283310736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nPCIe Registers");
283410736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
283510736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
283610736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
283710736SDaniel.Beauregard@Sun.COM 		}
283810736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
283910736SDaniel.Beauregard@Sun.COM 	}
284010736SDaniel.Beauregard@Sun.COM 
284110736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHost Interface Registers");
284210736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
284310736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
284410736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
284510736SDaniel.Beauregard@Sun.COM 		}
284610736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
284710736SDaniel.Beauregard@Sun.COM 	}
284810736SDaniel.Beauregard@Sun.COM 
284910736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nShadow Registers");
285010736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
285110736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
285210736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
285310736SDaniel.Beauregard@Sun.COM 		}
285410736SDaniel.Beauregard@Sun.COM 
285510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
285610736SDaniel.Beauregard@Sun.COM 	}
285710736SDaniel.Beauregard@Sun.COM 
285810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nMailbox Registers");
285910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
286010736SDaniel.Beauregard@Sun.COM 		if (cnt % 16 == 0) {
286110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
286210736SDaniel.Beauregard@Sun.COM 		}
286310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
286410736SDaniel.Beauregard@Sun.COM 	}
286510736SDaniel.Beauregard@Sun.COM 
286610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
286710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
286810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
286910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
287010736SDaniel.Beauregard@Sun.COM 		}
287110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
287210736SDaniel.Beauregard@Sun.COM 	}
287310736SDaniel.Beauregard@Sun.COM 
287410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
287510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
287610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
287710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
287810736SDaniel.Beauregard@Sun.COM 		}
287910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
288010736SDaniel.Beauregard@Sun.COM 	}
288110736SDaniel.Beauregard@Sun.COM 
288210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
288310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
288410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
288510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
288610736SDaniel.Beauregard@Sun.COM 		}
288710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
288810736SDaniel.Beauregard@Sun.COM 	}
288910736SDaniel.Beauregard@Sun.COM 
289010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
289110736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
289210736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
289310736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
289410736SDaniel.Beauregard@Sun.COM 		}
289510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
289610736SDaniel.Beauregard@Sun.COM 	}
289710736SDaniel.Beauregard@Sun.COM 
289810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
289910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
290010736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
290110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
290210736SDaniel.Beauregard@Sun.COM 		}
290310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
290410736SDaniel.Beauregard@Sun.COM 	}
290510736SDaniel.Beauregard@Sun.COM 
290610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
290710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
290810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
290910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
291010736SDaniel.Beauregard@Sun.COM 		}
291110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
291210736SDaniel.Beauregard@Sun.COM 	}
291310736SDaniel.Beauregard@Sun.COM 
291410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
291510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
291610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
291710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
291810736SDaniel.Beauregard@Sun.COM 		}
291910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
292010736SDaniel.Beauregard@Sun.COM 	}
292110736SDaniel.Beauregard@Sun.COM 
292210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ GP Registers");
292310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
292410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
292510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
292610736SDaniel.Beauregard@Sun.COM 		}
292710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
292810736SDaniel.Beauregard@Sun.COM 	}
292910736SDaniel.Beauregard@Sun.COM 
293010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-0 GP Registers");
293110736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
293210736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
293310736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
293410736SDaniel.Beauregard@Sun.COM 		}
293510736SDaniel.Beauregard@Sun.COM 
293610736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
293710736SDaniel.Beauregard@Sun.COM 	}
293810736SDaniel.Beauregard@Sun.COM 
293910736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-1 GP Registers");
294010736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
294110736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
294210736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
294310736SDaniel.Beauregard@Sun.COM 		}
294410736SDaniel.Beauregard@Sun.COM 
294510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
294610736SDaniel.Beauregard@Sun.COM 	}
294710736SDaniel.Beauregard@Sun.COM 
294810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-2 GP Registers");
294910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
295010736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
295110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
295210736SDaniel.Beauregard@Sun.COM 		}
295310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
295410736SDaniel.Beauregard@Sun.COM 	}
295510736SDaniel.Beauregard@Sun.COM 
295610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
295710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
295810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
295910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
296010736SDaniel.Beauregard@Sun.COM 		}
296110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
296210736SDaniel.Beauregard@Sun.COM 	}
296310736SDaniel.Beauregard@Sun.COM 
296410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
296510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
296610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
296710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
296810736SDaniel.Beauregard@Sun.COM 		}
296910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
297010736SDaniel.Beauregard@Sun.COM 	}
297110736SDaniel.Beauregard@Sun.COM 
297210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
297310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
297410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
297510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
297610736SDaniel.Beauregard@Sun.COM 		}
297710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
297810736SDaniel.Beauregard@Sun.COM 	}
297910736SDaniel.Beauregard@Sun.COM 
298010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
298110736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
298210736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
298310736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
298410736SDaniel.Beauregard@Sun.COM 		}
298510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
298610736SDaniel.Beauregard@Sun.COM 	}
298710736SDaniel.Beauregard@Sun.COM 
298810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
298910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
299010736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
299110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
299210736SDaniel.Beauregard@Sun.COM 		}
299310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
299410736SDaniel.Beauregard@Sun.COM 	}
299510736SDaniel.Beauregard@Sun.COM 
299610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
299710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
299810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
299910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
300010736SDaniel.Beauregard@Sun.COM 		}
300110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
300210736SDaniel.Beauregard@Sun.COM 	}
300310736SDaniel.Beauregard@Sun.COM 
300410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
300510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
300610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
300710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
300810736SDaniel.Beauregard@Sun.COM 		}
300910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
301010736SDaniel.Beauregard@Sun.COM 	}
301110736SDaniel.Beauregard@Sun.COM 
301210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
301310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
301410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
301510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
301610736SDaniel.Beauregard@Sun.COM 		}
301710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
301810736SDaniel.Beauregard@Sun.COM 	}
301910736SDaniel.Beauregard@Sun.COM 
302010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
302110736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
302210736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
302310736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
302410736SDaniel.Beauregard@Sun.COM 		}
302510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
302610736SDaniel.Beauregard@Sun.COM 	}
302710736SDaniel.Beauregard@Sun.COM 
302810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
302910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
303010736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
303110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
303210736SDaniel.Beauregard@Sun.COM 		}
303310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
303410736SDaniel.Beauregard@Sun.COM 	}
303510736SDaniel.Beauregard@Sun.COM 
303610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
303710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
303810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
303910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
304010736SDaniel.Beauregard@Sun.COM 		}
304110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
304210736SDaniel.Beauregard@Sun.COM 	}
304310736SDaniel.Beauregard@Sun.COM 
304410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
304510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
304610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
304710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
304810736SDaniel.Beauregard@Sun.COM 		}
304910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
305010736SDaniel.Beauregard@Sun.COM 	}
305110736SDaniel.Beauregard@Sun.COM 
305210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
305310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
305410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
305510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
305610736SDaniel.Beauregard@Sun.COM 		}
305710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
305810736SDaniel.Beauregard@Sun.COM 	}
305910736SDaniel.Beauregard@Sun.COM 
306010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
306110736SDaniel.Beauregard@Sun.COM 
306210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nLMC Registers");
306310736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
306410736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
306510736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
306610736SDaniel.Beauregard@Sun.COM 		}
306710736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
306810736SDaniel.Beauregard@Sun.COM 	}
306910736SDaniel.Beauregard@Sun.COM 
307010736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
307110736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
307210736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
307310736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
307410736SDaniel.Beauregard@Sun.COM 		}
307510736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
307610736SDaniel.Beauregard@Sun.COM 	}
307710736SDaniel.Beauregard@Sun.COM 
307810736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
307910736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
308010736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
308110736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
308210736SDaniel.Beauregard@Sun.COM 		}
308310736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
308410736SDaniel.Beauregard@Sun.COM 	}
308510736SDaniel.Beauregard@Sun.COM 
308610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nCode RAM");
308710736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
308810736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
308910736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
309010736SDaniel.Beauregard@Sun.COM 		}
309110736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
309210736SDaniel.Beauregard@Sun.COM 	}
309310736SDaniel.Beauregard@Sun.COM 
309410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nExternal Memory");
309510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
309610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
309710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
309810736SDaniel.Beauregard@Sun.COM 		}
309910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
310010736SDaniel.Beauregard@Sun.COM 	}
310110736SDaniel.Beauregard@Sun.COM 
310210736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
310310736SDaniel.Beauregard@Sun.COM 
310410736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
310510736SDaniel.Beauregard@Sun.COM 
310610736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
310710736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
310810736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
310910736SDaniel.Beauregard@Sun.COM 		}
311010736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
311110736SDaniel.Beauregard@Sun.COM 	}
311210736SDaniel.Beauregard@Sun.COM 
311310736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
311410736SDaniel.Beauregard@Sun.COM 
311510736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
311610736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
311710736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
311810736SDaniel.Beauregard@Sun.COM 		}
311910736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
312010736SDaniel.Beauregard@Sun.COM 	}
312110736SDaniel.Beauregard@Sun.COM 
312210736SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
312310736SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
312410736SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
312510736SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
312610736SDaniel.Beauregard@Sun.COM 
312710736SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
312810736SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
312910736SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
313010736SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
313110736SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
313210736SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
313310736SDaniel.Beauregard@Sun.COM 			}
313410736SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
313510736SDaniel.Beauregard@Sun.COM 		}
313610736SDaniel.Beauregard@Sun.COM 	}
313710736SDaniel.Beauregard@Sun.COM 
313810736SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
313910736SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
314010736SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
314110736SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
314210736SDaniel.Beauregard@Sun.COM 
314310736SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
314410736SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
314510736SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
314610736SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
314710736SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
314810736SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
314910736SDaniel.Beauregard@Sun.COM 			}
315010736SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
315110736SDaniel.Beauregard@Sun.COM 		}
315210736SDaniel.Beauregard@Sun.COM 	}
315310736SDaniel.Beauregard@Sun.COM 
315410736SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
315510736SDaniel.Beauregard@Sun.COM 
315610736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nreturn exit\n");
315710736SDaniel.Beauregard@Sun.COM 
315810736SDaniel.Beauregard@Sun.COM 	return (DCMD_OK);
315910736SDaniel.Beauregard@Sun.COM }
316010736SDaniel.Beauregard@Sun.COM 
316110736SDaniel.Beauregard@Sun.COM /*
31629156SDaniel.Beauregard@Sun.COM  * ql_gettrace_dcmd
31639156SDaniel.Beauregard@Sun.COM  *	prints out the Extended Logging trace buffer
31649156SDaniel.Beauregard@Sun.COM  *
31659156SDaniel.Beauregard@Sun.COM  * Input:
31669156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: must be an ha)
31679156SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
31689156SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
31699156SDaniel.Beauregard@Sun.COM  *	argv  = Arg array.
31709156SDaniel.Beauregard@Sun.COM  *
31719156SDaniel.Beauregard@Sun.COM  * Returns:
31729156SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
31739156SDaniel.Beauregard@Sun.COM  *
31749156SDaniel.Beauregard@Sun.COM  * Context:
31759156SDaniel.Beauregard@Sun.COM  *	User context.
31769156SDaniel.Beauregard@Sun.COM  *
31779156SDaniel.Beauregard@Sun.COM  */
31789156SDaniel.Beauregard@Sun.COM static int
qlc_gettrace_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)31799156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
31809156SDaniel.Beauregard@Sun.COM {
31819156SDaniel.Beauregard@Sun.COM 	ql_adapter_state_t	*ha;
31829156SDaniel.Beauregard@Sun.COM 	int			verbose = 0;
31839156SDaniel.Beauregard@Sun.COM 	int			wrapped = 0;
31849156SDaniel.Beauregard@Sun.COM 	char			*trace_start;
31859156SDaniel.Beauregard@Sun.COM 	char			*trace_end;
31869156SDaniel.Beauregard@Sun.COM 	char			*dump_start = 0;
31879156SDaniel.Beauregard@Sun.COM 	char			*trace_next  = 0;
31889156SDaniel.Beauregard@Sun.COM 	char			*dump_current  = 0;
31899156SDaniel.Beauregard@Sun.COM 	el_trace_desc_t		*trace_desc;
31909156SDaniel.Beauregard@Sun.COM 
31919156SDaniel.Beauregard@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
31929156SDaniel.Beauregard@Sun.COM 		mdb_warn("ql_adapter_state structure addr is required");
31939156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
31949156SDaniel.Beauregard@Sun.COM 	}
31959156SDaniel.Beauregard@Sun.COM 
31969156SDaniel.Beauregard@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
31979156SDaniel.Beauregard@Sun.COM 	    argc) {
31989156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
31999156SDaniel.Beauregard@Sun.COM 	}
32009156SDaniel.Beauregard@Sun.COM 
32019156SDaniel.Beauregard@Sun.COM 	/*
32029156SDaniel.Beauregard@Sun.COM 	 * Get the adapter state struct which was passed
32039156SDaniel.Beauregard@Sun.COM 	 */
32049156SDaniel.Beauregard@Sun.COM 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
32059156SDaniel.Beauregard@Sun.COM 	    UM_SLEEP)) == NULL) {
32069156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
32079156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32089156SDaniel.Beauregard@Sun.COM 	}
32099156SDaniel.Beauregard@Sun.COM 
32109156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
32119156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
32129156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32139156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32149156SDaniel.Beauregard@Sun.COM 	}
32159156SDaniel.Beauregard@Sun.COM 
32169156SDaniel.Beauregard@Sun.COM 	/*
32179156SDaniel.Beauregard@Sun.COM 	 * If its not a valid trace descriptor then bail out
32189156SDaniel.Beauregard@Sun.COM 	 */
32199156SDaniel.Beauregard@Sun.COM 	if (ha->el_trace_desc == NULL) {
32209156SDaniel.Beauregard@Sun.COM 		mdb_warn("trace descriptor does not exist for instance %d\n",
32219156SDaniel.Beauregard@Sun.COM 		    ha->instance);
32229156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32239156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32249156SDaniel.Beauregard@Sun.COM 	} else {
32259156SDaniel.Beauregard@Sun.COM 		trace_desc = (el_trace_desc_t *)
32269156SDaniel.Beauregard@Sun.COM 		    mdb_alloc(sizeof (el_trace_desc_t), UM_SLEEP);
32279156SDaniel.Beauregard@Sun.COM 		if (mdb_vread(trace_desc, sizeof (el_trace_desc_t),
32289156SDaniel.Beauregard@Sun.COM 		    (uintptr_t)ha->el_trace_desc) == -1) {
32299156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_adapter_state at %p",
32309156SDaniel.Beauregard@Sun.COM 			    addr);
32319156SDaniel.Beauregard@Sun.COM 			mdb_free(trace_desc, sizeof (el_trace_desc_t));
32329156SDaniel.Beauregard@Sun.COM 			mdb_free(ha, sizeof (ql_adapter_state_t));
32339156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
32349156SDaniel.Beauregard@Sun.COM 		}
32359156SDaniel.Beauregard@Sun.COM 		if (trace_desc->trace_buffer == NULL) {
32369156SDaniel.Beauregard@Sun.COM 			mdb_warn("trace buffer does not exist for "
32379156SDaniel.Beauregard@Sun.COM 			    "instance %d\n", ha->instance);
32389156SDaniel.Beauregard@Sun.COM 			mdb_free(trace_desc, sizeof (el_trace_desc_t));
32399156SDaniel.Beauregard@Sun.COM 			mdb_free(ha, sizeof (ql_adapter_state_t));
32409156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
32419156SDaniel.Beauregard@Sun.COM 		}
32429156SDaniel.Beauregard@Sun.COM 	}
32439156SDaniel.Beauregard@Sun.COM 
32449156SDaniel.Beauregard@Sun.COM 	/* Get the trace buffer */
32459156SDaniel.Beauregard@Sun.COM 
32469156SDaniel.Beauregard@Sun.COM 	trace_start = (char *)
32479156SDaniel.Beauregard@Sun.COM 	    mdb_zalloc(trace_desc->trace_buffer_size, UM_SLEEP);
32489156SDaniel.Beauregard@Sun.COM 
32499156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(trace_start, trace_desc->trace_buffer_size,
32509156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)trace_desc->trace_buffer) == -1) {
32519156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read trace buffer?)");
32529156SDaniel.Beauregard@Sun.COM 		mdb_free(trace_start, trace_desc->trace_buffer_size);
32539156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32549156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32559156SDaniel.Beauregard@Sun.COM 	}
32569156SDaniel.Beauregard@Sun.COM 
32579156SDaniel.Beauregard@Sun.COM 	/* set the end of the trace buffer. */
32589156SDaniel.Beauregard@Sun.COM 	trace_end = trace_start + trace_desc->trace_buffer_size;
32599156SDaniel.Beauregard@Sun.COM 
32609156SDaniel.Beauregard@Sun.COM 	/* Find the start point of trace. */
32619156SDaniel.Beauregard@Sun.COM 	trace_next = trace_start + trace_desc->next;
32629156SDaniel.Beauregard@Sun.COM 
32639156SDaniel.Beauregard@Sun.COM 	/*
32649156SDaniel.Beauregard@Sun.COM 	 * If the buffer has not wrapped next will point at a null so
32659156SDaniel.Beauregard@Sun.COM 	 * start is the begining of the buffer.  If next points at a char
32669156SDaniel.Beauregard@Sun.COM 	 * then we must traverse the buffer further until a null is detected.
32679156SDaniel.Beauregard@Sun.COM 	 * The location after the null will be the beginning of the oldest
32689156SDaniel.Beauregard@Sun.COM 	 * whole object in the buffer, which we use as the start.
32699156SDaniel.Beauregard@Sun.COM 	 */
32709156SDaniel.Beauregard@Sun.COM 
32719156SDaniel.Beauregard@Sun.COM 	if ((trace_next + EL_BUFFER_RESERVE) >= trace_end) {
32729156SDaniel.Beauregard@Sun.COM 		dump_start = trace_start;
32739156SDaniel.Beauregard@Sun.COM 	} else if (*trace_next != NULL) {
32749156SDaniel.Beauregard@Sun.COM 		dump_start = trace_next + (strlen(trace_next) + 1);
32759156SDaniel.Beauregard@Sun.COM 	} else {
32769156SDaniel.Beauregard@Sun.COM 		dump_start = trace_start;
32779156SDaniel.Beauregard@Sun.COM 	}
32789156SDaniel.Beauregard@Sun.COM 
32799156SDaniel.Beauregard@Sun.COM 	dump_current = dump_start;
32809156SDaniel.Beauregard@Sun.COM 
32819156SDaniel.Beauregard@Sun.COM 	mdb_printf("\nExtended Logging trace buffer @%x, start @%x, "
32829156SDaniel.Beauregard@Sun.COM 	    "size=%d\n\n", trace_start, dump_current,
32839156SDaniel.Beauregard@Sun.COM 	    trace_desc->trace_buffer_size);
32849156SDaniel.Beauregard@Sun.COM 
32859156SDaniel.Beauregard@Sun.COM 	/* Don't run off the end, no matter what. */
32869156SDaniel.Beauregard@Sun.COM 	while (((uintptr_t)dump_current - (uintptr_t)trace_start) <=
32879156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)trace_desc->trace_buffer_size) {
32889156SDaniel.Beauregard@Sun.COM 		/* Show it... */
32899156SDaniel.Beauregard@Sun.COM 		mdb_printf("%s", dump_current);
32909156SDaniel.Beauregard@Sun.COM 		/* Calculate the next and make it the current */
32919156SDaniel.Beauregard@Sun.COM 		dump_current += (strlen(dump_current) + 1);
32929156SDaniel.Beauregard@Sun.COM 		/* check for wrap */
32939156SDaniel.Beauregard@Sun.COM 		if ((dump_current + EL_BUFFER_RESERVE) >= trace_end) {
32949156SDaniel.Beauregard@Sun.COM 			mdb_printf("Wraping %x\n", dump_current);
32959156SDaniel.Beauregard@Sun.COM 			dump_current = trace_start;
32969156SDaniel.Beauregard@Sun.COM 			wrapped = 1;
32979156SDaniel.Beauregard@Sun.COM 		} else if (wrapped) {
32989156SDaniel.Beauregard@Sun.COM 			/*   Don't go past next. */
32999156SDaniel.Beauregard@Sun.COM 			if ((trace_start + trace_desc->next) <= dump_current) {
33009156SDaniel.Beauregard@Sun.COM 				mdb_printf("Done %x", dump_current);
33019156SDaniel.Beauregard@Sun.COM 				break;
33029156SDaniel.Beauregard@Sun.COM 			}
33039156SDaniel.Beauregard@Sun.COM 		} else if (*dump_current == NULL) {
33049156SDaniel.Beauregard@Sun.COM 			mdb_printf("Done %x(null)", dump_current);
33059156SDaniel.Beauregard@Sun.COM 			break;
33069156SDaniel.Beauregard@Sun.COM 		}
33079156SDaniel.Beauregard@Sun.COM 	}
33089156SDaniel.Beauregard@Sun.COM 
33099156SDaniel.Beauregard@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
33109156SDaniel.Beauregard@Sun.COM 	mdb_free(trace_start, trace_desc->trace_buffer_size);
33119156SDaniel.Beauregard@Sun.COM 	mdb_free(trace_desc, sizeof (el_trace_desc_t));
33129156SDaniel.Beauregard@Sun.COM 
33139156SDaniel.Beauregard@Sun.COM 	return (DCMD_OK);
33149156SDaniel.Beauregard@Sun.COM }
33159156SDaniel.Beauregard@Sun.COM /*
33167836SJohn.Forte@Sun.COM  * ql_doprint
33177836SJohn.Forte@Sun.COM  *	ql generic function to call the print dcmd
33187836SJohn.Forte@Sun.COM  *
33197836SJohn.Forte@Sun.COM  * Input:
33207836SJohn.Forte@Sun.COM  *	addr - address to struct
33217836SJohn.Forte@Sun.COM  *	prtsting - address to string
33227836SJohn.Forte@Sun.COM  *
33237836SJohn.Forte@Sun.COM  * Returns:
33247836SJohn.Forte@Sun.COM  *	WALK_DONE
33257836SJohn.Forte@Sun.COM  *
33267836SJohn.Forte@Sun.COM  * Context:
33277836SJohn.Forte@Sun.COM  *	User context.
33287836SJohn.Forte@Sun.COM  *
33297836SJohn.Forte@Sun.COM  */
33307836SJohn.Forte@Sun.COM static int32_t
ql_doprint(uintptr_t addr,int8_t * prtstring)33317836SJohn.Forte@Sun.COM ql_doprint(uintptr_t addr, int8_t *prtstring)
33327836SJohn.Forte@Sun.COM {
33337836SJohn.Forte@Sun.COM 	struct	mdb_arg		printarg;
33347836SJohn.Forte@Sun.COM 
33357836SJohn.Forte@Sun.COM 	printarg.a_un.a_str = (int8_t *)(mdb_zalloc(strlen(prtstring),
33367836SJohn.Forte@Sun.COM 	    UM_SLEEP));
33377836SJohn.Forte@Sun.COM 	printarg.a_type = MDB_TYPE_STRING;
33387836SJohn.Forte@Sun.COM 	(void) strcpy((int8_t *)(printarg.a_un.a_str), prtstring);
33397836SJohn.Forte@Sun.COM 
33407836SJohn.Forte@Sun.COM 	if ((mdb_call_dcmd("print", addr, DCMD_ADDRSPEC, 1,
33417836SJohn.Forte@Sun.COM 	    &printarg)) == -1) {
33427836SJohn.Forte@Sun.COM 		mdb_warn("ql_doprint: failed print dcmd: %s"
33437836SJohn.Forte@Sun.COM 		    "at addr: %llxh", prtstring, addr);
33447836SJohn.Forte@Sun.COM 	}
33457836SJohn.Forte@Sun.COM 
33467836SJohn.Forte@Sun.COM 	mdb_free((void *)(printarg.a_un.a_str), strlen(prtstring));
33477836SJohn.Forte@Sun.COM 	return (WALK_DONE);
33487836SJohn.Forte@Sun.COM }
33497836SJohn.Forte@Sun.COM 
33507836SJohn.Forte@Sun.COM /*
33517836SJohn.Forte@Sun.COM  * ql_dump_flags
33527836SJohn.Forte@Sun.COM  *	mdb utility to print the flag string
33537836SJohn.Forte@Sun.COM  *
33547836SJohn.Forte@Sun.COM  * Input:
33557836SJohn.Forte@Sun.COM  *	flags - flags to print
33567836SJohn.Forte@Sun.COM  *	strings - text to print when flag is set
33577836SJohn.Forte@Sun.COM  *
33587836SJohn.Forte@Sun.COM  * Returns:
33597836SJohn.Forte@Sun.COM  *
33607836SJohn.Forte@Sun.COM  *
33617836SJohn.Forte@Sun.COM  * Context:
33627836SJohn.Forte@Sun.COM  *	User context.
33637836SJohn.Forte@Sun.COM  *
33647836SJohn.Forte@Sun.COM  */
33657836SJohn.Forte@Sun.COM static void
ql_dump_flags(uint64_t flags,int8_t ** strings)33667836SJohn.Forte@Sun.COM ql_dump_flags(uint64_t flags, int8_t **strings)
33677836SJohn.Forte@Sun.COM {
33687836SJohn.Forte@Sun.COM 	int		i, linel, first = 1;
33697836SJohn.Forte@Sun.COM 	uint64_t	mask = 1;
33707836SJohn.Forte@Sun.COM 
33717836SJohn.Forte@Sun.COM 	linel = 8;
33727836SJohn.Forte@Sun.COM 	mdb_printf("\t");
33737836SJohn.Forte@Sun.COM 	for (i = 0; i < 64; i++) {
33747836SJohn.Forte@Sun.COM 		if (strings[i] == NULL)
33757836SJohn.Forte@Sun.COM 			break;
33767836SJohn.Forte@Sun.COM 		if (flags & mask) {
33777836SJohn.Forte@Sun.COM 			if (!first) {
33787836SJohn.Forte@Sun.COM 				mdb_printf(" | ");
33797836SJohn.Forte@Sun.COM 			} else {
33807836SJohn.Forte@Sun.COM 				first = 0;
33817836SJohn.Forte@Sun.COM 			}
33827836SJohn.Forte@Sun.COM 			linel += (int32_t)strlen(strings[i]) + 3;
33837836SJohn.Forte@Sun.COM 			if (linel > 80) {
33847836SJohn.Forte@Sun.COM 				mdb_printf("\n\t");
33857836SJohn.Forte@Sun.COM 				linel = (int32_t)strlen(strings[i]) + 1 + 8;
33867836SJohn.Forte@Sun.COM 			}
33877836SJohn.Forte@Sun.COM 			mdb_printf("%s", strings[i]);
33887836SJohn.Forte@Sun.COM 		}
33897836SJohn.Forte@Sun.COM 		mask <<= 1;
33907836SJohn.Forte@Sun.COM 	}
33917836SJohn.Forte@Sun.COM 	mdb_printf("\n");
33927836SJohn.Forte@Sun.COM }
33937836SJohn.Forte@Sun.COM 
33947836SJohn.Forte@Sun.COM /*
33957836SJohn.Forte@Sun.COM  * MDB module linkage information
33967836SJohn.Forte@Sun.COM  *
33977836SJohn.Forte@Sun.COM  *
33987836SJohn.Forte@Sun.COM  * dcmd structures for the _mdb_init function
33997836SJohn.Forte@Sun.COM  */
34007836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = {
34017836SJohn.Forte@Sun.COM 	{ "qlclinks", NULL, "Prints qlc link information", qlclinks_dcmd },
34027836SJohn.Forte@Sun.COM 	{ "qlcosc", NULL, "Prints outstanding cmd info", qlc_osc_dcmd },
34037836SJohn.Forte@Sun.COM 	{ "qlcver", NULL, "Prints driver/mdb version", qlcver_dcmd },
34047836SJohn.Forte@Sun.COM 	{ "qlc_elog", "[on|off] [<inst #>|all]", "Turns qlc extended logging "
34057836SJohn.Forte@Sun.COM 	    "on / off", qlc_el_dcmd },
34067836SJohn.Forte@Sun.COM 	{ "qlcstate", ":[-v]", "Prints qlc adapter state information",
34077836SJohn.Forte@Sun.COM 	    qlcstate_dcmd },
34087836SJohn.Forte@Sun.COM 	{ "qlctgtq", NULL, "Prints qlc target queues", qltgtq_dcmd },
34097836SJohn.Forte@Sun.COM 	{ "qlcwdog", NULL, "Prints out watchdog linked list", qlc_wdog_dcmd},
34109156SDaniel.Beauregard@Sun.COM 	{ "qlcgetdump", ":[-v]", "Retrieves the ASCII f/w dump",
34119156SDaniel.Beauregard@Sun.COM 	    qlc_getdump_dcmd },
34129156SDaniel.Beauregard@Sun.COM 	{ "qlcgettrace", ":[-v]", "Retrieves the ASCII Extended Logging trace",
34139156SDaniel.Beauregard@Sun.COM 	    qlc_gettrace_dcmd },
34147836SJohn.Forte@Sun.COM 	{ NULL }
34157836SJohn.Forte@Sun.COM };
34167836SJohn.Forte@Sun.COM 
34177836SJohn.Forte@Sun.COM /*
34187836SJohn.Forte@Sun.COM  * walker structures for the _mdb_init function
34197836SJohn.Forte@Sun.COM  */
34207836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = {
34217836SJohn.Forte@Sun.COM 	{ "qlcstates", "walk list of qlc ql_state_t structures",
34227836SJohn.Forte@Sun.COM 	    qlstates_walk_init, qlstates_walk_step, qlstates_walk_fini },
34237836SJohn.Forte@Sun.COM 	{ "qlcsrbs", "walk list of qlc ql_srb_t strctures",
34247836SJohn.Forte@Sun.COM 	    qlsrb_walk_init, qlsrb_walk_step, qlsrb_walk_fini },
34257836SJohn.Forte@Sun.COM 	{ "qlclunq", "walk list of qlc ql_lun_t strctures",
34267836SJohn.Forte@Sun.COM 	    qllunq_walk_init, qllunq_walk_step, qllunq_walk_fini },
34277836SJohn.Forte@Sun.COM 	{ NULL }
34287836SJohn.Forte@Sun.COM };
34297836SJohn.Forte@Sun.COM 
34307836SJohn.Forte@Sun.COM static const mdb_modinfo_t ql_mdb_modinfo = {
34317836SJohn.Forte@Sun.COM 	MDB_API_VERSION, dcmds, walkers
34327836SJohn.Forte@Sun.COM };
34337836SJohn.Forte@Sun.COM 
34347836SJohn.Forte@Sun.COM /*
34357836SJohn.Forte@Sun.COM  * Registration function which lists the dcmds and walker structures
34367836SJohn.Forte@Sun.COM  */
34377836SJohn.Forte@Sun.COM const mdb_modinfo_t *
_mdb_init(void)34387836SJohn.Forte@Sun.COM _mdb_init(void)
34397836SJohn.Forte@Sun.COM {
34407836SJohn.Forte@Sun.COM 	return (&ql_mdb_modinfo);
34417836SJohn.Forte@Sun.COM }
3442