xref: /onnv-gate/usr/src/cmd/mdb/common/modules/qlc/qlc.c (revision 10736:d831c82c5d2c)
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 
229156SDaniel.Beauregard@Sun.COM /* Copyright 2009 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					**
309156SDaniel.Beauregard@Sun.COM  * *		COPYRIGHT (C) 1996-2009 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 
379156SDaniel.Beauregard@Sun.COM #pragma ident	"Copyright 2009 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 *);
75*10736SDaniel.Beauregard@Sun.COM static int ql_81xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
76*10736SDaniel.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",
1337836SJohn.Forte@Sun.COM 	NULL
1347836SJohn.Forte@Sun.COM };
1357836SJohn.Forte@Sun.COM 
1367836SJohn.Forte@Sun.COM /*
1377836SJohn.Forte@Sun.COM  * local task daemon flags strings
1387836SJohn.Forte@Sun.COM  */
1397836SJohn.Forte@Sun.COM int8_t *task_daemon_flags[] = {
1407836SJohn.Forte@Sun.COM 	"TASK_DAEMON_STOP_FLG",
1417836SJohn.Forte@Sun.COM 	"TASK_DAEMON_SLEEPING_FLG",
1427836SJohn.Forte@Sun.COM 	"TASK_DAEMON_ALIVE_FLG",
1437836SJohn.Forte@Sun.COM 	"TASK_DAEMON_IDLE_CHK_FLG",
1447836SJohn.Forte@Sun.COM 	"SUSPENDED_WAKEUP_FLG",
1457836SJohn.Forte@Sun.COM 	"FC_STATE_CHANGE",
1467836SJohn.Forte@Sun.COM 	"NEED_UNSOLICITED_BUFFERS",
1477836SJohn.Forte@Sun.COM 	"RESET_MARKER_NEEDED",
1487836SJohn.Forte@Sun.COM 	"RESET_ACTIVE",
1497836SJohn.Forte@Sun.COM 	"ISP_ABORT_NEEDED",
1507836SJohn.Forte@Sun.COM 	"ABORT_ISP_ACTIVE",
1517836SJohn.Forte@Sun.COM 	"LOOP_RESYNC_NEEDED",
1527836SJohn.Forte@Sun.COM 	"LOOP_RESYNC_ACTIVE",
1537836SJohn.Forte@Sun.COM 	"LOOP_DOWN",
1547836SJohn.Forte@Sun.COM 	"DRIVER_STALL",
1557836SJohn.Forte@Sun.COM 	"COMMAND_WAIT_NEEDED",
1567836SJohn.Forte@Sun.COM 	"COMMAND_WAIT_ACTIVE",
1577836SJohn.Forte@Sun.COM 	"STATE_ONLINE",
1587836SJohn.Forte@Sun.COM 	"ABORT_QUEUES_NEEDED",
1597836SJohn.Forte@Sun.COM 	"TASK_DAEMON_STALLED_FLG",
1607836SJohn.Forte@Sun.COM 	"TASK_THREAD_CALLED",
1617836SJohn.Forte@Sun.COM 	"FIRMWARE_UP",
1627836SJohn.Forte@Sun.COM 	"LIP_RESET_PENDING",
1637836SJohn.Forte@Sun.COM 	"FIRMWARE_LOADED",
1647836SJohn.Forte@Sun.COM 	"RSCN_UPDATE_NEEDED",
1657836SJohn.Forte@Sun.COM 	"HANDLE_PORT_BYPASS_CHANGE",
1667836SJohn.Forte@Sun.COM 	"PORT_RETRY_NEEDED",
1677836SJohn.Forte@Sun.COM 	"TASK_DAEMON_POWERING_DOWN",
1687836SJohn.Forte@Sun.COM 	"TD_IIDMA_NEEDED",
1699446SDaniel.Beauregard@Sun.COM 	"SEND_PLOGI",
1709446SDaniel.Beauregard@Sun.COM 	"IDC_ACK_NEEDED",
1717836SJohn.Forte@Sun.COM 	NULL
1727836SJohn.Forte@Sun.COM };
1737836SJohn.Forte@Sun.COM 
1747836SJohn.Forte@Sun.COM /*
1757836SJohn.Forte@Sun.COM  * local interrupt aif flags
1767836SJohn.Forte@Sun.COM  */
1777836SJohn.Forte@Sun.COM int8_t *aif_flags[] = {
1787836SJohn.Forte@Sun.COM 	"IFLG_INTR_LEGACY",
1799446SDaniel.Beauregard@Sun.COM 	"IFLG_INTR_FIXED",
1807836SJohn.Forte@Sun.COM 	"IFLG_INTR_MSI",
1819446SDaniel.Beauregard@Sun.COM 	"IFLG_INTR_MSIX",
1827836SJohn.Forte@Sun.COM 	NULL
1837836SJohn.Forte@Sun.COM };
1847836SJohn.Forte@Sun.COM 
1857836SJohn.Forte@Sun.COM int8_t *qlsrb_flags[] = {
1867836SJohn.Forte@Sun.COM 	"SRB_ISP_STARTED",
1877836SJohn.Forte@Sun.COM 	"SRB_ISP_COMPLETED",
1887836SJohn.Forte@Sun.COM 	"SRB_RETRY",
1897836SJohn.Forte@Sun.COM 	"SRB_POLL",
1907836SJohn.Forte@Sun.COM 	"SRB_WATCHDOG_ENABLED",
1917836SJohn.Forte@Sun.COM 	"SRB_ABORT",
1927836SJohn.Forte@Sun.COM 	"SRB_UB_IN_FCA",
1937836SJohn.Forte@Sun.COM 	"SRB_UB_IN_ISP",
1947836SJohn.Forte@Sun.COM 	"SRB_UB_CALLBACK",
1957836SJohn.Forte@Sun.COM 	"SRB_UB_RSCN",
1967836SJohn.Forte@Sun.COM 	"SRB_UB_FCP",
1977836SJohn.Forte@Sun.COM 	"SRB_FCP_CMD_PKT",
1987836SJohn.Forte@Sun.COM 	"SRB_FCP_DATA_PKT",
1997836SJohn.Forte@Sun.COM 	"SRB_FCP_RSP_PKT",
2007836SJohn.Forte@Sun.COM 	"SRB_IP_PKT",
2017836SJohn.Forte@Sun.COM 	"SRB_GENERIC_SERVICES_PKT",
2027836SJohn.Forte@Sun.COM 	"SRB_COMMAND_TIMEOUT",
2037836SJohn.Forte@Sun.COM 	"SRB_ABORTING",
2047836SJohn.Forte@Sun.COM 	"SRB_IN_DEVICE_QUEUE",
2057836SJohn.Forte@Sun.COM 	"SRB_IN_TOKEN_ARRAY",
2067836SJohn.Forte@Sun.COM 	"SRB_UB_FREE_REQUESTED",
2077836SJohn.Forte@Sun.COM 	"SRB_UB_ACQUIRED",
2087836SJohn.Forte@Sun.COM 	"SRB_MS_PKT",
2097836SJohn.Forte@Sun.COM 	NULL
2107836SJohn.Forte@Sun.COM };
2117836SJohn.Forte@Sun.COM 
2127836SJohn.Forte@Sun.COM int8_t *qllun_flags[] = {
2137836SJohn.Forte@Sun.COM 	"LQF_UNTAGGED_PENDING",
2147836SJohn.Forte@Sun.COM 	NULL
2157836SJohn.Forte@Sun.COM };
2167836SJohn.Forte@Sun.COM 
2177836SJohn.Forte@Sun.COM int8_t *qltgt_flags[] = {
2187836SJohn.Forte@Sun.COM 	"TQF_TAPE_DEVICE",
2197836SJohn.Forte@Sun.COM 	"TQF_QUEUE_SUSPENDED",
2207836SJohn.Forte@Sun.COM 	"TQF_FABRIC_DEVICE",
2217836SJohn.Forte@Sun.COM 	"TQF_INITIATOR_DEVICE",
2227836SJohn.Forte@Sun.COM 	"TQF_RSCN_RCVD",
2237836SJohn.Forte@Sun.COM 	"TQF_NEED_AUTHENTICATION",
2247836SJohn.Forte@Sun.COM 	"TQF_PLOGI_PROGRS",
2257836SJohn.Forte@Sun.COM 	"TQF_IIDMA_NEEDED",
2267836SJohn.Forte@Sun.COM 	NULL
2277836SJohn.Forte@Sun.COM };
2287836SJohn.Forte@Sun.COM 
2299156SDaniel.Beauregard@Sun.COM int8_t *qldump_flags[] = {
2309156SDaniel.Beauregard@Sun.COM 	"QL_DUMPING",
2319156SDaniel.Beauregard@Sun.COM 	"QL_DUMP_VALID",
2329156SDaniel.Beauregard@Sun.COM 	"QL_DUMP_UPLOADED",
2339156SDaniel.Beauregard@Sun.COM 	NULL
2349156SDaniel.Beauregard@Sun.COM };
2359156SDaniel.Beauregard@Sun.COM 
2367836SJohn.Forte@Sun.COM /*
2377836SJohn.Forte@Sun.COM  * qlclinks_dcmd
2387836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the ql_hba pointers
2397836SJohn.Forte@Sun.COM  *
2407836SJohn.Forte@Sun.COM  * Input:
2417836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
2427836SJohn.Forte@Sun.COM  *	flags = mdb flags.
2437836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
2447836SJohn.Forte@Sun.COM  *	argv  = Arg array.
2457836SJohn.Forte@Sun.COM  *
2467836SJohn.Forte@Sun.COM  * Returns:
2477836SJohn.Forte@Sun.COM  *	DCMD_ERR, DCMD_USAGE, or DCMD_OK
2487836SJohn.Forte@Sun.COM  *
2497836SJohn.Forte@Sun.COM  * Context:
2507836SJohn.Forte@Sun.COM  *	User context.
2517836SJohn.Forte@Sun.COM  *
2527836SJohn.Forte@Sun.COM  */
2537836SJohn.Forte@Sun.COM /*ARGSUSED*/
2547836SJohn.Forte@Sun.COM static int
2557836SJohn.Forte@Sun.COM qlclinks_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2567836SJohn.Forte@Sun.COM {
2577836SJohn.Forte@Sun.COM 	ql_head_t		ql_hba;
2587836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
2597836SJohn.Forte@Sun.COM 	uintptr_t		hbaptr = NULL;
2607836SJohn.Forte@Sun.COM 
2617836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
2627836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
2637836SJohn.Forte@Sun.COM 	}
2647836SJohn.Forte@Sun.COM 
2657836SJohn.Forte@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
2667836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure");
2677836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2687836SJohn.Forte@Sun.COM 	}
2697836SJohn.Forte@Sun.COM 
2707836SJohn.Forte@Sun.COM 	if (&ql_hba == NULL) {
2717836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
2727836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2737836SJohn.Forte@Sun.COM 	}
2747836SJohn.Forte@Sun.COM 
2757836SJohn.Forte@Sun.COM 	mdb_printf("\nqlc adapter state linkages (f=0x%llx, l=0x%llx)\n\n",
2767836SJohn.Forte@Sun.COM 	    ql_hba.first, ql_hba.last);
2777836SJohn.Forte@Sun.COM 
2787836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
2797836SJohn.Forte@Sun.COM 	    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
2807836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
2817836SJohn.Forte@Sun.COM 		return (DCMD_OK);
2827836SJohn.Forte@Sun.COM 	}
2837836SJohn.Forte@Sun.COM 
2847836SJohn.Forte@Sun.COM 	(void) mdb_inc_indent((ulong_t)4);
2857836SJohn.Forte@Sun.COM 	mdb_printf("%<u>%-?s\t%-45s%</u>\n\n", "baseaddr", "instance");
2867836SJohn.Forte@Sun.COM 
2877836SJohn.Forte@Sun.COM 	hbaptr = (uintptr_t)ql_hba.first;
2887836SJohn.Forte@Sun.COM 	while (hbaptr != NULL) {
2897836SJohn.Forte@Sun.COM 
2907836SJohn.Forte@Sun.COM 		if (mdb_vread(qlstate, sizeof (ql_adapter_state_t),
2917836SJohn.Forte@Sun.COM 		    hbaptr) == -1) {
2927836SJohn.Forte@Sun.COM 			mdb_free(qlstate, sizeof (ql_adapter_state_t));
2937836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_adapter_state at %p",
2947836SJohn.Forte@Sun.COM 			    hbaptr);
2957836SJohn.Forte@Sun.COM 			return (DCMD_OK);
2967836SJohn.Forte@Sun.COM 		}
2977836SJohn.Forte@Sun.COM 
2987836SJohn.Forte@Sun.COM 		mdb_printf("%<b>0x%016p%t%d%</b>\n",
2997836SJohn.Forte@Sun.COM 		    qlstate->hba.base_address, qlstate->instance);
3007836SJohn.Forte@Sun.COM 
3017836SJohn.Forte@Sun.COM 		/*
3027836SJohn.Forte@Sun.COM 		 * If vp exists, loop through those
3037836SJohn.Forte@Sun.COM 		 */
3047836SJohn.Forte@Sun.COM 
3057836SJohn.Forte@Sun.COM 		if ((qlstate->flags & VP_ENABLED) &&
3067836SJohn.Forte@Sun.COM 		    (qlstate->vp_next != NULL)) {
3077836SJohn.Forte@Sun.COM 
3087836SJohn.Forte@Sun.COM 			ql_adapter_state_t	*vqlstate;
3097836SJohn.Forte@Sun.COM 			uintptr_t		vhbaptr = NULL;
3107836SJohn.Forte@Sun.COM 
3117836SJohn.Forte@Sun.COM 			vhbaptr = (uintptr_t)qlstate->vp_next;
3127836SJohn.Forte@Sun.COM 
3137836SJohn.Forte@Sun.COM 			if ((vqlstate = (ql_adapter_state_t *)mdb_alloc(
3147836SJohn.Forte@Sun.COM 			    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
3157836SJohn.Forte@Sun.COM 				mdb_warn("Unable to allocate memory for "
3167836SJohn.Forte@Sun.COM 				    "ql_adapter_state vp\n");
3177836SJohn.Forte@Sun.COM 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
3187836SJohn.Forte@Sun.COM 				return (DCMD_OK);
3197836SJohn.Forte@Sun.COM 			}
3207836SJohn.Forte@Sun.COM 
3217836SJohn.Forte@Sun.COM 			(void) mdb_inc_indent((ulong_t)30);
3227836SJohn.Forte@Sun.COM 
3237836SJohn.Forte@Sun.COM 			mdb_printf("%<u>vp baseaddr\t\tvp index%</u>\n");
3247836SJohn.Forte@Sun.COM 
3257836SJohn.Forte@Sun.COM 			while (vhbaptr != NULL) {
3267836SJohn.Forte@Sun.COM 
3277836SJohn.Forte@Sun.COM 				if (mdb_vread(vqlstate,
3289156SDaniel.Beauregard@Sun.COM 				    sizeof (ql_adapter_state_t), vhbaptr) ==
3299156SDaniel.Beauregard@Sun.COM 				    -1) {
3307836SJohn.Forte@Sun.COM 					mdb_free(vqlstate,
3317836SJohn.Forte@Sun.COM 					    sizeof (ql_adapter_state_t));
3327836SJohn.Forte@Sun.COM 					mdb_free(qlstate,
3337836SJohn.Forte@Sun.COM 					    sizeof (ql_adapter_state_t));
3347836SJohn.Forte@Sun.COM 					mdb_warn("failed to read vp "
3357836SJohn.Forte@Sun.COM 					    "ql_adapter_state at %p", vhbaptr);
3367836SJohn.Forte@Sun.COM 					return (DCMD_OK);
3377836SJohn.Forte@Sun.COM 				}
3387836SJohn.Forte@Sun.COM 
3397836SJohn.Forte@Sun.COM 				mdb_printf("%<b>0x%016p%t%d%</b>\n",
3407836SJohn.Forte@Sun.COM 				    vqlstate->hba.base_address,
3417836SJohn.Forte@Sun.COM 				    vqlstate->vp_index);
3427836SJohn.Forte@Sun.COM 
3437836SJohn.Forte@Sun.COM 				vhbaptr = (uintptr_t)vqlstate->vp_next;
3447836SJohn.Forte@Sun.COM 			}
3457836SJohn.Forte@Sun.COM 
3467836SJohn.Forte@Sun.COM 			mdb_free(vqlstate, sizeof (ql_adapter_state_t));
3477836SJohn.Forte@Sun.COM 
3487836SJohn.Forte@Sun.COM 			(void) mdb_dec_indent((ulong_t)30);
3497836SJohn.Forte@Sun.COM 
3507836SJohn.Forte@Sun.COM 			mdb_printf("\n");
3517836SJohn.Forte@Sun.COM 		}
3527836SJohn.Forte@Sun.COM 
3537836SJohn.Forte@Sun.COM 		hbaptr = (uintptr_t)qlstate->hba.next;
3547836SJohn.Forte@Sun.COM 	}
3557836SJohn.Forte@Sun.COM 
3567836SJohn.Forte@Sun.COM 	(void) mdb_dec_indent((ulong_t)4);
3577836SJohn.Forte@Sun.COM 
3587836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
3597836SJohn.Forte@Sun.COM 
3607836SJohn.Forte@Sun.COM 	return (DCMD_OK);
3617836SJohn.Forte@Sun.COM }
3627836SJohn.Forte@Sun.COM 
3637836SJohn.Forte@Sun.COM /*
3647836SJohn.Forte@Sun.COM  * qlcver_dcmd
3657836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the qlc driver version the mdb
3667836SJohn.Forte@Sun.COM  *	module was compiled with, and the verison of qlc which is
3677836SJohn.Forte@Sun.COM  *	currently loaded on the machine.
3687836SJohn.Forte@Sun.COM  *
3697836SJohn.Forte@Sun.COM  * Input:
3707836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
3717836SJohn.Forte@Sun.COM  *	flags = mdb flags.
3727836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
3737836SJohn.Forte@Sun.COM  *	argv  = Arg array.
3747836SJohn.Forte@Sun.COM  *
3757836SJohn.Forte@Sun.COM  * Returns:
3767836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
3777836SJohn.Forte@Sun.COM  *
3787836SJohn.Forte@Sun.COM  * Context:
3797836SJohn.Forte@Sun.COM  *	User context.
3807836SJohn.Forte@Sun.COM  *
3817836SJohn.Forte@Sun.COM  */
3827836SJohn.Forte@Sun.COM /*ARGSUSED*/
3837836SJohn.Forte@Sun.COM static int
3847836SJohn.Forte@Sun.COM qlcver_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3857836SJohn.Forte@Sun.COM {
3869156SDaniel.Beauregard@Sun.COM 	int8_t		qlcversion[100];
3879156SDaniel.Beauregard@Sun.COM 	struct fw_table	fw_table[10], *fwt = NULL;
3889156SDaniel.Beauregard@Sun.COM 	uint8_t		*fwverptr = NULL;
3899156SDaniel.Beauregard@Sun.COM 	ql_head_t	ql_hba;
3909156SDaniel.Beauregard@Sun.COM 	uint32_t	found = 0;
3917836SJohn.Forte@Sun.COM 
3927836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
3937836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
3947836SJohn.Forte@Sun.COM 	}
3957836SJohn.Forte@Sun.COM 
3967836SJohn.Forte@Sun.COM 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
3977836SJohn.Forte@Sun.COM 		mdb_warn("unable to read qlc driver version\n");
3987836SJohn.Forte@Sun.COM 	} else {
3999156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n%s version currently loaded is: %s\n",
4007836SJohn.Forte@Sun.COM 		    QL_NAME, qlcversion);
4017836SJohn.Forte@Sun.COM 	}
4027836SJohn.Forte@Sun.COM 
4039156SDaniel.Beauregard@Sun.COM 	mdb_printf("qlc mdb library compiled with %s version: %s\n",
4049156SDaniel.Beauregard@Sun.COM 	    QL_NAME, QL_VERSION);
4059156SDaniel.Beauregard@Sun.COM 
4069156SDaniel.Beauregard@Sun.COM 	if ((fwverptr = (uint8_t *)(mdb_alloc(50, UM_SLEEP))) == NULL) {
4079156SDaniel.Beauregard@Sun.COM 		mdb_warn("unable to alloc fwverptr\n");
4089156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
4099156SDaniel.Beauregard@Sun.COM 	}
4109156SDaniel.Beauregard@Sun.COM 
4119156SDaniel.Beauregard@Sun.COM 	if (mdb_readvar(&fw_table, "fw_table") == -1) {
4129156SDaniel.Beauregard@Sun.COM 		mdb_warn("unable to read firmware table\n");
4139156SDaniel.Beauregard@Sun.COM 	} else {
4149156SDaniel.Beauregard@Sun.COM 		ql_adapter_state_t	*qlstate;
4159156SDaniel.Beauregard@Sun.COM 		uintptr_t		hbaptr = NULL;
4169156SDaniel.Beauregard@Sun.COM 
4179156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
4189156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
4199156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
4209156SDaniel.Beauregard@Sun.COM 		}
4219156SDaniel.Beauregard@Sun.COM 
4229156SDaniel.Beauregard@Sun.COM 		if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
4239156SDaniel.Beauregard@Sun.COM 		    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
4249156SDaniel.Beauregard@Sun.COM 			mdb_warn("Unable to allocate memory for "
4259156SDaniel.Beauregard@Sun.COM 			    "ql_adapter_state\n");
4269156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
4279156SDaniel.Beauregard@Sun.COM 		}
4289156SDaniel.Beauregard@Sun.COM 
4299156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n%-8s%-11s%s\n", "f/w", "compiled", "loaded");
4309156SDaniel.Beauregard@Sun.COM 		mdb_printf("%<u>%-8s%-11s%-13s%s%</u>\n\n", "class", "version",
4319156SDaniel.Beauregard@Sun.COM 		    "version", "instance list");
4329156SDaniel.Beauregard@Sun.COM 
4339156SDaniel.Beauregard@Sun.COM 		for (fwt = &fw_table[0]; fwt->fw_class; fwt++) {
4349156SDaniel.Beauregard@Sun.COM 
4359156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(fwverptr, sizeof (void *),
4369156SDaniel.Beauregard@Sun.COM 			    (uintptr_t)fwt->fw_version) == -1) {
4379156SDaniel.Beauregard@Sun.COM 				mdb_warn("unable to read fwverptr\n");
4389156SDaniel.Beauregard@Sun.COM 				mdb_free(fwverptr, sizeof (void *));
4399156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
4409156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
4419156SDaniel.Beauregard@Sun.COM 			}
4429156SDaniel.Beauregard@Sun.COM 
4439156SDaniel.Beauregard@Sun.COM 			mdb_printf("%x\t%-11s", fwt->fw_class, fwverptr);
4449156SDaniel.Beauregard@Sun.COM 
4459156SDaniel.Beauregard@Sun.COM 			if (&ql_hba == NULL) {
4469156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read ql_hba structure");
4479156SDaniel.Beauregard@Sun.COM 				hbaptr = NULL;
4489156SDaniel.Beauregard@Sun.COM 			} else {
4499156SDaniel.Beauregard@Sun.COM 				hbaptr = (uintptr_t)ql_hba.first;
4509156SDaniel.Beauregard@Sun.COM 			}
4519156SDaniel.Beauregard@Sun.COM 
4529156SDaniel.Beauregard@Sun.COM 			found = 0;
4539156SDaniel.Beauregard@Sun.COM 			while (hbaptr != NULL) {
4549156SDaniel.Beauregard@Sun.COM 
4559156SDaniel.Beauregard@Sun.COM 				if (mdb_vread(qlstate,
4569156SDaniel.Beauregard@Sun.COM 				    sizeof (ql_adapter_state_t), hbaptr) ==
4579156SDaniel.Beauregard@Sun.COM 				    -1) {
4589156SDaniel.Beauregard@Sun.COM 					mdb_warn("failed to read "
4599156SDaniel.Beauregard@Sun.COM 					    "ql_adapter_state at %p", hbaptr);
4609156SDaniel.Beauregard@Sun.COM 					break;
4619156SDaniel.Beauregard@Sun.COM 				}
4629156SDaniel.Beauregard@Sun.COM 
4639156SDaniel.Beauregard@Sun.COM 				if (qlstate->fw_class == fwt->fw_class) {
4649156SDaniel.Beauregard@Sun.COM 					if (found == 0) {
4659156SDaniel.Beauregard@Sun.COM 						mdb_printf("%x.%02x.%02x\t",
4669156SDaniel.Beauregard@Sun.COM 						    qlstate->fw_major_version,
4679156SDaniel.Beauregard@Sun.COM 						    qlstate->fw_minor_version,
4689156SDaniel.Beauregard@Sun.COM 						    qlstate->
4699156SDaniel.Beauregard@Sun.COM 						    fw_subminor_version);
4709156SDaniel.Beauregard@Sun.COM 						mdb_printf("%d",
4719156SDaniel.Beauregard@Sun.COM 						    qlstate->instance);
4729156SDaniel.Beauregard@Sun.COM 					} else {
4739156SDaniel.Beauregard@Sun.COM 						mdb_printf(", %d",
4749156SDaniel.Beauregard@Sun.COM 						    qlstate->instance);
4759156SDaniel.Beauregard@Sun.COM 					}
4769156SDaniel.Beauregard@Sun.COM 					found = 1;
4779156SDaniel.Beauregard@Sun.COM 				}
4789156SDaniel.Beauregard@Sun.COM 
4799156SDaniel.Beauregard@Sun.COM 				hbaptr = (uintptr_t)qlstate->hba.next;
4809156SDaniel.Beauregard@Sun.COM 			}
4819156SDaniel.Beauregard@Sun.COM 
4829156SDaniel.Beauregard@Sun.COM 			if (found == 1) {
4839156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n");
4849156SDaniel.Beauregard@Sun.COM 			} else {
4859156SDaniel.Beauregard@Sun.COM 				mdb_printf("not loaded\n");
4869156SDaniel.Beauregard@Sun.COM 			}
4879156SDaniel.Beauregard@Sun.COM 		}
4889156SDaniel.Beauregard@Sun.COM 
4899156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
4909156SDaniel.Beauregard@Sun.COM 		mdb_free(fwverptr, sizeof (void *));
4919156SDaniel.Beauregard@Sun.COM 	}
4929156SDaniel.Beauregard@Sun.COM 
4937836SJohn.Forte@Sun.COM 	return (DCMD_OK);
4947836SJohn.Forte@Sun.COM }
4957836SJohn.Forte@Sun.COM 
4967836SJohn.Forte@Sun.COM /*
4977836SJohn.Forte@Sun.COM  * qlc_el_dcmd
4987836SJohn.Forte@Sun.COM  *	mdb dcmd which turns the extended logging bit on or off
4997836SJohn.Forte@Sun.COM  *	for the specificed qlc instance(s).
5007836SJohn.Forte@Sun.COM  *
5017836SJohn.Forte@Sun.COM  * Input:
5027836SJohn.Forte@Sun.COM  *	addr  = User supplied address -- error if supplied.
5037836SJohn.Forte@Sun.COM  *	flags = mdb flags.
5047836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args -- error if non-zero.
5057836SJohn.Forte@Sun.COM  *	argv  = Arg array.
5067836SJohn.Forte@Sun.COM  *
5077836SJohn.Forte@Sun.COM  * Returns:
5087836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
5097836SJohn.Forte@Sun.COM  *
5107836SJohn.Forte@Sun.COM  * Context:
5117836SJohn.Forte@Sun.COM  *	User context.
5127836SJohn.Forte@Sun.COM  *
5137836SJohn.Forte@Sun.COM  */
5147836SJohn.Forte@Sun.COM /*ARGSUSED*/
5157836SJohn.Forte@Sun.COM static int
5167836SJohn.Forte@Sun.COM qlc_el_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5177836SJohn.Forte@Sun.COM {
5187836SJohn.Forte@Sun.COM 	int8_t			qlcversion[100];
5197836SJohn.Forte@Sun.COM 	boolean_t		elswitch;
5207836SJohn.Forte@Sun.COM 	uint32_t		argcnt;
5217836SJohn.Forte@Sun.COM 	int			mdbs;
5227836SJohn.Forte@Sun.COM 	uint32_t		instance;
5237836SJohn.Forte@Sun.COM 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
5247836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
5257836SJohn.Forte@Sun.COM 	uintptr_t		hbaptr = NULL;
5267836SJohn.Forte@Sun.COM 	ql_head_t		ql_hba;
5277836SJohn.Forte@Sun.COM 
5287836SJohn.Forte@Sun.COM 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
5297836SJohn.Forte@Sun.COM 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
5307836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5317836SJohn.Forte@Sun.COM 	}
5327836SJohn.Forte@Sun.COM 
5337836SJohn.Forte@Sun.COM 	if ((flags & DCMD_ADDRSPEC) || argc < 2) {
5347836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
5357836SJohn.Forte@Sun.COM 	}
5367836SJohn.Forte@Sun.COM 
5377836SJohn.Forte@Sun.COM 	/*
5387836SJohn.Forte@Sun.COM 	 * Check and make sure the driver version and the mdb versions
5397836SJohn.Forte@Sun.COM 	 * match so all the structures and flags line up
5407836SJohn.Forte@Sun.COM 	 */
5417836SJohn.Forte@Sun.COM 
5427836SJohn.Forte@Sun.COM 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
5437836SJohn.Forte@Sun.COM 		mdb_warn("unable to read qlc driver version\n");
5447836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5457836SJohn.Forte@Sun.COM 	}
5467836SJohn.Forte@Sun.COM 
5477836SJohn.Forte@Sun.COM 	if ((strcmp(QL_VERSION, (const char *)&qlcversion)) != 0) {
5487836SJohn.Forte@Sun.COM 		mdb_warn("Error: qlc driver/qlc mdb version mismatch\n");
5497836SJohn.Forte@Sun.COM 		mdb_printf("\tqlc mdb library compiled version is: %s\n",
5507836SJohn.Forte@Sun.COM 		    QL_VERSION);
5517836SJohn.Forte@Sun.COM 		mdb_printf("\tqlc driver version is: %s\n", qlcversion);
5527836SJohn.Forte@Sun.COM 
5537836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5547836SJohn.Forte@Sun.COM 	}
5557836SJohn.Forte@Sun.COM 
5567836SJohn.Forte@Sun.COM 	if ((strcasecmp(argv[0].a_un.a_str, "on")) == 0) {
5577836SJohn.Forte@Sun.COM 		elswitch = TRUE;
5587836SJohn.Forte@Sun.COM 	} else if ((strcasecmp(argv[0].a_un.a_str, "off")) == 0) {
5597836SJohn.Forte@Sun.COM 		elswitch = FALSE;
5607836SJohn.Forte@Sun.COM 	} else {
5617836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
5627836SJohn.Forte@Sun.COM 	}
5637836SJohn.Forte@Sun.COM 
5647836SJohn.Forte@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
5657836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure");
5667836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
5677836SJohn.Forte@Sun.COM 	}
5687836SJohn.Forte@Sun.COM 
5697836SJohn.Forte@Sun.COM 	if (&ql_hba == NULL) {
5707836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_hba structure - is qlc loaded?");
5717836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
5727836SJohn.Forte@Sun.COM 	}
5737836SJohn.Forte@Sun.COM 
5747836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
5757836SJohn.Forte@Sun.COM 	    UM_SLEEP)) == NULL) {
5767836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for "
5777836SJohn.Forte@Sun.COM 		    "ql_adapter_state\n");
5787836SJohn.Forte@Sun.COM 		return (DCMD_OK);
5797836SJohn.Forte@Sun.COM 	}
5807836SJohn.Forte@Sun.COM 
5817836SJohn.Forte@Sun.COM 	if ((strcasecmp(argv[1].a_un.a_str, "all")) == 0) {
5827836SJohn.Forte@Sun.COM 
5837836SJohn.Forte@Sun.COM 		if (argc != 2) {
5847836SJohn.Forte@Sun.COM 			mdb_free(qlstate, qlsize);
5857836SJohn.Forte@Sun.COM 			return (DCMD_USAGE);
5867836SJohn.Forte@Sun.COM 		}
5877836SJohn.Forte@Sun.COM 
5887836SJohn.Forte@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
5897836SJohn.Forte@Sun.COM 
5907836SJohn.Forte@Sun.COM 		while (hbaptr != NULL) {
5917836SJohn.Forte@Sun.COM 
5927836SJohn.Forte@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
5937836SJohn.Forte@Sun.COM 				mdb_free(qlstate, qlsize);
5947836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_adapter_state "
5957836SJohn.Forte@Sun.COM 				    "at %p", hbaptr);
5967836SJohn.Forte@Sun.COM 				return (DCMD_OK);
5977836SJohn.Forte@Sun.COM 			}
5987836SJohn.Forte@Sun.COM 
5997836SJohn.Forte@Sun.COM 			ql_elog_common(qlstate, elswitch);
6007836SJohn.Forte@Sun.COM 
6017836SJohn.Forte@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
6027836SJohn.Forte@Sun.COM 		}
6037836SJohn.Forte@Sun.COM 	} else {
6047836SJohn.Forte@Sun.COM 		for (argcnt = 1; argcnt < argc; argcnt++) {
6057836SJohn.Forte@Sun.COM 
6067836SJohn.Forte@Sun.COM 			instance = (uint32_t)mdb_strtoull(
6077836SJohn.Forte@Sun.COM 			    argv[argcnt].a_un.a_str);
6087836SJohn.Forte@Sun.COM 
6097836SJohn.Forte@Sun.COM 			/* find the correct instance to change */
6107836SJohn.Forte@Sun.COM 			hbaptr = (uintptr_t)ql_hba.first;
6117836SJohn.Forte@Sun.COM 			while (hbaptr != NULL) {
6127836SJohn.Forte@Sun.COM 
6137836SJohn.Forte@Sun.COM 				if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
6147836SJohn.Forte@Sun.COM 					mdb_free(qlstate, qlsize);
6159156SDaniel.Beauregard@Sun.COM 					mdb_warn("failed to read "
6169156SDaniel.Beauregard@Sun.COM 					    "ql_adapter_state at %p", hbaptr);
6177836SJohn.Forte@Sun.COM 					return (DCMD_OK);
6187836SJohn.Forte@Sun.COM 				}
6197836SJohn.Forte@Sun.COM 
6207836SJohn.Forte@Sun.COM 				if (qlstate->instance == instance) {
6217836SJohn.Forte@Sun.COM 					break;
6227836SJohn.Forte@Sun.COM 				}
6237836SJohn.Forte@Sun.COM 
6247836SJohn.Forte@Sun.COM 				hbaptr = (uintptr_t)qlstate->hba.next;
6257836SJohn.Forte@Sun.COM 			}
6267836SJohn.Forte@Sun.COM 
6277836SJohn.Forte@Sun.COM 			if (hbaptr == NULL) {
6287836SJohn.Forte@Sun.COM 				mdb_printf("instance %d is not loaded",
6297836SJohn.Forte@Sun.COM 				    instance);
6307836SJohn.Forte@Sun.COM 				continue;
6317836SJohn.Forte@Sun.COM 			}
6327836SJohn.Forte@Sun.COM 
6337836SJohn.Forte@Sun.COM 			ql_elog_common(qlstate, elswitch);
6347836SJohn.Forte@Sun.COM 		}
6357836SJohn.Forte@Sun.COM 	}
6367836SJohn.Forte@Sun.COM 
6377836SJohn.Forte@Sun.COM 	mdb_free(qlstate, qlsize);
6387836SJohn.Forte@Sun.COM 
6397836SJohn.Forte@Sun.COM 	return (DCMD_OK);
6407836SJohn.Forte@Sun.COM }
6417836SJohn.Forte@Sun.COM 
6427836SJohn.Forte@Sun.COM /*
6437836SJohn.Forte@Sun.COM  * qlc_elog_common
6447836SJohn.Forte@Sun.COM  *	mdb helper function which set/resets the extended logging bit
6457836SJohn.Forte@Sun.COM  *
6467836SJohn.Forte@Sun.COM  * Input:
6477836SJohn.Forte@Sun.COM  *	qlstate  = adapter state structure
6487836SJohn.Forte@Sun.COM  *	elswitch = boolean which specifies to reset (0) or set (1) the
6497836SJohn.Forte@Sun.COM  *		   extended logging bit.
6507836SJohn.Forte@Sun.COM  *
6517836SJohn.Forte@Sun.COM  * Returns:
6527836SJohn.Forte@Sun.COM  *
6537836SJohn.Forte@Sun.COM  * Context:
6547836SJohn.Forte@Sun.COM  *	User context.
6557836SJohn.Forte@Sun.COM  *
6567836SJohn.Forte@Sun.COM  */
6577836SJohn.Forte@Sun.COM static void
6587836SJohn.Forte@Sun.COM ql_elog_common(ql_adapter_state_t *qlstate, boolean_t elswitch)
6597836SJohn.Forte@Sun.COM {
6607836SJohn.Forte@Sun.COM 	uintptr_t	hbaptr = (uintptr_t)qlstate->hba.base_address;
6617836SJohn.Forte@Sun.COM 	size_t		qlsize = sizeof (ql_adapter_state_t);
6627836SJohn.Forte@Sun.COM 
6637836SJohn.Forte@Sun.COM 	if (elswitch) {
6647836SJohn.Forte@Sun.COM 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) == 0) {
6657836SJohn.Forte@Sun.COM 
6667836SJohn.Forte@Sun.COM 			qlstate->cfg_flags |= CFG_ENABLE_EXTENDED_LOGGING;
6677836SJohn.Forte@Sun.COM 
6687836SJohn.Forte@Sun.COM 			if ((mdb_vwrite((const void *)qlstate, qlsize,
6697836SJohn.Forte@Sun.COM 			    hbaptr)) != (ssize_t)qlsize) {
6707836SJohn.Forte@Sun.COM 				mdb_warn("instance %d - unable to update",
6717836SJohn.Forte@Sun.COM 				    qlstate->instance);
6727836SJohn.Forte@Sun.COM 			} else {
6737836SJohn.Forte@Sun.COM 				mdb_printf("instance %d extended logging is "
6747836SJohn.Forte@Sun.COM 				    "now on\n", qlstate->instance);
6757836SJohn.Forte@Sun.COM 			}
6767836SJohn.Forte@Sun.COM 		} else {
6777836SJohn.Forte@Sun.COM 			mdb_printf("instance %d extended logging is "
6787836SJohn.Forte@Sun.COM 			    "already on\n", qlstate->instance);
6797836SJohn.Forte@Sun.COM 		}
6807836SJohn.Forte@Sun.COM 	} else {
6817836SJohn.Forte@Sun.COM 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) != 0) {
6827836SJohn.Forte@Sun.COM 
6837836SJohn.Forte@Sun.COM 			qlstate->cfg_flags &= ~CFG_ENABLE_EXTENDED_LOGGING;
6847836SJohn.Forte@Sun.COM 
6857836SJohn.Forte@Sun.COM 			if ((mdb_vwrite((const void *)qlstate, qlsize,
6867836SJohn.Forte@Sun.COM 			    hbaptr)) != (ssize_t)qlsize) {
6877836SJohn.Forte@Sun.COM 				mdb_warn("instance %d - unable to update",
6887836SJohn.Forte@Sun.COM 				    qlstate->instance);
6897836SJohn.Forte@Sun.COM 			} else {
6907836SJohn.Forte@Sun.COM 				mdb_printf("instance %d extended logging is "
6917836SJohn.Forte@Sun.COM 				    "now off\n", qlstate->instance);
6927836SJohn.Forte@Sun.COM 			}
6937836SJohn.Forte@Sun.COM 		} else {
6947836SJohn.Forte@Sun.COM 			mdb_printf("instance %d extended logging is "
6957836SJohn.Forte@Sun.COM 			    "already off\n", qlstate->instance);
6967836SJohn.Forte@Sun.COM 		}
6977836SJohn.Forte@Sun.COM 	}
6987836SJohn.Forte@Sun.COM }
6997836SJohn.Forte@Sun.COM 
7007836SJohn.Forte@Sun.COM /*
7017836SJohn.Forte@Sun.COM  * qlc_ocs_dcmd
7027836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the outstanding command array using
7037836SJohn.Forte@Sun.COM  *	caller supplied address (which sb the ha structure).
7047836SJohn.Forte@Sun.COM  *
7057836SJohn.Forte@Sun.COM  * Input:
7067836SJohn.Forte@Sun.COM  *	addr  = User supplied ha address.
7077836SJohn.Forte@Sun.COM  *	flags = mdb flags.
7087836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
7097836SJohn.Forte@Sun.COM  *	argv  = Arg array.
7107836SJohn.Forte@Sun.COM  *
7117836SJohn.Forte@Sun.COM  * Returns:
7127836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
7137836SJohn.Forte@Sun.COM  *
7147836SJohn.Forte@Sun.COM  * Context:
7157836SJohn.Forte@Sun.COM  *	User context.
7167836SJohn.Forte@Sun.COM  *
7177836SJohn.Forte@Sun.COM  *
7187836SJohn.Forte@Sun.COM  */
7197836SJohn.Forte@Sun.COM static int
7207836SJohn.Forte@Sun.COM /*ARGSUSED*/
7217836SJohn.Forte@Sun.COM qlc_osc_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
7227836SJohn.Forte@Sun.COM {
7237836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
7247836SJohn.Forte@Sun.COM 	uintptr_t		qlosc, ptr1;
7257836SJohn.Forte@Sun.COM 	uint32_t		indx, found = 0;
7267836SJohn.Forte@Sun.COM 	ql_srb_t		*qlsrb;
7277836SJohn.Forte@Sun.COM 
7287836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
7297836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
7307836SJohn.Forte@Sun.COM 	}
7317836SJohn.Forte@Sun.COM 
7327836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
7337836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
7347836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
7357836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7367836SJohn.Forte@Sun.COM 	}
7377836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
7387836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
7397836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
7407836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7417836SJohn.Forte@Sun.COM 	}
7427836SJohn.Forte@Sun.COM 
7437836SJohn.Forte@Sun.COM 	qlosc = (uintptr_t)qlstate->outstanding_cmds;
7447836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx, osc base = %p\n",
7457836SJohn.Forte@Sun.COM 	    qlstate->instance, qlstate->hba.base_address, qlosc);
7467836SJohn.Forte@Sun.COM 
7477836SJohn.Forte@Sun.COM 	if ((qlsrb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP)) ==
7487836SJohn.Forte@Sun.COM 	    NULL) {
7497836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
7507836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate space for srb_t\n");
7517836SJohn.Forte@Sun.COM 		return (DCMD_OK);
7527836SJohn.Forte@Sun.COM 	}
7537836SJohn.Forte@Sun.COM 	for (indx = 0; indx < MAX_OUTSTANDING_COMMANDS; indx++, qlosc += 8) {
7547836SJohn.Forte@Sun.COM 		if (mdb_vread(&ptr1, 8, qlosc) == -1) {
7557836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ptr1, indx=%d", indx);
7567836SJohn.Forte@Sun.COM 			break;
7577836SJohn.Forte@Sun.COM 		}
7587836SJohn.Forte@Sun.COM 		if (ptr1 == 0) {
7597836SJohn.Forte@Sun.COM 			continue;
7607836SJohn.Forte@Sun.COM 		}
7617836SJohn.Forte@Sun.COM 
7627836SJohn.Forte@Sun.COM 		mdb_printf("osc ptr = %p, indx = %xh\n", ptr1, indx);
7637836SJohn.Forte@Sun.COM 
7647836SJohn.Forte@Sun.COM 		if (mdb_vread(qlsrb, sizeof (ql_srb_t), ptr1) == -1) {
7657836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_srb_t at %p", ptr1);
7667836SJohn.Forte@Sun.COM 			break;
7677836SJohn.Forte@Sun.COM 		}
7687836SJohn.Forte@Sun.COM 		(void) ql_doprint(ptr1, "struct ql_srb");
7697836SJohn.Forte@Sun.COM 		found++;
7707836SJohn.Forte@Sun.COM 	}
7717836SJohn.Forte@Sun.COM 
7727836SJohn.Forte@Sun.COM 	mdb_free(qlsrb, sizeof (ql_srb_t));
7737836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
7747836SJohn.Forte@Sun.COM 
7757836SJohn.Forte@Sun.COM 	mdb_printf("number of outstanding command srb's is: %d\n", found);
7767836SJohn.Forte@Sun.COM 
7777836SJohn.Forte@Sun.COM 	return (DCMD_OK);
7787836SJohn.Forte@Sun.COM }
7797836SJohn.Forte@Sun.COM 
7807836SJohn.Forte@Sun.COM /*
7817836SJohn.Forte@Sun.COM  * qlc_wdog_dcmd
7827836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the commands which are linked
7837836SJohn.Forte@Sun.COM  *	on the watchdog linked list. Caller supplied address (which
7847836SJohn.Forte@Sun.COM  *	sb the ha structure).
7857836SJohn.Forte@Sun.COM  *
7867836SJohn.Forte@Sun.COM  * Input:
7877836SJohn.Forte@Sun.COM  *	addr  = User supplied ha address.
7887836SJohn.Forte@Sun.COM  *	flags = mdb flags.
7897836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
7907836SJohn.Forte@Sun.COM  *	argv  = Arg array.
7917836SJohn.Forte@Sun.COM  *
7927836SJohn.Forte@Sun.COM  * Returns:
7937836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
7947836SJohn.Forte@Sun.COM  *
7957836SJohn.Forte@Sun.COM  * Context:
7967836SJohn.Forte@Sun.COM  *	User context.
7977836SJohn.Forte@Sun.COM  *
7987836SJohn.Forte@Sun.COM  *
7997836SJohn.Forte@Sun.COM  */
8007836SJohn.Forte@Sun.COM static int
8017836SJohn.Forte@Sun.COM /*ARGSUSED*/
8027836SJohn.Forte@Sun.COM qlc_wdog_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
8037836SJohn.Forte@Sun.COM {
8047836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
8057836SJohn.Forte@Sun.COM 	uint16_t		index, count;
8067836SJohn.Forte@Sun.COM 	ql_head_t		*dev;
8077836SJohn.Forte@Sun.COM 	ql_srb_t		*srb;
8087836SJohn.Forte@Sun.COM 	ql_tgt_t		*tq;
8097836SJohn.Forte@Sun.COM 	ql_lun_t		*lq;
8107836SJohn.Forte@Sun.COM 	ql_link_t		*tqlink, *srblink, *lqlink;
8117836SJohn.Forte@Sun.COM 	int			nextlink;
8127836SJohn.Forte@Sun.COM 
8137836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
8147836SJohn.Forte@Sun.COM 		mdb_warn("Address required\n", addr);
8157836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
8167836SJohn.Forte@Sun.COM 	}
8177836SJohn.Forte@Sun.COM 
8187836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
8197836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
8207836SJohn.Forte@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
8217836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8227836SJohn.Forte@Sun.COM 	}
8237836SJohn.Forte@Sun.COM 
8247836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
8257836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
8267836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
8277836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8287836SJohn.Forte@Sun.COM 	}
8297836SJohn.Forte@Sun.COM 
8307836SJohn.Forte@Sun.COM 	/*
8317836SJohn.Forte@Sun.COM 	 * Read in the device array
8327836SJohn.Forte@Sun.COM 	 */
8337836SJohn.Forte@Sun.COM 	dev = (ql_head_t *)
8347836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
8357836SJohn.Forte@Sun.COM 
8367836SJohn.Forte@Sun.COM 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
8377836SJohn.Forte@Sun.COM 	    (uintptr_t)qlstate->dev) == -1) {
8387836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_head_t (dev) at %p", qlstate->dev);
8397836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
8407836SJohn.Forte@Sun.COM 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
8417836SJohn.Forte@Sun.COM 		return (DCMD_OK);
8427836SJohn.Forte@Sun.COM 	}
8437836SJohn.Forte@Sun.COM 
8447836SJohn.Forte@Sun.COM 	tqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8457836SJohn.Forte@Sun.COM 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
8467836SJohn.Forte@Sun.COM 	lqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8477836SJohn.Forte@Sun.COM 	lq = (ql_lun_t *)mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
8487836SJohn.Forte@Sun.COM 	srblink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
8497836SJohn.Forte@Sun.COM 	srb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
8507836SJohn.Forte@Sun.COM 
8517836SJohn.Forte@Sun.COM 	/*
8527836SJohn.Forte@Sun.COM 	 * Validate the devices watchdog queue
8537836SJohn.Forte@Sun.COM 	 */
8547836SJohn.Forte@Sun.COM 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
8557836SJohn.Forte@Sun.COM 
8567836SJohn.Forte@Sun.COM 		/* Skip empty ones */
8577836SJohn.Forte@Sun.COM 		if (dev[index].first == NULL) {
8587836SJohn.Forte@Sun.COM 			continue;
8597836SJohn.Forte@Sun.COM 		}
8607836SJohn.Forte@Sun.COM 
8617836SJohn.Forte@Sun.COM 		mdb_printf("dev array index = %x\n", index);
8627836SJohn.Forte@Sun.COM 
8637836SJohn.Forte@Sun.COM 		/* Loop through targets on device linked list */
8647836SJohn.Forte@Sun.COM 		/* get the first link */
8657836SJohn.Forte@Sun.COM 
8667836SJohn.Forte@Sun.COM 		nextlink = get_first_link(&dev[index], tqlink);
8677836SJohn.Forte@Sun.COM 
8687836SJohn.Forte@Sun.COM 		/*
8697836SJohn.Forte@Sun.COM 		 * traverse the targets linked list at this device array index.
8707836SJohn.Forte@Sun.COM 		 */
8717836SJohn.Forte@Sun.COM 		while (nextlink == DCMD_OK) {
8727836SJohn.Forte@Sun.COM 			/* Get the target */
8737836SJohn.Forte@Sun.COM 			if (mdb_vread(tq, sizeof (ql_tgt_t),
8747836SJohn.Forte@Sun.COM 			    (uintptr_t)(tqlink->base_address)) == -1) {
8757836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_tgt at %p",
8767836SJohn.Forte@Sun.COM 				    tqlink->base_address);
8777836SJohn.Forte@Sun.COM 				break;
8787836SJohn.Forte@Sun.COM 			}
8797836SJohn.Forte@Sun.COM 			mdb_printf("tgt q base = %llx, ",
8807836SJohn.Forte@Sun.COM 			    tqlink->base_address);
8817836SJohn.Forte@Sun.COM 
8827836SJohn.Forte@Sun.COM 			mdb_printf("flags: (%xh)", tq->flags);
8837836SJohn.Forte@Sun.COM 
8847836SJohn.Forte@Sun.COM 			if (tq->flags) {
8857836SJohn.Forte@Sun.COM 				ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
8867836SJohn.Forte@Sun.COM 			}
8877836SJohn.Forte@Sun.COM 
8887836SJohn.Forte@Sun.COM 			mdb_printf("tgt: %02x%02x%02x%02x%02x%02x%02x%02x ",
8897836SJohn.Forte@Sun.COM 			    tq->node_name[0], tq->node_name[1],
8907836SJohn.Forte@Sun.COM 			    tq->node_name[2], tq->node_name[3],
8917836SJohn.Forte@Sun.COM 			    tq->node_name[4], tq->node_name[5],
8927836SJohn.Forte@Sun.COM 			    tq->node_name[6], tq->node_name[7]);
8937836SJohn.Forte@Sun.COM 
8947836SJohn.Forte@Sun.COM 			/*
8957836SJohn.Forte@Sun.COM 			 * Loop through commands on this targets watchdog queue.
8967836SJohn.Forte@Sun.COM 			 */
8977836SJohn.Forte@Sun.COM 
8987836SJohn.Forte@Sun.COM 			/* Get the first link on the targets cmd wdg q. */
8997836SJohn.Forte@Sun.COM 			if (tq->wdg.first == NULL) {
9007836SJohn.Forte@Sun.COM 				mdb_printf(" watchdog list empty ");
9017836SJohn.Forte@Sun.COM 				break;
9027836SJohn.Forte@Sun.COM 			} else {
9037836SJohn.Forte@Sun.COM 				if (mdb_vread(srblink, sizeof (ql_link_t),
9047836SJohn.Forte@Sun.COM 				    (uintptr_t)tq->wdg.first) == -1) {
9057836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_link_t"
9067836SJohn.Forte@Sun.COM 					    " at %p", tq->wdg.first);
9077836SJohn.Forte@Sun.COM 					break;
9087836SJohn.Forte@Sun.COM 				}
9097836SJohn.Forte@Sun.COM 				/* There is aleast one. */
9107836SJohn.Forte@Sun.COM 				count = 1;
9117836SJohn.Forte@Sun.COM 				/*
9127836SJohn.Forte@Sun.COM 				 * Count the remaining items in the
9137836SJohn.Forte@Sun.COM 				 * cmd watchdog list.
9147836SJohn.Forte@Sun.COM 				 */
9157836SJohn.Forte@Sun.COM 				while (srblink->next != NULL) {
9167836SJohn.Forte@Sun.COM 					/* Read in the next ql_link_t header */
9177836SJohn.Forte@Sun.COM 					if (mdb_vread(srblink,
9187836SJohn.Forte@Sun.COM 					    sizeof (ql_link_t),
9197836SJohn.Forte@Sun.COM 					    (uintptr_t)srblink->next) == -1) {
9207836SJohn.Forte@Sun.COM 						mdb_warn("failed to read"
9217836SJohn.Forte@Sun.COM 						    " ql_link_t next at %p",
9227836SJohn.Forte@Sun.COM 						    srblink->next);
9237836SJohn.Forte@Sun.COM 						break;
9247836SJohn.Forte@Sun.COM 					}
9257836SJohn.Forte@Sun.COM 					count = (uint16_t)(count + 1);
9267836SJohn.Forte@Sun.COM 				}
9277836SJohn.Forte@Sun.COM 				mdb_printf(" watchdog list: %d entries\n",
9287836SJohn.Forte@Sun.COM 				    count);
9297836SJohn.Forte@Sun.COM 				/* get the first one again */
9307836SJohn.Forte@Sun.COM 				if (mdb_vread(srblink, sizeof (ql_link_t),
9317836SJohn.Forte@Sun.COM 				    (uintptr_t)tq->wdg.first) == -1) {
9327836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_link_t"
9337836SJohn.Forte@Sun.COM 					    " at %p", tq->wdg.first);
9347836SJohn.Forte@Sun.COM 					break;
9357836SJohn.Forte@Sun.COM 				}
9367836SJohn.Forte@Sun.COM 			}
9377836SJohn.Forte@Sun.COM 			/*
9387836SJohn.Forte@Sun.COM 			 * Traverse the targets cmd watchdog linked list
9397836SJohn.Forte@Sun.COM 			 * verifying srb's from the list are on a lun cmd list.
9407836SJohn.Forte@Sun.COM 			 */
9417836SJohn.Forte@Sun.COM 			while (nextlink == DCMD_OK) {
9427836SJohn.Forte@Sun.COM 				int	found = 0;
9437836SJohn.Forte@Sun.COM 				/* get the srb */
9447836SJohn.Forte@Sun.COM 				if (mdb_vread(srb, sizeof (ql_srb_t),
9457836SJohn.Forte@Sun.COM 				    (uintptr_t)srblink->base_address) == -1) {
9467836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_srb_t"
9477836SJohn.Forte@Sun.COM 					" at %p", srblink->base_address);
9487836SJohn.Forte@Sun.COM 					break;
9497836SJohn.Forte@Sun.COM 				}
9507836SJohn.Forte@Sun.COM 				mdb_printf("ql_srb %llx ",
9517836SJohn.Forte@Sun.COM 				    srblink->base_address);
9527836SJohn.Forte@Sun.COM 
9537836SJohn.Forte@Sun.COM 				/*
9547836SJohn.Forte@Sun.COM 				 * Get the lun q the srb is on
9557836SJohn.Forte@Sun.COM 				 */
9567836SJohn.Forte@Sun.COM 				if (mdb_vread(lq, sizeof (ql_lun_t),
9577836SJohn.Forte@Sun.COM 				    (uintptr_t)srb->lun_queue) == -1) {
9587836SJohn.Forte@Sun.COM 					mdb_warn("failed to read ql_srb_t"
9597836SJohn.Forte@Sun.COM 					    " at %p", srb->lun_queue);
9607836SJohn.Forte@Sun.COM 					break;
9617836SJohn.Forte@Sun.COM 				}
9627836SJohn.Forte@Sun.COM 				nextlink = get_first_link(&lq->cmd, lqlink);
9637836SJohn.Forte@Sun.COM 				/*
9647836SJohn.Forte@Sun.COM 				 * traverse the lun cmd linked list looking
9657836SJohn.Forte@Sun.COM 				 * for the srb from the targets watchdog list
9667836SJohn.Forte@Sun.COM 				 */
9677836SJohn.Forte@Sun.COM 				while (nextlink == DCMD_OK) {
9687836SJohn.Forte@Sun.COM 					if (srblink->base_address ==
9697836SJohn.Forte@Sun.COM 					    lqlink->base_address) {
9707836SJohn.Forte@Sun.COM 						mdb_printf("on lun %d cmd q\n",
9717836SJohn.Forte@Sun.COM 						    lq->lun_no);
9727836SJohn.Forte@Sun.COM 						found = 1;
9737836SJohn.Forte@Sun.COM 						break;
9747836SJohn.Forte@Sun.COM 					}
9757836SJohn.Forte@Sun.COM 					/* get next item on lun cmd list */
9767836SJohn.Forte@Sun.COM 					nextlink = get_next_link(lqlink);
9777836SJohn.Forte@Sun.COM 				}
9787836SJohn.Forte@Sun.COM 				if (!found) {
9797836SJohn.Forte@Sun.COM 					mdb_printf("not found on lun cmd q\n");
9807836SJohn.Forte@Sun.COM 				}
9817836SJohn.Forte@Sun.COM 				/* get next item in the watchdog list */
9827836SJohn.Forte@Sun.COM 				nextlink = get_next_link(srblink);
9837836SJohn.Forte@Sun.COM 			} /* End targets command watchdog list */
9847836SJohn.Forte@Sun.COM 			/* get next item in this target list */
9857836SJohn.Forte@Sun.COM 			nextlink = get_next_link(tqlink);
9867836SJohn.Forte@Sun.COM 		} /* End traverse the device targets linked list */
9877836SJohn.Forte@Sun.COM 		mdb_printf("\n");
9887836SJohn.Forte@Sun.COM 	} /* End device array */
9897836SJohn.Forte@Sun.COM 
9907836SJohn.Forte@Sun.COM 	mdb_free(tq, sizeof (ql_tgt_t));
9917836SJohn.Forte@Sun.COM 	mdb_free(lq, sizeof (ql_lun_t));
9927836SJohn.Forte@Sun.COM 	mdb_free(srb, sizeof (ql_srb_t));
9937836SJohn.Forte@Sun.COM 	mdb_free(tqlink, sizeof (ql_link_t));
9947836SJohn.Forte@Sun.COM 	mdb_free(srblink, sizeof (ql_link_t));
9957836SJohn.Forte@Sun.COM 	mdb_free(lqlink, sizeof (ql_link_t));
9967836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
9977836SJohn.Forte@Sun.COM 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
9987836SJohn.Forte@Sun.COM 
9997836SJohn.Forte@Sun.COM 	return (DCMD_OK);
10007836SJohn.Forte@Sun.COM }
10017836SJohn.Forte@Sun.COM 
10027836SJohn.Forte@Sun.COM /*
10037836SJohn.Forte@Sun.COM  * get_first_link
10047836SJohn.Forte@Sun.COM  *	Gets the first ql_link_t header on ql_head.
10057836SJohn.Forte@Sun.COM  *
10067836SJohn.Forte@Sun.COM  * Input:
10077836SJohn.Forte@Sun.COM  *	ql_head  = pointer to a ql_head_t structure.
10087836SJohn.Forte@Sun.COM  *	ql_link  = pointer to a ql_link_t structure.
10097836SJohn.Forte@Sun.COM  *
10107836SJohn.Forte@Sun.COM  * Returns:
10117836SJohn.Forte@Sun.COM  *	DCMD_ABORT, or DCMD_OK
10127836SJohn.Forte@Sun.COM  *
10137836SJohn.Forte@Sun.COM  * Context:
10147836SJohn.Forte@Sun.COM  *	User context.
10157836SJohn.Forte@Sun.COM  *
10167836SJohn.Forte@Sun.COM  */
10177836SJohn.Forte@Sun.COM static int
10187836SJohn.Forte@Sun.COM get_first_link(ql_head_t *qlhead, ql_link_t *qllink)
10197836SJohn.Forte@Sun.COM {
10207836SJohn.Forte@Sun.COM 	int	rval = DCMD_ABORT;
10217836SJohn.Forte@Sun.COM 
10227836SJohn.Forte@Sun.COM 	if (qlhead != NULL) {
10237836SJohn.Forte@Sun.COM 		if (qlhead->first != NULL) {
10247836SJohn.Forte@Sun.COM 			/* Read in the first ql_link_t header */
10257836SJohn.Forte@Sun.COM 			if (mdb_vread(qllink, sizeof (ql_link_t),
10267836SJohn.Forte@Sun.COM 			    (uintptr_t)(qlhead->first)) == -1) {
10277836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_link_t "
10287836SJohn.Forte@Sun.COM 				    "next at %p", qlhead->first);
10297836SJohn.Forte@Sun.COM 			} else {
10307836SJohn.Forte@Sun.COM 				rval = DCMD_OK;
10317836SJohn.Forte@Sun.COM 			}
10327836SJohn.Forte@Sun.COM 		}
10337836SJohn.Forte@Sun.COM 	}
10347836SJohn.Forte@Sun.COM 	return (rval);
10357836SJohn.Forte@Sun.COM }
10367836SJohn.Forte@Sun.COM 
10377836SJohn.Forte@Sun.COM /*
10387836SJohn.Forte@Sun.COM  * get_next_link
10397836SJohn.Forte@Sun.COM  *	Gets the next ql_link_t structure.
10407836SJohn.Forte@Sun.COM  *
10417836SJohn.Forte@Sun.COM  * Input:
10427836SJohn.Forte@Sun.COM  *	ql_link  = pointer to a ql_link_t structure.
10437836SJohn.Forte@Sun.COM  *
10447836SJohn.Forte@Sun.COM  * Returns:
10457836SJohn.Forte@Sun.COM  *	DCMD_ABORT, or DCMD_OK
10467836SJohn.Forte@Sun.COM  *
10477836SJohn.Forte@Sun.COM  * Context:
10487836SJohn.Forte@Sun.COM  *	User context.
10497836SJohn.Forte@Sun.COM  *
10507836SJohn.Forte@Sun.COM  */
10517836SJohn.Forte@Sun.COM static int
10527836SJohn.Forte@Sun.COM get_next_link(ql_link_t *qllink)
10537836SJohn.Forte@Sun.COM {
10547836SJohn.Forte@Sun.COM 	int	rval = DCMD_ABORT;
10557836SJohn.Forte@Sun.COM 
10567836SJohn.Forte@Sun.COM 	if (qllink != NULL) {
10577836SJohn.Forte@Sun.COM 		if (qllink->next != NULL) {
10587836SJohn.Forte@Sun.COM 			/* Read in the next ql_link_t header */
10597836SJohn.Forte@Sun.COM 			if (mdb_vread(qllink, sizeof (ql_link_t),
10607836SJohn.Forte@Sun.COM 			    (uintptr_t)(qllink->next)) == -1) {
10617836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_link_t "
10627836SJohn.Forte@Sun.COM 				    "next at %p", qllink->next);
10637836SJohn.Forte@Sun.COM 			} else {
10647836SJohn.Forte@Sun.COM 				rval = DCMD_OK;
10657836SJohn.Forte@Sun.COM 			}
10667836SJohn.Forte@Sun.COM 		}
10677836SJohn.Forte@Sun.COM 	}
10687836SJohn.Forte@Sun.COM 	return (rval);
10697836SJohn.Forte@Sun.COM }
10707836SJohn.Forte@Sun.COM 
10717836SJohn.Forte@Sun.COM /*
10727836SJohn.Forte@Sun.COM  * qlcstate_dcmd
10737836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out the ql_state info using
10747836SJohn.Forte@Sun.COM  *	caller supplied address.
10757836SJohn.Forte@Sun.COM  *
10767836SJohn.Forte@Sun.COM  * Input:
10777836SJohn.Forte@Sun.COM  *	addr  = User supplied address.
10787836SJohn.Forte@Sun.COM  *	flags = mdb flags.
10797836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
10807836SJohn.Forte@Sun.COM  *	argv  = Arg array.
10817836SJohn.Forte@Sun.COM  *
10827836SJohn.Forte@Sun.COM  * Returns:
10837836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
10847836SJohn.Forte@Sun.COM  *
10857836SJohn.Forte@Sun.COM  * Context:
10867836SJohn.Forte@Sun.COM  *	User context.
10877836SJohn.Forte@Sun.COM  *
10887836SJohn.Forte@Sun.COM  */
10897836SJohn.Forte@Sun.COM static int
10907836SJohn.Forte@Sun.COM qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
10917836SJohn.Forte@Sun.COM {
10927836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
10937836SJohn.Forte@Sun.COM 	int			verbose = 0;
10947836SJohn.Forte@Sun.COM 
10957836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
10967836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
10977836SJohn.Forte@Sun.COM 	}
10987836SJohn.Forte@Sun.COM 
10997836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
11007836SJohn.Forte@Sun.COM 	    argc) {
11017836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
11027836SJohn.Forte@Sun.COM 	}
11037836SJohn.Forte@Sun.COM 
11047836SJohn.Forte@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)
11057836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
11067836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
11077836SJohn.Forte@Sun.COM 		return (DCMD_OK);
11087836SJohn.Forte@Sun.COM 	}
11097836SJohn.Forte@Sun.COM 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
11107836SJohn.Forte@Sun.COM 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
11117836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
11127836SJohn.Forte@Sun.COM 		return (DCMD_OK);
11137836SJohn.Forte@Sun.COM 	}
11147836SJohn.Forte@Sun.COM 
11157836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx\n", qlstate->instance,
11167836SJohn.Forte@Sun.COM 	    addr);
11177836SJohn.Forte@Sun.COM 
11187836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state flags:\n");
11197836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
11207836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter cfg flags:\n");
11217836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
11227836SJohn.Forte@Sun.COM 	mdb_printf("\ntask daemon state flags:\n");
11237836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
11247836SJohn.Forte@Sun.COM 	    task_daemon_flags);
11257836SJohn.Forte@Sun.COM 
11267836SJohn.Forte@Sun.COM 	if (verbose) {
11277836SJohn.Forte@Sun.COM 		(void) ql_doprint(addr, "struct ql_adapter_state");
11287836SJohn.Forte@Sun.COM 	}
11297836SJohn.Forte@Sun.COM 
11307836SJohn.Forte@Sun.COM 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
11317836SJohn.Forte@Sun.COM 
11327836SJohn.Forte@Sun.COM 	return (DCMD_OK);
11337836SJohn.Forte@Sun.COM }
11347836SJohn.Forte@Sun.COM 
11357836SJohn.Forte@Sun.COM /*
11367836SJohn.Forte@Sun.COM  * qlcstates_walk_init
11377836SJohn.Forte@Sun.COM  *	mdb walker init which prints out all qlc states info.
11387836SJohn.Forte@Sun.COM  *
11397836SJohn.Forte@Sun.COM  * Input:
11407836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
11417836SJohn.Forte@Sun.COM  *
11427836SJohn.Forte@Sun.COM  * Returns:
11437836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
11447836SJohn.Forte@Sun.COM  *
11457836SJohn.Forte@Sun.COM  * Context:
11467836SJohn.Forte@Sun.COM  *	User context.
11477836SJohn.Forte@Sun.COM  *
11487836SJohn.Forte@Sun.COM  */
11497836SJohn.Forte@Sun.COM static int
11507836SJohn.Forte@Sun.COM qlstates_walk_init(mdb_walk_state_t *wsp)
11517836SJohn.Forte@Sun.COM {
11527836SJohn.Forte@Sun.COM 	ql_head_t	ql_hba;
11537836SJohn.Forte@Sun.COM 
11547836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
11557836SJohn.Forte@Sun.COM 		if ((mdb_readvar(&ql_hba, "ql_hba") == -1) ||
11567836SJohn.Forte@Sun.COM 		    (&ql_hba == NULL)) {
11577836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_hba structure");
11587836SJohn.Forte@Sun.COM 			return (WALK_ERR);
11597836SJohn.Forte@Sun.COM 		}
11607836SJohn.Forte@Sun.COM 
11617836SJohn.Forte@Sun.COM 		wsp->walk_addr = (uintptr_t)ql_hba.first;
11627836SJohn.Forte@Sun.COM 		wsp->walk_data = mdb_alloc(sizeof (ql_adapter_state_t),
11637836SJohn.Forte@Sun.COM 		    UM_SLEEP);
11647836SJohn.Forte@Sun.COM 		return (WALK_NEXT);
11657836SJohn.Forte@Sun.COM 	} else {
11667836SJohn.Forte@Sun.COM 		return (ql_doprint(wsp->walk_addr, "struct ql_adapter_state"));
11677836SJohn.Forte@Sun.COM 	}
11687836SJohn.Forte@Sun.COM }
11697836SJohn.Forte@Sun.COM 
11707836SJohn.Forte@Sun.COM /*
11717836SJohn.Forte@Sun.COM  * qlstates_walk_step
11727836SJohn.Forte@Sun.COM  *	mdb walker step which prints out all qlc states info.
11737836SJohn.Forte@Sun.COM  *
11747836SJohn.Forte@Sun.COM  * Input:
11757836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
11767836SJohn.Forte@Sun.COM  *
11777836SJohn.Forte@Sun.COM  * Returns:
11787836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
11797836SJohn.Forte@Sun.COM  *
11807836SJohn.Forte@Sun.COM  * Context:
11817836SJohn.Forte@Sun.COM  *	User context.
11827836SJohn.Forte@Sun.COM  *
11837836SJohn.Forte@Sun.COM  */
11847836SJohn.Forte@Sun.COM static int
11857836SJohn.Forte@Sun.COM qlstates_walk_step(mdb_walk_state_t *wsp)
11867836SJohn.Forte@Sun.COM {
11877836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*qlstate;
11887836SJohn.Forte@Sun.COM 
11897836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
11907836SJohn.Forte@Sun.COM 		return (WALK_DONE);
11917836SJohn.Forte@Sun.COM 	}
11927836SJohn.Forte@Sun.COM 
11937836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_adapter_state_t),
11947836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
11957836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p",
11967836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
11977836SJohn.Forte@Sun.COM 		return (WALK_DONE);
11987836SJohn.Forte@Sun.COM 	}
11997836SJohn.Forte@Sun.COM 
12007836SJohn.Forte@Sun.COM 	qlstate = (ql_adapter_state_t *)(wsp->walk_data);
12017836SJohn.Forte@Sun.COM 	mdb_printf("qlc instance: %d, base addr = %llx\n",
12027836SJohn.Forte@Sun.COM 	    qlstate->instance, wsp->walk_addr);
12037836SJohn.Forte@Sun.COM 
12047836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state flags:\n");
12057836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
12067836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter cfg flags:\n");
12077836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
12087836SJohn.Forte@Sun.COM 	mdb_printf("\ntask daemon state flags:\n");
12097836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
12107836SJohn.Forte@Sun.COM 	    task_daemon_flags);
12117836SJohn.Forte@Sun.COM 
12127836SJohn.Forte@Sun.COM 	mdb_printf("\nadapter state:\n");
12137836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_adapter_state");
12147836SJohn.Forte@Sun.COM 
12157836SJohn.Forte@Sun.COM 	mdb_printf("\n");
12167836SJohn.Forte@Sun.COM 
12177836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)
12187836SJohn.Forte@Sun.COM 	    (((ql_adapter_state_t *)wsp->walk_data)->hba.next);
12197836SJohn.Forte@Sun.COM 
12207836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
12217836SJohn.Forte@Sun.COM }
12227836SJohn.Forte@Sun.COM 
12237836SJohn.Forte@Sun.COM /*
12247836SJohn.Forte@Sun.COM  * qlstates_walk_fini
12257836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
12267836SJohn.Forte@Sun.COM  *
12277836SJohn.Forte@Sun.COM  * Input:
12287836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
12297836SJohn.Forte@Sun.COM  *
12307836SJohn.Forte@Sun.COM  * Returns:
12317836SJohn.Forte@Sun.COM  *
12327836SJohn.Forte@Sun.COM  * Context:
12337836SJohn.Forte@Sun.COM  *	User context.
12347836SJohn.Forte@Sun.COM  *
12357836SJohn.Forte@Sun.COM  */
12367836SJohn.Forte@Sun.COM static void
12377836SJohn.Forte@Sun.COM qlstates_walk_fini(mdb_walk_state_t *wsp)
12387836SJohn.Forte@Sun.COM {
12397836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_adapter_state_t));
12407836SJohn.Forte@Sun.COM }
12417836SJohn.Forte@Sun.COM 
12427836SJohn.Forte@Sun.COM /*
12437836SJohn.Forte@Sun.COM  * qlsrb_walk_init
12447836SJohn.Forte@Sun.COM  *	mdb walker init which prints out linked srb's
12457836SJohn.Forte@Sun.COM  *
12467836SJohn.Forte@Sun.COM  * Input:
12477836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker ql_srb struct
12487836SJohn.Forte@Sun.COM  *
12497836SJohn.Forte@Sun.COM  * Returns:
12507836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
12517836SJohn.Forte@Sun.COM  *
12527836SJohn.Forte@Sun.COM  * Context:
12537836SJohn.Forte@Sun.COM  *	User context.
12547836SJohn.Forte@Sun.COM  *
12557836SJohn.Forte@Sun.COM  */
12567836SJohn.Forte@Sun.COM static int
12577836SJohn.Forte@Sun.COM qlsrb_walk_init(mdb_walk_state_t *wsp)
12587836SJohn.Forte@Sun.COM {
12597836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
12607836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_srb addr at %p",
12617836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
12627836SJohn.Forte@Sun.COM 		return (WALK_ERR);
12637836SJohn.Forte@Sun.COM 	}
12647836SJohn.Forte@Sun.COM 
12657836SJohn.Forte@Sun.COM 	wsp->walk_data = mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
12667836SJohn.Forte@Sun.COM 
12677836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
12687836SJohn.Forte@Sun.COM }
12697836SJohn.Forte@Sun.COM 
12707836SJohn.Forte@Sun.COM /*
12717836SJohn.Forte@Sun.COM  * qlcsrb_walk_step
12727836SJohn.Forte@Sun.COM  *	mdb walker step which prints out linked ql_srb structures
12737836SJohn.Forte@Sun.COM  *
12747836SJohn.Forte@Sun.COM  * Input:
12757836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker srb struct
12767836SJohn.Forte@Sun.COM  *
12777836SJohn.Forte@Sun.COM  * Returns:
12787836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
12797836SJohn.Forte@Sun.COM  *
12807836SJohn.Forte@Sun.COM  * Context:
12817836SJohn.Forte@Sun.COM  *	User context.
12827836SJohn.Forte@Sun.COM  *
12837836SJohn.Forte@Sun.COM  */
12847836SJohn.Forte@Sun.COM static int
12857836SJohn.Forte@Sun.COM qlsrb_walk_step(mdb_walk_state_t *wsp)
12867836SJohn.Forte@Sun.COM {
12877836SJohn.Forte@Sun.COM 	ql_srb_t	*qlsrb;
12887836SJohn.Forte@Sun.COM 
12897836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
12907836SJohn.Forte@Sun.COM 		return (WALK_DONE);
12917836SJohn.Forte@Sun.COM 
12927836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_srb_t),
12937836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
12947836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_srb at %p", wsp->walk_addr);
12957836SJohn.Forte@Sun.COM 		return (WALK_DONE);
12967836SJohn.Forte@Sun.COM 	}
12977836SJohn.Forte@Sun.COM 
12987836SJohn.Forte@Sun.COM 	qlsrb = (ql_srb_t *)(wsp->walk_data);
12997836SJohn.Forte@Sun.COM 	mdb_printf("ql_srb base addr = %llx\n", wsp->walk_addr);
13007836SJohn.Forte@Sun.COM 
13017836SJohn.Forte@Sun.COM 	mdb_printf("\nql_srb flags:\n");
13027836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qlsrb->flags, qlsrb_flags);
13037836SJohn.Forte@Sun.COM 
13047836SJohn.Forte@Sun.COM 	mdb_printf("\nql_srb:\n");
13057836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_srb");
13067836SJohn.Forte@Sun.COM 
13077836SJohn.Forte@Sun.COM 	mdb_printf("\n");
13087836SJohn.Forte@Sun.COM 
13097836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)
13107836SJohn.Forte@Sun.COM 	    (((ql_srb_t *)wsp->walk_data)->cmd.next);
13117836SJohn.Forte@Sun.COM 
13127836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
13137836SJohn.Forte@Sun.COM }
13147836SJohn.Forte@Sun.COM 
13157836SJohn.Forte@Sun.COM /*
13167836SJohn.Forte@Sun.COM  * qlsrb_walk_fini
13177836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
13187836SJohn.Forte@Sun.COM  *
13197836SJohn.Forte@Sun.COM  * Input:
13207836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
13217836SJohn.Forte@Sun.COM  *
13227836SJohn.Forte@Sun.COM  * Returns:
13237836SJohn.Forte@Sun.COM  *
13247836SJohn.Forte@Sun.COM  * Context:
13257836SJohn.Forte@Sun.COM  *	User context.
13267836SJohn.Forte@Sun.COM  *
13277836SJohn.Forte@Sun.COM  */
13287836SJohn.Forte@Sun.COM static void
13297836SJohn.Forte@Sun.COM qlsrb_walk_fini(mdb_walk_state_t *wsp)
13307836SJohn.Forte@Sun.COM {
13317836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_srb_t));
13327836SJohn.Forte@Sun.COM }
13337836SJohn.Forte@Sun.COM 
13347836SJohn.Forte@Sun.COM /*
13357836SJohn.Forte@Sun.COM  * qllunq_dcmd
13367836SJohn.Forte@Sun.COM  *	mdb walker which prints out lun q's
13377836SJohn.Forte@Sun.COM  *
13387836SJohn.Forte@Sun.COM  * Input:
13397836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker ql_lun struct
13407836SJohn.Forte@Sun.COM  *
13417836SJohn.Forte@Sun.COM  * Returns:
13427836SJohn.Forte@Sun.COM  *	WALK_ERR, or WALK_NEXT
13437836SJohn.Forte@Sun.COM  *
13447836SJohn.Forte@Sun.COM  * Context:
13457836SJohn.Forte@Sun.COM  *	User context.
13467836SJohn.Forte@Sun.COM  *
13477836SJohn.Forte@Sun.COM  */
13487836SJohn.Forte@Sun.COM static int
13497836SJohn.Forte@Sun.COM qllunq_walk_init(mdb_walk_state_t *wsp)
13507836SJohn.Forte@Sun.COM {
13517836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
13527836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_lun addr at %p",
13537836SJohn.Forte@Sun.COM 		    wsp->walk_addr);
13547836SJohn.Forte@Sun.COM 		return (WALK_ERR);
13557836SJohn.Forte@Sun.COM 	}
13567836SJohn.Forte@Sun.COM 
13577836SJohn.Forte@Sun.COM 	wsp->walk_data = mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
13587836SJohn.Forte@Sun.COM 
13597836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
13607836SJohn.Forte@Sun.COM }
13617836SJohn.Forte@Sun.COM 
13627836SJohn.Forte@Sun.COM /*
13637836SJohn.Forte@Sun.COM  * qlclunq_walk_step
13647836SJohn.Forte@Sun.COM  *	mdb walker step which prints out linked ql_lun structures
13657836SJohn.Forte@Sun.COM  *
13667836SJohn.Forte@Sun.COM  * Input:
13677836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker srb struct
13687836SJohn.Forte@Sun.COM  *
13697836SJohn.Forte@Sun.COM  * Returns:
13707836SJohn.Forte@Sun.COM  *	WALK_DONE, or WALK_NEXT
13717836SJohn.Forte@Sun.COM  *
13727836SJohn.Forte@Sun.COM  * Context:
13737836SJohn.Forte@Sun.COM  *	User context.
13747836SJohn.Forte@Sun.COM  *
13757836SJohn.Forte@Sun.COM  */
13767836SJohn.Forte@Sun.COM static int
13777836SJohn.Forte@Sun.COM qllunq_walk_step(mdb_walk_state_t *wsp)
13787836SJohn.Forte@Sun.COM {
13797836SJohn.Forte@Sun.COM 	ql_lun_t	*qllun;
13807836SJohn.Forte@Sun.COM 	ql_link_t	ql_link;
13817836SJohn.Forte@Sun.COM 	ql_link_t	*qllink;
13827836SJohn.Forte@Sun.COM 
13837836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
13847836SJohn.Forte@Sun.COM 		return (WALK_DONE);
13857836SJohn.Forte@Sun.COM 
13867836SJohn.Forte@Sun.COM 	if (mdb_vread(wsp->walk_data, sizeof (ql_lun_t),
13877836SJohn.Forte@Sun.COM 	    wsp->walk_addr) == -1) {
13887836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_lun at %p", wsp->walk_addr);
13897836SJohn.Forte@Sun.COM 		return (WALK_DONE);
13907836SJohn.Forte@Sun.COM 	}
13917836SJohn.Forte@Sun.COM 
13927836SJohn.Forte@Sun.COM 	qllun = (ql_lun_t *)(wsp->walk_data);
13937836SJohn.Forte@Sun.COM 	mdb_printf("ql_lun base addr = %llx\n", wsp->walk_addr);
13947836SJohn.Forte@Sun.COM 
13957836SJohn.Forte@Sun.COM 	mdb_printf("\nql_lun flags:\n");
13967836SJohn.Forte@Sun.COM 	ql_dump_flags((uint64_t)qllun->flags, qllun_flags);
13977836SJohn.Forte@Sun.COM 
13987836SJohn.Forte@Sun.COM 	mdb_printf("\nql_lun:\n");
13997836SJohn.Forte@Sun.COM 	(void) ql_doprint(wsp->walk_addr, "struct ql_lun");
14007836SJohn.Forte@Sun.COM 
14017836SJohn.Forte@Sun.COM 	mdb_printf("\n");
14027836SJohn.Forte@Sun.COM 
14037836SJohn.Forte@Sun.COM 	qllink = (ql_link_t *)
14047836SJohn.Forte@Sun.COM 	    (((ql_lun_t *)wsp->walk_data)->link.next);
14057836SJohn.Forte@Sun.COM 
14067836SJohn.Forte@Sun.COM 	if (qllink == NULL) {
14077836SJohn.Forte@Sun.COM 		return (WALK_DONE);
14087836SJohn.Forte@Sun.COM 	} else {
14097836SJohn.Forte@Sun.COM 		/*
14107836SJohn.Forte@Sun.COM 		 * Read in the next link_t header
14117836SJohn.Forte@Sun.COM 		 */
14127836SJohn.Forte@Sun.COM 		if (mdb_vread(&ql_link, sizeof (ql_link_t),
14137836SJohn.Forte@Sun.COM 		    (uintptr_t)qllink) == -1) {
14147836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_link_t "
14157836SJohn.Forte@Sun.COM 			    "next at %p", qllink->next);
14167836SJohn.Forte@Sun.COM 			return (WALK_DONE);
14177836SJohn.Forte@Sun.COM 		}
14187836SJohn.Forte@Sun.COM 		qllink = &ql_link;
14197836SJohn.Forte@Sun.COM 	}
14207836SJohn.Forte@Sun.COM 
14217836SJohn.Forte@Sun.COM 	wsp->walk_addr = (uintptr_t)qllink->base_address;
14227836SJohn.Forte@Sun.COM 
14237836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
14247836SJohn.Forte@Sun.COM }
14257836SJohn.Forte@Sun.COM 
14267836SJohn.Forte@Sun.COM /*
14277836SJohn.Forte@Sun.COM  * qllunq_walk_fini
14287836SJohn.Forte@Sun.COM  *	mdb walker fini which wraps up the walker
14297836SJohn.Forte@Sun.COM  *
14307836SJohn.Forte@Sun.COM  * Input:
14317836SJohn.Forte@Sun.COM  *	wsp - Pointer to walker state struct
14327836SJohn.Forte@Sun.COM  *
14337836SJohn.Forte@Sun.COM  * Returns:
14347836SJohn.Forte@Sun.COM  *
14357836SJohn.Forte@Sun.COM  * Context:
14367836SJohn.Forte@Sun.COM  *	User context.
14377836SJohn.Forte@Sun.COM  *
14387836SJohn.Forte@Sun.COM  */
14397836SJohn.Forte@Sun.COM static void
14407836SJohn.Forte@Sun.COM qllunq_walk_fini(mdb_walk_state_t *wsp)
14417836SJohn.Forte@Sun.COM {
14427836SJohn.Forte@Sun.COM 	mdb_free(wsp->walk_data, sizeof (ql_lun_t));
14437836SJohn.Forte@Sun.COM }
14447836SJohn.Forte@Sun.COM 
14457836SJohn.Forte@Sun.COM /*
14467836SJohn.Forte@Sun.COM  * qltgtq_dcmd
14477836SJohn.Forte@Sun.COM  *	mdb dcmd which prints out an hs's tq struct info.
14487836SJohn.Forte@Sun.COM  *
14497836SJohn.Forte@Sun.COM  * Input:
14507836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
14517836SJohn.Forte@Sun.COM  *	flags = mdb flags.
14527836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
14537836SJohn.Forte@Sun.COM  *	argv  = Arg array.
14547836SJohn.Forte@Sun.COM  *
14557836SJohn.Forte@Sun.COM  * Returns:
14567836SJohn.Forte@Sun.COM  *	DCMD_USAGE, or DCMD_OK
14577836SJohn.Forte@Sun.COM  *
14587836SJohn.Forte@Sun.COM  * Context:
14597836SJohn.Forte@Sun.COM  *	User context.
14607836SJohn.Forte@Sun.COM  *
14617836SJohn.Forte@Sun.COM  */
14627836SJohn.Forte@Sun.COM /*ARGSUSED*/
14637836SJohn.Forte@Sun.COM static int
14647836SJohn.Forte@Sun.COM qltgtq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
14657836SJohn.Forte@Sun.COM {
14667836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*ha;
14677836SJohn.Forte@Sun.COM 	ql_link_t		*link;
14687836SJohn.Forte@Sun.COM 	ql_tgt_t		*tq;
14697836SJohn.Forte@Sun.COM 	uint32_t		index;
14707836SJohn.Forte@Sun.COM 	ql_head_t		*dev;
14717836SJohn.Forte@Sun.COM 
14727836SJohn.Forte@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
14737836SJohn.Forte@Sun.COM 		mdb_warn("ql_hba structure addr is required");
14747836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
14757836SJohn.Forte@Sun.COM 	}
14767836SJohn.Forte@Sun.COM 
14777836SJohn.Forte@Sun.COM 	/*
14787836SJohn.Forte@Sun.COM 	 * Get the adapter state struct which was passed
14797836SJohn.Forte@Sun.COM 	 */
14807836SJohn.Forte@Sun.COM 
14817836SJohn.Forte@Sun.COM 	ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
14827836SJohn.Forte@Sun.COM 	    UM_SLEEP);
14837836SJohn.Forte@Sun.COM 
14847836SJohn.Forte@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
14857836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
14867836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
14877836SJohn.Forte@Sun.COM 		return (DCMD_OK);
14887836SJohn.Forte@Sun.COM 	}
14897836SJohn.Forte@Sun.COM 
14907836SJohn.Forte@Sun.COM 	if (ha->dev == NULL) {
14917836SJohn.Forte@Sun.COM 		mdb_warn("dev ptr is NULL for ha: %p", addr);
14927836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
14937836SJohn.Forte@Sun.COM 		return (DCMD_OK);
14947836SJohn.Forte@Sun.COM 	}
14957836SJohn.Forte@Sun.COM 
14967836SJohn.Forte@Sun.COM 	/*
14977836SJohn.Forte@Sun.COM 	 * Read in the device array
14987836SJohn.Forte@Sun.COM 	 */
14997836SJohn.Forte@Sun.COM 	dev = (ql_head_t *)
15007836SJohn.Forte@Sun.COM 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
15017836SJohn.Forte@Sun.COM 
15027836SJohn.Forte@Sun.COM 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
15037836SJohn.Forte@Sun.COM 	    (uintptr_t)ha->dev) == -1) {
15047836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_head_t (dev) at %p", ha->dev);
15057836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
15067836SJohn.Forte@Sun.COM 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
15077836SJohn.Forte@Sun.COM 	}
15087836SJohn.Forte@Sun.COM 
15097836SJohn.Forte@Sun.COM 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
15107836SJohn.Forte@Sun.COM 	link = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
15117836SJohn.Forte@Sun.COM 
15127836SJohn.Forte@Sun.COM 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
15137836SJohn.Forte@Sun.COM 
15147836SJohn.Forte@Sun.COM 		if (dev[index].first == NULL) {
15157836SJohn.Forte@Sun.COM 			continue;
15167836SJohn.Forte@Sun.COM 		}
15177836SJohn.Forte@Sun.COM 
15187836SJohn.Forte@Sun.COM 		if (mdb_vread(link, sizeof (ql_link_t),
15197836SJohn.Forte@Sun.COM 		    (uintptr_t)dev[index].first) == -1) {
15207836SJohn.Forte@Sun.COM 			mdb_warn("failed to read ql_link_t at %p",
15217836SJohn.Forte@Sun.COM 			    dev[index].first);
15227836SJohn.Forte@Sun.COM 			break;
15237836SJohn.Forte@Sun.COM 		}
15247836SJohn.Forte@Sun.COM 
15257836SJohn.Forte@Sun.COM 		while (link != NULL) {
15267836SJohn.Forte@Sun.COM 			if (mdb_vread(tq, sizeof (ql_tgt_t),
15277836SJohn.Forte@Sun.COM 			    (uintptr_t)(link->base_address)) == -1) {
15287836SJohn.Forte@Sun.COM 				mdb_warn("failed to read ql_tgt at %p",
15297836SJohn.Forte@Sun.COM 				    link->base_address);
15307836SJohn.Forte@Sun.COM 				break;
15317836SJohn.Forte@Sun.COM 			}
15327836SJohn.Forte@Sun.COM 
15337836SJohn.Forte@Sun.COM 			mdb_printf("tgt queue base addr = %llx\n",
15347836SJohn.Forte@Sun.COM 			    link->base_address);
15357836SJohn.Forte@Sun.COM 
15367836SJohn.Forte@Sun.COM 			mdb_printf("\ntgt queue flags: (%xh)\n", tq->flags);
15377836SJohn.Forte@Sun.COM 			ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
15387836SJohn.Forte@Sun.COM 
15397836SJohn.Forte@Sun.COM 			mdb_printf("\ntgt queue:\n");
15407836SJohn.Forte@Sun.COM 
15417836SJohn.Forte@Sun.COM 			(void) ql_doprint((uintptr_t)link->base_address,
15427836SJohn.Forte@Sun.COM 			    "struct ql_target");
15437836SJohn.Forte@Sun.COM 
15447836SJohn.Forte@Sun.COM 			mdb_printf("\n");
15457836SJohn.Forte@Sun.COM 
15467836SJohn.Forte@Sun.COM 			if (get_next_link(link) != DCMD_OK) {
15477836SJohn.Forte@Sun.COM 				break;
15487836SJohn.Forte@Sun.COM 			}
15497836SJohn.Forte@Sun.COM 		}
15507836SJohn.Forte@Sun.COM 	}
15517836SJohn.Forte@Sun.COM 
15527836SJohn.Forte@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
15537836SJohn.Forte@Sun.COM 	mdb_free(tq, sizeof (ql_tgt_t));
15547836SJohn.Forte@Sun.COM 	mdb_free(link, sizeof (ql_link_t));
15557836SJohn.Forte@Sun.COM 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
15567836SJohn.Forte@Sun.COM 
15577836SJohn.Forte@Sun.COM 	return (DCMD_OK);
15587836SJohn.Forte@Sun.COM }
15597836SJohn.Forte@Sun.COM 
15607836SJohn.Forte@Sun.COM /*
15619156SDaniel.Beauregard@Sun.COM  * ql_triggerdump_dcmd
15629156SDaniel.Beauregard@Sun.COM  *	Triggers the driver to take a firmware dump
15639156SDaniel.Beauregard@Sun.COM  *
15649156SDaniel.Beauregard@Sun.COM  * Input:
15659156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address (optional)
15669156SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
15679156SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
15689156SDaniel.Beauregard@Sun.COM  *	argv  = Arg array (instance #, optional).
15699156SDaniel.Beauregard@Sun.COM  *
15709156SDaniel.Beauregard@Sun.COM  * Returns:
15719156SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
15729156SDaniel.Beauregard@Sun.COM  *
15739156SDaniel.Beauregard@Sun.COM  * Context:
15749156SDaniel.Beauregard@Sun.COM  *	User context.
15759156SDaniel.Beauregard@Sun.COM  *
15769156SDaniel.Beauregard@Sun.COM  */
15779156SDaniel.Beauregard@Sun.COM 
15789156SDaniel.Beauregard@Sun.COM #if 0
15799156SDaniel.Beauregard@Sun.COM 
15809156SDaniel.Beauregard@Sun.COM /*ARGSUSED*/
15819156SDaniel.Beauregard@Sun.COM static int
15829156SDaniel.Beauregard@Sun.COM qlc_triggerdump_dcmd(uintptr_t addr, uint_t flags, int argc,
15839156SDaniel.Beauregard@Sun.COM     const mdb_arg_t *argv)
15849156SDaniel.Beauregard@Sun.COM {
15859156SDaniel.Beauregard@Sun.COM 	ql_adapter_state_t	*qlstate;
15869156SDaniel.Beauregard@Sun.COM 	uintptr_t		hbaptr = NULL;
15879156SDaniel.Beauregard@Sun.COM 	ql_head_t		ql_hba;
15889156SDaniel.Beauregard@Sun.COM 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
15899156SDaniel.Beauregard@Sun.COM 	int			mdbs;
15909156SDaniel.Beauregard@Sun.COM 
15919156SDaniel.Beauregard@Sun.COM 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
15929156SDaniel.Beauregard@Sun.COM 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
15939156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
15949156SDaniel.Beauregard@Sun.COM 	}
15959156SDaniel.Beauregard@Sun.COM 
15969156SDaniel.Beauregard@Sun.COM 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
15979156SDaniel.Beauregard@Sun.COM 	    UM_SLEEP)) == NULL) {
15989156SDaniel.Beauregard@Sun.COM 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
15999156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
16009156SDaniel.Beauregard@Sun.COM 	}
16019156SDaniel.Beauregard@Sun.COM 
16029156SDaniel.Beauregard@Sun.COM 	if (addr == NULL) {
16039156SDaniel.Beauregard@Sun.COM 		char		*tptr;
16049156SDaniel.Beauregard@Sun.COM 		uint32_t	instance;
16059156SDaniel.Beauregard@Sun.COM 
16069156SDaniel.Beauregard@Sun.COM 		if (argc == 0) {
16079156SDaniel.Beauregard@Sun.COM 			mdb_warn("must specify either the ha addr or "
16089156SDaniel.Beauregard@Sun.COM 			    "the instance number\n");
16099156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16109156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
16119156SDaniel.Beauregard@Sun.COM 		}
16129156SDaniel.Beauregard@Sun.COM 
16139156SDaniel.Beauregard@Sun.COM 		/*
16149156SDaniel.Beauregard@Sun.COM 		 * find the specified instance in the ha list
16159156SDaniel.Beauregard@Sun.COM 		 */
16169156SDaniel.Beauregard@Sun.COM 
16179156SDaniel.Beauregard@Sun.COM 		instance = (uint32_t)strtol(argv[1].a_un.a_str, &tptr, 16);
16189156SDaniel.Beauregard@Sun.COM 		if (tptr == argv[1].a_un.a_str) {
16199156SDaniel.Beauregard@Sun.COM 			mdb_printf("instance # is illegal: '%s'\n",
16209156SDaniel.Beauregard@Sun.COM 			    argv[1].a_un.a_str);
16219156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16229156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
16239156SDaniel.Beauregard@Sun.COM 		}
16249156SDaniel.Beauregard@Sun.COM 
16259156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
16269156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
16279156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16289156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16299156SDaniel.Beauregard@Sun.COM 		}
16309156SDaniel.Beauregard@Sun.COM 
16319156SDaniel.Beauregard@Sun.COM 		if (&ql_hba == NULL) {
16329156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure - "
16339156SDaniel.Beauregard@Sun.COM 			    "is qlc loaded?");
16349156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16359156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16369156SDaniel.Beauregard@Sun.COM 		}
16379156SDaniel.Beauregard@Sun.COM 
16389156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
16399156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
16409156SDaniel.Beauregard@Sun.COM 
16419156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
16429156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, qlsize);
16439156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read "
16449156SDaniel.Beauregard@Sun.COM 				    "ql_adapter_state at %p", hbaptr);
16459156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
16469156SDaniel.Beauregard@Sun.COM 			}
16479156SDaniel.Beauregard@Sun.COM 
16489156SDaniel.Beauregard@Sun.COM 			if (qlstate->instance == instance) {
16499156SDaniel.Beauregard@Sun.COM 				break;
16509156SDaniel.Beauregard@Sun.COM 			}
16519156SDaniel.Beauregard@Sun.COM 
16529156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
16539156SDaniel.Beauregard@Sun.COM 		}
16549156SDaniel.Beauregard@Sun.COM 	} else {
16559156SDaniel.Beauregard@Sun.COM 
16569156SDaniel.Beauregard@Sun.COM 		/*
16579156SDaniel.Beauregard@Sun.COM 		 * verify the addr specified
16589156SDaniel.Beauregard@Sun.COM 		 */
16599156SDaniel.Beauregard@Sun.COM 
16609156SDaniel.Beauregard@Sun.COM 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
16619156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure");
16629156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16639156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16649156SDaniel.Beauregard@Sun.COM 		}
16659156SDaniel.Beauregard@Sun.COM 
16669156SDaniel.Beauregard@Sun.COM 		if (&ql_hba == NULL) {
16679156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_hba structure - "
16689156SDaniel.Beauregard@Sun.COM 			    "is qlc loaded?");
16699156SDaniel.Beauregard@Sun.COM 			mdb_free(qlstate, qlsize);
16709156SDaniel.Beauregard@Sun.COM 			return (DCMD_ERR);
16719156SDaniel.Beauregard@Sun.COM 		}
16729156SDaniel.Beauregard@Sun.COM 
16739156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
16749156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
16759156SDaniel.Beauregard@Sun.COM 
16769156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
16779156SDaniel.Beauregard@Sun.COM 				mdb_free(qlstate, qlsize);
16789156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed to read "
16799156SDaniel.Beauregard@Sun.COM 				    "ql_adapter_state at %p", hbaptr);
16809156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
16819156SDaniel.Beauregard@Sun.COM 			}
16829156SDaniel.Beauregard@Sun.COM 
16839156SDaniel.Beauregard@Sun.COM 			if (hbaptr == addr) {
16849156SDaniel.Beauregard@Sun.COM 				break;
16859156SDaniel.Beauregard@Sun.COM 			}
16869156SDaniel.Beauregard@Sun.COM 
16879156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)qlstate->hba.next;
16889156SDaniel.Beauregard@Sun.COM 		}
16899156SDaniel.Beauregard@Sun.COM 	}
16909156SDaniel.Beauregard@Sun.COM 
16919156SDaniel.Beauregard@Sun.COM 	if (hbaptr == NULL) {
16929156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, qlsize);
16939156SDaniel.Beauregard@Sun.COM 		if (argc == 0) {
16949156SDaniel.Beauregard@Sun.COM 			mdb_warn("addr specified is not in the hba list\n");
16959156SDaniel.Beauregard@Sun.COM 		} else {
16969156SDaniel.Beauregard@Sun.COM 			mdb_warn("instance specified does not exist\n");
16979156SDaniel.Beauregard@Sun.COM 		}
16989156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
16999156SDaniel.Beauregard@Sun.COM 	}
17009156SDaniel.Beauregard@Sun.COM 
17019156SDaniel.Beauregard@Sun.COM 	if (((qlstate->ql_dump_state & QL_DUMP_VALID) != 0) ||
17029156SDaniel.Beauregard@Sun.COM 	    (qlstate->ql_dump_ptr != NULL)) {
17039156SDaniel.Beauregard@Sun.COM 		mdb_warn("instance %d already has a valid dump\n",
17049156SDaniel.Beauregard@Sun.COM 		    qlstate->instance);
17059156SDaniel.Beauregard@Sun.COM 		mdb_free(qlstate, qlsize);
17069156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
17079156SDaniel.Beauregard@Sun.COM 	}
17089156SDaniel.Beauregard@Sun.COM }
17099156SDaniel.Beauregard@Sun.COM #endif
17109156SDaniel.Beauregard@Sun.COM 
17119156SDaniel.Beauregard@Sun.COM /*
17129156SDaniel.Beauregard@Sun.COM  * ql_getdump_dcmd
17137836SJohn.Forte@Sun.COM  *	prints out the firmware dump buffer
17147836SJohn.Forte@Sun.COM  *
17157836SJohn.Forte@Sun.COM  * Input:
17169156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: must be an ha)
17177836SJohn.Forte@Sun.COM  *	flags = mdb flags.
17187836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
17197836SJohn.Forte@Sun.COM  *	argv  = Arg array.
17207836SJohn.Forte@Sun.COM  *
17217836SJohn.Forte@Sun.COM  * Returns:
17227836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
17237836SJohn.Forte@Sun.COM  *
17247836SJohn.Forte@Sun.COM  * Context:
17257836SJohn.Forte@Sun.COM  *	User context.
17267836SJohn.Forte@Sun.COM  *
17277836SJohn.Forte@Sun.COM  */
17287836SJohn.Forte@Sun.COM static int
17299156SDaniel.Beauregard@Sun.COM qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
17307836SJohn.Forte@Sun.COM {
17317836SJohn.Forte@Sun.COM 	ql_adapter_state_t	*ha;
17329156SDaniel.Beauregard@Sun.COM 	ql_head_t		ql_hba;
17339156SDaniel.Beauregard@Sun.COM 	uintptr_t		hbaptr = NULL;
17349156SDaniel.Beauregard@Sun.COM 	int			verbose = 0;
17357836SJohn.Forte@Sun.COM 
17367836SJohn.Forte@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
17377836SJohn.Forte@Sun.COM 		mdb_warn("ql_adapter_state structure addr is required");
17387836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
17397836SJohn.Forte@Sun.COM 	}
17407836SJohn.Forte@Sun.COM 
17419156SDaniel.Beauregard@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
17429156SDaniel.Beauregard@Sun.COM 	    argc) {
17439156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
17449156SDaniel.Beauregard@Sun.COM 	}
17459156SDaniel.Beauregard@Sun.COM 
17467836SJohn.Forte@Sun.COM 	/*
17477836SJohn.Forte@Sun.COM 	 * Get the adapter state struct which was passed
17487836SJohn.Forte@Sun.COM 	 */
17497836SJohn.Forte@Sun.COM 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
17507836SJohn.Forte@Sun.COM 	    UM_SLEEP)) == NULL) {
17517836SJohn.Forte@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
17527836SJohn.Forte@Sun.COM 		return (DCMD_OK);
17537836SJohn.Forte@Sun.COM 	}
17547836SJohn.Forte@Sun.COM 
17559156SDaniel.Beauregard@Sun.COM 	/*
17569156SDaniel.Beauregard@Sun.COM 	 * show user which instances have valid f/w dumps available if
17579156SDaniel.Beauregard@Sun.COM 	 * user has specified verbose option
17589156SDaniel.Beauregard@Sun.COM 	 */
17599156SDaniel.Beauregard@Sun.COM 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
17609156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_hba structure");
17619156SDaniel.Beauregard@Sun.COM 	} else if (&ql_hba == NULL) {
17629156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
17639156SDaniel.Beauregard@Sun.COM 	} else if (verbose) {
17649156SDaniel.Beauregard@Sun.COM 		hbaptr = (uintptr_t)ql_hba.first;
17659156SDaniel.Beauregard@Sun.COM 		while (hbaptr != NULL) {
17669156SDaniel.Beauregard@Sun.COM 
17679156SDaniel.Beauregard@Sun.COM 			if (mdb_vread(ha, sizeof (ql_adapter_state_t),
17689156SDaniel.Beauregard@Sun.COM 			    hbaptr) == -1) {
17699156SDaniel.Beauregard@Sun.COM 				mdb_free(ha, sizeof (ql_adapter_state_t));
17709156SDaniel.Beauregard@Sun.COM 				mdb_warn("failed read ql_adapter_state at %p",
17719156SDaniel.Beauregard@Sun.COM 				    hbaptr);
17729156SDaniel.Beauregard@Sun.COM 				return (DCMD_OK);
17739156SDaniel.Beauregard@Sun.COM 			}
17749156SDaniel.Beauregard@Sun.COM 
17759156SDaniel.Beauregard@Sun.COM 			mdb_printf("instance %d:\n", ha->instance);
17769156SDaniel.Beauregard@Sun.COM 			(void) mdb_inc_indent((ulong_t)4);
17779156SDaniel.Beauregard@Sun.COM 
17789156SDaniel.Beauregard@Sun.COM 			if (ha->ql_dump_state == 0) {
17799156SDaniel.Beauregard@Sun.COM 				mdb_printf("no dump flags\n");
17809156SDaniel.Beauregard@Sun.COM 			} else {
17819156SDaniel.Beauregard@Sun.COM 				ql_dump_flags((uint64_t)ha->ql_dump_state,
17829156SDaniel.Beauregard@Sun.COM 				    qldump_flags);
17839156SDaniel.Beauregard@Sun.COM 			}
17849156SDaniel.Beauregard@Sun.COM 
17859156SDaniel.Beauregard@Sun.COM 			if (ha->ql_dump_ptr == NULL) {
17869156SDaniel.Beauregard@Sun.COM 				mdb_printf("no dump address\n");
17879156SDaniel.Beauregard@Sun.COM 			} else {
17889156SDaniel.Beauregard@Sun.COM 				mdb_printf("dump address is: %p\n",
17899156SDaniel.Beauregard@Sun.COM 				    ha->ql_dump_ptr);
17909156SDaniel.Beauregard@Sun.COM 			}
17919156SDaniel.Beauregard@Sun.COM 
17929156SDaniel.Beauregard@Sun.COM 			(void) mdb_dec_indent((ulong_t)4);
17939156SDaniel.Beauregard@Sun.COM 
17949156SDaniel.Beauregard@Sun.COM 			hbaptr = (uintptr_t)ha->hba.next;
17959156SDaniel.Beauregard@Sun.COM 		}
17969156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n");
17979156SDaniel.Beauregard@Sun.COM 	}
17989156SDaniel.Beauregard@Sun.COM 
17997836SJohn.Forte@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
18007836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
18017836SJohn.Forte@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
18027836SJohn.Forte@Sun.COM 		return (DCMD_OK);
18037836SJohn.Forte@Sun.COM 	}
18047836SJohn.Forte@Sun.COM 
18059156SDaniel.Beauregard@Sun.COM 	/*
18069156SDaniel.Beauregard@Sun.COM 	 * If its not a valid dump or there's not a f/w dump binary (???)
18079156SDaniel.Beauregard@Sun.COM 	 * then bail out
18089156SDaniel.Beauregard@Sun.COM 	 */
18099156SDaniel.Beauregard@Sun.COM 	if (((ha->ql_dump_state & QL_DUMP_VALID) == 0) ||
18109156SDaniel.Beauregard@Sun.COM 	    (ha->ql_dump_ptr == NULL)) {
18119156SDaniel.Beauregard@Sun.COM 		mdb_warn("dump does not exist for instance %d (%x, %p)\n",
18129156SDaniel.Beauregard@Sun.COM 		    ha->instance, ha->ql_dump_state, ha->ql_dump_ptr);
18139156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
18149156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
18159156SDaniel.Beauregard@Sun.COM 	}
18169156SDaniel.Beauregard@Sun.COM 
18177836SJohn.Forte@Sun.COM 	if (CFG_IST(ha, CFG_CTRL_2422)) {
18187836SJohn.Forte@Sun.COM 		(void) ql_24xx_dump_dcmd(ha, flags, argc, argv);
1819*10736SDaniel.Beauregard@Sun.COM 	} else if (CFG_IST(ha, CFG_CTRL_25XX))  {
18207836SJohn.Forte@Sun.COM 		(void) ql_25xx_dump_dcmd(ha, flags, argc, argv);
1821*10736SDaniel.Beauregard@Sun.COM 	} else if (CFG_IST(ha, CFG_CTRL_81XX))  {
1822*10736SDaniel.Beauregard@Sun.COM 		(void) ql_81xx_dump_dcmd(ha, flags, argc, argv);
18237836SJohn.Forte@Sun.COM 	} else {
18247836SJohn.Forte@Sun.COM 		(void) ql_23xx_dump_dcmd(ha, flags, argc, argv);
18257836SJohn.Forte@Sun.COM 	}
18267836SJohn.Forte@Sun.COM 
18277836SJohn.Forte@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
18287836SJohn.Forte@Sun.COM 
18297836SJohn.Forte@Sun.COM 	return (DCMD_OK);
18307836SJohn.Forte@Sun.COM }
18317836SJohn.Forte@Sun.COM 
18327836SJohn.Forte@Sun.COM /*
18337836SJohn.Forte@Sun.COM  * ql_23xx_dump_dcmd
18347836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
18357836SJohn.Forte@Sun.COM  *
18367836SJohn.Forte@Sun.COM  * Input:
18377836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
18387836SJohn.Forte@Sun.COM  *	flags = mdb flags.
18397836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
18407836SJohn.Forte@Sun.COM  *	argv  = Arg array.
18417836SJohn.Forte@Sun.COM  *
18427836SJohn.Forte@Sun.COM  * Returns:
18437836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
18447836SJohn.Forte@Sun.COM  *
18457836SJohn.Forte@Sun.COM  * Context:
18467836SJohn.Forte@Sun.COM  *	User context.
18477836SJohn.Forte@Sun.COM  *
18487836SJohn.Forte@Sun.COM  */
18497836SJohn.Forte@Sun.COM /*ARGSUSED*/
18507836SJohn.Forte@Sun.COM static int
18517836SJohn.Forte@Sun.COM ql_23xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
18527836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
18537836SJohn.Forte@Sun.COM {
18547836SJohn.Forte@Sun.COM 	ql_fw_dump_t	*fw;
18557836SJohn.Forte@Sun.COM 	uint32_t	cnt = 0;
18567836SJohn.Forte@Sun.COM 	int		mbox_cnt;
18577836SJohn.Forte@Sun.COM 
18589156SDaniel.Beauregard@Sun.COM 	fw = (ql_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
18599156SDaniel.Beauregard@Sun.COM 
18609156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
18619156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
18627836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
18639156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
18647836SJohn.Forte@Sun.COM 		return (DCMD_OK);
18657836SJohn.Forte@Sun.COM 	}
18667836SJohn.Forte@Sun.COM 
18677836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & CFG_CTRL_2300) {
18687836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 2300IP ");
18697836SJohn.Forte@Sun.COM 	} else if (ha->cfg_flags & CFG_CTRL_6322) {
18707836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 6322FLX ");
18717836SJohn.Forte@Sun.COM 	} else {
18727836SJohn.Forte@Sun.COM 		mdb_printf("\nISP 2200IP ");
18737836SJohn.Forte@Sun.COM 	}
18747836SJohn.Forte@Sun.COM 
18757836SJohn.Forte@Sun.COM 	mdb_printf("Firmware Version %d.%d.%d\n",
18767836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
18777836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version);
18787836SJohn.Forte@Sun.COM 
18797836SJohn.Forte@Sun.COM 	mdb_printf("\nPBIU Registers:");
18807836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
18817836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
18827836SJohn.Forte@Sun.COM 			mdb_printf("\n");
18837836SJohn.Forte@Sun.COM 		}
18847836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->pbiu_reg[cnt]);
18857836SJohn.Forte@Sun.COM 	}
18867836SJohn.Forte@Sun.COM 
18877836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
18887836SJohn.Forte@Sun.COM 		mdb_printf("\n\nReqQ-RspQ-Risc2Host Status registers:");
18897836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
18907836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
18917836SJohn.Forte@Sun.COM 				mdb_printf("\n");
18927836SJohn.Forte@Sun.COM 			}
18937836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_host_reg[cnt]);
18947836SJohn.Forte@Sun.COM 		}
18957836SJohn.Forte@Sun.COM 	}
18967836SJohn.Forte@Sun.COM 
18977836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers:");
18987836SJohn.Forte@Sun.COM 	mbox_cnt = (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) ? 16 : 8;
18997836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < mbox_cnt; cnt++) {
19007836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19017836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19027836SJohn.Forte@Sun.COM 		}
19037836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->mailbox_reg[cnt]);
19047836SJohn.Forte@Sun.COM 	}
19057836SJohn.Forte@Sun.COM 
19067836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
19077836SJohn.Forte@Sun.COM 		mdb_printf("\n\nAuto Request Response DMA Registers:");
19087836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
19097836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
19107836SJohn.Forte@Sun.COM 				mdb_printf("\n");
19117836SJohn.Forte@Sun.COM 			}
19127836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->resp_dma_reg[cnt]);
19137836SJohn.Forte@Sun.COM 		}
19147836SJohn.Forte@Sun.COM 	}
19157836SJohn.Forte@Sun.COM 
19167836SJohn.Forte@Sun.COM 	mdb_printf("\n\nDMA Registers:");
19177836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
19187836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19197836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19207836SJohn.Forte@Sun.COM 		}
19217836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->dma_reg[cnt]);
19227836SJohn.Forte@Sun.COM 	}
19237836SJohn.Forte@Sun.COM 
19247836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC Hardware Registers:");
19257836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
19267836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19277836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19287836SJohn.Forte@Sun.COM 		}
19297836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_hdw_reg[cnt]);
19307836SJohn.Forte@Sun.COM 	}
19317836SJohn.Forte@Sun.COM 
19327836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP0 Registers:");
19337836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
19347836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19357836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19367836SJohn.Forte@Sun.COM 		}
19377836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp0_reg[cnt]);
19387836SJohn.Forte@Sun.COM 	}
19397836SJohn.Forte@Sun.COM 
19407836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP1 Registers:");
19417836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
19427836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19437836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19447836SJohn.Forte@Sun.COM 		}
19457836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp1_reg[cnt]);
19467836SJohn.Forte@Sun.COM 	}
19477836SJohn.Forte@Sun.COM 
19487836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP2 Registers:");
19497836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
19507836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19517836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19527836SJohn.Forte@Sun.COM 		}
19537836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp2_reg[cnt]);
19547836SJohn.Forte@Sun.COM 	}
19557836SJohn.Forte@Sun.COM 
19567836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP3 Registers:");
19577836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
19587836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19597836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19607836SJohn.Forte@Sun.COM 		}
19617836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp3_reg[cnt]);
19627836SJohn.Forte@Sun.COM 	}
19637836SJohn.Forte@Sun.COM 
19647836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP4 Registers:");
19657836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
19667836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19677836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19687836SJohn.Forte@Sun.COM 		}
19697836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp4_reg[cnt]);
19707836SJohn.Forte@Sun.COM 	}
19717836SJohn.Forte@Sun.COM 
19727836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP5 Registers:");
19737836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
19747836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19757836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19767836SJohn.Forte@Sun.COM 		}
19777836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp5_reg[cnt]);
19787836SJohn.Forte@Sun.COM 	}
19797836SJohn.Forte@Sun.COM 
19807836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP6 Registers:");
19817836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
19827836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19837836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19847836SJohn.Forte@Sun.COM 		}
19857836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp6_reg[cnt]);
19867836SJohn.Forte@Sun.COM 	}
19877836SJohn.Forte@Sun.COM 
19887836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP7 Registers:");
19897836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
19907836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
19917836SJohn.Forte@Sun.COM 			mdb_printf("\n");
19927836SJohn.Forte@Sun.COM 		}
19937836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->risc_gp7_reg[cnt]);
19947836SJohn.Forte@Sun.COM 	}
19957836SJohn.Forte@Sun.COM 
19967836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFrame Buffer Hardware Registers:");
19977836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
19987836SJohn.Forte@Sun.COM 		if ((cnt == 16) &&
19997836SJohn.Forte@Sun.COM 		    ((ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) == 0)) {
20007836SJohn.Forte@Sun.COM 			break;
20017836SJohn.Forte@Sun.COM 		}
20027836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20037836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20047836SJohn.Forte@Sun.COM 		}
20057836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->frame_buf_hdw_reg[cnt]);
20067836SJohn.Forte@Sun.COM 	}
20077836SJohn.Forte@Sun.COM 
20087836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM B0 Registers:");
20097836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
20107836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20117836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20127836SJohn.Forte@Sun.COM 		}
20137836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->fpm_b0_reg[cnt]);
20147836SJohn.Forte@Sun.COM 	}
20157836SJohn.Forte@Sun.COM 
20167836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM B1 Registers:");
20177836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
20187836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
20197836SJohn.Forte@Sun.COM 			mdb_printf("\n");
20207836SJohn.Forte@Sun.COM 		}
20217836SJohn.Forte@Sun.COM 		mdb_printf("%04x  ", fw->fpm_b1_reg[cnt]);
20227836SJohn.Forte@Sun.COM 	}
20237836SJohn.Forte@Sun.COM 
20247836SJohn.Forte@Sun.COM 	if (ha->cfg_flags & (CFG_CTRL_2300 | CFG_CTRL_6322)) {
20257836SJohn.Forte@Sun.COM 		mdb_printf("\n\nCode RAM Dump:");
20267836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
20277836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20287836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x0800);
20297836SJohn.Forte@Sun.COM 			}
20307836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
20317836SJohn.Forte@Sun.COM 		}
20327836SJohn.Forte@Sun.COM 
20337836SJohn.Forte@Sun.COM 		mdb_printf("\n\nStack RAM Dump:");
20347836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
20357836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20367836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x010000);
20377836SJohn.Forte@Sun.COM 			}
20387836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->stack_ram[cnt]);
20397836SJohn.Forte@Sun.COM 		}
20407836SJohn.Forte@Sun.COM 
20417836SJohn.Forte@Sun.COM 		mdb_printf("\n\nData RAM Dump:");
20427836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) {
20437836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20447836SJohn.Forte@Sun.COM 				mdb_printf("\n%05x: ", cnt + 0x010800);
20457836SJohn.Forte@Sun.COM 			}
20467836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->data_ram[cnt]);
20477836SJohn.Forte@Sun.COM 		}
20487836SJohn.Forte@Sun.COM 
20497836SJohn.Forte@Sun.COM 		mdb_printf("\n\n[<==END] ISP Debug Dump.\n");
20509156SDaniel.Beauregard@Sun.COM 
20519156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nRequest Queue");
20529156SDaniel.Beauregard@Sun.COM 
20539156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
20549156SDaniel.Beauregard@Sun.COM 			if (cnt % 8 == 0) {
20559156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", cnt);
20569156SDaniel.Beauregard@Sun.COM 			}
20579156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->req_q[cnt]);
20589156SDaniel.Beauregard@Sun.COM 		}
20599156SDaniel.Beauregard@Sun.COM 
20609156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nResponse Queue");
20619156SDaniel.Beauregard@Sun.COM 
20629156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
20639156SDaniel.Beauregard@Sun.COM 			if (cnt % 8 == 0) {
20649156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", cnt);
20659156SDaniel.Beauregard@Sun.COM 			}
20669156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->rsp_q[cnt]);
20679156SDaniel.Beauregard@Sun.COM 		}
20689156SDaniel.Beauregard@Sun.COM 
20699156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n");
20709156SDaniel.Beauregard@Sun.COM 
20717836SJohn.Forte@Sun.COM 	} else {
20727836SJohn.Forte@Sun.COM 		mdb_printf("\n\nRISC SRAM:");
20737836SJohn.Forte@Sun.COM 		for (cnt = 0; cnt < 0xf000; cnt++) {
20747836SJohn.Forte@Sun.COM 			if (cnt % 8 == 0) {
20757836SJohn.Forte@Sun.COM 				mdb_printf("\n%04x: ", cnt + 0x1000);
20767836SJohn.Forte@Sun.COM 			}
20777836SJohn.Forte@Sun.COM 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
20787836SJohn.Forte@Sun.COM 		}
20797836SJohn.Forte@Sun.COM 	}
20807836SJohn.Forte@Sun.COM 
20819156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
20829156SDaniel.Beauregard@Sun.COM 
20837836SJohn.Forte@Sun.COM 	return (DCMD_OK);
20847836SJohn.Forte@Sun.COM }
20857836SJohn.Forte@Sun.COM 
20867836SJohn.Forte@Sun.COM /*
20877836SJohn.Forte@Sun.COM  * ql_24xx_dump_dcmd
20887836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
20897836SJohn.Forte@Sun.COM  *
20907836SJohn.Forte@Sun.COM  * Input:
20917836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
20927836SJohn.Forte@Sun.COM  *	flags = mdb flags.
20937836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
20947836SJohn.Forte@Sun.COM  *	argv  = Arg array.
20957836SJohn.Forte@Sun.COM  *
20967836SJohn.Forte@Sun.COM  * Returns:
20977836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
20987836SJohn.Forte@Sun.COM  *
20997836SJohn.Forte@Sun.COM  * Context:
21007836SJohn.Forte@Sun.COM  *	User context.
21017836SJohn.Forte@Sun.COM  *
21027836SJohn.Forte@Sun.COM  */
21037836SJohn.Forte@Sun.COM /*ARGSUSED*/
21047836SJohn.Forte@Sun.COM static int
21057836SJohn.Forte@Sun.COM ql_24xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
21067836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
21077836SJohn.Forte@Sun.COM {
21087836SJohn.Forte@Sun.COM 	ql_24xx_fw_dump_t	*fw;
21097836SJohn.Forte@Sun.COM 	uint32_t		cnt = 0;
21107836SJohn.Forte@Sun.COM 
21119156SDaniel.Beauregard@Sun.COM 	fw = (ql_24xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
21129156SDaniel.Beauregard@Sun.COM 
21139156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
21149156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
21157836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
21169156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
21177836SJohn.Forte@Sun.COM 		return (DCMD_OK);
21187836SJohn.Forte@Sun.COM 	}
21197836SJohn.Forte@Sun.COM 
21207836SJohn.Forte@Sun.COM 	mdb_printf("ISP FW Version %d.%02d.%02d Attributes %X\n",
21217836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
21227836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
21237836SJohn.Forte@Sun.COM 
21247836SJohn.Forte@Sun.COM 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
21257836SJohn.Forte@Sun.COM 
21267836SJohn.Forte@Sun.COM 	mdb_printf("\nHost Interface Registers");
21277836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
21287836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21297836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21307836SJohn.Forte@Sun.COM 		}
21317836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
21327836SJohn.Forte@Sun.COM 	}
21337836SJohn.Forte@Sun.COM 
21347836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers");
21357836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
21367836SJohn.Forte@Sun.COM 		if (cnt % 16 == 0) {
21377836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21387836SJohn.Forte@Sun.COM 		}
21397836SJohn.Forte@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
21407836SJohn.Forte@Sun.COM 	}
21417836SJohn.Forte@Sun.COM 
21427836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
21437836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
21447836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21457836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21467836SJohn.Forte@Sun.COM 		}
21477836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
21487836SJohn.Forte@Sun.COM 	}
21497836SJohn.Forte@Sun.COM 
21507836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
21517836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
21527836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21537836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21547836SJohn.Forte@Sun.COM 		}
21557836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
21567836SJohn.Forte@Sun.COM 	}
21577836SJohn.Forte@Sun.COM 
21587836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
21597836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
21607836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21617836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21627836SJohn.Forte@Sun.COM 		}
21637836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
21647836SJohn.Forte@Sun.COM 	}
21657836SJohn.Forte@Sun.COM 
21667836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
21677836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
21687836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21697836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21707836SJohn.Forte@Sun.COM 		}
21717836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
21727836SJohn.Forte@Sun.COM 	}
21737836SJohn.Forte@Sun.COM 
21747836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
21757836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
21767836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21777836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21787836SJohn.Forte@Sun.COM 		}
21797836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
21807836SJohn.Forte@Sun.COM 	}
21817836SJohn.Forte@Sun.COM 
21827836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
21837836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
21847836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21857836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21867836SJohn.Forte@Sun.COM 		}
21877836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
21887836SJohn.Forte@Sun.COM 	}
21897836SJohn.Forte@Sun.COM 
21907836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
21917836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
21927836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
21937836SJohn.Forte@Sun.COM 			mdb_printf("\n");
21947836SJohn.Forte@Sun.COM 		}
21957836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
21967836SJohn.Forte@Sun.COM 	}
21977836SJohn.Forte@Sun.COM 
21987836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
21997836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
22007836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22017836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22027836SJohn.Forte@Sun.COM 		}
22037836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
22047836SJohn.Forte@Sun.COM 	}
22057836SJohn.Forte@Sun.COM 
22067836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
22077836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
22087836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22097836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22107836SJohn.Forte@Sun.COM 		}
22117836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
22127836SJohn.Forte@Sun.COM 	}
22137836SJohn.Forte@Sun.COM 
22147836SJohn.Forte@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
22157836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
22167836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22177836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22187836SJohn.Forte@Sun.COM 		}
22197836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
22207836SJohn.Forte@Sun.COM 	}
22217836SJohn.Forte@Sun.COM 
22227836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
22237836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
22247836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22257836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22267836SJohn.Forte@Sun.COM 		}
22277836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
22287836SJohn.Forte@Sun.COM 	}
22297836SJohn.Forte@Sun.COM 
22307836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
22317836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
22327836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22337836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22347836SJohn.Forte@Sun.COM 		}
22357836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
22367836SJohn.Forte@Sun.COM 	}
22377836SJohn.Forte@Sun.COM 
22387836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
22397836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
22407836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22417836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22427836SJohn.Forte@Sun.COM 		}
22437836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
22447836SJohn.Forte@Sun.COM 	}
22457836SJohn.Forte@Sun.COM 
22467836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
22477836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
22487836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22497836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22507836SJohn.Forte@Sun.COM 		}
22517836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
22527836SJohn.Forte@Sun.COM 	}
22537836SJohn.Forte@Sun.COM 
22547836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
22557836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
22567836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22577836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22587836SJohn.Forte@Sun.COM 		}
22597836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
22607836SJohn.Forte@Sun.COM 	}
22617836SJohn.Forte@Sun.COM 
22627836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
22637836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
22647836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22657836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22667836SJohn.Forte@Sun.COM 		}
22677836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
22687836SJohn.Forte@Sun.COM 	}
22697836SJohn.Forte@Sun.COM 
22707836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
22717836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
22727836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22737836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22747836SJohn.Forte@Sun.COM 		}
22757836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
22767836SJohn.Forte@Sun.COM 	}
22777836SJohn.Forte@Sun.COM 
22787836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
22797836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
22807836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22817836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22827836SJohn.Forte@Sun.COM 		}
22837836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
22847836SJohn.Forte@Sun.COM 	}
22857836SJohn.Forte@Sun.COM 
22867836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
22877836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
22887836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22897836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22907836SJohn.Forte@Sun.COM 		}
22917836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
22927836SJohn.Forte@Sun.COM 	}
22937836SJohn.Forte@Sun.COM 
22947836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
22957836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
22967836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
22977836SJohn.Forte@Sun.COM 			mdb_printf("\n");
22987836SJohn.Forte@Sun.COM 		}
22997836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
23007836SJohn.Forte@Sun.COM 	}
23017836SJohn.Forte@Sun.COM 
23027836SJohn.Forte@Sun.COM 	mdb_printf("\n\nShadow Registers");
23037836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
23047836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23057836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23067836SJohn.Forte@Sun.COM 		}
23077836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
23087836SJohn.Forte@Sun.COM 	}
23097836SJohn.Forte@Sun.COM 
23107836SJohn.Forte@Sun.COM 	mdb_printf("\n\nLMC Registers");
23117836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
23127836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23137836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23147836SJohn.Forte@Sun.COM 		}
23157836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
23167836SJohn.Forte@Sun.COM 	}
23177836SJohn.Forte@Sun.COM 
23187836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
23197836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
23207836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23217836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23227836SJohn.Forte@Sun.COM 		}
23237836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
23247836SJohn.Forte@Sun.COM 	}
23257836SJohn.Forte@Sun.COM 
23267836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
23277836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
23287836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23297836SJohn.Forte@Sun.COM 			mdb_printf("\n");
23307836SJohn.Forte@Sun.COM 		}
23317836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
23327836SJohn.Forte@Sun.COM 	}
23337836SJohn.Forte@Sun.COM 
23347836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCode RAM");
23357836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
23367836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23377836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
23387836SJohn.Forte@Sun.COM 		}
23397836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
23407836SJohn.Forte@Sun.COM 	}
23417836SJohn.Forte@Sun.COM 
23427836SJohn.Forte@Sun.COM 	mdb_printf("\n\nExternal Memory");
23437836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
23447836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
23457836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
23467836SJohn.Forte@Sun.COM 		}
23477836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
23487836SJohn.Forte@Sun.COM 	}
23497836SJohn.Forte@Sun.COM 
23507836SJohn.Forte@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
23517836SJohn.Forte@Sun.COM 
23529156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
23539156SDaniel.Beauregard@Sun.COM 
23549156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
23559156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
23569156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
23579156SDaniel.Beauregard@Sun.COM 		}
23589156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
23599156SDaniel.Beauregard@Sun.COM 	}
23609156SDaniel.Beauregard@Sun.COM 
23619156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
23629156SDaniel.Beauregard@Sun.COM 
23639156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
23649156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
23659156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
23669156SDaniel.Beauregard@Sun.COM 		}
23679156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
23689156SDaniel.Beauregard@Sun.COM 	}
23699156SDaniel.Beauregard@Sun.COM 
23709156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
23719156SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
23729156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
23739156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
23749156SDaniel.Beauregard@Sun.COM 
23759156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
23769156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
23779156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
23789156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
23799156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
23809156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
23819156SDaniel.Beauregard@Sun.COM 			}
23829156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
23839156SDaniel.Beauregard@Sun.COM 		}
23849156SDaniel.Beauregard@Sun.COM 	}
23859156SDaniel.Beauregard@Sun.COM 
23869156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
23879156SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
23889156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
23899156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
23909156SDaniel.Beauregard@Sun.COM 
23919156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
23929156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
23939156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
23949156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
23959156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
23969156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
23979156SDaniel.Beauregard@Sun.COM 			}
23989156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
23999156SDaniel.Beauregard@Sun.COM 		}
24009156SDaniel.Beauregard@Sun.COM 	}
24019156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
24027836SJohn.Forte@Sun.COM 
24037836SJohn.Forte@Sun.COM 	return (DCMD_OK);
24047836SJohn.Forte@Sun.COM }
24057836SJohn.Forte@Sun.COM 
24067836SJohn.Forte@Sun.COM /*
24077836SJohn.Forte@Sun.COM  * ql_25xx_dump_dcmd
24087836SJohn.Forte@Sun.COM  *	prints out a firmware dump buffer
24097836SJohn.Forte@Sun.COM  *
24107836SJohn.Forte@Sun.COM  * Input:
24117836SJohn.Forte@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
24127836SJohn.Forte@Sun.COM  *	flags = mdb flags.
24137836SJohn.Forte@Sun.COM  *	argc  = Number of user supplied args.
24147836SJohn.Forte@Sun.COM  *	argv  = Arg array.
24157836SJohn.Forte@Sun.COM  *
24167836SJohn.Forte@Sun.COM  * Returns:
24177836SJohn.Forte@Sun.COM  *	DCMD_OK or DCMD_ERR
24187836SJohn.Forte@Sun.COM  *
24197836SJohn.Forte@Sun.COM  * Context:
24207836SJohn.Forte@Sun.COM  *	User context.
24217836SJohn.Forte@Sun.COM  *
24227836SJohn.Forte@Sun.COM  */
24237836SJohn.Forte@Sun.COM /*ARGSUSED*/
24247836SJohn.Forte@Sun.COM static int
24257836SJohn.Forte@Sun.COM ql_25xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
24267836SJohn.Forte@Sun.COM     const mdb_arg_t *argv)
24277836SJohn.Forte@Sun.COM {
24287836SJohn.Forte@Sun.COM 	ql_25xx_fw_dump_t	*fw;
24297836SJohn.Forte@Sun.COM 	uint32_t		cnt = 0;
24307836SJohn.Forte@Sun.COM 
24319156SDaniel.Beauregard@Sun.COM 	fw = (ql_25xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
24329156SDaniel.Beauregard@Sun.COM 
24339156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
24349156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
24357836SJohn.Forte@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
24369156SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
24377836SJohn.Forte@Sun.COM 		return (DCMD_OK);
24387836SJohn.Forte@Sun.COM 	}
24397836SJohn.Forte@Sun.COM 
24409156SDaniel.Beauregard@Sun.COM 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
24417836SJohn.Forte@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
24427836SJohn.Forte@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
24437836SJohn.Forte@Sun.COM 
24447836SJohn.Forte@Sun.COM 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
24457836SJohn.Forte@Sun.COM 
24469156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHostRisc Registers");
24477836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
24487836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24497836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24507836SJohn.Forte@Sun.COM 		}
24517836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
24527836SJohn.Forte@Sun.COM 	}
24537836SJohn.Forte@Sun.COM 
24549156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nPCIe Registers");
24557836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
24567836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24577836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24587836SJohn.Forte@Sun.COM 		}
24597836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
24607836SJohn.Forte@Sun.COM 	}
24617836SJohn.Forte@Sun.COM 
24629156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHost Interface Registers");
24637836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
24647836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24657836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24667836SJohn.Forte@Sun.COM 		}
24677836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
24687836SJohn.Forte@Sun.COM 	}
24697836SJohn.Forte@Sun.COM 
24709156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nShadow Registers");
24719156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
24729156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
24739156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
24749156SDaniel.Beauregard@Sun.COM 		}
24759156SDaniel.Beauregard@Sun.COM 
24769156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
24779156SDaniel.Beauregard@Sun.COM 	}
24789156SDaniel.Beauregard@Sun.COM 
24797836SJohn.Forte@Sun.COM 	mdb_printf("\n\nMailbox Registers");
24807836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
24817836SJohn.Forte@Sun.COM 		if (cnt % 16 == 0) {
24827836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24837836SJohn.Forte@Sun.COM 		}
24847836SJohn.Forte@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
24857836SJohn.Forte@Sun.COM 	}
24867836SJohn.Forte@Sun.COM 
24877836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
24887836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
24897836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24907836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24917836SJohn.Forte@Sun.COM 		}
24927836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
24937836SJohn.Forte@Sun.COM 	}
24947836SJohn.Forte@Sun.COM 
24957836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
24967836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
24977836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
24987836SJohn.Forte@Sun.COM 			mdb_printf("\n");
24997836SJohn.Forte@Sun.COM 		}
25007836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
25017836SJohn.Forte@Sun.COM 	}
25027836SJohn.Forte@Sun.COM 
25037836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
25047836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
25057836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25067836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25077836SJohn.Forte@Sun.COM 		}
25087836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
25097836SJohn.Forte@Sun.COM 	}
25107836SJohn.Forte@Sun.COM 
25117836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
25127836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
25137836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25147836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25157836SJohn.Forte@Sun.COM 		}
25167836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
25177836SJohn.Forte@Sun.COM 	}
25187836SJohn.Forte@Sun.COM 
25197836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
25207836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
25217836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25227836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25237836SJohn.Forte@Sun.COM 		}
25247836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
25257836SJohn.Forte@Sun.COM 	}
25267836SJohn.Forte@Sun.COM 
25277836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
25287836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
25297836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25307836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25317836SJohn.Forte@Sun.COM 		}
25327836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
25337836SJohn.Forte@Sun.COM 	}
25347836SJohn.Forte@Sun.COM 
25357836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
25367836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
25377836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25387836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25397836SJohn.Forte@Sun.COM 		}
25407836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
25417836SJohn.Forte@Sun.COM 	}
25427836SJohn.Forte@Sun.COM 
25437836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ GP Registers");
25447836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
25457836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25467836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25477836SJohn.Forte@Sun.COM 		}
25487836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
25497836SJohn.Forte@Sun.COM 	}
25507836SJohn.Forte@Sun.COM 
25517836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-0 GP Registers");
25527836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
25537836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25547836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25557836SJohn.Forte@Sun.COM 		}
25567836SJohn.Forte@Sun.COM 
25577836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
25587836SJohn.Forte@Sun.COM 	}
25597836SJohn.Forte@Sun.COM 
25607836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-1 GP Registers");
25617836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
25627836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25637836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25647836SJohn.Forte@Sun.COM 		}
25657836SJohn.Forte@Sun.COM 
25667836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
25677836SJohn.Forte@Sun.COM 	}
25687836SJohn.Forte@Sun.COM 
25697836SJohn.Forte@Sun.COM 	mdb_printf("\n\nASEQ-2 GP Registers");
25707836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
25717836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25727836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25737836SJohn.Forte@Sun.COM 		}
25747836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
25757836SJohn.Forte@Sun.COM 	}
25767836SJohn.Forte@Sun.COM 
25777836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
25787836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
25797836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25807836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25817836SJohn.Forte@Sun.COM 		}
25827836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
25837836SJohn.Forte@Sun.COM 	}
25847836SJohn.Forte@Sun.COM 
25857836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
25867836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
25877836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25887836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25897836SJohn.Forte@Sun.COM 		}
25907836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
25917836SJohn.Forte@Sun.COM 	}
25927836SJohn.Forte@Sun.COM 
25937836SJohn.Forte@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
25947836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
25957836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
25967836SJohn.Forte@Sun.COM 			mdb_printf("\n");
25977836SJohn.Forte@Sun.COM 		}
25987836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
25997836SJohn.Forte@Sun.COM 	}
26007836SJohn.Forte@Sun.COM 
26017836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
26027836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
26037836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26047836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26057836SJohn.Forte@Sun.COM 		}
26067836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
26077836SJohn.Forte@Sun.COM 	}
26087836SJohn.Forte@Sun.COM 
26097836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
26107836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
26117836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26127836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26137836SJohn.Forte@Sun.COM 		}
26147836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
26157836SJohn.Forte@Sun.COM 	}
26167836SJohn.Forte@Sun.COM 
26177836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
26187836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
26197836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26207836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26217836SJohn.Forte@Sun.COM 		}
26227836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
26237836SJohn.Forte@Sun.COM 	}
26247836SJohn.Forte@Sun.COM 
26257836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
26267836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
26277836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26287836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26297836SJohn.Forte@Sun.COM 		}
26307836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
26317836SJohn.Forte@Sun.COM 	}
26327836SJohn.Forte@Sun.COM 
26337836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
26347836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
26357836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26367836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26377836SJohn.Forte@Sun.COM 		}
26387836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
26397836SJohn.Forte@Sun.COM 	}
26407836SJohn.Forte@Sun.COM 
26417836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
26427836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
26437836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26447836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26457836SJohn.Forte@Sun.COM 		}
26467836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
26477836SJohn.Forte@Sun.COM 	}
26487836SJohn.Forte@Sun.COM 
26497836SJohn.Forte@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
26507836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
26517836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26527836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26537836SJohn.Forte@Sun.COM 		}
26547836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
26557836SJohn.Forte@Sun.COM 	}
26567836SJohn.Forte@Sun.COM 
26577836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
26587836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
26597836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26607836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26617836SJohn.Forte@Sun.COM 		}
26627836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
26637836SJohn.Forte@Sun.COM 	}
26647836SJohn.Forte@Sun.COM 
26657836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
26667836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
26677836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26687836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26697836SJohn.Forte@Sun.COM 		}
26707836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
26717836SJohn.Forte@Sun.COM 	}
26727836SJohn.Forte@Sun.COM 
26737836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
26747836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
26757836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26767836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26777836SJohn.Forte@Sun.COM 		}
26787836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
26797836SJohn.Forte@Sun.COM 	}
26807836SJohn.Forte@Sun.COM 
26817836SJohn.Forte@Sun.COM 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
26827836SJohn.Forte@Sun.COM 
26837836SJohn.Forte@Sun.COM 	mdb_printf("\n\nLMC Registers");
26847836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
26857836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26867836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26877836SJohn.Forte@Sun.COM 		}
26887836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
26897836SJohn.Forte@Sun.COM 	}
26907836SJohn.Forte@Sun.COM 
26917836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
26927836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
26937836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
26947836SJohn.Forte@Sun.COM 			mdb_printf("\n");
26957836SJohn.Forte@Sun.COM 		}
26967836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
26977836SJohn.Forte@Sun.COM 	}
26987836SJohn.Forte@Sun.COM 
26997836SJohn.Forte@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
27007836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
27017836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27027836SJohn.Forte@Sun.COM 			mdb_printf("\n");
27037836SJohn.Forte@Sun.COM 		}
27047836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
27057836SJohn.Forte@Sun.COM 	}
27067836SJohn.Forte@Sun.COM 
27077836SJohn.Forte@Sun.COM 	mdb_printf("\n\nCode RAM");
27087836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
27097836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27107836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
27117836SJohn.Forte@Sun.COM 		}
27127836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
27137836SJohn.Forte@Sun.COM 	}
27147836SJohn.Forte@Sun.COM 
27157836SJohn.Forte@Sun.COM 	mdb_printf("\n\nExternal Memory");
27167836SJohn.Forte@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
27177836SJohn.Forte@Sun.COM 		if (cnt % 8 == 0) {
27187836SJohn.Forte@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
27197836SJohn.Forte@Sun.COM 		}
27207836SJohn.Forte@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
27217836SJohn.Forte@Sun.COM 	}
27227836SJohn.Forte@Sun.COM 
27237836SJohn.Forte@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
27247836SJohn.Forte@Sun.COM 
27259156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
27269156SDaniel.Beauregard@Sun.COM 
27279156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
27289156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
27299156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
27309156SDaniel.Beauregard@Sun.COM 		}
27319156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
27329156SDaniel.Beauregard@Sun.COM 	}
27339156SDaniel.Beauregard@Sun.COM 
27349156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
27359156SDaniel.Beauregard@Sun.COM 
27369156SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
27379156SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
27389156SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
27399156SDaniel.Beauregard@Sun.COM 		}
27409156SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
27419156SDaniel.Beauregard@Sun.COM 	}
27429156SDaniel.Beauregard@Sun.COM 
27439156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
27449156SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
27459156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
27469156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
27479156SDaniel.Beauregard@Sun.COM 
27489156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
27499156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
27509156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
27519156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
27529156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
27539156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
27549156SDaniel.Beauregard@Sun.COM 			}
27559156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
27569156SDaniel.Beauregard@Sun.COM 		}
27579156SDaniel.Beauregard@Sun.COM 	}
27589156SDaniel.Beauregard@Sun.COM 
27599156SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
27609156SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
27619156SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
27629156SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
27639156SDaniel.Beauregard@Sun.COM 
27649156SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
27659156SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
27669156SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
27679156SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
27689156SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
27699156SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
27709156SDaniel.Beauregard@Sun.COM 			}
27719156SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
27729156SDaniel.Beauregard@Sun.COM 		}
27739156SDaniel.Beauregard@Sun.COM 	}
27749156SDaniel.Beauregard@Sun.COM 
27759156SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
27769156SDaniel.Beauregard@Sun.COM 
27779156SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nreturn exit\n");
27787836SJohn.Forte@Sun.COM 
27797836SJohn.Forte@Sun.COM 	return (DCMD_OK);
27807836SJohn.Forte@Sun.COM }
27817836SJohn.Forte@Sun.COM 
27827836SJohn.Forte@Sun.COM /*
2783*10736SDaniel.Beauregard@Sun.COM  * ql_81xx_dump_dcmd
2784*10736SDaniel.Beauregard@Sun.COM  *	prints out a firmware dump buffer
2785*10736SDaniel.Beauregard@Sun.COM  *
2786*10736SDaniel.Beauregard@Sun.COM  * Input:
2787*10736SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: nust be an ha)
2788*10736SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
2789*10736SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
2790*10736SDaniel.Beauregard@Sun.COM  *	argv  = Arg array.
2791*10736SDaniel.Beauregard@Sun.COM  *
2792*10736SDaniel.Beauregard@Sun.COM  * Returns:
2793*10736SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
2794*10736SDaniel.Beauregard@Sun.COM  *
2795*10736SDaniel.Beauregard@Sun.COM  * Context:
2796*10736SDaniel.Beauregard@Sun.COM  *	User context.
2797*10736SDaniel.Beauregard@Sun.COM  *
2798*10736SDaniel.Beauregard@Sun.COM  */
2799*10736SDaniel.Beauregard@Sun.COM /*ARGSUSED*/
2800*10736SDaniel.Beauregard@Sun.COM static int
2801*10736SDaniel.Beauregard@Sun.COM ql_81xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
2802*10736SDaniel.Beauregard@Sun.COM     const mdb_arg_t *argv)
2803*10736SDaniel.Beauregard@Sun.COM {
2804*10736SDaniel.Beauregard@Sun.COM 	ql_81xx_fw_dump_t	*fw;
2805*10736SDaniel.Beauregard@Sun.COM 	uint32_t		cnt = 0;
2806*10736SDaniel.Beauregard@Sun.COM 
2807*10736SDaniel.Beauregard@Sun.COM 	fw = (ql_81xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
2808*10736SDaniel.Beauregard@Sun.COM 
2809*10736SDaniel.Beauregard@Sun.COM 	if (mdb_vread(fw, ha->ql_dump_size,
2810*10736SDaniel.Beauregard@Sun.COM 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
2811*10736SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
2812*10736SDaniel.Beauregard@Sun.COM 		mdb_free(fw, ha->ql_dump_size);
2813*10736SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
2814*10736SDaniel.Beauregard@Sun.COM 	}
2815*10736SDaniel.Beauregard@Sun.COM 
2816*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
2817*10736SDaniel.Beauregard@Sun.COM 	    ha->fw_major_version, ha->fw_minor_version,
2818*10736SDaniel.Beauregard@Sun.COM 	    ha->fw_subminor_version, ha->fw_attributes);
2819*10736SDaniel.Beauregard@Sun.COM 
2820*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
2821*10736SDaniel.Beauregard@Sun.COM 
2822*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHostRisc Registers");
2823*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
2824*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2825*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2826*10736SDaniel.Beauregard@Sun.COM 		}
2827*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
2828*10736SDaniel.Beauregard@Sun.COM 	}
2829*10736SDaniel.Beauregard@Sun.COM 
2830*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nPCIe Registers");
2831*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
2832*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2833*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2834*10736SDaniel.Beauregard@Sun.COM 		}
2835*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
2836*10736SDaniel.Beauregard@Sun.COM 	}
2837*10736SDaniel.Beauregard@Sun.COM 
2838*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nHost Interface Registers");
2839*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
2840*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2841*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2842*10736SDaniel.Beauregard@Sun.COM 		}
2843*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->host_reg[cnt]);
2844*10736SDaniel.Beauregard@Sun.COM 	}
2845*10736SDaniel.Beauregard@Sun.COM 
2846*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nShadow Registers");
2847*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
2848*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2849*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2850*10736SDaniel.Beauregard@Sun.COM 		}
2851*10736SDaniel.Beauregard@Sun.COM 
2852*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
2853*10736SDaniel.Beauregard@Sun.COM 	}
2854*10736SDaniel.Beauregard@Sun.COM 
2855*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nMailbox Registers");
2856*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
2857*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 16 == 0) {
2858*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2859*10736SDaniel.Beauregard@Sun.COM 		}
2860*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
2861*10736SDaniel.Beauregard@Sun.COM 	}
2862*10736SDaniel.Beauregard@Sun.COM 
2863*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ GP Registers");
2864*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
2865*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2866*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2867*10736SDaniel.Beauregard@Sun.COM 		}
2868*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
2869*10736SDaniel.Beauregard@Sun.COM 	}
2870*10736SDaniel.Beauregard@Sun.COM 
2871*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ-0 Registers");
2872*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
2873*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2874*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2875*10736SDaniel.Beauregard@Sun.COM 		}
2876*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
2877*10736SDaniel.Beauregard@Sun.COM 	}
2878*10736SDaniel.Beauregard@Sun.COM 
2879*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXSEQ-1 Registers");
2880*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
2881*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2882*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2883*10736SDaniel.Beauregard@Sun.COM 		}
2884*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
2885*10736SDaniel.Beauregard@Sun.COM 	}
2886*10736SDaniel.Beauregard@Sun.COM 
2887*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ GP Registers");
2888*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
2889*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2890*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2891*10736SDaniel.Beauregard@Sun.COM 		}
2892*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
2893*10736SDaniel.Beauregard@Sun.COM 	}
2894*10736SDaniel.Beauregard@Sun.COM 
2895*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-0 Registers");
2896*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
2897*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2898*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2899*10736SDaniel.Beauregard@Sun.COM 		}
2900*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
2901*10736SDaniel.Beauregard@Sun.COM 	}
2902*10736SDaniel.Beauregard@Sun.COM 
2903*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-1 Registers");
2904*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
2905*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2906*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2907*10736SDaniel.Beauregard@Sun.COM 		}
2908*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
2909*10736SDaniel.Beauregard@Sun.COM 	}
2910*10736SDaniel.Beauregard@Sun.COM 
2911*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRSEQ-2 Registers");
2912*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
2913*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2914*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2915*10736SDaniel.Beauregard@Sun.COM 		}
2916*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
2917*10736SDaniel.Beauregard@Sun.COM 	}
2918*10736SDaniel.Beauregard@Sun.COM 
2919*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ GP Registers");
2920*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
2921*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2922*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2923*10736SDaniel.Beauregard@Sun.COM 		}
2924*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
2925*10736SDaniel.Beauregard@Sun.COM 	}
2926*10736SDaniel.Beauregard@Sun.COM 
2927*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-0 GP Registers");
2928*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
2929*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2930*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2931*10736SDaniel.Beauregard@Sun.COM 		}
2932*10736SDaniel.Beauregard@Sun.COM 
2933*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
2934*10736SDaniel.Beauregard@Sun.COM 	}
2935*10736SDaniel.Beauregard@Sun.COM 
2936*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-1 GP Registers");
2937*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
2938*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2939*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2940*10736SDaniel.Beauregard@Sun.COM 		}
2941*10736SDaniel.Beauregard@Sun.COM 
2942*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
2943*10736SDaniel.Beauregard@Sun.COM 	}
2944*10736SDaniel.Beauregard@Sun.COM 
2945*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nASEQ-2 GP Registers");
2946*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
2947*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2948*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2949*10736SDaniel.Beauregard@Sun.COM 		}
2950*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
2951*10736SDaniel.Beauregard@Sun.COM 	}
2952*10736SDaniel.Beauregard@Sun.COM 
2953*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nCommand DMA Registers");
2954*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
2955*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2956*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2957*10736SDaniel.Beauregard@Sun.COM 		}
2958*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
2959*10736SDaniel.Beauregard@Sun.COM 	}
2960*10736SDaniel.Beauregard@Sun.COM 
2961*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
2962*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
2963*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2964*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2965*10736SDaniel.Beauregard@Sun.COM 		}
2966*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
2967*10736SDaniel.Beauregard@Sun.COM 	}
2968*10736SDaniel.Beauregard@Sun.COM 
2969*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
2970*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
2971*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2972*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2973*10736SDaniel.Beauregard@Sun.COM 		}
2974*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
2975*10736SDaniel.Beauregard@Sun.COM 	}
2976*10736SDaniel.Beauregard@Sun.COM 
2977*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
2978*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
2979*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2980*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2981*10736SDaniel.Beauregard@Sun.COM 		}
2982*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
2983*10736SDaniel.Beauregard@Sun.COM 	}
2984*10736SDaniel.Beauregard@Sun.COM 
2985*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT0 Data DMA Registers");
2986*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
2987*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2988*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2989*10736SDaniel.Beauregard@Sun.COM 		}
2990*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
2991*10736SDaniel.Beauregard@Sun.COM 	}
2992*10736SDaniel.Beauregard@Sun.COM 
2993*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT1 Data DMA Registers");
2994*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
2995*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
2996*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
2997*10736SDaniel.Beauregard@Sun.COM 		}
2998*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
2999*10736SDaniel.Beauregard@Sun.COM 	}
3000*10736SDaniel.Beauregard@Sun.COM 
3001*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT2 Data DMA Registers");
3002*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
3003*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3004*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3005*10736SDaniel.Beauregard@Sun.COM 		}
3006*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
3007*10736SDaniel.Beauregard@Sun.COM 	}
3008*10736SDaniel.Beauregard@Sun.COM 
3009*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT3 Data DMA Registers");
3010*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
3011*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3012*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3013*10736SDaniel.Beauregard@Sun.COM 		}
3014*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
3015*10736SDaniel.Beauregard@Sun.COM 	}
3016*10736SDaniel.Beauregard@Sun.COM 
3017*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT4 Data DMA Registers");
3018*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
3019*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3020*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3021*10736SDaniel.Beauregard@Sun.COM 		}
3022*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
3023*10736SDaniel.Beauregard@Sun.COM 	}
3024*10736SDaniel.Beauregard@Sun.COM 
3025*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nXMT Data DMA Common Registers");
3026*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
3027*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3028*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3029*10736SDaniel.Beauregard@Sun.COM 		}
3030*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
3031*10736SDaniel.Beauregard@Sun.COM 	}
3032*10736SDaniel.Beauregard@Sun.COM 
3033*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
3034*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
3035*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3036*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3037*10736SDaniel.Beauregard@Sun.COM 		}
3038*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
3039*10736SDaniel.Beauregard@Sun.COM 	}
3040*10736SDaniel.Beauregard@Sun.COM 
3041*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
3042*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
3043*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3044*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3045*10736SDaniel.Beauregard@Sun.COM 		}
3046*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
3047*10736SDaniel.Beauregard@Sun.COM 	}
3048*10736SDaniel.Beauregard@Sun.COM 
3049*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRISC GP Registers");
3050*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
3051*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3052*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3053*10736SDaniel.Beauregard@Sun.COM 		}
3054*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
3055*10736SDaniel.Beauregard@Sun.COM 	}
3056*10736SDaniel.Beauregard@Sun.COM 
3057*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
3058*10736SDaniel.Beauregard@Sun.COM 
3059*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nLMC Registers");
3060*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
3061*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3062*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3063*10736SDaniel.Beauregard@Sun.COM 		}
3064*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
3065*10736SDaniel.Beauregard@Sun.COM 	}
3066*10736SDaniel.Beauregard@Sun.COM 
3067*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nFPM Hardware Registers");
3068*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
3069*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3070*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3071*10736SDaniel.Beauregard@Sun.COM 		}
3072*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
3073*10736SDaniel.Beauregard@Sun.COM 	}
3074*10736SDaniel.Beauregard@Sun.COM 
3075*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nFB Hardware Registers");
3076*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
3077*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3078*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n");
3079*10736SDaniel.Beauregard@Sun.COM 		}
3080*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
3081*10736SDaniel.Beauregard@Sun.COM 	}
3082*10736SDaniel.Beauregard@Sun.COM 
3083*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nCode RAM");
3084*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
3085*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3086*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x20000);
3087*10736SDaniel.Beauregard@Sun.COM 		}
3088*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->code_ram[cnt]);
3089*10736SDaniel.Beauregard@Sun.COM 	}
3090*10736SDaniel.Beauregard@Sun.COM 
3091*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nExternal Memory");
3092*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
3093*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3094*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt + 0x100000);
3095*10736SDaniel.Beauregard@Sun.COM 		}
3096*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->ext_mem[cnt]);
3097*10736SDaniel.Beauregard@Sun.COM 	}
3098*10736SDaniel.Beauregard@Sun.COM 
3099*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n[<==END] ISP Debug Dump");
3100*10736SDaniel.Beauregard@Sun.COM 
3101*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nRequest Queue");
3102*10736SDaniel.Beauregard@Sun.COM 
3103*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
3104*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3105*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
3106*10736SDaniel.Beauregard@Sun.COM 		}
3107*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->req_q[cnt]);
3108*10736SDaniel.Beauregard@Sun.COM 	}
3109*10736SDaniel.Beauregard@Sun.COM 
3110*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nResponse Queue");
3111*10736SDaniel.Beauregard@Sun.COM 
3112*10736SDaniel.Beauregard@Sun.COM 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
3113*10736SDaniel.Beauregard@Sun.COM 		if (cnt % 8 == 0) {
3114*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("\n%08x: ", cnt);
3115*10736SDaniel.Beauregard@Sun.COM 		}
3116*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("%08x ", fw->rsp_q[cnt]);
3117*10736SDaniel.Beauregard@Sun.COM 	}
3118*10736SDaniel.Beauregard@Sun.COM 
3119*10736SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
3120*10736SDaniel.Beauregard@Sun.COM 	    (ha->fwexttracebuf.bp != NULL)) {
3121*10736SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
3122*10736SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwexttracebuf.bp;
3123*10736SDaniel.Beauregard@Sun.COM 
3124*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nExtended Trace Buffer Memory");
3125*10736SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
3126*10736SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
3127*10736SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
3128*10736SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
3129*10736SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
3130*10736SDaniel.Beauregard@Sun.COM 			}
3131*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
3132*10736SDaniel.Beauregard@Sun.COM 		}
3133*10736SDaniel.Beauregard@Sun.COM 	}
3134*10736SDaniel.Beauregard@Sun.COM 
3135*10736SDaniel.Beauregard@Sun.COM 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
3136*10736SDaniel.Beauregard@Sun.COM 	    (ha->fwfcetracebuf.bp != NULL)) {
3137*10736SDaniel.Beauregard@Sun.COM 		uint32_t cnt_b = 0;
3138*10736SDaniel.Beauregard@Sun.COM 		uint32_t *w32 = ha->fwfcetracebuf.bp;
3139*10736SDaniel.Beauregard@Sun.COM 
3140*10736SDaniel.Beauregard@Sun.COM 		mdb_printf("\n\nFC Event Trace Buffer Memory");
3141*10736SDaniel.Beauregard@Sun.COM 		/* show data address as a byte address, data as long words */
3142*10736SDaniel.Beauregard@Sun.COM 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
3143*10736SDaniel.Beauregard@Sun.COM 			cnt_b = cnt * 4;
3144*10736SDaniel.Beauregard@Sun.COM 			if (cnt_b % 32 == 0) {
3145*10736SDaniel.Beauregard@Sun.COM 				mdb_printf("\n%08x: ", w32 + cnt_b);
3146*10736SDaniel.Beauregard@Sun.COM 			}
3147*10736SDaniel.Beauregard@Sun.COM 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
3148*10736SDaniel.Beauregard@Sun.COM 		}
3149*10736SDaniel.Beauregard@Sun.COM 	}
3150*10736SDaniel.Beauregard@Sun.COM 
3151*10736SDaniel.Beauregard@Sun.COM 	mdb_free(fw, ha->ql_dump_size);
3152*10736SDaniel.Beauregard@Sun.COM 
3153*10736SDaniel.Beauregard@Sun.COM 	mdb_printf("\n\nreturn exit\n");
3154*10736SDaniel.Beauregard@Sun.COM 
3155*10736SDaniel.Beauregard@Sun.COM 	return (DCMD_OK);
3156*10736SDaniel.Beauregard@Sun.COM }
3157*10736SDaniel.Beauregard@Sun.COM 
3158*10736SDaniel.Beauregard@Sun.COM /*
31599156SDaniel.Beauregard@Sun.COM  * ql_gettrace_dcmd
31609156SDaniel.Beauregard@Sun.COM  *	prints out the Extended Logging trace buffer
31619156SDaniel.Beauregard@Sun.COM  *
31629156SDaniel.Beauregard@Sun.COM  * Input:
31639156SDaniel.Beauregard@Sun.COM  *	addr  = User supplied address. (NB: must be an ha)
31649156SDaniel.Beauregard@Sun.COM  *	flags = mdb flags.
31659156SDaniel.Beauregard@Sun.COM  *	argc  = Number of user supplied args.
31669156SDaniel.Beauregard@Sun.COM  *	argv  = Arg array.
31679156SDaniel.Beauregard@Sun.COM  *
31689156SDaniel.Beauregard@Sun.COM  * Returns:
31699156SDaniel.Beauregard@Sun.COM  *	DCMD_OK or DCMD_ERR
31709156SDaniel.Beauregard@Sun.COM  *
31719156SDaniel.Beauregard@Sun.COM  * Context:
31729156SDaniel.Beauregard@Sun.COM  *	User context.
31739156SDaniel.Beauregard@Sun.COM  *
31749156SDaniel.Beauregard@Sun.COM  */
31759156SDaniel.Beauregard@Sun.COM static int
31769156SDaniel.Beauregard@Sun.COM qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
31779156SDaniel.Beauregard@Sun.COM {
31789156SDaniel.Beauregard@Sun.COM 	ql_adapter_state_t	*ha;
31799156SDaniel.Beauregard@Sun.COM 	int			verbose = 0;
31809156SDaniel.Beauregard@Sun.COM 	int			wrapped = 0;
31819156SDaniel.Beauregard@Sun.COM 	char			*trace_start;
31829156SDaniel.Beauregard@Sun.COM 	char			*trace_end;
31839156SDaniel.Beauregard@Sun.COM 	char			*dump_start = 0;
31849156SDaniel.Beauregard@Sun.COM 	char			*trace_next  = 0;
31859156SDaniel.Beauregard@Sun.COM 	char			*dump_current  = 0;
31869156SDaniel.Beauregard@Sun.COM 	el_trace_desc_t		*trace_desc;
31879156SDaniel.Beauregard@Sun.COM 
31889156SDaniel.Beauregard@Sun.COM 	if ((!(flags & DCMD_ADDRSPEC)) || addr == NULL) {
31899156SDaniel.Beauregard@Sun.COM 		mdb_warn("ql_adapter_state structure addr is required");
31909156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
31919156SDaniel.Beauregard@Sun.COM 	}
31929156SDaniel.Beauregard@Sun.COM 
31939156SDaniel.Beauregard@Sun.COM 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
31949156SDaniel.Beauregard@Sun.COM 	    argc) {
31959156SDaniel.Beauregard@Sun.COM 		return (DCMD_USAGE);
31969156SDaniel.Beauregard@Sun.COM 	}
31979156SDaniel.Beauregard@Sun.COM 
31989156SDaniel.Beauregard@Sun.COM 	/*
31999156SDaniel.Beauregard@Sun.COM 	 * Get the adapter state struct which was passed
32009156SDaniel.Beauregard@Sun.COM 	 */
32019156SDaniel.Beauregard@Sun.COM 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
32029156SDaniel.Beauregard@Sun.COM 	    UM_SLEEP)) == NULL) {
32039156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
32049156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32059156SDaniel.Beauregard@Sun.COM 	}
32069156SDaniel.Beauregard@Sun.COM 
32079156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
32089156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read ql_adapter_state at %p", addr);
32099156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32109156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32119156SDaniel.Beauregard@Sun.COM 	}
32129156SDaniel.Beauregard@Sun.COM 
32139156SDaniel.Beauregard@Sun.COM 	/*
32149156SDaniel.Beauregard@Sun.COM 	 * If its not a valid trace descriptor then bail out
32159156SDaniel.Beauregard@Sun.COM 	 */
32169156SDaniel.Beauregard@Sun.COM 	if (ha->el_trace_desc == NULL) {
32179156SDaniel.Beauregard@Sun.COM 		mdb_warn("trace descriptor does not exist for instance %d\n",
32189156SDaniel.Beauregard@Sun.COM 		    ha->instance);
32199156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32209156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32219156SDaniel.Beauregard@Sun.COM 	} else {
32229156SDaniel.Beauregard@Sun.COM 		trace_desc = (el_trace_desc_t *)
32239156SDaniel.Beauregard@Sun.COM 		    mdb_alloc(sizeof (el_trace_desc_t), UM_SLEEP);
32249156SDaniel.Beauregard@Sun.COM 		if (mdb_vread(trace_desc, sizeof (el_trace_desc_t),
32259156SDaniel.Beauregard@Sun.COM 		    (uintptr_t)ha->el_trace_desc) == -1) {
32269156SDaniel.Beauregard@Sun.COM 			mdb_warn("failed to read ql_adapter_state at %p",
32279156SDaniel.Beauregard@Sun.COM 			    addr);
32289156SDaniel.Beauregard@Sun.COM 			mdb_free(trace_desc, sizeof (el_trace_desc_t));
32299156SDaniel.Beauregard@Sun.COM 			mdb_free(ha, sizeof (ql_adapter_state_t));
32309156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
32319156SDaniel.Beauregard@Sun.COM 		}
32329156SDaniel.Beauregard@Sun.COM 		if (trace_desc->trace_buffer == NULL) {
32339156SDaniel.Beauregard@Sun.COM 			mdb_warn("trace buffer does not exist for "
32349156SDaniel.Beauregard@Sun.COM 			    "instance %d\n", ha->instance);
32359156SDaniel.Beauregard@Sun.COM 			mdb_free(trace_desc, sizeof (el_trace_desc_t));
32369156SDaniel.Beauregard@Sun.COM 			mdb_free(ha, sizeof (ql_adapter_state_t));
32379156SDaniel.Beauregard@Sun.COM 			return (DCMD_OK);
32389156SDaniel.Beauregard@Sun.COM 		}
32399156SDaniel.Beauregard@Sun.COM 	}
32409156SDaniel.Beauregard@Sun.COM 
32419156SDaniel.Beauregard@Sun.COM 	/* Get the trace buffer */
32429156SDaniel.Beauregard@Sun.COM 
32439156SDaniel.Beauregard@Sun.COM 	trace_start = (char *)
32449156SDaniel.Beauregard@Sun.COM 	    mdb_zalloc(trace_desc->trace_buffer_size, UM_SLEEP);
32459156SDaniel.Beauregard@Sun.COM 
32469156SDaniel.Beauregard@Sun.COM 	if (mdb_vread(trace_start, trace_desc->trace_buffer_size,
32479156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)trace_desc->trace_buffer) == -1) {
32489156SDaniel.Beauregard@Sun.COM 		mdb_warn("failed to read trace buffer?)");
32499156SDaniel.Beauregard@Sun.COM 		mdb_free(trace_start, trace_desc->trace_buffer_size);
32509156SDaniel.Beauregard@Sun.COM 		mdb_free(ha, sizeof (ql_adapter_state_t));
32519156SDaniel.Beauregard@Sun.COM 		return (DCMD_OK);
32529156SDaniel.Beauregard@Sun.COM 	}
32539156SDaniel.Beauregard@Sun.COM 
32549156SDaniel.Beauregard@Sun.COM 	/* set the end of the trace buffer. */
32559156SDaniel.Beauregard@Sun.COM 	trace_end = trace_start + trace_desc->trace_buffer_size;
32569156SDaniel.Beauregard@Sun.COM 
32579156SDaniel.Beauregard@Sun.COM 	/* Find the start point of trace. */
32589156SDaniel.Beauregard@Sun.COM 	trace_next = trace_start + trace_desc->next;
32599156SDaniel.Beauregard@Sun.COM 
32609156SDaniel.Beauregard@Sun.COM 	/*
32619156SDaniel.Beauregard@Sun.COM 	 * If the buffer has not wrapped next will point at a null so
32629156SDaniel.Beauregard@Sun.COM 	 * start is the begining of the buffer.  If next points at a char
32639156SDaniel.Beauregard@Sun.COM 	 * then we must traverse the buffer further until a null is detected.
32649156SDaniel.Beauregard@Sun.COM 	 * The location after the null will be the beginning of the oldest
32659156SDaniel.Beauregard@Sun.COM 	 * whole object in the buffer, which we use as the start.
32669156SDaniel.Beauregard@Sun.COM 	 */
32679156SDaniel.Beauregard@Sun.COM 
32689156SDaniel.Beauregard@Sun.COM 	if ((trace_next + EL_BUFFER_RESERVE) >= trace_end) {
32699156SDaniel.Beauregard@Sun.COM 		dump_start = trace_start;
32709156SDaniel.Beauregard@Sun.COM 	} else if (*trace_next != NULL) {
32719156SDaniel.Beauregard@Sun.COM 		dump_start = trace_next + (strlen(trace_next) + 1);
32729156SDaniel.Beauregard@Sun.COM 	} else {
32739156SDaniel.Beauregard@Sun.COM 		dump_start = trace_start;
32749156SDaniel.Beauregard@Sun.COM 	}
32759156SDaniel.Beauregard@Sun.COM 
32769156SDaniel.Beauregard@Sun.COM 	dump_current = dump_start;
32779156SDaniel.Beauregard@Sun.COM 
32789156SDaniel.Beauregard@Sun.COM 	mdb_printf("\nExtended Logging trace buffer @%x, start @%x, "
32799156SDaniel.Beauregard@Sun.COM 	    "size=%d\n\n", trace_start, dump_current,
32809156SDaniel.Beauregard@Sun.COM 	    trace_desc->trace_buffer_size);
32819156SDaniel.Beauregard@Sun.COM 
32829156SDaniel.Beauregard@Sun.COM 	/* Don't run off the end, no matter what. */
32839156SDaniel.Beauregard@Sun.COM 	while (((uintptr_t)dump_current - (uintptr_t)trace_start) <=
32849156SDaniel.Beauregard@Sun.COM 	    (uintptr_t)trace_desc->trace_buffer_size) {
32859156SDaniel.Beauregard@Sun.COM 		/* Show it... */
32869156SDaniel.Beauregard@Sun.COM 		mdb_printf("%s", dump_current);
32879156SDaniel.Beauregard@Sun.COM 		/* Calculate the next and make it the current */
32889156SDaniel.Beauregard@Sun.COM 		dump_current += (strlen(dump_current) + 1);
32899156SDaniel.Beauregard@Sun.COM 		/* check for wrap */
32909156SDaniel.Beauregard@Sun.COM 		if ((dump_current + EL_BUFFER_RESERVE) >= trace_end) {
32919156SDaniel.Beauregard@Sun.COM 			mdb_printf("Wraping %x\n", dump_current);
32929156SDaniel.Beauregard@Sun.COM 			dump_current = trace_start;
32939156SDaniel.Beauregard@Sun.COM 			wrapped = 1;
32949156SDaniel.Beauregard@Sun.COM 		} else if (wrapped) {
32959156SDaniel.Beauregard@Sun.COM 			/*   Don't go past next. */
32969156SDaniel.Beauregard@Sun.COM 			if ((trace_start + trace_desc->next) <= dump_current) {
32979156SDaniel.Beauregard@Sun.COM 				mdb_printf("Done %x", dump_current);
32989156SDaniel.Beauregard@Sun.COM 				break;
32999156SDaniel.Beauregard@Sun.COM 			}
33009156SDaniel.Beauregard@Sun.COM 		} else if (*dump_current == NULL) {
33019156SDaniel.Beauregard@Sun.COM 			mdb_printf("Done %x(null)", dump_current);
33029156SDaniel.Beauregard@Sun.COM 			break;
33039156SDaniel.Beauregard@Sun.COM 		}
33049156SDaniel.Beauregard@Sun.COM 	}
33059156SDaniel.Beauregard@Sun.COM 
33069156SDaniel.Beauregard@Sun.COM 	mdb_free(ha, sizeof (ql_adapter_state_t));
33079156SDaniel.Beauregard@Sun.COM 	mdb_free(trace_start, trace_desc->trace_buffer_size);
33089156SDaniel.Beauregard@Sun.COM 	mdb_free(trace_desc, sizeof (el_trace_desc_t));
33099156SDaniel.Beauregard@Sun.COM 
33109156SDaniel.Beauregard@Sun.COM 	return (DCMD_OK);
33119156SDaniel.Beauregard@Sun.COM }
33129156SDaniel.Beauregard@Sun.COM /*
33137836SJohn.Forte@Sun.COM  * ql_doprint
33147836SJohn.Forte@Sun.COM  *	ql generic function to call the print dcmd
33157836SJohn.Forte@Sun.COM  *
33167836SJohn.Forte@Sun.COM  * Input:
33177836SJohn.Forte@Sun.COM  *	addr - address to struct
33187836SJohn.Forte@Sun.COM  *	prtsting - address to string
33197836SJohn.Forte@Sun.COM  *
33207836SJohn.Forte@Sun.COM  * Returns:
33217836SJohn.Forte@Sun.COM  *	WALK_DONE
33227836SJohn.Forte@Sun.COM  *
33237836SJohn.Forte@Sun.COM  * Context:
33247836SJohn.Forte@Sun.COM  *	User context.
33257836SJohn.Forte@Sun.COM  *
33267836SJohn.Forte@Sun.COM  */
33277836SJohn.Forte@Sun.COM static int32_t
33287836SJohn.Forte@Sun.COM ql_doprint(uintptr_t addr, int8_t *prtstring)
33297836SJohn.Forte@Sun.COM {
33307836SJohn.Forte@Sun.COM 	struct	mdb_arg		printarg;
33317836SJohn.Forte@Sun.COM 
33327836SJohn.Forte@Sun.COM 	printarg.a_un.a_str = (int8_t *)(mdb_zalloc(strlen(prtstring),
33337836SJohn.Forte@Sun.COM 	    UM_SLEEP));
33347836SJohn.Forte@Sun.COM 	printarg.a_type = MDB_TYPE_STRING;
33357836SJohn.Forte@Sun.COM 	(void) strcpy((int8_t *)(printarg.a_un.a_str), prtstring);
33367836SJohn.Forte@Sun.COM 
33377836SJohn.Forte@Sun.COM 	if ((mdb_call_dcmd("print", addr, DCMD_ADDRSPEC, 1,
33387836SJohn.Forte@Sun.COM 	    &printarg)) == -1) {
33397836SJohn.Forte@Sun.COM 		mdb_warn("ql_doprint: failed print dcmd: %s"
33407836SJohn.Forte@Sun.COM 		    "at addr: %llxh", prtstring, addr);
33417836SJohn.Forte@Sun.COM 	}
33427836SJohn.Forte@Sun.COM 
33437836SJohn.Forte@Sun.COM 	mdb_free((void *)(printarg.a_un.a_str), strlen(prtstring));
33447836SJohn.Forte@Sun.COM 	return (WALK_DONE);
33457836SJohn.Forte@Sun.COM }
33467836SJohn.Forte@Sun.COM 
33477836SJohn.Forte@Sun.COM /*
33487836SJohn.Forte@Sun.COM  * ql_dump_flags
33497836SJohn.Forte@Sun.COM  *	mdb utility to print the flag string
33507836SJohn.Forte@Sun.COM  *
33517836SJohn.Forte@Sun.COM  * Input:
33527836SJohn.Forte@Sun.COM  *	flags - flags to print
33537836SJohn.Forte@Sun.COM  *	strings - text to print when flag is set
33547836SJohn.Forte@Sun.COM  *
33557836SJohn.Forte@Sun.COM  * Returns:
33567836SJohn.Forte@Sun.COM  *
33577836SJohn.Forte@Sun.COM  *
33587836SJohn.Forte@Sun.COM  * Context:
33597836SJohn.Forte@Sun.COM  *	User context.
33607836SJohn.Forte@Sun.COM  *
33617836SJohn.Forte@Sun.COM  */
33627836SJohn.Forte@Sun.COM static void
33637836SJohn.Forte@Sun.COM ql_dump_flags(uint64_t flags, int8_t **strings)
33647836SJohn.Forte@Sun.COM {
33657836SJohn.Forte@Sun.COM 	int		i, linel, first = 1;
33667836SJohn.Forte@Sun.COM 	uint64_t	mask = 1;
33677836SJohn.Forte@Sun.COM 
33687836SJohn.Forte@Sun.COM 	linel = 8;
33697836SJohn.Forte@Sun.COM 	mdb_printf("\t");
33707836SJohn.Forte@Sun.COM 	for (i = 0; i < 64; i++) {
33717836SJohn.Forte@Sun.COM 		if (strings[i] == NULL)
33727836SJohn.Forte@Sun.COM 			break;
33737836SJohn.Forte@Sun.COM 		if (flags & mask) {
33747836SJohn.Forte@Sun.COM 			if (!first) {
33757836SJohn.Forte@Sun.COM 				mdb_printf(" | ");
33767836SJohn.Forte@Sun.COM 			} else {
33777836SJohn.Forte@Sun.COM 				first = 0;
33787836SJohn.Forte@Sun.COM 			}
33797836SJohn.Forte@Sun.COM 			linel += (int32_t)strlen(strings[i]) + 3;
33807836SJohn.Forte@Sun.COM 			if (linel > 80) {
33817836SJohn.Forte@Sun.COM 				mdb_printf("\n\t");
33827836SJohn.Forte@Sun.COM 				linel = (int32_t)strlen(strings[i]) + 1 + 8;
33837836SJohn.Forte@Sun.COM 			}
33847836SJohn.Forte@Sun.COM 			mdb_printf("%s", strings[i]);
33857836SJohn.Forte@Sun.COM 		}
33867836SJohn.Forte@Sun.COM 		mask <<= 1;
33877836SJohn.Forte@Sun.COM 	}
33887836SJohn.Forte@Sun.COM 	mdb_printf("\n");
33897836SJohn.Forte@Sun.COM }
33907836SJohn.Forte@Sun.COM 
33917836SJohn.Forte@Sun.COM /*
33927836SJohn.Forte@Sun.COM  * MDB module linkage information
33937836SJohn.Forte@Sun.COM  *
33947836SJohn.Forte@Sun.COM  *
33957836SJohn.Forte@Sun.COM  * dcmd structures for the _mdb_init function
33967836SJohn.Forte@Sun.COM  */
33977836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = {
33987836SJohn.Forte@Sun.COM 	{ "qlclinks", NULL, "Prints qlc link information", qlclinks_dcmd },
33997836SJohn.Forte@Sun.COM 	{ "qlcosc", NULL, "Prints outstanding cmd info", qlc_osc_dcmd },
34007836SJohn.Forte@Sun.COM 	{ "qlcver", NULL, "Prints driver/mdb version", qlcver_dcmd },
34017836SJohn.Forte@Sun.COM 	{ "qlc_elog", "[on|off] [<inst #>|all]", "Turns qlc extended logging "
34027836SJohn.Forte@Sun.COM 	    "on / off", qlc_el_dcmd },
34037836SJohn.Forte@Sun.COM 	{ "qlcstate", ":[-v]", "Prints qlc adapter state information",
34047836SJohn.Forte@Sun.COM 	    qlcstate_dcmd },
34057836SJohn.Forte@Sun.COM 	{ "qlctgtq", NULL, "Prints qlc target queues", qltgtq_dcmd },
34067836SJohn.Forte@Sun.COM 	{ "qlcwdog", NULL, "Prints out watchdog linked list", qlc_wdog_dcmd},
34079156SDaniel.Beauregard@Sun.COM 	{ "qlcgetdump", ":[-v]", "Retrieves the ASCII f/w dump",
34089156SDaniel.Beauregard@Sun.COM 	    qlc_getdump_dcmd },
34099156SDaniel.Beauregard@Sun.COM 	{ "qlcgettrace", ":[-v]", "Retrieves the ASCII Extended Logging trace",
34109156SDaniel.Beauregard@Sun.COM 	    qlc_gettrace_dcmd },
34117836SJohn.Forte@Sun.COM 	{ NULL }
34127836SJohn.Forte@Sun.COM };
34137836SJohn.Forte@Sun.COM 
34147836SJohn.Forte@Sun.COM /*
34157836SJohn.Forte@Sun.COM  * walker structures for the _mdb_init function
34167836SJohn.Forte@Sun.COM  */
34177836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = {
34187836SJohn.Forte@Sun.COM 	{ "qlcstates", "walk list of qlc ql_state_t structures",
34197836SJohn.Forte@Sun.COM 	    qlstates_walk_init, qlstates_walk_step, qlstates_walk_fini },
34207836SJohn.Forte@Sun.COM 	{ "qlcsrbs", "walk list of qlc ql_srb_t strctures",
34217836SJohn.Forte@Sun.COM 	    qlsrb_walk_init, qlsrb_walk_step, qlsrb_walk_fini },
34227836SJohn.Forte@Sun.COM 	{ "qlclunq", "walk list of qlc ql_lun_t strctures",
34237836SJohn.Forte@Sun.COM 	    qllunq_walk_init, qllunq_walk_step, qllunq_walk_fini },
34247836SJohn.Forte@Sun.COM 	{ NULL }
34257836SJohn.Forte@Sun.COM };
34267836SJohn.Forte@Sun.COM 
34277836SJohn.Forte@Sun.COM static const mdb_modinfo_t ql_mdb_modinfo = {
34287836SJohn.Forte@Sun.COM 	MDB_API_VERSION, dcmds, walkers
34297836SJohn.Forte@Sun.COM };
34307836SJohn.Forte@Sun.COM 
34317836SJohn.Forte@Sun.COM /*
34327836SJohn.Forte@Sun.COM  * Registration function which lists the dcmds and walker structures
34337836SJohn.Forte@Sun.COM  */
34347836SJohn.Forte@Sun.COM const mdb_modinfo_t *
34357836SJohn.Forte@Sun.COM _mdb_init(void)
34367836SJohn.Forte@Sun.COM {
34377836SJohn.Forte@Sun.COM 	return (&ql_mdb_modinfo);
34387836SJohn.Forte@Sun.COM }
3439