xref: /illumos-gate/usr/src/cmd/mdb/common/modules/qlc/qlc.c (revision 4c3888b8)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte 
22*4c3888b8SHans Rosenfeld /* Copyright 2015 QLogic Corporation */
23fcf3ce44SJohn Forte 
24fcf3ce44SJohn Forte /*
25fcf3ce44SJohn Forte  * ISP2xxx Solaris Fibre Channel Adapter (FCA) qlc mdb source file.
26fcf3ce44SJohn Forte  *
27fcf3ce44SJohn Forte  * ***********************************************************************
28fcf3ce44SJohn Forte  * *									**
29fcf3ce44SJohn Forte  * *				NOTICE					**
30*4c3888b8SHans Rosenfeld  * *		COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION		**
31fcf3ce44SJohn Forte  * *			ALL RIGHTS RESERVED				**
32fcf3ce44SJohn Forte  * *									**
33fcf3ce44SJohn Forte  * ***********************************************************************
34fcf3ce44SJohn Forte  *
35fcf3ce44SJohn Forte  */
36fcf3ce44SJohn Forte 
373b442230SJordan Paige Hendricks /*
383b442230SJordan Paige Hendricks  * Copyright 2019 Joyent, Inc.
393b442230SJordan Paige Hendricks  */
403b442230SJordan Paige Hendricks 
41fcf3ce44SJohn Forte #include <sys/mdb_modapi.h>
4216dd44c2SDaniel Beauregard #include <ql_apps.h>
4316dd44c2SDaniel Beauregard #include <ql_api.h>
4416dd44c2SDaniel Beauregard #include <ql_init.h>
45fcf3ce44SJohn Forte 
46fcf3ce44SJohn Forte /*
47fcf3ce44SJohn Forte  * local prototypes
48fcf3ce44SJohn Forte  */
49fcf3ce44SJohn Forte static int32_t ql_doprint(uintptr_t, int8_t *);
50fcf3ce44SJohn Forte static void ql_dump_flags(uint64_t, int8_t **);
51fcf3ce44SJohn Forte static int qlclinks_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
52fcf3ce44SJohn Forte static int qlcstate_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
53fcf3ce44SJohn Forte static int qlc_osc_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
5416dd44c2SDaniel Beauregard static int qlc_wdog_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
5516dd44c2SDaniel Beauregard static int qlc_getdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
5616dd44c2SDaniel Beauregard static int qlc_gettrace_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
5716dd44c2SDaniel Beauregard #if 0
5816dd44c2SDaniel Beauregard static int qlc_triggerdump_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
5916dd44c2SDaniel Beauregard #endif
60fcf3ce44SJohn Forte static int qlcver_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
61fcf3ce44SJohn Forte static int qlstates_walk_init(mdb_walk_state_t *);
62fcf3ce44SJohn Forte static int qlstates_walk_step(mdb_walk_state_t *);
63fcf3ce44SJohn Forte static void qlstates_walk_fini(mdb_walk_state_t *);
64fcf3ce44SJohn Forte static int qlsrb_walk_init(mdb_walk_state_t *);
65fcf3ce44SJohn Forte static int qlsrb_walk_step(mdb_walk_state_t *);
66fcf3ce44SJohn Forte static void qlsrb_walk_fini(mdb_walk_state_t *);
67fcf3ce44SJohn Forte static int get_next_link(ql_link_t *);
68fcf3ce44SJohn Forte static int get_first_link(ql_head_t *, ql_link_t *);
69fcf3ce44SJohn Forte 
70fcf3ce44SJohn Forte static int ql_24xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
71fcf3ce44SJohn Forte     const mdb_arg_t *);
72fcf3ce44SJohn Forte static int ql_23xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
73fcf3ce44SJohn Forte     const mdb_arg_t *);
74fcf3ce44SJohn Forte static int ql_25xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
75fcf3ce44SJohn Forte     const mdb_arg_t *);
76f33c1cdbSDaniel Beauregard static int ql_81xx_dump_dcmd(ql_adapter_state_t *, uint_t, int,
77f33c1cdbSDaniel Beauregard     const mdb_arg_t *);
78*4c3888b8SHans Rosenfeld static int ql_8021_dump_dcmd(ql_adapter_state_t *, uint_t, int,
79*4c3888b8SHans Rosenfeld     const mdb_arg_t *);
80*4c3888b8SHans Rosenfeld static int ql_8300_dump_dcmd(ql_adapter_state_t *, uint_t, int,
81*4c3888b8SHans Rosenfeld     const mdb_arg_t *);
82fcf3ce44SJohn Forte static void ql_elog_common(ql_adapter_state_t *, boolean_t);
83fcf3ce44SJohn Forte 
84fcf3ce44SJohn Forte /*
85fcf3ce44SJohn Forte  * local adapter state flags strings
86fcf3ce44SJohn Forte  */
87fcf3ce44SJohn Forte int8_t *adapter_state_flags[] = {
88fcf3ce44SJohn Forte 	"FCA_BOUND",
89fcf3ce44SJohn Forte 	"QL_OPENED",
90fcf3ce44SJohn Forte 	"ONLINE",
91fcf3ce44SJohn Forte 	"INTERRUPTS_ENABLED",
9216dd44c2SDaniel Beauregard 	"ABORT_CMDS_LOOP_DOWN_TMO",
93fcf3ce44SJohn Forte 	"POINT_TO_POINT",
94fcf3ce44SJohn Forte 	"IP_ENABLED",
95fcf3ce44SJohn Forte 	"IP_INITIALIZED",
965dfd244aSDaniel Beauregard 	"MENLO_LOGIN_OPERATIONAL",
97fcf3ce44SJohn Forte 	"ADAPTER_SUSPENDED",
98*4c3888b8SHans Rosenfeld 	"FW_DUMP_NEEDED",
99fcf3ce44SJohn Forte 	"PARITY_ERROR",
100fcf3ce44SJohn Forte 	"FLASH_ERRLOG_MARKER",
101fcf3ce44SJohn Forte 	"VP_ENABLED",
102fcf3ce44SJohn Forte 	"FDISC_ENABLED",
103*4c3888b8SHans Rosenfeld 	"MULTI_QUEUE",
1044f8b8adcSDaniel Beauregard 	"MPI_RESET_NEEDED",
105*4c3888b8SHans Rosenfeld 	"VP_ID_NOT_ACQUIRED",
106*4c3888b8SHans Rosenfeld 	"IDC_STALL_NEEDED",
107*4c3888b8SHans Rosenfeld 	"POLL_INTR",
108*4c3888b8SHans Rosenfeld 	"IDC_RESTART_NEEDED",
109*4c3888b8SHans Rosenfeld 	"IDC_ACK_NEEDED",
110*4c3888b8SHans Rosenfeld 	"LOOPBACK_ACTIVE",
111*4c3888b8SHans Rosenfeld 	"QUEUE_SHADOW_PTRS",
112*4c3888b8SHans Rosenfeld 	"NO_INTR_HANDSHAKE",
113*4c3888b8SHans Rosenfeld 	"COMP_THD_TERMINATE",
114*4c3888b8SHans Rosenfeld 	"DISABLE_NIC_FW_DMP",
115*4c3888b8SHans Rosenfeld 	"MULTI_CHIP_ADAPTER",
116fcf3ce44SJohn Forte 	NULL
117fcf3ce44SJohn Forte };
118fcf3ce44SJohn Forte 
119fcf3ce44SJohn Forte int8_t *adapter_config_flags[] = {
120*4c3888b8SHans Rosenfeld 	"CTRL_27XX",
121fcf3ce44SJohn Forte 	"ENABLE_64BIT_ADDRESSING",
122fcf3ce44SJohn Forte 	"ENABLE_LIP_RESET",
123fcf3ce44SJohn Forte 	"ENABLE_FULL_LIP_LOGIN",
124fcf3ce44SJohn Forte 	"ENABLE_TARGET_RESET",
125fcf3ce44SJohn Forte 	"ENABLE_LINK_DOWN_REPORTING",
1265dfd244aSDaniel Beauregard 	"DISABLE_EXTENDED_LOGGING_TRACE",
127fcf3ce44SJohn Forte 	"ENABLE_FCP_2_SUPPORT",
128*4c3888b8SHans Rosenfeld 	"CTRL_83XX",
129fcf3ce44SJohn Forte 	"SBUS_CARD",
130*4c3888b8SHans Rosenfeld 	"CTRL_23XX",
131*4c3888b8SHans Rosenfeld 	"CTRL_63XX",
132*4c3888b8SHans Rosenfeld 	"CTRL_22XX",
133*4c3888b8SHans Rosenfeld 	"CTRL_24XX",
134fcf3ce44SJohn Forte 	"CTRL_25XX",
135fcf3ce44SJohn Forte 	"ENABLE_EXTENDED_LOGGING",
136fcf3ce44SJohn Forte 	"DISABLE_RISC_CODE_LOAD",
137fcf3ce44SJohn Forte 	"SET_CACHE_LINE_SIZE_1",
1385dfd244aSDaniel Beauregard 	"CTRL_MENLO",
139fcf3ce44SJohn Forte 	"EXT_FW_INTERFACE",
140fcf3ce44SJohn Forte 	"LOAD_FLASH_FW",
141fcf3ce44SJohn Forte 	"DUMP_MAILBOX_TIMEOUT",
142fcf3ce44SJohn Forte 	"DUMP_ISP_SYSTEM_ERROR",
143fcf3ce44SJohn Forte 	"DUMP_DRIVER_COMMAND_TIMEOUT",
144fcf3ce44SJohn Forte 	"DUMP_LOOP_OFFLINE_TIMEOUT",
145fcf3ce44SJohn Forte 	"ENABLE_FWEXTTRACE",
146fcf3ce44SJohn Forte 	"ENABLE_FWFCETRACE",
147*4c3888b8SHans Rosenfeld 	"CTRL_80XX",
1485dfd244aSDaniel Beauregard 	"CTRL_81XX",
149*4c3888b8SHans Rosenfeld 	"CTRL_82XX",
150*4c3888b8SHans Rosenfeld 	"FAST_TIMEOUT",
151eb82ff87SDaniel Beauregard 	"LR_SUPPORT",
152fcf3ce44SJohn Forte 	NULL
153fcf3ce44SJohn Forte };
154fcf3ce44SJohn Forte 
155fcf3ce44SJohn Forte /*
156fcf3ce44SJohn Forte  * local task daemon flags strings
157fcf3ce44SJohn Forte  */
158fcf3ce44SJohn Forte int8_t *task_daemon_flags[] = {
159fcf3ce44SJohn Forte 	"TASK_DAEMON_STOP_FLG",
160fcf3ce44SJohn Forte 	"TASK_DAEMON_SLEEPING_FLG",
161fcf3ce44SJohn Forte 	"TASK_DAEMON_ALIVE_FLG",
162fcf3ce44SJohn Forte 	"TASK_DAEMON_IDLE_CHK_FLG",
163fcf3ce44SJohn Forte 	"SUSPENDED_WAKEUP_FLG",
164fcf3ce44SJohn Forte 	"FC_STATE_CHANGE",
165fcf3ce44SJohn Forte 	"NEED_UNSOLICITED_BUFFERS",
166*4c3888b8SHans Rosenfeld 	"MARKER_NEEDED",
167*4c3888b8SHans Rosenfeld 	"MARKER_ACTIVE",
168fcf3ce44SJohn Forte 	"ISP_ABORT_NEEDED",
169fcf3ce44SJohn Forte 	"ABORT_ISP_ACTIVE",
170fcf3ce44SJohn Forte 	"LOOP_RESYNC_NEEDED",
171fcf3ce44SJohn Forte 	"LOOP_RESYNC_ACTIVE",
172fcf3ce44SJohn Forte 	"LOOP_DOWN",
173fcf3ce44SJohn Forte 	"DRIVER_STALL",
174fcf3ce44SJohn Forte 	"COMMAND_WAIT_NEEDED",
175fcf3ce44SJohn Forte 	"COMMAND_WAIT_ACTIVE",
176fcf3ce44SJohn Forte 	"STATE_ONLINE",
177fcf3ce44SJohn Forte 	"ABORT_QUEUES_NEEDED",
178fcf3ce44SJohn Forte 	"TASK_DAEMON_STALLED_FLG",
179*4c3888b8SHans Rosenfeld 	"SEND_PLOGI",
180fcf3ce44SJohn Forte 	"FIRMWARE_UP",
181*4c3888b8SHans Rosenfeld 	"IDC_POLL_NEEDED",
182fcf3ce44SJohn Forte 	"FIRMWARE_LOADED",
183fcf3ce44SJohn Forte 	"RSCN_UPDATE_NEEDED",
184fcf3ce44SJohn Forte 	"HANDLE_PORT_BYPASS_CHANGE",
185fcf3ce44SJohn Forte 	"PORT_RETRY_NEEDED",
186fcf3ce44SJohn Forte 	"TASK_DAEMON_POWERING_DOWN",
187fcf3ce44SJohn Forte 	"TD_IIDMA_NEEDED",
188*4c3888b8SHans Rosenfeld 	"WATCHDOG_NEEDED",
189*4c3888b8SHans Rosenfeld 	"LED_BLINK",
190fcf3ce44SJohn Forte 	NULL
191fcf3ce44SJohn Forte };
192fcf3ce44SJohn Forte 
193fcf3ce44SJohn Forte /*
194fcf3ce44SJohn Forte  * local interrupt aif flags
195fcf3ce44SJohn Forte  */
196fcf3ce44SJohn Forte int8_t *aif_flags[] = {
197fcf3ce44SJohn Forte 	"IFLG_INTR_LEGACY",
198fcf3ce44SJohn Forte 	"IFLG_INTR_FIXED",
1995dfd244aSDaniel Beauregard 	"IFLG_INTR_MSI",
2005dfd244aSDaniel Beauregard 	"IFLG_INTR_MSIX",
201fcf3ce44SJohn Forte 	NULL
202fcf3ce44SJohn Forte };
203fcf3ce44SJohn Forte 
204fcf3ce44SJohn Forte int8_t *qlsrb_flags[] = {
205fcf3ce44SJohn Forte 	"SRB_ISP_STARTED",
206fcf3ce44SJohn Forte 	"SRB_ISP_COMPLETED",
207fcf3ce44SJohn Forte 	"SRB_RETRY",
208fcf3ce44SJohn Forte 	"SRB_POLL",
209fcf3ce44SJohn Forte 	"SRB_WATCHDOG_ENABLED",
210fcf3ce44SJohn Forte 	"SRB_ABORT",
211fcf3ce44SJohn Forte 	"SRB_UB_IN_FCA",
212fcf3ce44SJohn Forte 	"SRB_UB_IN_ISP",
213fcf3ce44SJohn Forte 	"SRB_UB_CALLBACK",
214fcf3ce44SJohn Forte 	"SRB_UB_RSCN",
215fcf3ce44SJohn Forte 	"SRB_UB_FCP",
216fcf3ce44SJohn Forte 	"SRB_FCP_CMD_PKT",
217fcf3ce44SJohn Forte 	"SRB_FCP_DATA_PKT",
218fcf3ce44SJohn Forte 	"SRB_FCP_RSP_PKT",
219fcf3ce44SJohn Forte 	"SRB_IP_PKT",
220fcf3ce44SJohn Forte 	"SRB_GENERIC_SERVICES_PKT",
221fcf3ce44SJohn Forte 	"SRB_COMMAND_TIMEOUT",
222fcf3ce44SJohn Forte 	"SRB_ABORTING",
223fcf3ce44SJohn Forte 	"SRB_IN_DEVICE_QUEUE",
224fcf3ce44SJohn Forte 	"SRB_IN_TOKEN_ARRAY",
225fcf3ce44SJohn Forte 	"SRB_UB_FREE_REQUESTED",
226fcf3ce44SJohn Forte 	"SRB_UB_ACQUIRED",
227fcf3ce44SJohn Forte 	"SRB_MS_PKT",
228*4c3888b8SHans Rosenfeld 	"SRB_ELS_PKT",
229fcf3ce44SJohn Forte 	NULL
230fcf3ce44SJohn Forte };
231fcf3ce44SJohn Forte 
232fcf3ce44SJohn Forte int8_t *qllun_flags[] = {
233fcf3ce44SJohn Forte 	"LQF_UNTAGGED_PENDING",
234fcf3ce44SJohn Forte 	NULL
235fcf3ce44SJohn Forte };
236fcf3ce44SJohn Forte 
237fcf3ce44SJohn Forte int8_t *qltgt_flags[] = {
238fcf3ce44SJohn Forte 	"TQF_TAPE_DEVICE",
239fcf3ce44SJohn Forte 	"TQF_QUEUE_SUSPENDED",
240fcf3ce44SJohn Forte 	"TQF_FABRIC_DEVICE",
241fcf3ce44SJohn Forte 	"TQF_INITIATOR_DEVICE",
242fcf3ce44SJohn Forte 	"TQF_RSCN_RCVD",
243fcf3ce44SJohn Forte 	"TQF_NEED_AUTHENTICATION",
244fcf3ce44SJohn Forte 	"TQF_PLOGI_PROGRS",
245fcf3ce44SJohn Forte 	"TQF_IIDMA_NEEDED",
246*4c3888b8SHans Rosenfeld 	"TQF_LOGIN_NEEDED",
247fcf3ce44SJohn Forte 	NULL
248fcf3ce44SJohn Forte };
249fcf3ce44SJohn Forte 
25016dd44c2SDaniel Beauregard int8_t *qldump_flags[] = {
25116dd44c2SDaniel Beauregard 	"QL_DUMPING",
25216dd44c2SDaniel Beauregard 	"QL_DUMP_VALID",
25316dd44c2SDaniel Beauregard 	"QL_DUMP_UPLOADED",
25416dd44c2SDaniel Beauregard 	NULL
25516dd44c2SDaniel Beauregard };
25616dd44c2SDaniel Beauregard 
257fcf3ce44SJohn Forte /*
258fcf3ce44SJohn Forte  * qlclinks_dcmd
259fcf3ce44SJohn Forte  *	mdb dcmd which prints out the ql_hba pointers
260fcf3ce44SJohn Forte  *
261fcf3ce44SJohn Forte  * Input:
262fcf3ce44SJohn Forte  *	addr  = User supplied address -- error if supplied.
263fcf3ce44SJohn Forte  *	flags = mdb flags.
264fcf3ce44SJohn Forte  *	argc  = Number of user supplied args -- error if non-zero.
265fcf3ce44SJohn Forte  *	argv  = Arg array.
266fcf3ce44SJohn Forte  *
267fcf3ce44SJohn Forte  * Returns:
268fcf3ce44SJohn Forte  *	DCMD_ERR, DCMD_USAGE, or DCMD_OK
269fcf3ce44SJohn Forte  *
270fcf3ce44SJohn Forte  * Context:
271fcf3ce44SJohn Forte  *	User context.
272fcf3ce44SJohn Forte  *
273fcf3ce44SJohn Forte  */
274fcf3ce44SJohn Forte /*ARGSUSED*/
275fcf3ce44SJohn Forte static int
qlclinks_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)276fcf3ce44SJohn Forte qlclinks_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
277fcf3ce44SJohn Forte {
278fcf3ce44SJohn Forte 	ql_head_t		ql_hba;
279fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
280892ad162SToomas Soome 	uintptr_t		hbaptr = 0;
281fcf3ce44SJohn Forte 
282fcf3ce44SJohn Forte 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
283fcf3ce44SJohn Forte 		return (DCMD_USAGE);
284fcf3ce44SJohn Forte 	}
285fcf3ce44SJohn Forte 
286fcf3ce44SJohn Forte 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
287fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_hba structure");
288fcf3ce44SJohn Forte 		return (DCMD_ERR);
289fcf3ce44SJohn Forte 	}
290fcf3ce44SJohn Forte 
291*4c3888b8SHans Rosenfeld 	if (ql_hba.first == NULL) {
292fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
293fcf3ce44SJohn Forte 		return (DCMD_ERR);
294fcf3ce44SJohn Forte 	}
295fcf3ce44SJohn Forte 
296fcf3ce44SJohn Forte 	mdb_printf("\nqlc adapter state linkages (f=0x%llx, l=0x%llx)\n\n",
297fcf3ce44SJohn Forte 	    ql_hba.first, ql_hba.last);
298fcf3ce44SJohn Forte 
299fcf3ce44SJohn Forte 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
300fcf3ce44SJohn Forte 	    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
301fcf3ce44SJohn Forte 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
302fcf3ce44SJohn Forte 		return (DCMD_OK);
303fcf3ce44SJohn Forte 	}
304fcf3ce44SJohn Forte 
305fcf3ce44SJohn Forte 	(void) mdb_inc_indent((ulong_t)4);
306fcf3ce44SJohn Forte 	mdb_printf("%<u>%-?s\t%-45s%</u>\n\n", "baseaddr", "instance");
307fcf3ce44SJohn Forte 
308fcf3ce44SJohn Forte 	hbaptr = (uintptr_t)ql_hba.first;
309892ad162SToomas Soome 	while (hbaptr != 0) {
310fcf3ce44SJohn Forte 
311fcf3ce44SJohn Forte 		if (mdb_vread(qlstate, sizeof (ql_adapter_state_t),
312fcf3ce44SJohn Forte 		    hbaptr) == -1) {
313fcf3ce44SJohn Forte 			mdb_free(qlstate, sizeof (ql_adapter_state_t));
314fcf3ce44SJohn Forte 			mdb_warn("failed to read ql_adapter_state at %p",
315fcf3ce44SJohn Forte 			    hbaptr);
316fcf3ce44SJohn Forte 			return (DCMD_OK);
317fcf3ce44SJohn Forte 		}
318fcf3ce44SJohn Forte 
319fcf3ce44SJohn Forte 		mdb_printf("%<b>0x%016p%t%d%</b>\n",
320fcf3ce44SJohn Forte 		    qlstate->hba.base_address, qlstate->instance);
321fcf3ce44SJohn Forte 
322fcf3ce44SJohn Forte 		/*
323fcf3ce44SJohn Forte 		 * If vp exists, loop through those
324fcf3ce44SJohn Forte 		 */
325fcf3ce44SJohn Forte 
326fcf3ce44SJohn Forte 		if ((qlstate->flags & VP_ENABLED) &&
327fcf3ce44SJohn Forte 		    (qlstate->vp_next != NULL)) {
328fcf3ce44SJohn Forte 
329fcf3ce44SJohn Forte 			ql_adapter_state_t	*vqlstate;
330892ad162SToomas Soome 			uintptr_t		vhbaptr = 0;
331fcf3ce44SJohn Forte 
332fcf3ce44SJohn Forte 			vhbaptr = (uintptr_t)qlstate->vp_next;
333fcf3ce44SJohn Forte 
334fcf3ce44SJohn Forte 			if ((vqlstate = (ql_adapter_state_t *)mdb_alloc(
335fcf3ce44SJohn Forte 			    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
336fcf3ce44SJohn Forte 				mdb_warn("Unable to allocate memory for "
337fcf3ce44SJohn Forte 				    "ql_adapter_state vp\n");
338fcf3ce44SJohn Forte 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
339fcf3ce44SJohn Forte 				return (DCMD_OK);
340fcf3ce44SJohn Forte 			}
341fcf3ce44SJohn Forte 
342fcf3ce44SJohn Forte 			(void) mdb_inc_indent((ulong_t)30);
343fcf3ce44SJohn Forte 
344fcf3ce44SJohn Forte 			mdb_printf("%<u>vp baseaddr\t\tvp index%</u>\n");
345fcf3ce44SJohn Forte 
346892ad162SToomas Soome 			while (vhbaptr != 0) {
347fcf3ce44SJohn Forte 
348fcf3ce44SJohn Forte 				if (mdb_vread(vqlstate,
34916dd44c2SDaniel Beauregard 				    sizeof (ql_adapter_state_t), vhbaptr) ==
35016dd44c2SDaniel Beauregard 				    -1) {
351fcf3ce44SJohn Forte 					mdb_free(vqlstate,
352fcf3ce44SJohn Forte 					    sizeof (ql_adapter_state_t));
353fcf3ce44SJohn Forte 					mdb_free(qlstate,
354fcf3ce44SJohn Forte 					    sizeof (ql_adapter_state_t));
355fcf3ce44SJohn Forte 					mdb_warn("failed to read vp "
356fcf3ce44SJohn Forte 					    "ql_adapter_state at %p", vhbaptr);
357fcf3ce44SJohn Forte 					return (DCMD_OK);
358fcf3ce44SJohn Forte 				}
359fcf3ce44SJohn Forte 
360fcf3ce44SJohn Forte 				mdb_printf("%<b>0x%016p%t%d%</b>\n",
361fcf3ce44SJohn Forte 				    vqlstate->hba.base_address,
362fcf3ce44SJohn Forte 				    vqlstate->vp_index);
363fcf3ce44SJohn Forte 
364fcf3ce44SJohn Forte 				vhbaptr = (uintptr_t)vqlstate->vp_next;
365fcf3ce44SJohn Forte 			}
366fcf3ce44SJohn Forte 
367fcf3ce44SJohn Forte 			mdb_free(vqlstate, sizeof (ql_adapter_state_t));
368fcf3ce44SJohn Forte 
369fcf3ce44SJohn Forte 			(void) mdb_dec_indent((ulong_t)30);
370fcf3ce44SJohn Forte 
371fcf3ce44SJohn Forte 			mdb_printf("\n");
372fcf3ce44SJohn Forte 		}
373fcf3ce44SJohn Forte 
374fcf3ce44SJohn Forte 		hbaptr = (uintptr_t)qlstate->hba.next;
375fcf3ce44SJohn Forte 	}
376fcf3ce44SJohn Forte 
377fcf3ce44SJohn Forte 	(void) mdb_dec_indent((ulong_t)4);
378fcf3ce44SJohn Forte 
379fcf3ce44SJohn Forte 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
380fcf3ce44SJohn Forte 
381fcf3ce44SJohn Forte 	return (DCMD_OK);
382fcf3ce44SJohn Forte }
383fcf3ce44SJohn Forte 
384fcf3ce44SJohn Forte /*
385fcf3ce44SJohn Forte  * qlcver_dcmd
386fcf3ce44SJohn Forte  *	mdb dcmd which prints out the qlc driver version the mdb
387fcf3ce44SJohn Forte  *	module was compiled with, and the verison of qlc which is
388fcf3ce44SJohn Forte  *	currently loaded on the machine.
389fcf3ce44SJohn Forte  *
390fcf3ce44SJohn Forte  * Input:
391fcf3ce44SJohn Forte  *	addr  = User supplied address -- error if supplied.
392fcf3ce44SJohn Forte  *	flags = mdb flags.
393fcf3ce44SJohn Forte  *	argc  = Number of user supplied args -- error if non-zero.
394fcf3ce44SJohn Forte  *	argv  = Arg array.
395fcf3ce44SJohn Forte  *
396fcf3ce44SJohn Forte  * Returns:
397fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
398fcf3ce44SJohn Forte  *
399fcf3ce44SJohn Forte  * Context:
400fcf3ce44SJohn Forte  *	User context.
401fcf3ce44SJohn Forte  *
402fcf3ce44SJohn Forte  */
403fcf3ce44SJohn Forte /*ARGSUSED*/
404fcf3ce44SJohn Forte static int
qlcver_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)405fcf3ce44SJohn Forte qlcver_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
406fcf3ce44SJohn Forte {
40716dd44c2SDaniel Beauregard 	int8_t		qlcversion[100];
40816dd44c2SDaniel Beauregard 	struct fw_table	fw_table[10], *fwt = NULL;
40916dd44c2SDaniel Beauregard 	uint8_t		*fwverptr = NULL;
41016dd44c2SDaniel Beauregard 	ql_head_t	ql_hba;
41116dd44c2SDaniel Beauregard 	uint32_t	found = 0;
412fcf3ce44SJohn Forte 
413fcf3ce44SJohn Forte 	if ((flags & DCMD_ADDRSPEC) || argc != 0) {
414fcf3ce44SJohn Forte 		return (DCMD_USAGE);
415fcf3ce44SJohn Forte 	}
416fcf3ce44SJohn Forte 
417fcf3ce44SJohn Forte 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
418fcf3ce44SJohn Forte 		mdb_warn("unable to read qlc driver version\n");
419fcf3ce44SJohn Forte 	} else {
42016dd44c2SDaniel Beauregard 		mdb_printf("\n%s version currently loaded is: %s\n",
421fcf3ce44SJohn Forte 		    QL_NAME, qlcversion);
422fcf3ce44SJohn Forte 	}
423fcf3ce44SJohn Forte 
42416dd44c2SDaniel Beauregard 	mdb_printf("qlc mdb library compiled with %s version: %s\n",
42516dd44c2SDaniel Beauregard 	    QL_NAME, QL_VERSION);
42616dd44c2SDaniel Beauregard 
42716dd44c2SDaniel Beauregard 	if ((fwverptr = (uint8_t *)(mdb_alloc(50, UM_SLEEP))) == NULL) {
42816dd44c2SDaniel Beauregard 		mdb_warn("unable to alloc fwverptr\n");
42916dd44c2SDaniel Beauregard 		return (DCMD_OK);
43016dd44c2SDaniel Beauregard 	}
43116dd44c2SDaniel Beauregard 
43216dd44c2SDaniel Beauregard 	if (mdb_readvar(&fw_table, "fw_table") == -1) {
43316dd44c2SDaniel Beauregard 		mdb_warn("unable to read firmware table\n");
43416dd44c2SDaniel Beauregard 	} else {
43516dd44c2SDaniel Beauregard 		ql_adapter_state_t	*qlstate;
436892ad162SToomas Soome 		uintptr_t		hbaptr = 0;
43716dd44c2SDaniel Beauregard 
43816dd44c2SDaniel Beauregard 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
43916dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_hba structure");
44016dd44c2SDaniel Beauregard 			return (DCMD_ERR);
44116dd44c2SDaniel Beauregard 		}
44216dd44c2SDaniel Beauregard 
44316dd44c2SDaniel Beauregard 		if ((qlstate = (ql_adapter_state_t *)mdb_alloc(
44416dd44c2SDaniel Beauregard 		    sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
44516dd44c2SDaniel Beauregard 			mdb_warn("Unable to allocate memory for "
44616dd44c2SDaniel Beauregard 			    "ql_adapter_state\n");
44716dd44c2SDaniel Beauregard 			return (DCMD_OK);
44816dd44c2SDaniel Beauregard 		}
44916dd44c2SDaniel Beauregard 
45016dd44c2SDaniel Beauregard 		mdb_printf("\n%-8s%-11s%s\n", "f/w", "compiled", "loaded");
45116dd44c2SDaniel Beauregard 		mdb_printf("%<u>%-8s%-11s%-13s%s%</u>\n\n", "class", "version",
45216dd44c2SDaniel Beauregard 		    "version", "instance list");
45316dd44c2SDaniel Beauregard 
45416dd44c2SDaniel Beauregard 		for (fwt = &fw_table[0]; fwt->fw_class; fwt++) {
45516dd44c2SDaniel Beauregard 
45616dd44c2SDaniel Beauregard 			if (mdb_vread(fwverptr, sizeof (void *),
45716dd44c2SDaniel Beauregard 			    (uintptr_t)fwt->fw_version) == -1) {
45816dd44c2SDaniel Beauregard 				mdb_warn("unable to read fwverptr\n");
45916dd44c2SDaniel Beauregard 				mdb_free(fwverptr, sizeof (void *));
46016dd44c2SDaniel Beauregard 				mdb_free(qlstate, sizeof (ql_adapter_state_t));
46116dd44c2SDaniel Beauregard 				return (DCMD_OK);
46216dd44c2SDaniel Beauregard 			}
46316dd44c2SDaniel Beauregard 
46416dd44c2SDaniel Beauregard 			mdb_printf("%x\t%-11s", fwt->fw_class, fwverptr);
46516dd44c2SDaniel Beauregard 
466*4c3888b8SHans Rosenfeld 			if (ql_hba.first == NULL) {
46716dd44c2SDaniel Beauregard 				mdb_warn("failed to read ql_hba structure");
468892ad162SToomas Soome 				hbaptr = 0;
46916dd44c2SDaniel Beauregard 			} else {
47016dd44c2SDaniel Beauregard 				hbaptr = (uintptr_t)ql_hba.first;
47116dd44c2SDaniel Beauregard 			}
47216dd44c2SDaniel Beauregard 
47316dd44c2SDaniel Beauregard 			found = 0;
474892ad162SToomas Soome 			while (hbaptr != 0) {
47516dd44c2SDaniel Beauregard 
47616dd44c2SDaniel Beauregard 				if (mdb_vread(qlstate,
47716dd44c2SDaniel Beauregard 				    sizeof (ql_adapter_state_t), hbaptr) ==
47816dd44c2SDaniel Beauregard 				    -1) {
47916dd44c2SDaniel Beauregard 					mdb_warn("failed to read "
48016dd44c2SDaniel Beauregard 					    "ql_adapter_state at %p", hbaptr);
48116dd44c2SDaniel Beauregard 					break;
48216dd44c2SDaniel Beauregard 				}
48316dd44c2SDaniel Beauregard 
48416dd44c2SDaniel Beauregard 				if (qlstate->fw_class == fwt->fw_class) {
48516dd44c2SDaniel Beauregard 					if (found == 0) {
48616dd44c2SDaniel Beauregard 						mdb_printf("%x.%02x.%02x\t",
48716dd44c2SDaniel Beauregard 						    qlstate->fw_major_version,
48816dd44c2SDaniel Beauregard 						    qlstate->fw_minor_version,
48916dd44c2SDaniel Beauregard 						    qlstate->
49016dd44c2SDaniel Beauregard 						    fw_subminor_version);
49116dd44c2SDaniel Beauregard 						mdb_printf("%d",
49216dd44c2SDaniel Beauregard 						    qlstate->instance);
49316dd44c2SDaniel Beauregard 					} else {
49416dd44c2SDaniel Beauregard 						mdb_printf(", %d",
49516dd44c2SDaniel Beauregard 						    qlstate->instance);
49616dd44c2SDaniel Beauregard 					}
49716dd44c2SDaniel Beauregard 					found = 1;
49816dd44c2SDaniel Beauregard 				}
49916dd44c2SDaniel Beauregard 
50016dd44c2SDaniel Beauregard 				hbaptr = (uintptr_t)qlstate->hba.next;
50116dd44c2SDaniel Beauregard 			}
50216dd44c2SDaniel Beauregard 
50316dd44c2SDaniel Beauregard 			if (found == 1) {
50416dd44c2SDaniel Beauregard 				mdb_printf("\n");
50516dd44c2SDaniel Beauregard 			} else {
50616dd44c2SDaniel Beauregard 				mdb_printf("not loaded\n");
50716dd44c2SDaniel Beauregard 			}
50816dd44c2SDaniel Beauregard 		}
50916dd44c2SDaniel Beauregard 
51016dd44c2SDaniel Beauregard 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
51116dd44c2SDaniel Beauregard 		mdb_free(fwverptr, sizeof (void *));
51216dd44c2SDaniel Beauregard 	}
51316dd44c2SDaniel Beauregard 
514fcf3ce44SJohn Forte 	return (DCMD_OK);
515fcf3ce44SJohn Forte }
516fcf3ce44SJohn Forte 
517fcf3ce44SJohn Forte /*
518fcf3ce44SJohn Forte  * qlc_el_dcmd
519fcf3ce44SJohn Forte  *	mdb dcmd which turns the extended logging bit on or off
520fcf3ce44SJohn Forte  *	for the specificed qlc instance(s).
521fcf3ce44SJohn Forte  *
522fcf3ce44SJohn Forte  * Input:
523fcf3ce44SJohn Forte  *	addr  = User supplied address -- error if supplied.
524fcf3ce44SJohn Forte  *	flags = mdb flags.
525fcf3ce44SJohn Forte  *	argc  = Number of user supplied args -- error if non-zero.
526fcf3ce44SJohn Forte  *	argv  = Arg array.
527fcf3ce44SJohn Forte  *
528fcf3ce44SJohn Forte  * Returns:
529fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
530fcf3ce44SJohn Forte  *
531fcf3ce44SJohn Forte  * Context:
532fcf3ce44SJohn Forte  *	User context.
533fcf3ce44SJohn Forte  *
534fcf3ce44SJohn Forte  */
535fcf3ce44SJohn Forte /*ARGSUSED*/
536fcf3ce44SJohn Forte static int
qlc_el_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)537fcf3ce44SJohn Forte qlc_el_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538fcf3ce44SJohn Forte {
539fcf3ce44SJohn Forte 	int8_t			qlcversion[100];
540fcf3ce44SJohn Forte 	boolean_t		elswitch;
541fcf3ce44SJohn Forte 	uint32_t		argcnt;
542fcf3ce44SJohn Forte 	int			mdbs;
543fcf3ce44SJohn Forte 	uint32_t		instance;
544fcf3ce44SJohn Forte 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
545fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
546892ad162SToomas Soome 	uintptr_t		hbaptr = 0;
547fcf3ce44SJohn Forte 	ql_head_t		ql_hba;
548fcf3ce44SJohn Forte 
549fcf3ce44SJohn Forte 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
550fcf3ce44SJohn Forte 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
551fcf3ce44SJohn Forte 		return (DCMD_OK);
552fcf3ce44SJohn Forte 	}
553fcf3ce44SJohn Forte 
554fcf3ce44SJohn Forte 	if ((flags & DCMD_ADDRSPEC) || argc < 2) {
555fcf3ce44SJohn Forte 		return (DCMD_USAGE);
556fcf3ce44SJohn Forte 	}
557fcf3ce44SJohn Forte 
558fcf3ce44SJohn Forte 	/*
559fcf3ce44SJohn Forte 	 * Check and make sure the driver version and the mdb versions
560fcf3ce44SJohn Forte 	 * match so all the structures and flags line up
561fcf3ce44SJohn Forte 	 */
562fcf3ce44SJohn Forte 
563fcf3ce44SJohn Forte 	if (mdb_readvar(&qlcversion, "qlc_driver_version") == -1) {
564fcf3ce44SJohn Forte 		mdb_warn("unable to read qlc driver version\n");
565fcf3ce44SJohn Forte 		return (DCMD_OK);
566fcf3ce44SJohn Forte 	}
567fcf3ce44SJohn Forte 
568fcf3ce44SJohn Forte 	if ((strcmp(QL_VERSION, (const char *)&qlcversion)) != 0) {
569fcf3ce44SJohn Forte 		mdb_warn("Error: qlc driver/qlc mdb version mismatch\n");
570fcf3ce44SJohn Forte 		mdb_printf("\tqlc mdb library compiled version is: %s\n",
571fcf3ce44SJohn Forte 		    QL_VERSION);
572fcf3ce44SJohn Forte 		mdb_printf("\tqlc driver version is: %s\n", qlcversion);
573fcf3ce44SJohn Forte 
574fcf3ce44SJohn Forte 		return (DCMD_OK);
575fcf3ce44SJohn Forte 	}
576fcf3ce44SJohn Forte 
577fcf3ce44SJohn Forte 	if ((strcasecmp(argv[0].a_un.a_str, "on")) == 0) {
578fcf3ce44SJohn Forte 		elswitch = TRUE;
579fcf3ce44SJohn Forte 	} else if ((strcasecmp(argv[0].a_un.a_str, "off")) == 0) {
580fcf3ce44SJohn Forte 		elswitch = FALSE;
581fcf3ce44SJohn Forte 	} else {
582fcf3ce44SJohn Forte 		return (DCMD_USAGE);
583fcf3ce44SJohn Forte 	}
584fcf3ce44SJohn Forte 
585fcf3ce44SJohn Forte 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
586fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_hba structure");
587fcf3ce44SJohn Forte 		return (DCMD_ERR);
588fcf3ce44SJohn Forte 	}
589fcf3ce44SJohn Forte 
590*4c3888b8SHans Rosenfeld 	if (ql_hba.first == NULL) {
591fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_hba structure - is qlc loaded?");
592fcf3ce44SJohn Forte 		return (DCMD_ERR);
593fcf3ce44SJohn Forte 	}
594fcf3ce44SJohn Forte 
595fcf3ce44SJohn Forte 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
596fcf3ce44SJohn Forte 	    UM_SLEEP)) == NULL) {
597fcf3ce44SJohn Forte 		mdb_warn("Unable to allocate memory for "
598fcf3ce44SJohn Forte 		    "ql_adapter_state\n");
599fcf3ce44SJohn Forte 		return (DCMD_OK);
600fcf3ce44SJohn Forte 	}
601fcf3ce44SJohn Forte 
602fcf3ce44SJohn Forte 	if ((strcasecmp(argv[1].a_un.a_str, "all")) == 0) {
603fcf3ce44SJohn Forte 
604fcf3ce44SJohn Forte 		if (argc != 2) {
605fcf3ce44SJohn Forte 			mdb_free(qlstate, qlsize);
606fcf3ce44SJohn Forte 			return (DCMD_USAGE);
607fcf3ce44SJohn Forte 		}
608fcf3ce44SJohn Forte 
609fcf3ce44SJohn Forte 		hbaptr = (uintptr_t)ql_hba.first;
610fcf3ce44SJohn Forte 
611892ad162SToomas Soome 		while (hbaptr != 0) {
612fcf3ce44SJohn Forte 
613fcf3ce44SJohn Forte 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
614fcf3ce44SJohn Forte 				mdb_free(qlstate, qlsize);
615fcf3ce44SJohn Forte 				mdb_warn("failed to read ql_adapter_state "
616fcf3ce44SJohn Forte 				    "at %p", hbaptr);
617fcf3ce44SJohn Forte 				return (DCMD_OK);
618fcf3ce44SJohn Forte 			}
619fcf3ce44SJohn Forte 
620fcf3ce44SJohn Forte 			ql_elog_common(qlstate, elswitch);
621fcf3ce44SJohn Forte 
622fcf3ce44SJohn Forte 			hbaptr = (uintptr_t)qlstate->hba.next;
623fcf3ce44SJohn Forte 		}
624fcf3ce44SJohn Forte 	} else {
625fcf3ce44SJohn Forte 		for (argcnt = 1; argcnt < argc; argcnt++) {
626fcf3ce44SJohn Forte 
627fcf3ce44SJohn Forte 			instance = (uint32_t)mdb_strtoull(
628fcf3ce44SJohn Forte 			    argv[argcnt].a_un.a_str);
629fcf3ce44SJohn Forte 
630fcf3ce44SJohn Forte 			/* find the correct instance to change */
631fcf3ce44SJohn Forte 			hbaptr = (uintptr_t)ql_hba.first;
632892ad162SToomas Soome 			while (hbaptr != 0) {
633fcf3ce44SJohn Forte 
634fcf3ce44SJohn Forte 				if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
635fcf3ce44SJohn Forte 					mdb_free(qlstate, qlsize);
63616dd44c2SDaniel Beauregard 					mdb_warn("failed to read "
63716dd44c2SDaniel Beauregard 					    "ql_adapter_state at %p", hbaptr);
638fcf3ce44SJohn Forte 					return (DCMD_OK);
639fcf3ce44SJohn Forte 				}
640fcf3ce44SJohn Forte 
641fcf3ce44SJohn Forte 				if (qlstate->instance == instance) {
642fcf3ce44SJohn Forte 					break;
643fcf3ce44SJohn Forte 				}
644fcf3ce44SJohn Forte 
645fcf3ce44SJohn Forte 				hbaptr = (uintptr_t)qlstate->hba.next;
646fcf3ce44SJohn Forte 			}
647fcf3ce44SJohn Forte 
648892ad162SToomas Soome 			if (hbaptr == 0) {
649fcf3ce44SJohn Forte 				mdb_printf("instance %d is not loaded",
650fcf3ce44SJohn Forte 				    instance);
651fcf3ce44SJohn Forte 				continue;
652fcf3ce44SJohn Forte 			}
653fcf3ce44SJohn Forte 
654fcf3ce44SJohn Forte 			ql_elog_common(qlstate, elswitch);
655fcf3ce44SJohn Forte 		}
656fcf3ce44SJohn Forte 	}
657fcf3ce44SJohn Forte 
658fcf3ce44SJohn Forte 	mdb_free(qlstate, qlsize);
659fcf3ce44SJohn Forte 
660fcf3ce44SJohn Forte 	return (DCMD_OK);
661fcf3ce44SJohn Forte }
662fcf3ce44SJohn Forte 
663fcf3ce44SJohn Forte /*
664fcf3ce44SJohn Forte  * qlc_elog_common
665fcf3ce44SJohn Forte  *	mdb helper function which set/resets the extended logging bit
666fcf3ce44SJohn Forte  *
667fcf3ce44SJohn Forte  * Input:
668fcf3ce44SJohn Forte  *	qlstate  = adapter state structure
669fcf3ce44SJohn Forte  *	elswitch = boolean which specifies to reset (0) or set (1) the
670fcf3ce44SJohn Forte  *		   extended logging bit.
671fcf3ce44SJohn Forte  *
672fcf3ce44SJohn Forte  * Returns:
673fcf3ce44SJohn Forte  *
674fcf3ce44SJohn Forte  * Context:
675fcf3ce44SJohn Forte  *	User context.
676fcf3ce44SJohn Forte  *
677fcf3ce44SJohn Forte  */
678fcf3ce44SJohn Forte static void
ql_elog_common(ql_adapter_state_t * qlstate,boolean_t elswitch)679fcf3ce44SJohn Forte ql_elog_common(ql_adapter_state_t *qlstate, boolean_t elswitch)
680fcf3ce44SJohn Forte {
681fcf3ce44SJohn Forte 	uintptr_t	hbaptr = (uintptr_t)qlstate->hba.base_address;
682fcf3ce44SJohn Forte 	size_t		qlsize = sizeof (ql_adapter_state_t);
683fcf3ce44SJohn Forte 
684fcf3ce44SJohn Forte 	if (elswitch) {
685fcf3ce44SJohn Forte 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) == 0) {
686fcf3ce44SJohn Forte 
687fcf3ce44SJohn Forte 			qlstate->cfg_flags |= CFG_ENABLE_EXTENDED_LOGGING;
688fcf3ce44SJohn Forte 
689fcf3ce44SJohn Forte 			if ((mdb_vwrite((const void *)qlstate, qlsize,
690fcf3ce44SJohn Forte 			    hbaptr)) != (ssize_t)qlsize) {
691fcf3ce44SJohn Forte 				mdb_warn("instance %d - unable to update",
692fcf3ce44SJohn Forte 				    qlstate->instance);
693fcf3ce44SJohn Forte 			} else {
694fcf3ce44SJohn Forte 				mdb_printf("instance %d extended logging is "
695fcf3ce44SJohn Forte 				    "now on\n", qlstate->instance);
696fcf3ce44SJohn Forte 			}
697fcf3ce44SJohn Forte 		} else {
698fcf3ce44SJohn Forte 			mdb_printf("instance %d extended logging is "
699fcf3ce44SJohn Forte 			    "already on\n", qlstate->instance);
700fcf3ce44SJohn Forte 		}
701fcf3ce44SJohn Forte 	} else {
702fcf3ce44SJohn Forte 		if ((qlstate->cfg_flags & CFG_ENABLE_EXTENDED_LOGGING) != 0) {
703fcf3ce44SJohn Forte 
704fcf3ce44SJohn Forte 			qlstate->cfg_flags &= ~CFG_ENABLE_EXTENDED_LOGGING;
705fcf3ce44SJohn Forte 
706fcf3ce44SJohn Forte 			if ((mdb_vwrite((const void *)qlstate, qlsize,
707fcf3ce44SJohn Forte 			    hbaptr)) != (ssize_t)qlsize) {
708fcf3ce44SJohn Forte 				mdb_warn("instance %d - unable to update",
709fcf3ce44SJohn Forte 				    qlstate->instance);
710fcf3ce44SJohn Forte 			} else {
711fcf3ce44SJohn Forte 				mdb_printf("instance %d extended logging is "
712fcf3ce44SJohn Forte 				    "now off\n", qlstate->instance);
713fcf3ce44SJohn Forte 			}
714fcf3ce44SJohn Forte 		} else {
715fcf3ce44SJohn Forte 			mdb_printf("instance %d extended logging is "
716fcf3ce44SJohn Forte 			    "already off\n", qlstate->instance);
717fcf3ce44SJohn Forte 		}
718fcf3ce44SJohn Forte 	}
719fcf3ce44SJohn Forte }
720fcf3ce44SJohn Forte 
721fcf3ce44SJohn Forte /*
722fcf3ce44SJohn Forte  * qlc_ocs_dcmd
723fcf3ce44SJohn Forte  *	mdb dcmd which prints out the outstanding command array using
724fcf3ce44SJohn Forte  *	caller supplied address (which sb the ha structure).
725fcf3ce44SJohn Forte  *
726fcf3ce44SJohn Forte  * Input:
727fcf3ce44SJohn Forte  *	addr  = User supplied ha address.
728fcf3ce44SJohn Forte  *	flags = mdb flags.
729fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
730fcf3ce44SJohn Forte  *	argv  = Arg array.
731fcf3ce44SJohn Forte  *
732fcf3ce44SJohn Forte  * Returns:
733fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
734fcf3ce44SJohn Forte  *
735fcf3ce44SJohn Forte  * Context:
736fcf3ce44SJohn Forte  *	User context.
737fcf3ce44SJohn Forte  *
738fcf3ce44SJohn Forte  *
739fcf3ce44SJohn Forte  */
740fcf3ce44SJohn Forte static int
741fcf3ce44SJohn Forte /*ARGSUSED*/
qlc_osc_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)742fcf3ce44SJohn Forte qlc_osc_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
743fcf3ce44SJohn Forte {
744fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
745fcf3ce44SJohn Forte 	uintptr_t		qlosc, ptr1;
746fcf3ce44SJohn Forte 	uint32_t		indx, found = 0;
747fcf3ce44SJohn Forte 	ql_srb_t		*qlsrb;
748fcf3ce44SJohn Forte 
749fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
750fcf3ce44SJohn Forte 		return (DCMD_USAGE);
751fcf3ce44SJohn Forte 	}
752fcf3ce44SJohn Forte 
753fcf3ce44SJohn Forte 	if ((qlstate = (ql_adapter_state_t *)
754fcf3ce44SJohn Forte 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
755fcf3ce44SJohn Forte 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
756fcf3ce44SJohn Forte 		return (DCMD_OK);
757fcf3ce44SJohn Forte 	}
758fcf3ce44SJohn Forte 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
759fcf3ce44SJohn Forte 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
760fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p", addr);
761fcf3ce44SJohn Forte 		return (DCMD_OK);
762fcf3ce44SJohn Forte 	}
763fcf3ce44SJohn Forte 
764fcf3ce44SJohn Forte 	qlosc = (uintptr_t)qlstate->outstanding_cmds;
765fcf3ce44SJohn Forte 	mdb_printf("qlc instance: %d, base addr = %llx, osc base = %p\n",
766fcf3ce44SJohn Forte 	    qlstate->instance, qlstate->hba.base_address, qlosc);
767fcf3ce44SJohn Forte 
768fcf3ce44SJohn Forte 	if ((qlsrb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP)) ==
769fcf3ce44SJohn Forte 	    NULL) {
770fcf3ce44SJohn Forte 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
771fcf3ce44SJohn Forte 		mdb_warn("failed to allocate space for srb_t\n");
772fcf3ce44SJohn Forte 		return (DCMD_OK);
773fcf3ce44SJohn Forte 	}
774*4c3888b8SHans Rosenfeld 	for (indx = 0; indx < qlstate->osc_max_cnt; indx++, qlosc += 8) {
775fcf3ce44SJohn Forte 		if (mdb_vread(&ptr1, 8, qlosc) == -1) {
776fcf3ce44SJohn Forte 			mdb_warn("failed to read ptr1, indx=%d", indx);
777fcf3ce44SJohn Forte 			break;
778fcf3ce44SJohn Forte 		}
779fcf3ce44SJohn Forte 		if (ptr1 == 0) {
780fcf3ce44SJohn Forte 			continue;
781fcf3ce44SJohn Forte 		}
782fcf3ce44SJohn Forte 
783fcf3ce44SJohn Forte 		mdb_printf("osc ptr = %p, indx = %xh\n", ptr1, indx);
784fcf3ce44SJohn Forte 
785fcf3ce44SJohn Forte 		if (mdb_vread(qlsrb, sizeof (ql_srb_t), ptr1) == -1) {
786fcf3ce44SJohn Forte 			mdb_warn("failed to read ql_srb_t at %p", ptr1);
787fcf3ce44SJohn Forte 			break;
788fcf3ce44SJohn Forte 		}
789fcf3ce44SJohn Forte 		(void) ql_doprint(ptr1, "struct ql_srb");
790fcf3ce44SJohn Forte 		found++;
791fcf3ce44SJohn Forte 	}
792fcf3ce44SJohn Forte 
793fcf3ce44SJohn Forte 	mdb_free(qlsrb, sizeof (ql_srb_t));
794fcf3ce44SJohn Forte 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
795fcf3ce44SJohn Forte 
796fcf3ce44SJohn Forte 	mdb_printf("number of outstanding command srb's is: %d\n", found);
797fcf3ce44SJohn Forte 
798fcf3ce44SJohn Forte 	return (DCMD_OK);
799fcf3ce44SJohn Forte }
800fcf3ce44SJohn Forte 
801fcf3ce44SJohn Forte /*
802fcf3ce44SJohn Forte  * qlc_wdog_dcmd
803fcf3ce44SJohn Forte  *	mdb dcmd which prints out the commands which are linked
804fcf3ce44SJohn Forte  *	on the watchdog linked list. Caller supplied address (which
805fcf3ce44SJohn Forte  *	sb the ha structure).
806fcf3ce44SJohn Forte  *
807fcf3ce44SJohn Forte  * Input:
808fcf3ce44SJohn Forte  *	addr  = User supplied ha address.
809fcf3ce44SJohn Forte  *	flags = mdb flags.
810fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
811fcf3ce44SJohn Forte  *	argv  = Arg array.
812fcf3ce44SJohn Forte  *
813fcf3ce44SJohn Forte  * Returns:
814fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
815fcf3ce44SJohn Forte  *
816fcf3ce44SJohn Forte  * Context:
817fcf3ce44SJohn Forte  *	User context.
818fcf3ce44SJohn Forte  *
819fcf3ce44SJohn Forte  *
820fcf3ce44SJohn Forte  */
821fcf3ce44SJohn Forte static int
822fcf3ce44SJohn Forte /*ARGSUSED*/
qlc_wdog_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)823fcf3ce44SJohn Forte qlc_wdog_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
824fcf3ce44SJohn Forte {
825fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
826fcf3ce44SJohn Forte 	uint16_t		index, count;
827fcf3ce44SJohn Forte 	ql_head_t		*dev;
828fcf3ce44SJohn Forte 	ql_srb_t		*srb;
829fcf3ce44SJohn Forte 	ql_tgt_t		*tq;
830fcf3ce44SJohn Forte 	ql_lun_t		*lq;
831fcf3ce44SJohn Forte 	ql_link_t		*tqlink, *srblink, *lqlink;
832fcf3ce44SJohn Forte 	int			nextlink;
833fcf3ce44SJohn Forte 
834fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
835fcf3ce44SJohn Forte 		mdb_warn("Address required\n", addr);
836fcf3ce44SJohn Forte 		return (DCMD_USAGE);
837fcf3ce44SJohn Forte 	}
838fcf3ce44SJohn Forte 
839fcf3ce44SJohn Forte 	if ((qlstate = (ql_adapter_state_t *)
840fcf3ce44SJohn Forte 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
841fcf3ce44SJohn Forte 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
842fcf3ce44SJohn Forte 		return (DCMD_OK);
843fcf3ce44SJohn Forte 	}
844fcf3ce44SJohn Forte 
845fcf3ce44SJohn Forte 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
846fcf3ce44SJohn Forte 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
847fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p", addr);
848fcf3ce44SJohn Forte 		return (DCMD_OK);
849fcf3ce44SJohn Forte 	}
850fcf3ce44SJohn Forte 
851fcf3ce44SJohn Forte 	/*
852fcf3ce44SJohn Forte 	 * Read in the device array
853fcf3ce44SJohn Forte 	 */
854fcf3ce44SJohn Forte 	dev = (ql_head_t *)
855fcf3ce44SJohn Forte 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
856fcf3ce44SJohn Forte 
857fcf3ce44SJohn Forte 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
858fcf3ce44SJohn Forte 	    (uintptr_t)qlstate->dev) == -1) {
859fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_head_t (dev) at %p", qlstate->dev);
860fcf3ce44SJohn Forte 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
861fcf3ce44SJohn Forte 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
862fcf3ce44SJohn Forte 		return (DCMD_OK);
863fcf3ce44SJohn Forte 	}
864fcf3ce44SJohn Forte 
865fcf3ce44SJohn Forte 	tqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
866fcf3ce44SJohn Forte 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
867fcf3ce44SJohn Forte 	lqlink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
868fcf3ce44SJohn Forte 	lq = (ql_lun_t *)mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
869fcf3ce44SJohn Forte 	srblink = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
870fcf3ce44SJohn Forte 	srb = (ql_srb_t *)mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
871fcf3ce44SJohn Forte 
872fcf3ce44SJohn Forte 	/*
873fcf3ce44SJohn Forte 	 * Validate the devices watchdog queue
874fcf3ce44SJohn Forte 	 */
875fcf3ce44SJohn Forte 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
876fcf3ce44SJohn Forte 
877fcf3ce44SJohn Forte 		/* Skip empty ones */
878fcf3ce44SJohn Forte 		if (dev[index].first == NULL) {
879fcf3ce44SJohn Forte 			continue;
880fcf3ce44SJohn Forte 		}
881fcf3ce44SJohn Forte 
882fcf3ce44SJohn Forte 		mdb_printf("dev array index = %x\n", index);
883fcf3ce44SJohn Forte 
884fcf3ce44SJohn Forte 		/* Loop through targets on device linked list */
885fcf3ce44SJohn Forte 		/* get the first link */
886fcf3ce44SJohn Forte 
887fcf3ce44SJohn Forte 		nextlink = get_first_link(&dev[index], tqlink);
888fcf3ce44SJohn Forte 
889fcf3ce44SJohn Forte 		/*
890fcf3ce44SJohn Forte 		 * traverse the targets linked list at this device array index.
891fcf3ce44SJohn Forte 		 */
892fcf3ce44SJohn Forte 		while (nextlink == DCMD_OK) {
893fcf3ce44SJohn Forte 			/* Get the target */
894fcf3ce44SJohn Forte 			if (mdb_vread(tq, sizeof (ql_tgt_t),
895fcf3ce44SJohn Forte 			    (uintptr_t)(tqlink->base_address)) == -1) {
896fcf3ce44SJohn Forte 				mdb_warn("failed to read ql_tgt at %p",
897fcf3ce44SJohn Forte 				    tqlink->base_address);
898fcf3ce44SJohn Forte 				break;
899fcf3ce44SJohn Forte 			}
900fcf3ce44SJohn Forte 			mdb_printf("tgt q base = %llx, ",
901fcf3ce44SJohn Forte 			    tqlink->base_address);
902fcf3ce44SJohn Forte 
903fcf3ce44SJohn Forte 			mdb_printf("flags: (%xh)", tq->flags);
904fcf3ce44SJohn Forte 
905fcf3ce44SJohn Forte 			if (tq->flags) {
906fcf3ce44SJohn Forte 				ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
907fcf3ce44SJohn Forte 			}
908fcf3ce44SJohn Forte 
909fcf3ce44SJohn Forte 			mdb_printf("tgt: %02x%02x%02x%02x%02x%02x%02x%02x ",
910fcf3ce44SJohn Forte 			    tq->node_name[0], tq->node_name[1],
911fcf3ce44SJohn Forte 			    tq->node_name[2], tq->node_name[3],
912fcf3ce44SJohn Forte 			    tq->node_name[4], tq->node_name[5],
913fcf3ce44SJohn Forte 			    tq->node_name[6], tq->node_name[7]);
914fcf3ce44SJohn Forte 
915fcf3ce44SJohn Forte 			/*
916fcf3ce44SJohn Forte 			 * Loop through commands on this targets watchdog queue.
917fcf3ce44SJohn Forte 			 */
918fcf3ce44SJohn Forte 
919fcf3ce44SJohn Forte 			/* Get the first link on the targets cmd wdg q. */
920fcf3ce44SJohn Forte 			if (tq->wdg.first == NULL) {
921fcf3ce44SJohn Forte 				mdb_printf(" watchdog list empty ");
922fcf3ce44SJohn Forte 				break;
923fcf3ce44SJohn Forte 			} else {
924fcf3ce44SJohn Forte 				if (mdb_vread(srblink, sizeof (ql_link_t),
925fcf3ce44SJohn Forte 				    (uintptr_t)tq->wdg.first) == -1) {
926fcf3ce44SJohn Forte 					mdb_warn("failed to read ql_link_t"
927fcf3ce44SJohn Forte 					    " at %p", tq->wdg.first);
928fcf3ce44SJohn Forte 					break;
929fcf3ce44SJohn Forte 				}
930fcf3ce44SJohn Forte 				/* There is aleast one. */
931fcf3ce44SJohn Forte 				count = 1;
932fcf3ce44SJohn Forte 				/*
933fcf3ce44SJohn Forte 				 * Count the remaining items in the
934fcf3ce44SJohn Forte 				 * cmd watchdog list.
935fcf3ce44SJohn Forte 				 */
936fcf3ce44SJohn Forte 				while (srblink->next != NULL) {
937fcf3ce44SJohn Forte 					/* Read in the next ql_link_t header */
938fcf3ce44SJohn Forte 					if (mdb_vread(srblink,
939fcf3ce44SJohn Forte 					    sizeof (ql_link_t),
940fcf3ce44SJohn Forte 					    (uintptr_t)srblink->next) == -1) {
941fcf3ce44SJohn Forte 						mdb_warn("failed to read"
942fcf3ce44SJohn Forte 						    " ql_link_t next at %p",
943fcf3ce44SJohn Forte 						    srblink->next);
944fcf3ce44SJohn Forte 						break;
945fcf3ce44SJohn Forte 					}
946fcf3ce44SJohn Forte 					count = (uint16_t)(count + 1);
947fcf3ce44SJohn Forte 				}
948fcf3ce44SJohn Forte 				mdb_printf(" watchdog list: %d entries\n",
949fcf3ce44SJohn Forte 				    count);
950fcf3ce44SJohn Forte 				/* get the first one again */
951fcf3ce44SJohn Forte 				if (mdb_vread(srblink, sizeof (ql_link_t),
952fcf3ce44SJohn Forte 				    (uintptr_t)tq->wdg.first) == -1) {
953fcf3ce44SJohn Forte 					mdb_warn("failed to read ql_link_t"
954fcf3ce44SJohn Forte 					    " at %p", tq->wdg.first);
955fcf3ce44SJohn Forte 					break;
956fcf3ce44SJohn Forte 				}
957fcf3ce44SJohn Forte 			}
958fcf3ce44SJohn Forte 			/*
959fcf3ce44SJohn Forte 			 * Traverse the targets cmd watchdog linked list
960fcf3ce44SJohn Forte 			 * verifying srb's from the list are on a lun cmd list.
961fcf3ce44SJohn Forte 			 */
962fcf3ce44SJohn Forte 			while (nextlink == DCMD_OK) {
963fcf3ce44SJohn Forte 				int	found = 0;
964fcf3ce44SJohn Forte 				/* get the srb */
965fcf3ce44SJohn Forte 				if (mdb_vread(srb, sizeof (ql_srb_t),
966fcf3ce44SJohn Forte 				    (uintptr_t)srblink->base_address) == -1) {
967fcf3ce44SJohn Forte 					mdb_warn("failed to read ql_srb_t"
968fcf3ce44SJohn Forte 					" at %p", srblink->base_address);
969fcf3ce44SJohn Forte 					break;
970fcf3ce44SJohn Forte 				}
971fcf3ce44SJohn Forte 				mdb_printf("ql_srb %llx ",
972fcf3ce44SJohn Forte 				    srblink->base_address);
973fcf3ce44SJohn Forte 
974fcf3ce44SJohn Forte 				/*
975fcf3ce44SJohn Forte 				 * Get the lun q the srb is on
976fcf3ce44SJohn Forte 				 */
977fcf3ce44SJohn Forte 				if (mdb_vread(lq, sizeof (ql_lun_t),
978fcf3ce44SJohn Forte 				    (uintptr_t)srb->lun_queue) == -1) {
979fcf3ce44SJohn Forte 					mdb_warn("failed to read ql_srb_t"
980fcf3ce44SJohn Forte 					    " at %p", srb->lun_queue);
981fcf3ce44SJohn Forte 					break;
982fcf3ce44SJohn Forte 				}
983fcf3ce44SJohn Forte 				nextlink = get_first_link(&lq->cmd, lqlink);
984fcf3ce44SJohn Forte 				/*
985fcf3ce44SJohn Forte 				 * traverse the lun cmd linked list looking
986fcf3ce44SJohn Forte 				 * for the srb from the targets watchdog list
987fcf3ce44SJohn Forte 				 */
988fcf3ce44SJohn Forte 				while (nextlink == DCMD_OK) {
989fcf3ce44SJohn Forte 					if (srblink->base_address ==
990fcf3ce44SJohn Forte 					    lqlink->base_address) {
991fcf3ce44SJohn Forte 						mdb_printf("on lun %d cmd q\n",
992fcf3ce44SJohn Forte 						    lq->lun_no);
993fcf3ce44SJohn Forte 						found = 1;
994fcf3ce44SJohn Forte 						break;
995fcf3ce44SJohn Forte 					}
996fcf3ce44SJohn Forte 					/* get next item on lun cmd list */
997fcf3ce44SJohn Forte 					nextlink = get_next_link(lqlink);
998fcf3ce44SJohn Forte 				}
999fcf3ce44SJohn Forte 				if (!found) {
1000fcf3ce44SJohn Forte 					mdb_printf("not found on lun cmd q\n");
1001fcf3ce44SJohn Forte 				}
1002fcf3ce44SJohn Forte 				/* get next item in the watchdog list */
1003fcf3ce44SJohn Forte 				nextlink = get_next_link(srblink);
1004fcf3ce44SJohn Forte 			} /* End targets command watchdog list */
1005fcf3ce44SJohn Forte 			/* get next item in this target list */
1006fcf3ce44SJohn Forte 			nextlink = get_next_link(tqlink);
1007fcf3ce44SJohn Forte 		} /* End traverse the device targets linked list */
1008fcf3ce44SJohn Forte 		mdb_printf("\n");
1009fcf3ce44SJohn Forte 	} /* End device array */
1010fcf3ce44SJohn Forte 
1011fcf3ce44SJohn Forte 	mdb_free(tq, sizeof (ql_tgt_t));
1012fcf3ce44SJohn Forte 	mdb_free(lq, sizeof (ql_lun_t));
1013fcf3ce44SJohn Forte 	mdb_free(srb, sizeof (ql_srb_t));
1014fcf3ce44SJohn Forte 	mdb_free(tqlink, sizeof (ql_link_t));
1015fcf3ce44SJohn Forte 	mdb_free(srblink, sizeof (ql_link_t));
1016fcf3ce44SJohn Forte 	mdb_free(lqlink, sizeof (ql_link_t));
1017fcf3ce44SJohn Forte 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
1018fcf3ce44SJohn Forte 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
1019fcf3ce44SJohn Forte 
1020fcf3ce44SJohn Forte 	return (DCMD_OK);
1021fcf3ce44SJohn Forte }
1022fcf3ce44SJohn Forte 
1023fcf3ce44SJohn Forte /*
1024fcf3ce44SJohn Forte  * get_first_link
1025fcf3ce44SJohn Forte  *	Gets the first ql_link_t header on ql_head.
1026fcf3ce44SJohn Forte  *
1027fcf3ce44SJohn Forte  * Input:
1028fcf3ce44SJohn Forte  *	ql_head  = pointer to a ql_head_t structure.
1029fcf3ce44SJohn Forte  *	ql_link  = pointer to a ql_link_t structure.
1030fcf3ce44SJohn Forte  *
1031fcf3ce44SJohn Forte  * Returns:
1032fcf3ce44SJohn Forte  *	DCMD_ABORT, or DCMD_OK
1033fcf3ce44SJohn Forte  *
1034fcf3ce44SJohn Forte  * Context:
1035fcf3ce44SJohn Forte  *	User context.
1036fcf3ce44SJohn Forte  *
1037fcf3ce44SJohn Forte  */
1038fcf3ce44SJohn Forte static int
get_first_link(ql_head_t * qlhead,ql_link_t * qllink)1039fcf3ce44SJohn Forte get_first_link(ql_head_t *qlhead, ql_link_t *qllink)
1040fcf3ce44SJohn Forte {
1041fcf3ce44SJohn Forte 	int	rval = DCMD_ABORT;
1042fcf3ce44SJohn Forte 
1043fcf3ce44SJohn Forte 	if (qlhead != NULL) {
1044fcf3ce44SJohn Forte 		if (qlhead->first != NULL) {
1045fcf3ce44SJohn Forte 			/* Read in the first ql_link_t header */
1046fcf3ce44SJohn Forte 			if (mdb_vread(qllink, sizeof (ql_link_t),
1047fcf3ce44SJohn Forte 			    (uintptr_t)(qlhead->first)) == -1) {
1048fcf3ce44SJohn Forte 				mdb_warn("failed to read ql_link_t "
1049fcf3ce44SJohn Forte 				    "next at %p", qlhead->first);
1050fcf3ce44SJohn Forte 			} else {
1051fcf3ce44SJohn Forte 				rval = DCMD_OK;
1052fcf3ce44SJohn Forte 			}
1053fcf3ce44SJohn Forte 		}
1054fcf3ce44SJohn Forte 	}
1055fcf3ce44SJohn Forte 	return (rval);
1056fcf3ce44SJohn Forte }
1057fcf3ce44SJohn Forte 
1058fcf3ce44SJohn Forte /*
1059fcf3ce44SJohn Forte  * get_next_link
1060fcf3ce44SJohn Forte  *	Gets the next ql_link_t structure.
1061fcf3ce44SJohn Forte  *
1062fcf3ce44SJohn Forte  * Input:
1063fcf3ce44SJohn Forte  *	ql_link  = pointer to a ql_link_t structure.
1064fcf3ce44SJohn Forte  *
1065fcf3ce44SJohn Forte  * Returns:
1066fcf3ce44SJohn Forte  *	DCMD_ABORT, or DCMD_OK
1067fcf3ce44SJohn Forte  *
1068fcf3ce44SJohn Forte  * Context:
1069fcf3ce44SJohn Forte  *	User context.
1070fcf3ce44SJohn Forte  *
1071fcf3ce44SJohn Forte  */
1072fcf3ce44SJohn Forte static int
get_next_link(ql_link_t * qllink)1073fcf3ce44SJohn Forte get_next_link(ql_link_t *qllink)
1074fcf3ce44SJohn Forte {
1075fcf3ce44SJohn Forte 	int	rval = DCMD_ABORT;
1076fcf3ce44SJohn Forte 
1077fcf3ce44SJohn Forte 	if (qllink != NULL) {
1078fcf3ce44SJohn Forte 		if (qllink->next != NULL) {
1079fcf3ce44SJohn Forte 			/* Read in the next ql_link_t header */
1080fcf3ce44SJohn Forte 			if (mdb_vread(qllink, sizeof (ql_link_t),
1081fcf3ce44SJohn Forte 			    (uintptr_t)(qllink->next)) == -1) {
1082fcf3ce44SJohn Forte 				mdb_warn("failed to read ql_link_t "
1083fcf3ce44SJohn Forte 				    "next at %p", qllink->next);
1084fcf3ce44SJohn Forte 			} else {
1085fcf3ce44SJohn Forte 				rval = DCMD_OK;
1086fcf3ce44SJohn Forte 			}
1087fcf3ce44SJohn Forte 		}
1088fcf3ce44SJohn Forte 	}
1089fcf3ce44SJohn Forte 	return (rval);
1090fcf3ce44SJohn Forte }
1091fcf3ce44SJohn Forte 
1092fcf3ce44SJohn Forte /*
1093fcf3ce44SJohn Forte  * qlcstate_dcmd
1094fcf3ce44SJohn Forte  *	mdb dcmd which prints out the ql_state info using
1095fcf3ce44SJohn Forte  *	caller supplied address.
1096fcf3ce44SJohn Forte  *
1097fcf3ce44SJohn Forte  * Input:
1098fcf3ce44SJohn Forte  *	addr  = User supplied address.
1099fcf3ce44SJohn Forte  *	flags = mdb flags.
1100fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
1101fcf3ce44SJohn Forte  *	argv  = Arg array.
1102fcf3ce44SJohn Forte  *
1103fcf3ce44SJohn Forte  * Returns:
1104fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
1105fcf3ce44SJohn Forte  *
1106fcf3ce44SJohn Forte  * Context:
1107fcf3ce44SJohn Forte  *	User context.
1108fcf3ce44SJohn Forte  *
1109fcf3ce44SJohn Forte  */
1110fcf3ce44SJohn Forte static int
qlcstate_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1111fcf3ce44SJohn Forte qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1112fcf3ce44SJohn Forte {
1113fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
1114fcf3ce44SJohn Forte 	int			verbose = 0;
1115fcf3ce44SJohn Forte 
1116fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
1117fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1118fcf3ce44SJohn Forte 	}
1119fcf3ce44SJohn Forte 
11203b442230SJordan Paige Hendricks 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
11213b442230SJordan Paige Hendricks 	    NULL) != argc) {
1122fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1123fcf3ce44SJohn Forte 	}
1124fcf3ce44SJohn Forte 
1125fcf3ce44SJohn Forte 	if ((qlstate = (ql_adapter_state_t *)
1126fcf3ce44SJohn Forte 	    mdb_alloc(sizeof (ql_adapter_state_t), UM_SLEEP)) == NULL) {
1127fcf3ce44SJohn Forte 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
1128fcf3ce44SJohn Forte 		return (DCMD_OK);
1129fcf3ce44SJohn Forte 	}
1130fcf3ce44SJohn Forte 	if (mdb_vread(qlstate, sizeof (ql_adapter_state_t), addr) == -1) {
1131fcf3ce44SJohn Forte 		mdb_free(qlstate, sizeof (ql_adapter_state_t));
1132fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p", addr);
1133fcf3ce44SJohn Forte 		return (DCMD_OK);
1134fcf3ce44SJohn Forte 	}
1135fcf3ce44SJohn Forte 
1136fcf3ce44SJohn Forte 	mdb_printf("qlc instance: %d, base addr = %llx\n", qlstate->instance,
1137fcf3ce44SJohn Forte 	    addr);
1138fcf3ce44SJohn Forte 
1139fcf3ce44SJohn Forte 	mdb_printf("\nadapter state flags:\n");
1140fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
1141fcf3ce44SJohn Forte 	mdb_printf("\nadapter cfg flags:\n");
1142fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
1143fcf3ce44SJohn Forte 	mdb_printf("\ntask daemon state flags:\n");
1144fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
1145fcf3ce44SJohn Forte 	    task_daemon_flags);
1146fcf3ce44SJohn Forte 
1147fcf3ce44SJohn Forte 	if (verbose) {
1148fcf3ce44SJohn Forte 		(void) ql_doprint(addr, "struct ql_adapter_state");
1149fcf3ce44SJohn Forte 	}
1150fcf3ce44SJohn Forte 
1151fcf3ce44SJohn Forte 	mdb_free(qlstate, sizeof (ql_adapter_state_t));
1152fcf3ce44SJohn Forte 
1153fcf3ce44SJohn Forte 	return (DCMD_OK);
1154fcf3ce44SJohn Forte }
1155fcf3ce44SJohn Forte 
1156fcf3ce44SJohn Forte /*
1157fcf3ce44SJohn Forte  * qlcstates_walk_init
1158fcf3ce44SJohn Forte  *	mdb walker init which prints out all qlc states info.
1159fcf3ce44SJohn Forte  *
1160fcf3ce44SJohn Forte  * Input:
1161fcf3ce44SJohn Forte  *	wsp - Pointer to walker state struct
1162fcf3ce44SJohn Forte  *
1163fcf3ce44SJohn Forte  * Returns:
1164fcf3ce44SJohn Forte  *	WALK_ERR, or WALK_NEXT
1165fcf3ce44SJohn Forte  *
1166fcf3ce44SJohn Forte  * Context:
1167fcf3ce44SJohn Forte  *	User context.
1168fcf3ce44SJohn Forte  *
1169fcf3ce44SJohn Forte  */
1170fcf3ce44SJohn Forte static int
qlstates_walk_init(mdb_walk_state_t * wsp)1171fcf3ce44SJohn Forte qlstates_walk_init(mdb_walk_state_t *wsp)
1172fcf3ce44SJohn Forte {
1173fcf3ce44SJohn Forte 	ql_head_t	ql_hba;
1174fcf3ce44SJohn Forte 
1175892ad162SToomas Soome 	if (wsp->walk_addr == 0) {
1176fcf3ce44SJohn Forte 		if ((mdb_readvar(&ql_hba, "ql_hba") == -1) ||
1177fcf3ce44SJohn Forte 		    (&ql_hba == NULL)) {
1178fcf3ce44SJohn Forte 			mdb_warn("failed to read ql_hba structure");
1179fcf3ce44SJohn Forte 			return (WALK_ERR);
1180fcf3ce44SJohn Forte 		}
1181fcf3ce44SJohn Forte 
1182fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)ql_hba.first;
1183fcf3ce44SJohn Forte 		wsp->walk_data = mdb_alloc(sizeof (ql_adapter_state_t),
1184fcf3ce44SJohn Forte 		    UM_SLEEP);
1185fcf3ce44SJohn Forte 		return (WALK_NEXT);
1186fcf3ce44SJohn Forte 	} else {
1187fcf3ce44SJohn Forte 		return (ql_doprint(wsp->walk_addr, "struct ql_adapter_state"));
1188fcf3ce44SJohn Forte 	}
1189fcf3ce44SJohn Forte }
1190fcf3ce44SJohn Forte 
1191fcf3ce44SJohn Forte /*
1192fcf3ce44SJohn Forte  * qlstates_walk_step
1193fcf3ce44SJohn Forte  *	mdb walker step which prints out all qlc states info.
1194fcf3ce44SJohn Forte  *
1195fcf3ce44SJohn Forte  * Input:
1196fcf3ce44SJohn Forte  *	wsp - Pointer to walker state struct
1197fcf3ce44SJohn Forte  *
1198fcf3ce44SJohn Forte  * Returns:
1199fcf3ce44SJohn Forte  *	WALK_DONE, or WALK_NEXT
1200fcf3ce44SJohn Forte  *
1201fcf3ce44SJohn Forte  * Context:
1202fcf3ce44SJohn Forte  *	User context.
1203fcf3ce44SJohn Forte  *
1204fcf3ce44SJohn Forte  */
1205fcf3ce44SJohn Forte static int
qlstates_walk_step(mdb_walk_state_t * wsp)1206fcf3ce44SJohn Forte qlstates_walk_step(mdb_walk_state_t *wsp)
1207fcf3ce44SJohn Forte {
1208fcf3ce44SJohn Forte 	ql_adapter_state_t	*qlstate;
1209fcf3ce44SJohn Forte 
1210892ad162SToomas Soome 	if (wsp->walk_addr == 0) {
1211fcf3ce44SJohn Forte 		return (WALK_DONE);
1212fcf3ce44SJohn Forte 	}
1213fcf3ce44SJohn Forte 
1214fcf3ce44SJohn Forte 	if (mdb_vread(wsp->walk_data, sizeof (ql_adapter_state_t),
1215fcf3ce44SJohn Forte 	    wsp->walk_addr) == -1) {
1216fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p",
1217fcf3ce44SJohn Forte 		    wsp->walk_addr);
1218fcf3ce44SJohn Forte 		return (WALK_DONE);
1219fcf3ce44SJohn Forte 	}
1220fcf3ce44SJohn Forte 
1221fcf3ce44SJohn Forte 	qlstate = (ql_adapter_state_t *)(wsp->walk_data);
1222fcf3ce44SJohn Forte 	mdb_printf("qlc instance: %d, base addr = %llx\n",
1223fcf3ce44SJohn Forte 	    qlstate->instance, wsp->walk_addr);
1224fcf3ce44SJohn Forte 
1225fcf3ce44SJohn Forte 	mdb_printf("\nadapter state flags:\n");
1226fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->flags, adapter_state_flags);
1227fcf3ce44SJohn Forte 	mdb_printf("\nadapter cfg flags:\n");
1228fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->cfg_flags, adapter_config_flags);
1229fcf3ce44SJohn Forte 	mdb_printf("\ntask daemon state flags:\n");
1230fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlstate->task_daemon_flags,
1231fcf3ce44SJohn Forte 	    task_daemon_flags);
1232fcf3ce44SJohn Forte 
1233fcf3ce44SJohn Forte 	mdb_printf("\nadapter state:\n");
1234fcf3ce44SJohn Forte 	(void) ql_doprint(wsp->walk_addr, "struct ql_adapter_state");
1235fcf3ce44SJohn Forte 
1236fcf3ce44SJohn Forte 	mdb_printf("\n");
1237fcf3ce44SJohn Forte 
1238fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)
1239fcf3ce44SJohn Forte 	    (((ql_adapter_state_t *)wsp->walk_data)->hba.next);
1240fcf3ce44SJohn Forte 
1241fcf3ce44SJohn Forte 	return (WALK_NEXT);
1242fcf3ce44SJohn Forte }
1243fcf3ce44SJohn Forte 
1244fcf3ce44SJohn Forte /*
1245fcf3ce44SJohn Forte  * qlstates_walk_fini
1246fcf3ce44SJohn Forte  *	mdb walker fini which wraps up the walker
1247fcf3ce44SJohn Forte  *
1248fcf3ce44SJohn Forte  * Input:
1249fcf3ce44SJohn Forte  *	wsp - Pointer to walker state struct
1250fcf3ce44SJohn Forte  *
1251fcf3ce44SJohn Forte  * Returns:
1252fcf3ce44SJohn Forte  *
1253fcf3ce44SJohn Forte  * Context:
1254fcf3ce44SJohn Forte  *	User context.
1255fcf3ce44SJohn Forte  *
1256fcf3ce44SJohn Forte  */
1257fcf3ce44SJohn Forte static void
qlstates_walk_fini(mdb_walk_state_t * wsp)1258fcf3ce44SJohn Forte qlstates_walk_fini(mdb_walk_state_t *wsp)
1259fcf3ce44SJohn Forte {
1260fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (ql_adapter_state_t));
1261fcf3ce44SJohn Forte }
1262fcf3ce44SJohn Forte 
1263fcf3ce44SJohn Forte /*
1264fcf3ce44SJohn Forte  * qlsrb_walk_init
1265fcf3ce44SJohn Forte  *	mdb walker init which prints out linked srb's
1266fcf3ce44SJohn Forte  *
1267fcf3ce44SJohn Forte  * Input:
1268fcf3ce44SJohn Forte  *	wsp - Pointer to walker ql_srb struct
1269fcf3ce44SJohn Forte  *
1270fcf3ce44SJohn Forte  * Returns:
1271fcf3ce44SJohn Forte  *	WALK_ERR, or WALK_NEXT
1272fcf3ce44SJohn Forte  *
1273fcf3ce44SJohn Forte  * Context:
1274fcf3ce44SJohn Forte  *	User context.
1275fcf3ce44SJohn Forte  *
1276fcf3ce44SJohn Forte  */
1277fcf3ce44SJohn Forte static int
qlsrb_walk_init(mdb_walk_state_t * wsp)1278fcf3ce44SJohn Forte qlsrb_walk_init(mdb_walk_state_t *wsp)
1279fcf3ce44SJohn Forte {
1280892ad162SToomas Soome 	if (wsp->walk_addr == 0) {
1281fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_srb addr at %p",
1282fcf3ce44SJohn Forte 		    wsp->walk_addr);
1283fcf3ce44SJohn Forte 		return (WALK_ERR);
1284fcf3ce44SJohn Forte 	}
1285fcf3ce44SJohn Forte 
1286fcf3ce44SJohn Forte 	wsp->walk_data = mdb_alloc(sizeof (ql_srb_t), UM_SLEEP);
1287fcf3ce44SJohn Forte 
1288fcf3ce44SJohn Forte 	return (WALK_NEXT);
1289fcf3ce44SJohn Forte }
1290fcf3ce44SJohn Forte 
1291fcf3ce44SJohn Forte /*
1292fcf3ce44SJohn Forte  * qlcsrb_walk_step
1293fcf3ce44SJohn Forte  *	mdb walker step which prints out linked ql_srb structures
1294fcf3ce44SJohn Forte  *
1295fcf3ce44SJohn Forte  * Input:
1296fcf3ce44SJohn Forte  *	wsp - Pointer to walker srb struct
1297fcf3ce44SJohn Forte  *
1298fcf3ce44SJohn Forte  * Returns:
1299fcf3ce44SJohn Forte  *	WALK_DONE, or WALK_NEXT
1300fcf3ce44SJohn Forte  *
1301fcf3ce44SJohn Forte  * Context:
1302fcf3ce44SJohn Forte  *	User context.
1303fcf3ce44SJohn Forte  *
1304fcf3ce44SJohn Forte  */
1305fcf3ce44SJohn Forte static int
qlsrb_walk_step(mdb_walk_state_t * wsp)1306fcf3ce44SJohn Forte qlsrb_walk_step(mdb_walk_state_t *wsp)
1307fcf3ce44SJohn Forte {
1308fcf3ce44SJohn Forte 	ql_srb_t	*qlsrb;
1309fcf3ce44SJohn Forte 
1310892ad162SToomas Soome 	if (wsp->walk_addr == 0)
1311fcf3ce44SJohn Forte 		return (WALK_DONE);
1312fcf3ce44SJohn Forte 
1313fcf3ce44SJohn Forte 	if (mdb_vread(wsp->walk_data, sizeof (ql_srb_t),
1314fcf3ce44SJohn Forte 	    wsp->walk_addr) == -1) {
1315fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_srb at %p", wsp->walk_addr);
1316fcf3ce44SJohn Forte 		return (WALK_DONE);
1317fcf3ce44SJohn Forte 	}
1318fcf3ce44SJohn Forte 
1319fcf3ce44SJohn Forte 	qlsrb = (ql_srb_t *)(wsp->walk_data);
1320fcf3ce44SJohn Forte 	mdb_printf("ql_srb base addr = %llx\n", wsp->walk_addr);
1321fcf3ce44SJohn Forte 
1322fcf3ce44SJohn Forte 	mdb_printf("\nql_srb flags:\n");
1323fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qlsrb->flags, qlsrb_flags);
1324fcf3ce44SJohn Forte 
1325fcf3ce44SJohn Forte 	mdb_printf("\nql_srb:\n");
1326fcf3ce44SJohn Forte 	(void) ql_doprint(wsp->walk_addr, "struct ql_srb");
1327fcf3ce44SJohn Forte 
1328fcf3ce44SJohn Forte 	mdb_printf("\n");
1329fcf3ce44SJohn Forte 
1330fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)
1331fcf3ce44SJohn Forte 	    (((ql_srb_t *)wsp->walk_data)->cmd.next);
1332fcf3ce44SJohn Forte 
1333fcf3ce44SJohn Forte 	return (WALK_NEXT);
1334fcf3ce44SJohn Forte }
1335fcf3ce44SJohn Forte 
1336fcf3ce44SJohn Forte /*
1337fcf3ce44SJohn Forte  * qlsrb_walk_fini
1338fcf3ce44SJohn Forte  *	mdb walker fini which wraps up the walker
1339fcf3ce44SJohn Forte  *
1340fcf3ce44SJohn Forte  * Input:
1341fcf3ce44SJohn Forte  *	wsp - Pointer to walker state struct
1342fcf3ce44SJohn Forte  *
1343fcf3ce44SJohn Forte  * Returns:
1344fcf3ce44SJohn Forte  *
1345fcf3ce44SJohn Forte  * Context:
1346fcf3ce44SJohn Forte  *	User context.
1347fcf3ce44SJohn Forte  *
1348fcf3ce44SJohn Forte  */
1349fcf3ce44SJohn Forte static void
qlsrb_walk_fini(mdb_walk_state_t * wsp)1350fcf3ce44SJohn Forte qlsrb_walk_fini(mdb_walk_state_t *wsp)
1351fcf3ce44SJohn Forte {
1352fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (ql_srb_t));
1353fcf3ce44SJohn Forte }
1354fcf3ce44SJohn Forte 
1355fcf3ce44SJohn Forte /*
1356fcf3ce44SJohn Forte  * qllunq_dcmd
1357fcf3ce44SJohn Forte  *	mdb walker which prints out lun q's
1358fcf3ce44SJohn Forte  *
1359fcf3ce44SJohn Forte  * Input:
1360fcf3ce44SJohn Forte  *	wsp - Pointer to walker ql_lun struct
1361fcf3ce44SJohn Forte  *
1362fcf3ce44SJohn Forte  * Returns:
1363fcf3ce44SJohn Forte  *	WALK_ERR, or WALK_NEXT
1364fcf3ce44SJohn Forte  *
1365fcf3ce44SJohn Forte  * Context:
1366fcf3ce44SJohn Forte  *	User context.
1367fcf3ce44SJohn Forte  *
1368fcf3ce44SJohn Forte  */
1369fcf3ce44SJohn Forte static int
qllunq_walk_init(mdb_walk_state_t * wsp)1370fcf3ce44SJohn Forte qllunq_walk_init(mdb_walk_state_t *wsp)
1371fcf3ce44SJohn Forte {
1372892ad162SToomas Soome 	if (wsp->walk_addr == 0) {
1373fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_lun addr at %p",
1374fcf3ce44SJohn Forte 		    wsp->walk_addr);
1375fcf3ce44SJohn Forte 		return (WALK_ERR);
1376fcf3ce44SJohn Forte 	}
1377fcf3ce44SJohn Forte 
1378fcf3ce44SJohn Forte 	wsp->walk_data = mdb_alloc(sizeof (ql_lun_t), UM_SLEEP);
1379fcf3ce44SJohn Forte 
1380fcf3ce44SJohn Forte 	return (WALK_NEXT);
1381fcf3ce44SJohn Forte }
1382fcf3ce44SJohn Forte 
1383fcf3ce44SJohn Forte /*
1384fcf3ce44SJohn Forte  * qlclunq_walk_step
1385fcf3ce44SJohn Forte  *	mdb walker step which prints out linked ql_lun structures
1386fcf3ce44SJohn Forte  *
1387fcf3ce44SJohn Forte  * Input:
1388fcf3ce44SJohn Forte  *	wsp - Pointer to walker srb struct
1389fcf3ce44SJohn Forte  *
1390fcf3ce44SJohn Forte  * Returns:
1391fcf3ce44SJohn Forte  *	WALK_DONE, or WALK_NEXT
1392fcf3ce44SJohn Forte  *
1393fcf3ce44SJohn Forte  * Context:
1394fcf3ce44SJohn Forte  *	User context.
1395fcf3ce44SJohn Forte  *
1396fcf3ce44SJohn Forte  */
1397fcf3ce44SJohn Forte static int
qllunq_walk_step(mdb_walk_state_t * wsp)1398fcf3ce44SJohn Forte qllunq_walk_step(mdb_walk_state_t *wsp)
1399fcf3ce44SJohn Forte {
1400fcf3ce44SJohn Forte 	ql_lun_t	*qllun;
1401fcf3ce44SJohn Forte 	ql_link_t	ql_link;
1402fcf3ce44SJohn Forte 	ql_link_t	*qllink;
1403fcf3ce44SJohn Forte 
1404892ad162SToomas Soome 	if (wsp->walk_addr == 0)
1405fcf3ce44SJohn Forte 		return (WALK_DONE);
1406fcf3ce44SJohn Forte 
1407fcf3ce44SJohn Forte 	if (mdb_vread(wsp->walk_data, sizeof (ql_lun_t),
1408fcf3ce44SJohn Forte 	    wsp->walk_addr) == -1) {
1409fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_lun at %p", wsp->walk_addr);
1410fcf3ce44SJohn Forte 		return (WALK_DONE);
1411fcf3ce44SJohn Forte 	}
1412fcf3ce44SJohn Forte 
1413fcf3ce44SJohn Forte 	qllun = (ql_lun_t *)(wsp->walk_data);
1414fcf3ce44SJohn Forte 	mdb_printf("ql_lun base addr = %llx\n", wsp->walk_addr);
1415fcf3ce44SJohn Forte 
1416fcf3ce44SJohn Forte 	mdb_printf("\nql_lun flags:\n");
1417fcf3ce44SJohn Forte 	ql_dump_flags((uint64_t)qllun->flags, qllun_flags);
1418fcf3ce44SJohn Forte 
1419fcf3ce44SJohn Forte 	mdb_printf("\nql_lun:\n");
1420fcf3ce44SJohn Forte 	(void) ql_doprint(wsp->walk_addr, "struct ql_lun");
1421fcf3ce44SJohn Forte 
1422fcf3ce44SJohn Forte 	mdb_printf("\n");
1423fcf3ce44SJohn Forte 
1424fcf3ce44SJohn Forte 	qllink = (ql_link_t *)
1425fcf3ce44SJohn Forte 	    (((ql_lun_t *)wsp->walk_data)->link.next);
1426fcf3ce44SJohn Forte 
1427fcf3ce44SJohn Forte 	if (qllink == NULL) {
1428fcf3ce44SJohn Forte 		return (WALK_DONE);
1429fcf3ce44SJohn Forte 	} else {
1430fcf3ce44SJohn Forte 		/*
1431fcf3ce44SJohn Forte 		 * Read in the next link_t header
1432fcf3ce44SJohn Forte 		 */
1433fcf3ce44SJohn Forte 		if (mdb_vread(&ql_link, sizeof (ql_link_t),
1434fcf3ce44SJohn Forte 		    (uintptr_t)qllink) == -1) {
1435fcf3ce44SJohn Forte 			mdb_warn("failed to read ql_link_t "
1436fcf3ce44SJohn Forte 			    "next at %p", qllink->next);
1437fcf3ce44SJohn Forte 			return (WALK_DONE);
1438fcf3ce44SJohn Forte 		}
1439fcf3ce44SJohn Forte 		qllink = &ql_link;
1440fcf3ce44SJohn Forte 	}
1441fcf3ce44SJohn Forte 
1442fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)qllink->base_address;
1443fcf3ce44SJohn Forte 
1444fcf3ce44SJohn Forte 	return (WALK_NEXT);
1445fcf3ce44SJohn Forte }
1446fcf3ce44SJohn Forte 
1447fcf3ce44SJohn Forte /*
1448fcf3ce44SJohn Forte  * qllunq_walk_fini
1449fcf3ce44SJohn Forte  *	mdb walker fini which wraps up the walker
1450fcf3ce44SJohn Forte  *
1451fcf3ce44SJohn Forte  * Input:
1452fcf3ce44SJohn Forte  *	wsp - Pointer to walker state struct
1453fcf3ce44SJohn Forte  *
1454fcf3ce44SJohn Forte  * Returns:
1455fcf3ce44SJohn Forte  *
1456fcf3ce44SJohn Forte  * Context:
1457fcf3ce44SJohn Forte  *	User context.
1458fcf3ce44SJohn Forte  *
1459fcf3ce44SJohn Forte  */
1460fcf3ce44SJohn Forte static void
qllunq_walk_fini(mdb_walk_state_t * wsp)1461fcf3ce44SJohn Forte qllunq_walk_fini(mdb_walk_state_t *wsp)
1462fcf3ce44SJohn Forte {
1463fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (ql_lun_t));
1464fcf3ce44SJohn Forte }
1465fcf3ce44SJohn Forte 
1466fcf3ce44SJohn Forte /*
1467fcf3ce44SJohn Forte  * qltgtq_dcmd
1468fcf3ce44SJohn Forte  *	mdb dcmd which prints out an hs's tq struct info.
1469fcf3ce44SJohn Forte  *
1470fcf3ce44SJohn Forte  * Input:
1471fcf3ce44SJohn Forte  *	addr  = User supplied address. (NB: nust be an ha)
1472fcf3ce44SJohn Forte  *	flags = mdb flags.
1473fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
1474fcf3ce44SJohn Forte  *	argv  = Arg array.
1475fcf3ce44SJohn Forte  *
1476fcf3ce44SJohn Forte  * Returns:
1477fcf3ce44SJohn Forte  *	DCMD_USAGE, or DCMD_OK
1478fcf3ce44SJohn Forte  *
1479fcf3ce44SJohn Forte  * Context:
1480fcf3ce44SJohn Forte  *	User context.
1481fcf3ce44SJohn Forte  *
1482fcf3ce44SJohn Forte  */
1483fcf3ce44SJohn Forte /*ARGSUSED*/
1484fcf3ce44SJohn Forte static int
qltgtq_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1485fcf3ce44SJohn Forte qltgtq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1486fcf3ce44SJohn Forte {
1487fcf3ce44SJohn Forte 	ql_adapter_state_t	*ha;
1488fcf3ce44SJohn Forte 	ql_link_t		*link;
1489fcf3ce44SJohn Forte 	ql_tgt_t		*tq;
1490fcf3ce44SJohn Forte 	uint32_t		index;
1491fcf3ce44SJohn Forte 	ql_head_t		*dev;
1492fcf3ce44SJohn Forte 
1493892ad162SToomas Soome 	if ((!(flags & DCMD_ADDRSPEC)) || addr == 0) {
1494fcf3ce44SJohn Forte 		mdb_warn("ql_hba structure addr is required");
1495fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1496fcf3ce44SJohn Forte 	}
1497fcf3ce44SJohn Forte 
1498fcf3ce44SJohn Forte 	/*
1499fcf3ce44SJohn Forte 	 * Get the adapter state struct which was passed
1500fcf3ce44SJohn Forte 	 */
1501fcf3ce44SJohn Forte 
1502fcf3ce44SJohn Forte 	ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
1503fcf3ce44SJohn Forte 	    UM_SLEEP);
1504fcf3ce44SJohn Forte 
1505fcf3ce44SJohn Forte 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
1506fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p", addr);
1507fcf3ce44SJohn Forte 		mdb_free(ha, sizeof (ql_adapter_state_t));
1508fcf3ce44SJohn Forte 		return (DCMD_OK);
1509fcf3ce44SJohn Forte 	}
1510fcf3ce44SJohn Forte 
1511fcf3ce44SJohn Forte 	if (ha->dev == NULL) {
1512fcf3ce44SJohn Forte 		mdb_warn("dev ptr is NULL for ha: %p", addr);
1513fcf3ce44SJohn Forte 		mdb_free(ha, sizeof (ql_adapter_state_t));
1514fcf3ce44SJohn Forte 		return (DCMD_OK);
1515fcf3ce44SJohn Forte 	}
1516fcf3ce44SJohn Forte 
1517fcf3ce44SJohn Forte 	/*
1518fcf3ce44SJohn Forte 	 * Read in the device array
1519fcf3ce44SJohn Forte 	 */
1520fcf3ce44SJohn Forte 	dev = (ql_head_t *)
1521fcf3ce44SJohn Forte 	    mdb_alloc(sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE, UM_SLEEP);
1522fcf3ce44SJohn Forte 
1523fcf3ce44SJohn Forte 	if (mdb_vread(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE,
1524fcf3ce44SJohn Forte 	    (uintptr_t)ha->dev) == -1) {
1525fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_head_t (dev) at %p", ha->dev);
1526fcf3ce44SJohn Forte 		mdb_free(ha, sizeof (ql_adapter_state_t));
1527fcf3ce44SJohn Forte 		mdb_free(dev, sizeof (ql_head_t) * DEVICE_HEAD_LIST_SIZE);
1528fcf3ce44SJohn Forte 	}
1529fcf3ce44SJohn Forte 
1530fcf3ce44SJohn Forte 	tq = (ql_tgt_t *)mdb_alloc(sizeof (ql_tgt_t), UM_SLEEP);
1531fcf3ce44SJohn Forte 	link = (ql_link_t *)mdb_alloc(sizeof (ql_link_t), UM_SLEEP);
1532fcf3ce44SJohn Forte 
1533fcf3ce44SJohn Forte 	for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
1534fcf3ce44SJohn Forte 
1535fcf3ce44SJohn Forte 		if (dev[index].first == NULL) {
1536fcf3ce44SJohn Forte 			continue;
1537fcf3ce44SJohn Forte 		}
1538fcf3ce44SJohn Forte 
1539fcf3ce44SJohn Forte 		if (mdb_vread(link, sizeof (ql_link_t),
1540fcf3ce44SJohn Forte 		    (uintptr_t)dev[index].first) == -1) {
1541fcf3ce44SJohn Forte 			mdb_warn("failed to read ql_link_t at %p",
1542fcf3ce44SJohn Forte 			    dev[index].first);
1543fcf3ce44SJohn Forte 			break;
1544fcf3ce44SJohn Forte 		}
1545fcf3ce44SJohn Forte 
1546fcf3ce44SJohn Forte 		while (link != NULL) {
1547fcf3ce44SJohn Forte 			if (mdb_vread(tq, sizeof (ql_tgt_t),
1548fcf3ce44SJohn Forte 			    (uintptr_t)(link->base_address)) == -1) {
1549fcf3ce44SJohn Forte 				mdb_warn("failed to read ql_tgt at %p",
1550fcf3ce44SJohn Forte 				    link->base_address);
1551fcf3ce44SJohn Forte 				break;
1552fcf3ce44SJohn Forte 			}
1553fcf3ce44SJohn Forte 
1554fcf3ce44SJohn Forte 			mdb_printf("tgt queue base addr = %llx\n",
1555fcf3ce44SJohn Forte 			    link->base_address);
1556fcf3ce44SJohn Forte 
1557fcf3ce44SJohn Forte 			mdb_printf("\ntgt queue flags: (%xh)\n", tq->flags);
1558fcf3ce44SJohn Forte 			ql_dump_flags((uint64_t)tq->flags, qltgt_flags);
1559fcf3ce44SJohn Forte 
1560fcf3ce44SJohn Forte 			mdb_printf("\ntgt queue:\n");
1561fcf3ce44SJohn Forte 
1562fcf3ce44SJohn Forte 			(void) ql_doprint((uintptr_t)link->base_address,
1563fcf3ce44SJohn Forte 			    "struct ql_target");
1564fcf3ce44SJohn Forte 
1565fcf3ce44SJohn Forte 			mdb_printf("\n");
1566fcf3ce44SJohn Forte 
1567fcf3ce44SJohn Forte 			if (get_next_link(link) != DCMD_OK) {
1568fcf3ce44SJohn Forte 				break;
1569fcf3ce44SJohn Forte 			}
1570fcf3ce44SJohn Forte 		}
1571fcf3ce44SJohn Forte 	}
1572fcf3ce44SJohn Forte 
1573fcf3ce44SJohn Forte 	mdb_free(ha, sizeof (ql_adapter_state_t));
1574fcf3ce44SJohn Forte 	mdb_free(tq, sizeof (ql_tgt_t));
1575fcf3ce44SJohn Forte 	mdb_free(link, sizeof (ql_link_t));
1576fcf3ce44SJohn Forte 	mdb_free(dev, sizeof (ql_head_t)*DEVICE_HEAD_LIST_SIZE);
1577fcf3ce44SJohn Forte 
1578fcf3ce44SJohn Forte 	return (DCMD_OK);
1579fcf3ce44SJohn Forte }
1580fcf3ce44SJohn Forte 
1581fcf3ce44SJohn Forte /*
158216dd44c2SDaniel Beauregard  * ql_triggerdump_dcmd
158316dd44c2SDaniel Beauregard  *	Triggers the driver to take a firmware dump
158416dd44c2SDaniel Beauregard  *
158516dd44c2SDaniel Beauregard  * Input:
158616dd44c2SDaniel Beauregard  *	addr  = User supplied address (optional)
158716dd44c2SDaniel Beauregard  *	flags = mdb flags.
158816dd44c2SDaniel Beauregard  *	argc  = Number of user supplied args.
158916dd44c2SDaniel Beauregard  *	argv  = Arg array (instance #, optional).
159016dd44c2SDaniel Beauregard  *
159116dd44c2SDaniel Beauregard  * Returns:
159216dd44c2SDaniel Beauregard  *	DCMD_OK or DCMD_ERR
159316dd44c2SDaniel Beauregard  *
159416dd44c2SDaniel Beauregard  * Context:
159516dd44c2SDaniel Beauregard  *	User context.
159616dd44c2SDaniel Beauregard  *
159716dd44c2SDaniel Beauregard  */
159816dd44c2SDaniel Beauregard 
159916dd44c2SDaniel Beauregard #if 0
160016dd44c2SDaniel Beauregard 
160116dd44c2SDaniel Beauregard /*ARGSUSED*/
160216dd44c2SDaniel Beauregard static int
160316dd44c2SDaniel Beauregard qlc_triggerdump_dcmd(uintptr_t addr, uint_t flags, int argc,
160416dd44c2SDaniel Beauregard     const mdb_arg_t *argv)
160516dd44c2SDaniel Beauregard {
160616dd44c2SDaniel Beauregard 	ql_adapter_state_t	*qlstate;
160716dd44c2SDaniel Beauregard 	uintptr_t		hbaptr = NULL;
160816dd44c2SDaniel Beauregard 	ql_head_t		ql_hba;
160916dd44c2SDaniel Beauregard 	uint32_t		qlsize = sizeof (ql_adapter_state_t);
161016dd44c2SDaniel Beauregard 	int			mdbs;
161116dd44c2SDaniel Beauregard 
161216dd44c2SDaniel Beauregard 	if ((mdbs = mdb_get_state()) == MDB_STATE_DEAD) {
161316dd44c2SDaniel Beauregard 		mdb_warn("Cannot change core file data (state=%xh)\n", mdbs);
161416dd44c2SDaniel Beauregard 		return (DCMD_OK);
161516dd44c2SDaniel Beauregard 	}
161616dd44c2SDaniel Beauregard 
161716dd44c2SDaniel Beauregard 	if ((qlstate = (ql_adapter_state_t *)mdb_alloc(qlsize,
161816dd44c2SDaniel Beauregard 	    UM_SLEEP)) == NULL) {
161916dd44c2SDaniel Beauregard 		mdb_warn("Unable to allocate memory for ql_adapter_state\n");
162016dd44c2SDaniel Beauregard 		return (DCMD_OK);
162116dd44c2SDaniel Beauregard 	}
162216dd44c2SDaniel Beauregard 
162316dd44c2SDaniel Beauregard 	if (addr == NULL) {
162416dd44c2SDaniel Beauregard 		uint32_t	instance;
162516dd44c2SDaniel Beauregard 
162616dd44c2SDaniel Beauregard 		if (argc == 0) {
162716dd44c2SDaniel Beauregard 			mdb_warn("must specify either the ha addr or "
162816dd44c2SDaniel Beauregard 			    "the instance number\n");
162916dd44c2SDaniel Beauregard 			mdb_free(qlstate, qlsize);
163016dd44c2SDaniel Beauregard 			return (DCMD_OK);
163116dd44c2SDaniel Beauregard 		}
163216dd44c2SDaniel Beauregard 
163316dd44c2SDaniel Beauregard 		/*
163416dd44c2SDaniel Beauregard 		 * find the specified instance in the ha list
163516dd44c2SDaniel Beauregard 		 */
163616dd44c2SDaniel Beauregard 
1637*4c3888b8SHans Rosenfeld 		instance = (uint32_t)mdb_strtoull(argv[1].a_un.a_str);
163816dd44c2SDaniel Beauregard 
163916dd44c2SDaniel Beauregard 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
164016dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_hba structure");
164116dd44c2SDaniel Beauregard 			mdb_free(qlstate, qlsize);
164216dd44c2SDaniel Beauregard 			return (DCMD_ERR);
164316dd44c2SDaniel Beauregard 		}
164416dd44c2SDaniel Beauregard 
164516dd44c2SDaniel Beauregard 		if (&ql_hba == NULL) {
164616dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_hba structure - "
164716dd44c2SDaniel Beauregard 			    "is qlc loaded?");
164816dd44c2SDaniel Beauregard 			mdb_free(qlstate, qlsize);
164916dd44c2SDaniel Beauregard 			return (DCMD_ERR);
165016dd44c2SDaniel Beauregard 		}
165116dd44c2SDaniel Beauregard 
165216dd44c2SDaniel Beauregard 		hbaptr = (uintptr_t)ql_hba.first;
165316dd44c2SDaniel Beauregard 		while (hbaptr != NULL) {
165416dd44c2SDaniel Beauregard 
165516dd44c2SDaniel Beauregard 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
165616dd44c2SDaniel Beauregard 				mdb_free(qlstate, qlsize);
165716dd44c2SDaniel Beauregard 				mdb_warn("failed to read "
165816dd44c2SDaniel Beauregard 				    "ql_adapter_state at %p", hbaptr);
165916dd44c2SDaniel Beauregard 				return (DCMD_OK);
166016dd44c2SDaniel Beauregard 			}
166116dd44c2SDaniel Beauregard 
166216dd44c2SDaniel Beauregard 			if (qlstate->instance == instance) {
166316dd44c2SDaniel Beauregard 				break;
166416dd44c2SDaniel Beauregard 			}
166516dd44c2SDaniel Beauregard 
166616dd44c2SDaniel Beauregard 			hbaptr = (uintptr_t)qlstate->hba.next;
166716dd44c2SDaniel Beauregard 		}
166816dd44c2SDaniel Beauregard 	} else {
166916dd44c2SDaniel Beauregard 
167016dd44c2SDaniel Beauregard 		/*
167116dd44c2SDaniel Beauregard 		 * verify the addr specified
167216dd44c2SDaniel Beauregard 		 */
167316dd44c2SDaniel Beauregard 
167416dd44c2SDaniel Beauregard 		if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
167516dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_hba structure");
167616dd44c2SDaniel Beauregard 			mdb_free(qlstate, qlsize);
167716dd44c2SDaniel Beauregard 			return (DCMD_ERR);
167816dd44c2SDaniel Beauregard 		}
167916dd44c2SDaniel Beauregard 
168016dd44c2SDaniel Beauregard 		if (&ql_hba == NULL) {
168116dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_hba structure - "
168216dd44c2SDaniel Beauregard 			    "is qlc loaded?");
168316dd44c2SDaniel Beauregard 			mdb_free(qlstate, qlsize);
168416dd44c2SDaniel Beauregard 			return (DCMD_ERR);
168516dd44c2SDaniel Beauregard 		}
168616dd44c2SDaniel Beauregard 
168716dd44c2SDaniel Beauregard 		hbaptr = (uintptr_t)ql_hba.first;
168816dd44c2SDaniel Beauregard 		while (hbaptr != NULL) {
168916dd44c2SDaniel Beauregard 
169016dd44c2SDaniel Beauregard 			if (mdb_vread(qlstate, qlsize, hbaptr) == -1) {
169116dd44c2SDaniel Beauregard 				mdb_free(qlstate, qlsize);
169216dd44c2SDaniel Beauregard 				mdb_warn("failed to read "
169316dd44c2SDaniel Beauregard 				    "ql_adapter_state at %p", hbaptr);
169416dd44c2SDaniel Beauregard 				return (DCMD_OK);
169516dd44c2SDaniel Beauregard 			}
169616dd44c2SDaniel Beauregard 
169716dd44c2SDaniel Beauregard 			if (hbaptr == addr) {
169816dd44c2SDaniel Beauregard 				break;
169916dd44c2SDaniel Beauregard 			}
170016dd44c2SDaniel Beauregard 
170116dd44c2SDaniel Beauregard 			hbaptr = (uintptr_t)qlstate->hba.next;
170216dd44c2SDaniel Beauregard 		}
170316dd44c2SDaniel Beauregard 	}
170416dd44c2SDaniel Beauregard 
170516dd44c2SDaniel Beauregard 	if (hbaptr == NULL) {
170616dd44c2SDaniel Beauregard 		mdb_free(qlstate, qlsize);
170716dd44c2SDaniel Beauregard 		if (argc == 0) {
170816dd44c2SDaniel Beauregard 			mdb_warn("addr specified is not in the hba list\n");
170916dd44c2SDaniel Beauregard 		} else {
171016dd44c2SDaniel Beauregard 			mdb_warn("instance specified does not exist\n");
171116dd44c2SDaniel Beauregard 		}
171216dd44c2SDaniel Beauregard 		return (DCMD_OK);
171316dd44c2SDaniel Beauregard 	}
171416dd44c2SDaniel Beauregard 
171516dd44c2SDaniel Beauregard 	if (((qlstate->ql_dump_state & QL_DUMP_VALID) != 0) ||
171616dd44c2SDaniel Beauregard 	    (qlstate->ql_dump_ptr != NULL)) {
171716dd44c2SDaniel Beauregard 		mdb_warn("instance %d already has a valid dump\n",
171816dd44c2SDaniel Beauregard 		    qlstate->instance);
171916dd44c2SDaniel Beauregard 		mdb_free(qlstate, qlsize);
172016dd44c2SDaniel Beauregard 		return (DCMD_OK);
172116dd44c2SDaniel Beauregard 	}
172216dd44c2SDaniel Beauregard }
172316dd44c2SDaniel Beauregard #endif
172416dd44c2SDaniel Beauregard 
172516dd44c2SDaniel Beauregard /*
172616dd44c2SDaniel Beauregard  * ql_getdump_dcmd
1727fcf3ce44SJohn Forte  *	prints out the firmware dump buffer
1728fcf3ce44SJohn Forte  *
1729fcf3ce44SJohn Forte  * Input:
173016dd44c2SDaniel Beauregard  *	addr  = User supplied address. (NB: must be an ha)
1731fcf3ce44SJohn Forte  *	flags = mdb flags.
1732fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
1733fcf3ce44SJohn Forte  *	argv  = Arg array.
1734fcf3ce44SJohn Forte  *
1735fcf3ce44SJohn Forte  * Returns:
1736fcf3ce44SJohn Forte  *	DCMD_OK or DCMD_ERR
1737fcf3ce44SJohn Forte  *
1738fcf3ce44SJohn Forte  * Context:
1739fcf3ce44SJohn Forte  *	User context.
1740fcf3ce44SJohn Forte  *
1741fcf3ce44SJohn Forte  */
1742fcf3ce44SJohn Forte static int
qlc_getdump_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)174316dd44c2SDaniel Beauregard qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1744fcf3ce44SJohn Forte {
1745fcf3ce44SJohn Forte 	ql_adapter_state_t	*ha;
174616dd44c2SDaniel Beauregard 	ql_head_t		ql_hba;
1747892ad162SToomas Soome 	uintptr_t		hbaptr = 0;
174816dd44c2SDaniel Beauregard 	int			verbose = 0;
1749fcf3ce44SJohn Forte 
1750892ad162SToomas Soome 	if ((!(flags & DCMD_ADDRSPEC)) || addr == 0) {
1751fcf3ce44SJohn Forte 		mdb_warn("ql_adapter_state structure addr is required");
1752fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1753fcf3ce44SJohn Forte 	}
1754fcf3ce44SJohn Forte 
17553b442230SJordan Paige Hendricks 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
17563b442230SJordan Paige Hendricks 	    NULL) != argc) {
175716dd44c2SDaniel Beauregard 		return (DCMD_USAGE);
175816dd44c2SDaniel Beauregard 	}
175916dd44c2SDaniel Beauregard 
1760fcf3ce44SJohn Forte 	/*
1761fcf3ce44SJohn Forte 	 * Get the adapter state struct which was passed
1762fcf3ce44SJohn Forte 	 */
1763fcf3ce44SJohn Forte 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
1764fcf3ce44SJohn Forte 	    UM_SLEEP)) == NULL) {
1765fcf3ce44SJohn Forte 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
1766fcf3ce44SJohn Forte 		return (DCMD_OK);
1767fcf3ce44SJohn Forte 	}
1768fcf3ce44SJohn Forte 
176916dd44c2SDaniel Beauregard 	/*
177016dd44c2SDaniel Beauregard 	 * show user which instances have valid f/w dumps available if
177116dd44c2SDaniel Beauregard 	 * user has specified verbose option
177216dd44c2SDaniel Beauregard 	 */
177316dd44c2SDaniel Beauregard 	if (mdb_readvar(&ql_hba, "ql_hba") == -1) {
177416dd44c2SDaniel Beauregard 		mdb_warn("failed to read ql_hba structure");
1775*4c3888b8SHans Rosenfeld 	} else if (ql_hba.first == NULL) {
177616dd44c2SDaniel Beauregard 		mdb_warn("failed to read ql_hba structure -- is qlc loaded?");
177716dd44c2SDaniel Beauregard 	} else if (verbose) {
177816dd44c2SDaniel Beauregard 		hbaptr = (uintptr_t)ql_hba.first;
1779892ad162SToomas Soome 		while (hbaptr != 0) {
178016dd44c2SDaniel Beauregard 
178116dd44c2SDaniel Beauregard 			if (mdb_vread(ha, sizeof (ql_adapter_state_t),
178216dd44c2SDaniel Beauregard 			    hbaptr) == -1) {
178316dd44c2SDaniel Beauregard 				mdb_free(ha, sizeof (ql_adapter_state_t));
178416dd44c2SDaniel Beauregard 				mdb_warn("failed read ql_adapter_state at %p",
178516dd44c2SDaniel Beauregard 				    hbaptr);
178616dd44c2SDaniel Beauregard 				return (DCMD_OK);
178716dd44c2SDaniel Beauregard 			}
178816dd44c2SDaniel Beauregard 
178916dd44c2SDaniel Beauregard 			mdb_printf("instance %d:\n", ha->instance);
179016dd44c2SDaniel Beauregard 			(void) mdb_inc_indent((ulong_t)4);
179116dd44c2SDaniel Beauregard 
179216dd44c2SDaniel Beauregard 			if (ha->ql_dump_state == 0) {
179316dd44c2SDaniel Beauregard 				mdb_printf("no dump flags\n");
179416dd44c2SDaniel Beauregard 			} else {
179516dd44c2SDaniel Beauregard 				ql_dump_flags((uint64_t)ha->ql_dump_state,
179616dd44c2SDaniel Beauregard 				    qldump_flags);
179716dd44c2SDaniel Beauregard 			}
179816dd44c2SDaniel Beauregard 
179916dd44c2SDaniel Beauregard 			if (ha->ql_dump_ptr == NULL) {
180016dd44c2SDaniel Beauregard 				mdb_printf("no dump address\n");
180116dd44c2SDaniel Beauregard 			} else {
180216dd44c2SDaniel Beauregard 				mdb_printf("dump address is: %p\n",
180316dd44c2SDaniel Beauregard 				    ha->ql_dump_ptr);
180416dd44c2SDaniel Beauregard 			}
180516dd44c2SDaniel Beauregard 
180616dd44c2SDaniel Beauregard 			(void) mdb_dec_indent((ulong_t)4);
180716dd44c2SDaniel Beauregard 
180816dd44c2SDaniel Beauregard 			hbaptr = (uintptr_t)ha->hba.next;
180916dd44c2SDaniel Beauregard 		}
181016dd44c2SDaniel Beauregard 		mdb_printf("\n");
181116dd44c2SDaniel Beauregard 	}
181216dd44c2SDaniel Beauregard 
1813fcf3ce44SJohn Forte 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
1814fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_adapter_state at %p", addr);
1815fcf3ce44SJohn Forte 		mdb_free(ha, sizeof (ql_adapter_state_t));
1816fcf3ce44SJohn Forte 		return (DCMD_OK);
1817fcf3ce44SJohn Forte 	}
1818fcf3ce44SJohn Forte 
181916dd44c2SDaniel Beauregard 	/*
182016dd44c2SDaniel Beauregard 	 * If its not a valid dump or there's not a f/w dump binary (???)
182116dd44c2SDaniel Beauregard 	 * then bail out
182216dd44c2SDaniel Beauregard 	 */
182316dd44c2SDaniel Beauregard 	if (((ha->ql_dump_state & QL_DUMP_VALID) == 0) ||
182416dd44c2SDaniel Beauregard 	    (ha->ql_dump_ptr == NULL)) {
182516dd44c2SDaniel Beauregard 		mdb_warn("dump does not exist for instance %d (%x, %p)\n",
182616dd44c2SDaniel Beauregard 		    ha->instance, ha->ql_dump_state, ha->ql_dump_ptr);
182716dd44c2SDaniel Beauregard 		mdb_free(ha, sizeof (ql_adapter_state_t));
182816dd44c2SDaniel Beauregard 		return (DCMD_OK);
182916dd44c2SDaniel Beauregard 	}
183016dd44c2SDaniel Beauregard 
1831*4c3888b8SHans Rosenfeld 	if (CFG_IST(ha, CFG_CTRL_24XX)) {
1832fcf3ce44SJohn Forte 		(void) ql_24xx_dump_dcmd(ha, flags, argc, argv);
1833*4c3888b8SHans Rosenfeld 	} else if (CFG_IST(ha, CFG_CTRL_25XX)) {
1834fcf3ce44SJohn Forte 		(void) ql_25xx_dump_dcmd(ha, flags, argc, argv);
1835*4c3888b8SHans Rosenfeld 	} else if (CFG_IST(ha, CFG_CTRL_81XX)) {
1836f33c1cdbSDaniel Beauregard 		(void) ql_81xx_dump_dcmd(ha, flags, argc, argv);
1837*4c3888b8SHans Rosenfeld 	} else if (CFG_IST(ha, CFG_CTRL_82XX | CFG_CTRL_27XX)) {
1838*4c3888b8SHans Rosenfeld 		(void) ql_8021_dump_dcmd(ha, flags, argc, argv);
1839*4c3888b8SHans Rosenfeld 	} else if (CFG_IST(ha, CFG_CTRL_83XX)) {
1840*4c3888b8SHans Rosenfeld 		(void) ql_8300_dump_dcmd(ha, flags, argc, argv);
1841*4c3888b8SHans Rosenfeld 	} else {
1842fcf3ce44SJohn Forte 		(void) ql_23xx_dump_dcmd(ha, flags, argc, argv);
1843fcf3ce44SJohn Forte 	}
1844fcf3ce44SJohn Forte 
1845fcf3ce44SJohn Forte 	mdb_free(ha, sizeof (ql_adapter_state_t));
1846fcf3ce44SJohn Forte 
1847fcf3ce44SJohn Forte 	return (DCMD_OK);
1848fcf3ce44SJohn Forte }
1849fcf3ce44SJohn Forte 
1850fcf3ce44SJohn Forte /*
1851*4c3888b8SHans Rosenfeld  * ql_8021_dump_dcmd
1852fcf3ce44SJohn Forte  *	prints out a firmware dump buffer
1853fcf3ce44SJohn Forte  *
1854fcf3ce44SJohn Forte  * Input:
1855fcf3ce44SJohn Forte  *	addr  = User supplied address. (NB: nust be an ha)
1856fcf3ce44SJohn Forte  *	flags = mdb flags.
1857fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
1858fcf3ce44SJohn Forte  *	argv  = Arg array.
1859fcf3ce44SJohn Forte  *
1860fcf3ce44SJohn Forte  * Returns:
1861fcf3ce44SJohn Forte  *	DCMD_OK or DCMD_ERR
1862fcf3ce44SJohn Forte  *
1863fcf3ce44SJohn Forte  * Context:
1864fcf3ce44SJohn Forte  *	User context.
1865fcf3ce44SJohn Forte  *
1866fcf3ce44SJohn Forte  */
1867fcf3ce44SJohn Forte /*ARGSUSED*/
1868fcf3ce44SJohn Forte static int
ql_8021_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)1869*4c3888b8SHans Rosenfeld ql_8021_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
1870fcf3ce44SJohn Forte     const mdb_arg_t *argv)
1871fcf3ce44SJohn Forte {
1872*4c3888b8SHans Rosenfeld 	uint8_t		*fw, *bp;
1873fcf3ce44SJohn Forte 	uint32_t	cnt = 0;
1874fcf3ce44SJohn Forte 
1875*4c3888b8SHans Rosenfeld 	bp = fw = (uint8_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
1876fcf3ce44SJohn Forte 
187716dd44c2SDaniel Beauregard 	if (mdb_vread(fw, ha->ql_dump_size,
187816dd44c2SDaniel Beauregard 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
187916dd44c2SDaniel Beauregard 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
188016dd44c2SDaniel Beauregard 		mdb_free(fw, ha->ql_dump_size);
1881fcf3ce44SJohn Forte 		return (DCMD_OK);
1882fcf3ce44SJohn Forte 	}
1883fcf3ce44SJohn Forte 
1884*4c3888b8SHans Rosenfeld 	while (cnt < ha->ql_dump_size) {
1885*4c3888b8SHans Rosenfeld 		mdb_printf("%02x ", *bp++);
1886*4c3888b8SHans Rosenfeld 		if (++cnt % 16 == 0) {
1887*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
1888*4c3888b8SHans Rosenfeld 		}
1889*4c3888b8SHans Rosenfeld 	}
1890*4c3888b8SHans Rosenfeld 	if (cnt % 16 != 0) {
1891*4c3888b8SHans Rosenfeld 		mdb_printf("\n");
1892fcf3ce44SJohn Forte 	}
1893fcf3ce44SJohn Forte 
1894*4c3888b8SHans Rosenfeld 	mdb_free(fw, ha->ql_dump_size);
1895*4c3888b8SHans Rosenfeld 
1896*4c3888b8SHans Rosenfeld 	return (DCMD_OK);
1897*4c3888b8SHans Rosenfeld }
1898*4c3888b8SHans Rosenfeld 
1899*4c3888b8SHans Rosenfeld /*
1900*4c3888b8SHans Rosenfeld  * ql_83xx_dump_dcmd
1901*4c3888b8SHans Rosenfeld  *	prints out a firmware dump buffer
1902*4c3888b8SHans Rosenfeld  *
1903*4c3888b8SHans Rosenfeld  * Input:
1904*4c3888b8SHans Rosenfeld  *	addr  = User supplied address. (NB: must be an ha)
1905*4c3888b8SHans Rosenfeld  *	flags = mdb flags.
1906*4c3888b8SHans Rosenfeld  *	argc  = Number of user supplied args.
1907*4c3888b8SHans Rosenfeld  *	argv  = Arg array.
1908*4c3888b8SHans Rosenfeld  *
1909*4c3888b8SHans Rosenfeld  * Returns:
1910*4c3888b8SHans Rosenfeld  *	DCMD_OK or DCMD_ERR
1911*4c3888b8SHans Rosenfeld  *
1912*4c3888b8SHans Rosenfeld  * Context:
1913*4c3888b8SHans Rosenfeld  *	User context.
1914*4c3888b8SHans Rosenfeld  *
1915*4c3888b8SHans Rosenfeld  */
1916*4c3888b8SHans Rosenfeld /*ARGSUSED*/
1917*4c3888b8SHans Rosenfeld static int
ql_8300_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)1918*4c3888b8SHans Rosenfeld ql_8300_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
1919*4c3888b8SHans Rosenfeld     const mdb_arg_t *argv)
1920*4c3888b8SHans Rosenfeld {
1921*4c3888b8SHans Rosenfeld 	ql_83xx_fw_dump_t	*fw;
1922*4c3888b8SHans Rosenfeld 	ql_response_q_t		**rsp_queues, *rsp_q;
1923*4c3888b8SHans Rosenfeld 	uint32_t		cnt, cnt1, *dp, *dp2;
1924*4c3888b8SHans Rosenfeld 
1925*4c3888b8SHans Rosenfeld 	fw = mdb_alloc(ha->ql_dump_size, UM_SLEEP);
1926*4c3888b8SHans Rosenfeld 	rsp_queues = mdb_alloc(ha->rsp_queues_cnt *
1927*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), UM_SLEEP);
1928*4c3888b8SHans Rosenfeld 	rsp_q = mdb_alloc(sizeof (ql_response_q_t), UM_SLEEP);
1929*4c3888b8SHans Rosenfeld 
1930*4c3888b8SHans Rosenfeld 	if (mdb_vread(fw, ha->ql_dump_size,
1931*4c3888b8SHans Rosenfeld 	    (uintptr_t)ha->ql_dump_ptr) == -1 ||
1932*4c3888b8SHans Rosenfeld 	    mdb_vread(rsp_queues, ha->rsp_queues_cnt *
1933*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), (uintptr_t)ha->rsp_queues) == -1) {
1934*4c3888b8SHans Rosenfeld 		mdb_warn("failed to read fw_dump_buffer (no f/w dump active?)");
1935*4c3888b8SHans Rosenfeld 		mdb_free(rsp_q, sizeof (ql_response_q_t));
1936*4c3888b8SHans Rosenfeld 		mdb_free(rsp_queues, ha->rsp_queues_cnt *
1937*4c3888b8SHans Rosenfeld 		    sizeof (ql_response_q_t *));
1938*4c3888b8SHans Rosenfeld 		mdb_free(fw, ha->ql_dump_size);
1939*4c3888b8SHans Rosenfeld 		return (DCMD_OK);
1940*4c3888b8SHans Rosenfeld 	}
1941*4c3888b8SHans Rosenfeld 
1942*4c3888b8SHans Rosenfeld 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
1943fcf3ce44SJohn Forte 	    ha->fw_major_version, ha->fw_minor_version,
1944*4c3888b8SHans Rosenfeld 	    ha->fw_subminor_version, ha->fw_attributes);
1945fcf3ce44SJohn Forte 
1946*4c3888b8SHans Rosenfeld 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
1947*4c3888b8SHans Rosenfeld 
1948*4c3888b8SHans Rosenfeld 	mdb_printf("\nR2H Status Register\n%08x\n", fw->r2h_status);
1949*4c3888b8SHans Rosenfeld 
1950*4c3888b8SHans Rosenfeld 	mdb_printf("\nAER Uncorrectable Error Status Register\n%08x\n",
1951*4c3888b8SHans Rosenfeld 	    fw->aer_ues);
1952*4c3888b8SHans Rosenfeld 
1953*4c3888b8SHans Rosenfeld 	mdb_printf("\nHostRisc Registers");
1954*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
1955fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
1956fcf3ce44SJohn Forte 			mdb_printf("\n");
1957fcf3ce44SJohn Forte 		}
1958*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
1959fcf3ce44SJohn Forte 	}
1960fcf3ce44SJohn Forte 
1961*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nPCIe Registers");
1962*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
1963*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
1964*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
1965fcf3ce44SJohn Forte 		}
1966*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
1967fcf3ce44SJohn Forte 	}
1968fcf3ce44SJohn Forte 
1969*4c3888b8SHans Rosenfeld 	dp = fw->req_rsp_ext_mem;
1970*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < ha->rsp_queues_cnt; cnt++) {
1971*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nQueue Pointers #%d:\n", cnt);
1972*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < 4; cnt1++) {
1973*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
1974*4c3888b8SHans Rosenfeld 		}
1975*4c3888b8SHans Rosenfeld 	}
1976*4c3888b8SHans Rosenfeld 
1977*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nHost Interface Registers");
1978*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
1979fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
1980fcf3ce44SJohn Forte 			mdb_printf("\n");
1981fcf3ce44SJohn Forte 		}
1982*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->host_reg[cnt]);
1983fcf3ce44SJohn Forte 	}
1984fcf3ce44SJohn Forte 
1985*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nShadow Registers");
1986*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
1987*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
1988*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
1989fcf3ce44SJohn Forte 		}
1990*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
1991fcf3ce44SJohn Forte 	}
1992fcf3ce44SJohn Forte 
1993*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
1994*4c3888b8SHans Rosenfeld 
1995*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nMailbox Registers");
1996*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
1997*4c3888b8SHans Rosenfeld 		if (cnt % 16 == 0) {
1998fcf3ce44SJohn Forte 			mdb_printf("\n");
1999fcf3ce44SJohn Forte 		}
2000*4c3888b8SHans Rosenfeld 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
2001fcf3ce44SJohn Forte 	}
2002fcf3ce44SJohn Forte 
2003*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXSEQ GP Registers");
2004*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
2005fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2006fcf3ce44SJohn Forte 			mdb_printf("\n");
2007fcf3ce44SJohn Forte 		}
2008*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
2009fcf3ce44SJohn Forte 	}
2010fcf3ce44SJohn Forte 
2011*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXSEQ-0 Registers");
2012*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
2013fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2014fcf3ce44SJohn Forte 			mdb_printf("\n");
2015fcf3ce44SJohn Forte 		}
2016*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
2017fcf3ce44SJohn Forte 	}
2018fcf3ce44SJohn Forte 
2019*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXSEQ-1 Registers");
2020*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
2021fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2022fcf3ce44SJohn Forte 			mdb_printf("\n");
2023fcf3ce44SJohn Forte 		}
2024*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
2025fcf3ce44SJohn Forte 	}
2026fcf3ce44SJohn Forte 
2027*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXSEQ-2 Registers");
2028*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xseq_2_reg) / 4; cnt++) {
2029fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2030fcf3ce44SJohn Forte 			mdb_printf("\n");
2031fcf3ce44SJohn Forte 		}
2032*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xseq_2_reg[cnt]);
2033fcf3ce44SJohn Forte 	}
2034fcf3ce44SJohn Forte 
2035*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRSEQ GP Registers");
2036*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
2037fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2038fcf3ce44SJohn Forte 			mdb_printf("\n");
2039fcf3ce44SJohn Forte 		}
2040*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
2041fcf3ce44SJohn Forte 	}
2042fcf3ce44SJohn Forte 
2043*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRSEQ-0 Registers");
2044*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
2045fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2046fcf3ce44SJohn Forte 			mdb_printf("\n");
2047fcf3ce44SJohn Forte 		}
2048*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
2049fcf3ce44SJohn Forte 	}
2050fcf3ce44SJohn Forte 
2051*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRSEQ-1 Registers");
2052*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
2053fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2054fcf3ce44SJohn Forte 			mdb_printf("\n");
2055fcf3ce44SJohn Forte 		}
2056*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
2057fcf3ce44SJohn Forte 	}
2058fcf3ce44SJohn Forte 
2059*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRSEQ-2 Registers");
2060*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
2061fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2062fcf3ce44SJohn Forte 			mdb_printf("\n");
2063fcf3ce44SJohn Forte 		}
2064*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
2065fcf3ce44SJohn Forte 	}
2066fcf3ce44SJohn Forte 
2067*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRSEQ-3 Registers");
2068*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rseq_3_reg) / 4; cnt++) {
2069fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2070fcf3ce44SJohn Forte 			mdb_printf("\n");
2071fcf3ce44SJohn Forte 		}
2072*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rseq_3_reg[cnt]);
2073fcf3ce44SJohn Forte 	}
2074fcf3ce44SJohn Forte 
2075*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nASEQ GP Registers");
2076*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
2077fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2078fcf3ce44SJohn Forte 			mdb_printf("\n");
2079fcf3ce44SJohn Forte 		}
2080*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
2081fcf3ce44SJohn Forte 	}
2082fcf3ce44SJohn Forte 
2083*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nASEQ-0 Registers");
2084*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
2085fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2086fcf3ce44SJohn Forte 			mdb_printf("\n");
2087fcf3ce44SJohn Forte 		}
2088*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
2089fcf3ce44SJohn Forte 	}
2090fcf3ce44SJohn Forte 
2091*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nASEQ-1 Registers");
2092*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
2093fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2094fcf3ce44SJohn Forte 			mdb_printf("\n");
2095fcf3ce44SJohn Forte 		}
2096*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
2097fcf3ce44SJohn Forte 	}
2098fcf3ce44SJohn Forte 
2099*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nASEQ-2 Registers");
2100*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
2101*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2102*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2103fcf3ce44SJohn Forte 		}
2104*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
2105*4c3888b8SHans Rosenfeld 	}
2106fcf3ce44SJohn Forte 
2107*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nASEQ-3 Registers");
2108*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->aseq_3_reg) / 4; cnt++) {
2109*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2110*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2111fcf3ce44SJohn Forte 		}
2112*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->aseq_3_reg[cnt]);
2113*4c3888b8SHans Rosenfeld 	}
2114fcf3ce44SJohn Forte 
2115*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nCommand DMA Registers");
2116*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
2117*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2118*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2119fcf3ce44SJohn Forte 		}
2120*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
2121*4c3888b8SHans Rosenfeld 	}
2122fcf3ce44SJohn Forte 
2123*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
2124*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
2125*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2126*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
212716dd44c2SDaniel Beauregard 		}
2128*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
2129*4c3888b8SHans Rosenfeld 	}
213016dd44c2SDaniel Beauregard 
2131*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
2132*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
2133*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2134*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
213516dd44c2SDaniel Beauregard 		}
2136*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
2137*4c3888b8SHans Rosenfeld 	}
213816dd44c2SDaniel Beauregard 
2139*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
2140*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
2141*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2142*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2143*4c3888b8SHans Rosenfeld 		}
2144*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
2145*4c3888b8SHans Rosenfeld 	}
214616dd44c2SDaniel Beauregard 
2147*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT0 Data DMA Registers");
2148*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
2149*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2150*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2151fcf3ce44SJohn Forte 		}
2152*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
2153fcf3ce44SJohn Forte 	}
2154fcf3ce44SJohn Forte 
2155*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT1 Data DMA Registers");
2156*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
2157*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2158*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2159*4c3888b8SHans Rosenfeld 		}
2160*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
2161*4c3888b8SHans Rosenfeld 	}
2162*4c3888b8SHans Rosenfeld 
2163*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT2 Data DMA Registers");
2164*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
2165*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2166*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2167*4c3888b8SHans Rosenfeld 		}
2168*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
2169*4c3888b8SHans Rosenfeld 	}
2170*4c3888b8SHans Rosenfeld 
2171*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT3 Data DMA Registers");
2172*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
2173*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2174*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2175*4c3888b8SHans Rosenfeld 		}
2176*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
2177*4c3888b8SHans Rosenfeld 	}
2178*4c3888b8SHans Rosenfeld 
2179*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT4 Data DMA Registers");
2180*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
2181*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2182*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2183*4c3888b8SHans Rosenfeld 		}
2184*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
2185*4c3888b8SHans Rosenfeld 	}
2186*4c3888b8SHans Rosenfeld 
2187*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nXMT Data DMA Common Registers");
2188*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
2189*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2190*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2191*4c3888b8SHans Rosenfeld 		}
2192*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
2193*4c3888b8SHans Rosenfeld 	}
2194*4c3888b8SHans Rosenfeld 
2195*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
2196*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
2197*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2198*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2199*4c3888b8SHans Rosenfeld 		}
2200*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
2201*4c3888b8SHans Rosenfeld 	}
2202*4c3888b8SHans Rosenfeld 
2203*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
2204*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
2205*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2206*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2207*4c3888b8SHans Rosenfeld 		}
2208*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
2209*4c3888b8SHans Rosenfeld 	}
2210*4c3888b8SHans Rosenfeld 
2211*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP Registers");
2212*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
2213*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2214*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2215*4c3888b8SHans Rosenfeld 		}
2216*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
2217*4c3888b8SHans Rosenfeld 	}
2218*4c3888b8SHans Rosenfeld 
2219*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nLMC Registers");
2220*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
2221*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2222*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2223*4c3888b8SHans Rosenfeld 		}
2224*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
2225*4c3888b8SHans Rosenfeld 	}
2226*4c3888b8SHans Rosenfeld 
2227*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nFPM Hardware Registers");
2228*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
2229*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2230*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2231*4c3888b8SHans Rosenfeld 		}
2232*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
2233*4c3888b8SHans Rosenfeld 	}
2234*4c3888b8SHans Rosenfeld 
2235*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRQ0 Array Registers");
2236*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rq0_array_reg) / 4; cnt++) {
2237*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2238*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2239*4c3888b8SHans Rosenfeld 		}
2240*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rq0_array_reg[cnt]);
2241*4c3888b8SHans Rosenfeld 	}
2242*4c3888b8SHans Rosenfeld 
2243*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRQ1 Array Registers");
2244*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rq1_array_reg) / 4; cnt++) {
2245*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2246*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2247*4c3888b8SHans Rosenfeld 		}
2248*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rq1_array_reg[cnt]);
2249*4c3888b8SHans Rosenfeld 	}
2250*4c3888b8SHans Rosenfeld 
2251*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRP0 Array Registers");
2252*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rp0_array_reg) / 4; cnt++) {
2253*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2254*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2255*4c3888b8SHans Rosenfeld 		}
2256*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rp0_array_reg[cnt]);
2257*4c3888b8SHans Rosenfeld 	}
2258*4c3888b8SHans Rosenfeld 
2259*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRP1 Array Registers");
2260*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->rp1_array_reg) / 4; cnt++) {
2261*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2262*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2263*4c3888b8SHans Rosenfeld 		}
2264*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->rp1_array_reg[cnt]);
2265*4c3888b8SHans Rosenfeld 	}
2266*4c3888b8SHans Rosenfeld 
2267*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nAT0 Array Registers");
2268*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->ato_array_reg) / 4; cnt++) {
2269*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2270*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2271*4c3888b8SHans Rosenfeld 		}
2272*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->ato_array_reg[cnt]);
2273*4c3888b8SHans Rosenfeld 	}
2274*4c3888b8SHans Rosenfeld 
2275*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nQueue Control Registers");
2276*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->queue_control_reg) / 4; cnt++) {
2277*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2278*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2279*4c3888b8SHans Rosenfeld 		}
2280*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->queue_control_reg[cnt]);
2281*4c3888b8SHans Rosenfeld 	}
2282*4c3888b8SHans Rosenfeld 
2283*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nFB Hardware Registers");
2284*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
2285*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2286*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2287*4c3888b8SHans Rosenfeld 		}
2288*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
2289*4c3888b8SHans Rosenfeld 	}
2290*4c3888b8SHans Rosenfeld 
2291*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nCode RAM");
2292*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
2293*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2294*4c3888b8SHans Rosenfeld 			mdb_printf("\n%08x: ", cnt + 0x20000);
2295*4c3888b8SHans Rosenfeld 		}
2296*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", fw->code_ram[cnt]);
2297*4c3888b8SHans Rosenfeld 	}
2298*4c3888b8SHans Rosenfeld 
2299*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nExternal Memory");
2300*4c3888b8SHans Rosenfeld 	dp = (uint32_t *)(void *)((caddr_t)fw->req_rsp_ext_mem +
2301*4c3888b8SHans Rosenfeld 	    fw->req_q_size[0] + fw->req_q_size[1] + fw->rsp_q_size +
2302*4c3888b8SHans Rosenfeld 	    (ha->rsp_queues_cnt * 16));
2303*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
2304*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2305*4c3888b8SHans Rosenfeld 			mdb_printf("\n%08x: ", cnt + 0x100000);
2306*4c3888b8SHans Rosenfeld 		}
2307*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", *dp++);
2308*4c3888b8SHans Rosenfeld 	}
2309*4c3888b8SHans Rosenfeld 
2310*4c3888b8SHans Rosenfeld 	mdb_printf("\n\n[<==END] ISP Debug Dump");
2311*4c3888b8SHans Rosenfeld 
2312*4c3888b8SHans Rosenfeld 	dp = fw->req_rsp_ext_mem + (ha->rsp_queues_cnt * 4);
2313*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < 2 && fw->req_q_size[cnt]; cnt++) {
2314*4c3888b8SHans Rosenfeld 		dp2 = dp;
2315*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
2316*4c3888b8SHans Rosenfeld 			if (*dp2++) {
2317*4c3888b8SHans Rosenfeld 				break;
2318*4c3888b8SHans Rosenfeld 			}
2319*4c3888b8SHans Rosenfeld 		}
2320*4c3888b8SHans Rosenfeld 		if (cnt1 == fw->req_q_size[cnt] / 4) {
2321*4c3888b8SHans Rosenfeld 			dp = dp2;
2322*4c3888b8SHans Rosenfeld 			continue;
2323*4c3888b8SHans Rosenfeld 		}
2324*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nRequest Queue\nQueue 0%d:", cnt);
2325*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
2326*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
2327*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
2328*4c3888b8SHans Rosenfeld 			}
2329*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
2330*4c3888b8SHans Rosenfeld 		}
2331*4c3888b8SHans Rosenfeld 	}
2332*4c3888b8SHans Rosenfeld 
2333*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < ha->rsp_queues_cnt; cnt++) {
2334*4c3888b8SHans Rosenfeld 		if (mdb_vread(rsp_q, sizeof (ql_response_q_t),
2335*4c3888b8SHans Rosenfeld 		    (uintptr_t)rsp_queues[cnt]) == -1) {
2336*4c3888b8SHans Rosenfeld 			mdb_warn("failed to read ha->rsp_queues[%d]", cnt);
2337*4c3888b8SHans Rosenfeld 			break;
2338*4c3888b8SHans Rosenfeld 		}
2339*4c3888b8SHans Rosenfeld 		dp2 = dp;
2340*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
2341*4c3888b8SHans Rosenfeld 			if (*dp2++) {
2342*4c3888b8SHans Rosenfeld 				break;
2343*4c3888b8SHans Rosenfeld 			}
2344*4c3888b8SHans Rosenfeld 		}
2345*4c3888b8SHans Rosenfeld 		if (cnt1 == rsp_q->rsp_ring.size / 4) {
2346*4c3888b8SHans Rosenfeld 			dp = dp2;
2347*4c3888b8SHans Rosenfeld 			continue;
2348*4c3888b8SHans Rosenfeld 		}
2349*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nResponse Queue\nQueue 0%d:", cnt);
2350*4c3888b8SHans Rosenfeld 
2351*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
2352*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
2353*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
2354*4c3888b8SHans Rosenfeld 			}
2355*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
2356*4c3888b8SHans Rosenfeld 		}
2357*4c3888b8SHans Rosenfeld 	}
2358*4c3888b8SHans Rosenfeld 
2359*4c3888b8SHans Rosenfeld 	if (ha->fwexttracebuf.dma_handle != NULL) {
2360*4c3888b8SHans Rosenfeld 		uint32_t	cnt_b;
2361*4c3888b8SHans Rosenfeld 		uint32_t	*w32 = ha->fwexttracebuf.bp;
2362*4c3888b8SHans Rosenfeld 
2363*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nExtended Trace Buffer Memory");
2364*4c3888b8SHans Rosenfeld 		/* show data address as a byte address, data as long words */
2365*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
2366*4c3888b8SHans Rosenfeld 			cnt_b = cnt * 4;
2367*4c3888b8SHans Rosenfeld 			if (cnt_b % 32 == 0) {
2368*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", w32 + cnt_b);
2369*4c3888b8SHans Rosenfeld 			}
2370*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
2371*4c3888b8SHans Rosenfeld 		}
2372*4c3888b8SHans Rosenfeld 	}
2373*4c3888b8SHans Rosenfeld 
2374*4c3888b8SHans Rosenfeld 	if (ha->fwfcetracebuf.dma_handle != NULL) {
2375*4c3888b8SHans Rosenfeld 		uint32_t	cnt_b;
2376*4c3888b8SHans Rosenfeld 		uint32_t	*w32 = ha->fwfcetracebuf.bp;
2377*4c3888b8SHans Rosenfeld 
2378*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nFC Event Trace Buffer Memory");
2379*4c3888b8SHans Rosenfeld 		/* show data address as a byte address, data as long words */
2380*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
2381*4c3888b8SHans Rosenfeld 			cnt_b = cnt * 4;
2382*4c3888b8SHans Rosenfeld 			if (cnt_b % 32 == 0) {
2383*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", w32 + cnt_b);
2384*4c3888b8SHans Rosenfeld 			}
2385*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
2386*4c3888b8SHans Rosenfeld 		}
2387*4c3888b8SHans Rosenfeld 	}
2388*4c3888b8SHans Rosenfeld 
2389*4c3888b8SHans Rosenfeld 	mdb_free(rsp_q, sizeof (ql_response_q_t));
2390*4c3888b8SHans Rosenfeld 	mdb_free(rsp_queues, ha->rsp_queues_cnt * sizeof (ql_response_q_t *));
2391*4c3888b8SHans Rosenfeld 	mdb_free(fw, ha->ql_dump_size);
2392*4c3888b8SHans Rosenfeld 
2393*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nreturn exit\n");
2394*4c3888b8SHans Rosenfeld 
2395*4c3888b8SHans Rosenfeld 	return (DCMD_OK);
2396*4c3888b8SHans Rosenfeld }
2397*4c3888b8SHans Rosenfeld 
2398*4c3888b8SHans Rosenfeld /*
2399*4c3888b8SHans Rosenfeld  * ql_23xx_dump_dcmd
2400*4c3888b8SHans Rosenfeld  *	prints out a firmware dump buffer
2401*4c3888b8SHans Rosenfeld  *
2402*4c3888b8SHans Rosenfeld  * Input:
2403*4c3888b8SHans Rosenfeld  *	addr  = User supplied address. (NB: nust be an ha)
2404*4c3888b8SHans Rosenfeld  *	flags = mdb flags.
2405*4c3888b8SHans Rosenfeld  *	argc  = Number of user supplied args.
2406*4c3888b8SHans Rosenfeld  *	argv  = Arg array.
2407*4c3888b8SHans Rosenfeld  *
2408*4c3888b8SHans Rosenfeld  * Returns:
2409*4c3888b8SHans Rosenfeld  *	DCMD_OK or DCMD_ERR
2410*4c3888b8SHans Rosenfeld  *
2411*4c3888b8SHans Rosenfeld  * Context:
2412*4c3888b8SHans Rosenfeld  *	User context.
2413*4c3888b8SHans Rosenfeld  *
2414*4c3888b8SHans Rosenfeld  */
2415*4c3888b8SHans Rosenfeld /*ARGSUSED*/
2416*4c3888b8SHans Rosenfeld static int
ql_23xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)2417*4c3888b8SHans Rosenfeld ql_23xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
2418*4c3888b8SHans Rosenfeld     const mdb_arg_t *argv)
2419*4c3888b8SHans Rosenfeld {
2420*4c3888b8SHans Rosenfeld 	ql_fw_dump_t	*fw;
2421*4c3888b8SHans Rosenfeld 	uint32_t	cnt = 0;
2422*4c3888b8SHans Rosenfeld 	int		mbox_cnt;
2423*4c3888b8SHans Rosenfeld 
2424*4c3888b8SHans Rosenfeld 	fw = (ql_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
2425*4c3888b8SHans Rosenfeld 
2426*4c3888b8SHans Rosenfeld 	if (mdb_vread(fw, ha->ql_dump_size,
2427*4c3888b8SHans Rosenfeld 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
2428*4c3888b8SHans Rosenfeld 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
2429*4c3888b8SHans Rosenfeld 		mdb_free(fw, ha->ql_dump_size);
2430*4c3888b8SHans Rosenfeld 		return (DCMD_OK);
2431*4c3888b8SHans Rosenfeld 	}
2432*4c3888b8SHans Rosenfeld 
2433*4c3888b8SHans Rosenfeld 	if (ha->cfg_flags & CFG_CTRL_23XX) {
2434*4c3888b8SHans Rosenfeld 		mdb_printf("\nISP 2300IP ");
2435*4c3888b8SHans Rosenfeld 	} else if (ha->cfg_flags & CFG_CTRL_63XX) {
2436*4c3888b8SHans Rosenfeld 		mdb_printf("\nISP 2322/6322FLX ");
2437*4c3888b8SHans Rosenfeld 	} else {
2438*4c3888b8SHans Rosenfeld 		mdb_printf("\nISP 2200IP ");
2439*4c3888b8SHans Rosenfeld 	}
2440*4c3888b8SHans Rosenfeld 
2441*4c3888b8SHans Rosenfeld 	mdb_printf("Firmware Version %d.%d.%d\n",
2442*4c3888b8SHans Rosenfeld 	    ha->fw_major_version, ha->fw_minor_version,
2443*4c3888b8SHans Rosenfeld 	    ha->fw_subminor_version);
2444*4c3888b8SHans Rosenfeld 
2445*4c3888b8SHans Rosenfeld 	mdb_printf("\nPBIU Registers:");
2446*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
2447*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2448*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2449*4c3888b8SHans Rosenfeld 		}
2450*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->pbiu_reg[cnt]);
2451*4c3888b8SHans Rosenfeld 	}
2452*4c3888b8SHans Rosenfeld 
2453*4c3888b8SHans Rosenfeld 	if (ha->cfg_flags & CFG_CTRL_2363) {
2454*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nReqQ-RspQ-Risc2Host Status registers:");
2455*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
2456*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2457*4c3888b8SHans Rosenfeld 				mdb_printf("\n");
2458*4c3888b8SHans Rosenfeld 			}
2459*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->risc_host_reg[cnt]);
2460*4c3888b8SHans Rosenfeld 		}
2461*4c3888b8SHans Rosenfeld 	}
2462*4c3888b8SHans Rosenfeld 
2463*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nMailbox Registers:");
2464*4c3888b8SHans Rosenfeld 	mbox_cnt = ha->cfg_flags & CFG_CTRL_2363 ? 16 : 8;
2465*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < mbox_cnt; cnt++) {
2466*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2467*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2468*4c3888b8SHans Rosenfeld 		}
2469*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->mailbox_reg[cnt]);
2470*4c3888b8SHans Rosenfeld 	}
2471*4c3888b8SHans Rosenfeld 
2472*4c3888b8SHans Rosenfeld 	if (ha->cfg_flags & CFG_CTRL_2363) {
2473*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nAuto Request Response DMA Registers:");
2474*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
2475*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2476*4c3888b8SHans Rosenfeld 				mdb_printf("\n");
2477*4c3888b8SHans Rosenfeld 			}
2478*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->resp_dma_reg[cnt]);
2479*4c3888b8SHans Rosenfeld 		}
2480*4c3888b8SHans Rosenfeld 	}
2481*4c3888b8SHans Rosenfeld 
2482*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nDMA Registers:");
2483*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
2484*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2485*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2486*4c3888b8SHans Rosenfeld 		}
2487*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->dma_reg[cnt]);
2488*4c3888b8SHans Rosenfeld 	}
2489*4c3888b8SHans Rosenfeld 
2490*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC Hardware Registers:");
2491*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
2492*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2493*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2494*4c3888b8SHans Rosenfeld 		}
2495*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_hdw_reg[cnt]);
2496*4c3888b8SHans Rosenfeld 	}
2497*4c3888b8SHans Rosenfeld 
2498*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP0 Registers:");
2499*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
2500*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2501*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2502*4c3888b8SHans Rosenfeld 		}
2503*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp0_reg[cnt]);
2504*4c3888b8SHans Rosenfeld 	}
2505*4c3888b8SHans Rosenfeld 
2506*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP1 Registers:");
2507*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
2508*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2509*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2510*4c3888b8SHans Rosenfeld 		}
2511*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp1_reg[cnt]);
2512*4c3888b8SHans Rosenfeld 	}
2513*4c3888b8SHans Rosenfeld 
2514*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP2 Registers:");
2515*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
2516*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2517*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2518*4c3888b8SHans Rosenfeld 		}
2519*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp2_reg[cnt]);
2520*4c3888b8SHans Rosenfeld 	}
2521*4c3888b8SHans Rosenfeld 
2522*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP3 Registers:");
2523*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
2524*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2525*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2526*4c3888b8SHans Rosenfeld 		}
2527*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp3_reg[cnt]);
2528*4c3888b8SHans Rosenfeld 	}
2529*4c3888b8SHans Rosenfeld 
2530*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP4 Registers:");
2531*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
2532*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2533*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2534*4c3888b8SHans Rosenfeld 		}
2535*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp4_reg[cnt]);
2536*4c3888b8SHans Rosenfeld 	}
2537*4c3888b8SHans Rosenfeld 
2538*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP5 Registers:");
2539*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
2540*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2541*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2542*4c3888b8SHans Rosenfeld 		}
2543*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp5_reg[cnt]);
2544*4c3888b8SHans Rosenfeld 	}
2545*4c3888b8SHans Rosenfeld 
2546*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP6 Registers:");
2547*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
2548*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2549*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2550*4c3888b8SHans Rosenfeld 		}
2551*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp6_reg[cnt]);
2552*4c3888b8SHans Rosenfeld 	}
2553*4c3888b8SHans Rosenfeld 
2554*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nRISC GP7 Registers:");
2555*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
2556*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2557*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2558*4c3888b8SHans Rosenfeld 		}
2559*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->risc_gp7_reg[cnt]);
2560*4c3888b8SHans Rosenfeld 	}
2561*4c3888b8SHans Rosenfeld 
2562*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nFrame Buffer Hardware Registers:");
2563*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
2564*4c3888b8SHans Rosenfeld 		if ((cnt == 16) &&
2565*4c3888b8SHans Rosenfeld 		    ((ha->cfg_flags & CFG_CTRL_2363) == 0)) {
2566*4c3888b8SHans Rosenfeld 			break;
2567*4c3888b8SHans Rosenfeld 		}
2568*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2569*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2570*4c3888b8SHans Rosenfeld 		}
2571*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->frame_buf_hdw_reg[cnt]);
2572*4c3888b8SHans Rosenfeld 	}
2573*4c3888b8SHans Rosenfeld 
2574*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nFPM B0 Registers:");
2575*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
2576*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2577*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2578*4c3888b8SHans Rosenfeld 		}
2579*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->fpm_b0_reg[cnt]);
2580*4c3888b8SHans Rosenfeld 	}
2581*4c3888b8SHans Rosenfeld 
2582*4c3888b8SHans Rosenfeld 	mdb_printf("\n\nFPM B1 Registers:");
2583*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
2584*4c3888b8SHans Rosenfeld 		if (cnt % 8 == 0) {
2585*4c3888b8SHans Rosenfeld 			mdb_printf("\n");
2586*4c3888b8SHans Rosenfeld 		}
2587*4c3888b8SHans Rosenfeld 		mdb_printf("%04x  ", fw->fpm_b1_reg[cnt]);
2588*4c3888b8SHans Rosenfeld 	}
2589*4c3888b8SHans Rosenfeld 
2590*4c3888b8SHans Rosenfeld 	if (ha->cfg_flags & CFG_CTRL_2363) {
2591*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nCode RAM Dump:");
2592*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
2593*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2594*4c3888b8SHans Rosenfeld 				mdb_printf("\n%05x: ", cnt + 0x0800);
2595*4c3888b8SHans Rosenfeld 			}
2596*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
2597*4c3888b8SHans Rosenfeld 		}
2598*4c3888b8SHans Rosenfeld 
2599*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nStack RAM Dump:");
2600*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
2601*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2602*4c3888b8SHans Rosenfeld 				mdb_printf("\n%05x: ", cnt + 0x010000);
2603*4c3888b8SHans Rosenfeld 			}
2604*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->stack_ram[cnt]);
2605*4c3888b8SHans Rosenfeld 		}
2606*4c3888b8SHans Rosenfeld 
2607*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nData RAM Dump:");
2608*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) {
2609*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2610*4c3888b8SHans Rosenfeld 				mdb_printf("\n%05x: ", cnt + 0x010800);
2611*4c3888b8SHans Rosenfeld 			}
2612*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->data_ram[cnt]);
2613*4c3888b8SHans Rosenfeld 		}
2614*4c3888b8SHans Rosenfeld 
2615*4c3888b8SHans Rosenfeld 		mdb_printf("\n\n[<==END] ISP Debug Dump.\n");
2616*4c3888b8SHans Rosenfeld 
2617*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nRequest Queue");
2618*4c3888b8SHans Rosenfeld 
2619*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
2620*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2621*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt);
2622*4c3888b8SHans Rosenfeld 			}
2623*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", fw->req_q[cnt]);
2624*4c3888b8SHans Rosenfeld 		}
2625*4c3888b8SHans Rosenfeld 
2626*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nResponse Queue");
2627*4c3888b8SHans Rosenfeld 
2628*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
2629*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2630*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt);
2631*4c3888b8SHans Rosenfeld 			}
2632*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", fw->rsp_q[cnt]);
2633*4c3888b8SHans Rosenfeld 		}
2634*4c3888b8SHans Rosenfeld 
2635*4c3888b8SHans Rosenfeld 		mdb_printf("\n");
2636*4c3888b8SHans Rosenfeld 
2637*4c3888b8SHans Rosenfeld 	} else {
2638*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nRISC SRAM:");
2639*4c3888b8SHans Rosenfeld 		for (cnt = 0; cnt < 0xf000; cnt++) {
2640*4c3888b8SHans Rosenfeld 			if (cnt % 8 == 0) {
2641*4c3888b8SHans Rosenfeld 				mdb_printf("\n%04x: ", cnt + 0x1000);
2642*4c3888b8SHans Rosenfeld 			}
2643*4c3888b8SHans Rosenfeld 			mdb_printf("%04x  ", fw->risc_ram[cnt]);
2644*4c3888b8SHans Rosenfeld 		}
2645*4c3888b8SHans Rosenfeld 	}
2646*4c3888b8SHans Rosenfeld 
2647*4c3888b8SHans Rosenfeld 	mdb_free(fw, ha->ql_dump_size);
264816dd44c2SDaniel Beauregard 
2649fcf3ce44SJohn Forte 	return (DCMD_OK);
2650fcf3ce44SJohn Forte }
2651fcf3ce44SJohn Forte 
2652fcf3ce44SJohn Forte /*
2653fcf3ce44SJohn Forte  * ql_24xx_dump_dcmd
2654fcf3ce44SJohn Forte  *	prints out a firmware dump buffer
2655fcf3ce44SJohn Forte  *
2656fcf3ce44SJohn Forte  * Input:
2657fcf3ce44SJohn Forte  *	addr  = User supplied address. (NB: nust be an ha)
2658fcf3ce44SJohn Forte  *	flags = mdb flags.
2659fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
2660fcf3ce44SJohn Forte  *	argv  = Arg array.
2661fcf3ce44SJohn Forte  *
2662fcf3ce44SJohn Forte  * Returns:
2663fcf3ce44SJohn Forte  *	DCMD_OK or DCMD_ERR
2664fcf3ce44SJohn Forte  *
2665fcf3ce44SJohn Forte  * Context:
2666fcf3ce44SJohn Forte  *	User context.
2667fcf3ce44SJohn Forte  *
2668fcf3ce44SJohn Forte  */
2669fcf3ce44SJohn Forte /*ARGSUSED*/
2670fcf3ce44SJohn Forte static int
ql_24xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)2671fcf3ce44SJohn Forte ql_24xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
2672fcf3ce44SJohn Forte     const mdb_arg_t *argv)
2673fcf3ce44SJohn Forte {
2674fcf3ce44SJohn Forte 	ql_24xx_fw_dump_t	*fw;
2675fcf3ce44SJohn Forte 	uint32_t		cnt = 0;
2676fcf3ce44SJohn Forte 
267716dd44c2SDaniel Beauregard 	fw = (ql_24xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
2678fcf3ce44SJohn Forte 
267916dd44c2SDaniel Beauregard 	if (mdb_vread(fw, ha->ql_dump_size,
268016dd44c2SDaniel Beauregard 	    (uintptr_t)ha->ql_dump_ptr) == -1) {
268116dd44c2SDaniel Beauregard 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
268216dd44c2SDaniel Beauregard 		mdb_free(fw, ha->ql_dump_size);
2683fcf3ce44SJohn Forte 		return (DCMD_OK);
2684fcf3ce44SJohn Forte 	}
2685fcf3ce44SJohn Forte 
2686fcf3ce44SJohn Forte 	mdb_printf("ISP FW Version %d.%02d.%02d Attributes %X\n",
2687fcf3ce44SJohn Forte 	    ha->fw_major_version, ha->fw_minor_version,
2688fcf3ce44SJohn Forte 	    ha->fw_subminor_version, ha->fw_attributes);
2689fcf3ce44SJohn Forte 
2690fcf3ce44SJohn Forte 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
2691fcf3ce44SJohn Forte 
2692fcf3ce44SJohn Forte 	mdb_printf("\nHost Interface Registers");
2693fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
2694fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2695fcf3ce44SJohn Forte 			mdb_printf("\n");
2696fcf3ce44SJohn Forte 		}
2697fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->host_reg[cnt]);
2698fcf3ce44SJohn Forte 	}
2699fcf3ce44SJohn Forte 
2700fcf3ce44SJohn Forte 	mdb_printf("\n\nMailbox Registers");
2701fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
2702fcf3ce44SJohn Forte 		if (cnt % 16 == 0) {
2703fcf3ce44SJohn Forte 			mdb_printf("\n");
2704fcf3ce44SJohn Forte 		}
2705fcf3ce44SJohn Forte 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
2706fcf3ce44SJohn Forte 	}
2707fcf3ce44SJohn Forte 
2708fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ GP Registers");
2709fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
2710fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2711fcf3ce44SJohn Forte 			mdb_printf("\n");
2712fcf3ce44SJohn Forte 		}
2713fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
2714fcf3ce44SJohn Forte 	}
2715fcf3ce44SJohn Forte 
2716fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ-0 Registers");
2717fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
2718fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2719fcf3ce44SJohn Forte 			mdb_printf("\n");
2720fcf3ce44SJohn Forte 		}
2721fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
2722fcf3ce44SJohn Forte 	}
2723fcf3ce44SJohn Forte 
2724fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ-1 Registers");
2725fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
2726fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2727fcf3ce44SJohn Forte 			mdb_printf("\n");
2728fcf3ce44SJohn Forte 		}
2729fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
2730fcf3ce44SJohn Forte 	}
2731fcf3ce44SJohn Forte 
2732fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ GP Registers");
2733fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
2734fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2735fcf3ce44SJohn Forte 			mdb_printf("\n");
2736fcf3ce44SJohn Forte 		}
2737fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
2738fcf3ce44SJohn Forte 	}
2739fcf3ce44SJohn Forte 
2740fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-0 Registers");
2741fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
2742fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2743fcf3ce44SJohn Forte 			mdb_printf("\n");
2744fcf3ce44SJohn Forte 		}
2745fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
2746fcf3ce44SJohn Forte 	}
2747fcf3ce44SJohn Forte 
2748fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-1 Registers");
2749fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
2750fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2751fcf3ce44SJohn Forte 			mdb_printf("\n");
2752fcf3ce44SJohn Forte 		}
2753fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
2754fcf3ce44SJohn Forte 	}
2755fcf3ce44SJohn Forte 
2756fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-2 Registers");
2757fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
2758fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2759fcf3ce44SJohn Forte 			mdb_printf("\n");
2760fcf3ce44SJohn Forte 		}
2761fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
2762fcf3ce44SJohn Forte 	}
2763fcf3ce44SJohn Forte 
2764fcf3ce44SJohn Forte 	mdb_printf("\n\nCommand DMA Registers");
2765fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
2766fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2767fcf3ce44SJohn Forte 			mdb_printf("\n");
2768fcf3ce44SJohn Forte 		}
2769fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
2770fcf3ce44SJohn Forte 	}
2771fcf3ce44SJohn Forte 
2772fcf3ce44SJohn Forte 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
2773fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
2774fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2775fcf3ce44SJohn Forte 			mdb_printf("\n");
2776fcf3ce44SJohn Forte 		}
2777fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
2778fcf3ce44SJohn Forte 	}
2779fcf3ce44SJohn Forte 
2780fcf3ce44SJohn Forte 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
2781fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
2782fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2783fcf3ce44SJohn Forte 			mdb_printf("\n");
2784fcf3ce44SJohn Forte 		}
2785fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
2786fcf3ce44SJohn Forte 	}
2787fcf3ce44SJohn Forte 
2788fcf3ce44SJohn Forte 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
2789fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
2790fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2791fcf3ce44SJohn Forte 			mdb_printf("\n");
2792fcf3ce44SJohn Forte 		}
2793fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
2794fcf3ce44SJohn Forte 	}
2795fcf3ce44SJohn Forte 
2796fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT0 Data DMA Registers");
2797fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
2798fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2799fcf3ce44SJohn Forte 			mdb_printf("\n");
2800fcf3ce44SJohn Forte 		}
2801fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
2802fcf3ce44SJohn Forte 	}
2803fcf3ce44SJohn Forte 
2804fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT1 Data DMA Registers");
2805fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
2806fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2807fcf3ce44SJohn Forte 			mdb_printf("\n");
2808fcf3ce44SJohn Forte 		}
2809fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
2810fcf3ce44SJohn Forte 	}
2811fcf3ce44SJohn Forte 
2812fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT2 Data DMA Registers");
2813fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
2814fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2815fcf3ce44SJohn Forte 			mdb_printf("\n");
2816fcf3ce44SJohn Forte 		}
2817fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
2818fcf3ce44SJohn Forte 	}
2819fcf3ce44SJohn Forte 
2820fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT3 Data DMA Registers");
2821fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
2822fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2823fcf3ce44SJohn Forte 			mdb_printf("\n");
2824fcf3ce44SJohn Forte 		}
2825fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
2826fcf3ce44SJohn Forte 	}
2827fcf3ce44SJohn Forte 
2828fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT4 Data DMA Registers");
2829fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
2830fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2831fcf3ce44SJohn Forte 			mdb_printf("\n");
2832fcf3ce44SJohn Forte 		}
2833fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
2834fcf3ce44SJohn Forte 	}
2835fcf3ce44SJohn Forte 
2836fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT Data DMA Common Registers");
2837fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
2838fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2839fcf3ce44SJohn Forte 			mdb_printf("\n");
2840fcf3ce44SJohn Forte 		}
2841fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
2842fcf3ce44SJohn Forte 	}
2843fcf3ce44SJohn Forte 
2844fcf3ce44SJohn Forte 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
2845fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
2846fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2847fcf3ce44SJohn Forte 			mdb_printf("\n");
2848fcf3ce44SJohn Forte 		}
2849fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
2850fcf3ce44SJohn Forte 	}
2851fcf3ce44SJohn Forte 
2852fcf3ce44SJohn Forte 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
2853fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
2854fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2855fcf3ce44SJohn Forte 			mdb_printf("\n");
2856fcf3ce44SJohn Forte 		}
2857fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
2858fcf3ce44SJohn Forte 	}
2859fcf3ce44SJohn Forte 
2860fcf3ce44SJohn Forte 	mdb_printf("\n\nRISC GP Registers");
2861fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
2862fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2863fcf3ce44SJohn Forte 			mdb_printf("\n");
2864fcf3ce44SJohn Forte 		}
2865fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
2866fcf3ce44SJohn Forte 	}
2867fcf3ce44SJohn Forte 
2868fcf3ce44SJohn Forte 	mdb_printf("\n\nShadow Registers");
2869fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
2870fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2871fcf3ce44SJohn Forte 			mdb_printf("\n");
2872fcf3ce44SJohn Forte 		}
2873fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
2874fcf3ce44SJohn Forte 	}
2875fcf3ce44SJohn Forte 
2876fcf3ce44SJohn Forte 	mdb_printf("\n\nLMC Registers");
2877fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
2878fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2879fcf3ce44SJohn Forte 			mdb_printf("\n");
2880fcf3ce44SJohn Forte 		}
2881fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
2882fcf3ce44SJohn Forte 	}
2883fcf3ce44SJohn Forte 
2884fcf3ce44SJohn Forte 	mdb_printf("\n\nFPM Hardware Registers");
2885fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
2886fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2887fcf3ce44SJohn Forte 			mdb_printf("\n");
2888fcf3ce44SJohn Forte 		}
2889fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
2890fcf3ce44SJohn Forte 	}
2891fcf3ce44SJohn Forte 
2892fcf3ce44SJohn Forte 	mdb_printf("\n\nFB Hardware Registers");
2893fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
2894fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2895fcf3ce44SJohn Forte 			mdb_printf("\n");
2896fcf3ce44SJohn Forte 		}
2897fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
2898fcf3ce44SJohn Forte 	}
2899fcf3ce44SJohn Forte 
2900fcf3ce44SJohn Forte 	mdb_printf("\n\nCode RAM");
2901fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
2902fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2903fcf3ce44SJohn Forte 			mdb_printf("\n%08x: ", cnt + 0x20000);
2904fcf3ce44SJohn Forte 		}
2905fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->code_ram[cnt]);
2906fcf3ce44SJohn Forte 	}
2907fcf3ce44SJohn Forte 
2908fcf3ce44SJohn Forte 	mdb_printf("\n\nExternal Memory");
2909fcf3ce44SJohn Forte 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
2910fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
2911fcf3ce44SJohn Forte 			mdb_printf("\n%08x: ", cnt + 0x100000);
2912fcf3ce44SJohn Forte 		}
2913fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->ext_mem[cnt]);
2914fcf3ce44SJohn Forte 	}
2915fcf3ce44SJohn Forte 
2916fcf3ce44SJohn Forte 	mdb_printf("\n[<==END] ISP Debug Dump");
2917fcf3ce44SJohn Forte 
291816dd44c2SDaniel Beauregard 	mdb_printf("\n\nRequest Queue");
291916dd44c2SDaniel Beauregard 
292016dd44c2SDaniel Beauregard 	for (cnt = 0; cnt < REQUEST_QUEUE_SIZE / 4; cnt++) {
292116dd44c2SDaniel Beauregard 		if (cnt % 8 == 0) {
292216dd44c2SDaniel Beauregard 			mdb_printf("\n%08x: ", cnt);
292316dd44c2SDaniel Beauregard 		}
292416dd44c2SDaniel Beauregard 		mdb_printf("%08x ", fw->req_q[cnt]);
292516dd44c2SDaniel Beauregard 	}
292616dd44c2SDaniel Beauregard 
292716dd44c2SDaniel Beauregard 	mdb_printf("\n\nResponse Queue");
292816dd44c2SDaniel Beauregard 
292916dd44c2SDaniel Beauregard 	for (cnt = 0; cnt < RESPONSE_QUEUE_SIZE / 4; cnt++) {
293016dd44c2SDaniel Beauregard 		if (cnt % 8 == 0) {
293116dd44c2SDaniel Beauregard 			mdb_printf("\n%08x: ", cnt);
293216dd44c2SDaniel Beauregard 		}
293316dd44c2SDaniel Beauregard 		mdb_printf("%08x ", fw->rsp_q[cnt]);
293416dd44c2SDaniel Beauregard 	}
293516dd44c2SDaniel Beauregard 
293616dd44c2SDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
293716dd44c2SDaniel Beauregard 	    (ha->fwexttracebuf.bp != NULL)) {
293816dd44c2SDaniel Beauregard 		uint32_t cnt_b = 0;
293916dd44c2SDaniel Beauregard 		uint32_t *w32 = ha->fwexttracebuf.bp;
294016dd44c2SDaniel Beauregard 
294116dd44c2SDaniel Beauregard 		mdb_printf("\n\nExtended Trace Buffer Memory");
294216dd44c2SDaniel Beauregard 		/* show data address as a byte address, data as long words */
294316dd44c2SDaniel Beauregard 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
294416dd44c2SDaniel Beauregard 			cnt_b = cnt * 4;
294516dd44c2SDaniel Beauregard 			if (cnt_b % 32 == 0) {
294616dd44c2SDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
294716dd44c2SDaniel Beauregard 			}
294816dd44c2SDaniel Beauregard 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
294916dd44c2SDaniel Beauregard 		}
295016dd44c2SDaniel Beauregard 	}
295116dd44c2SDaniel Beauregard 
295216dd44c2SDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
295316dd44c2SDaniel Beauregard 	    (ha->fwfcetracebuf.bp != NULL)) {
295416dd44c2SDaniel Beauregard 		uint32_t cnt_b = 0;
295516dd44c2SDaniel Beauregard 		uint32_t *w32 = ha->fwfcetracebuf.bp;
295616dd44c2SDaniel Beauregard 
295716dd44c2SDaniel Beauregard 		mdb_printf("\n\nFC Event Trace Buffer Memory");
295816dd44c2SDaniel Beauregard 		/* show data address as a byte address, data as long words */
295916dd44c2SDaniel Beauregard 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
296016dd44c2SDaniel Beauregard 			cnt_b = cnt * 4;
296116dd44c2SDaniel Beauregard 			if (cnt_b % 32 == 0) {
296216dd44c2SDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
296316dd44c2SDaniel Beauregard 			}
296416dd44c2SDaniel Beauregard 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
296516dd44c2SDaniel Beauregard 		}
296616dd44c2SDaniel Beauregard 	}
296716dd44c2SDaniel Beauregard 	mdb_free(fw, ha->ql_dump_size);
2968fcf3ce44SJohn Forte 
2969fcf3ce44SJohn Forte 	return (DCMD_OK);
2970fcf3ce44SJohn Forte }
2971fcf3ce44SJohn Forte 
2972fcf3ce44SJohn Forte /*
2973fcf3ce44SJohn Forte  * ql_25xx_dump_dcmd
2974fcf3ce44SJohn Forte  *	prints out a firmware dump buffer
2975fcf3ce44SJohn Forte  *
2976fcf3ce44SJohn Forte  * Input:
2977fcf3ce44SJohn Forte  *	addr  = User supplied address. (NB: nust be an ha)
2978fcf3ce44SJohn Forte  *	flags = mdb flags.
2979fcf3ce44SJohn Forte  *	argc  = Number of user supplied args.
2980fcf3ce44SJohn Forte  *	argv  = Arg array.
2981fcf3ce44SJohn Forte  *
2982fcf3ce44SJohn Forte  * Returns:
2983fcf3ce44SJohn Forte  *	DCMD_OK or DCMD_ERR
2984fcf3ce44SJohn Forte  *
2985fcf3ce44SJohn Forte  * Context:
2986fcf3ce44SJohn Forte  *	User context.
2987fcf3ce44SJohn Forte  *
2988fcf3ce44SJohn Forte  */
2989fcf3ce44SJohn Forte /*ARGSUSED*/
2990fcf3ce44SJohn Forte static int
ql_25xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)2991fcf3ce44SJohn Forte ql_25xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
2992fcf3ce44SJohn Forte     const mdb_arg_t *argv)
2993fcf3ce44SJohn Forte {
2994fcf3ce44SJohn Forte 	ql_25xx_fw_dump_t	*fw;
2995*4c3888b8SHans Rosenfeld 	ql_response_q_t		**rsp_queues, *rsp_q;
2996*4c3888b8SHans Rosenfeld 	uint32_t		cnt, cnt1, *dp, *dp2;
2997fcf3ce44SJohn Forte 
299816dd44c2SDaniel Beauregard 	fw = (ql_25xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
2999*4c3888b8SHans Rosenfeld 	rsp_queues = mdb_alloc(ha->rsp_queues_cnt *
3000*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), UM_SLEEP);
3001*4c3888b8SHans Rosenfeld 	rsp_q = mdb_alloc(sizeof (ql_response_q_t), UM_SLEEP);
3002fcf3ce44SJohn Forte 
300316dd44c2SDaniel Beauregard 	if (mdb_vread(fw, ha->ql_dump_size,
3004*4c3888b8SHans Rosenfeld 	    (uintptr_t)ha->ql_dump_ptr) == -1 ||
3005*4c3888b8SHans Rosenfeld 	    mdb_vread(rsp_queues, ha->rsp_queues_cnt *
3006*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), (uintptr_t)ha->rsp_queues) == -1) {
3007fcf3ce44SJohn Forte 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
3008*4c3888b8SHans Rosenfeld 		mdb_free(rsp_q, sizeof (ql_response_q_t));
3009*4c3888b8SHans Rosenfeld 		mdb_free(rsp_queues, ha->rsp_queues_cnt *
3010*4c3888b8SHans Rosenfeld 		    sizeof (ql_response_q_t *));
301116dd44c2SDaniel Beauregard 		mdb_free(fw, ha->ql_dump_size);
3012fcf3ce44SJohn Forte 		return (DCMD_OK);
3013fcf3ce44SJohn Forte 	}
3014fcf3ce44SJohn Forte 
301516dd44c2SDaniel Beauregard 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
3016fcf3ce44SJohn Forte 	    ha->fw_major_version, ha->fw_minor_version,
3017fcf3ce44SJohn Forte 	    ha->fw_subminor_version, ha->fw_attributes);
3018fcf3ce44SJohn Forte 
3019*4c3888b8SHans Rosenfeld 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
3020fcf3ce44SJohn Forte 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
3021*4c3888b8SHans Rosenfeld 	mdb_printf("\nAER Uncorrectable Error Status Register\n%08x\n",
3022*4c3888b8SHans Rosenfeld 	    fw->aer_ues);
3023fcf3ce44SJohn Forte 
302416dd44c2SDaniel Beauregard 	mdb_printf("\n\nHostRisc Registers");
3025fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
3026fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3027fcf3ce44SJohn Forte 			mdb_printf("\n");
3028fcf3ce44SJohn Forte 		}
3029fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
3030fcf3ce44SJohn Forte 	}
3031fcf3ce44SJohn Forte 
3032f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nPCIe Registers");
3033f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
3034f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3035f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3036f33c1cdbSDaniel Beauregard 		}
3037f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
3038f33c1cdbSDaniel Beauregard 	}
3039f33c1cdbSDaniel Beauregard 
3040f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nHost Interface Registers");
3041f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
3042f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3043f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3044f33c1cdbSDaniel Beauregard 		}
3045f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->host_reg[cnt]);
3046f33c1cdbSDaniel Beauregard 	}
3047f33c1cdbSDaniel Beauregard 
3048f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nShadow Registers");
3049f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
3050f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3051f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3052f33c1cdbSDaniel Beauregard 		}
3053f33c1cdbSDaniel Beauregard 
3054f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
3055f33c1cdbSDaniel Beauregard 	}
3056f33c1cdbSDaniel Beauregard 
3057f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nMailbox Registers");
3058f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
3059f33c1cdbSDaniel Beauregard 		if (cnt % 16 == 0) {
3060f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3061f33c1cdbSDaniel Beauregard 		}
3062f33c1cdbSDaniel Beauregard 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
3063f33c1cdbSDaniel Beauregard 	}
3064f33c1cdbSDaniel Beauregard 
3065f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXSEQ GP Registers");
3066f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
3067f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3068f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3069f33c1cdbSDaniel Beauregard 		}
3070f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
3071f33c1cdbSDaniel Beauregard 	}
3072f33c1cdbSDaniel Beauregard 
3073f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXSEQ-0 Registers");
3074f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
3075f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3076f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3077f33c1cdbSDaniel Beauregard 		}
3078f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
3079f33c1cdbSDaniel Beauregard 	}
3080f33c1cdbSDaniel Beauregard 
3081f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXSEQ-1 Registers");
3082f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
3083f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3084f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3085f33c1cdbSDaniel Beauregard 		}
3086f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
3087f33c1cdbSDaniel Beauregard 	}
3088f33c1cdbSDaniel Beauregard 
3089f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRSEQ GP Registers");
3090f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
3091f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3092f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3093f33c1cdbSDaniel Beauregard 		}
3094f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
3095f33c1cdbSDaniel Beauregard 	}
3096f33c1cdbSDaniel Beauregard 
3097f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRSEQ-0 Registers");
3098f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
3099f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3100f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3101f33c1cdbSDaniel Beauregard 		}
3102f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
3103f33c1cdbSDaniel Beauregard 	}
3104f33c1cdbSDaniel Beauregard 
3105f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRSEQ-1 Registers");
3106f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
3107f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3108f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3109f33c1cdbSDaniel Beauregard 		}
3110f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
3111f33c1cdbSDaniel Beauregard 	}
3112f33c1cdbSDaniel Beauregard 
3113f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRSEQ-2 Registers");
3114f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
3115f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3116f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3117f33c1cdbSDaniel Beauregard 		}
3118f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
3119f33c1cdbSDaniel Beauregard 	}
3120f33c1cdbSDaniel Beauregard 
3121f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nASEQ GP Registers");
3122f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
3123f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3124f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3125f33c1cdbSDaniel Beauregard 		}
3126f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
3127f33c1cdbSDaniel Beauregard 	}
3128f33c1cdbSDaniel Beauregard 
3129f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nASEQ-0 GP Registers");
3130f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
3131f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3132f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3133f33c1cdbSDaniel Beauregard 		}
3134f33c1cdbSDaniel Beauregard 
3135f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
3136f33c1cdbSDaniel Beauregard 	}
3137f33c1cdbSDaniel Beauregard 
3138f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nASEQ-1 GP Registers");
3139f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
3140f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3141f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3142f33c1cdbSDaniel Beauregard 		}
3143f33c1cdbSDaniel Beauregard 
3144f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
3145f33c1cdbSDaniel Beauregard 	}
3146f33c1cdbSDaniel Beauregard 
3147f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nASEQ-2 GP Registers");
3148f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
3149f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3150f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3151f33c1cdbSDaniel Beauregard 		}
3152f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
3153f33c1cdbSDaniel Beauregard 	}
3154f33c1cdbSDaniel Beauregard 
3155f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nCommand DMA Registers");
3156f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
3157f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3158f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3159f33c1cdbSDaniel Beauregard 		}
3160f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
3161f33c1cdbSDaniel Beauregard 	}
3162f33c1cdbSDaniel Beauregard 
3163f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
3164f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
3165f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3166f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3167f33c1cdbSDaniel Beauregard 		}
3168f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
3169f33c1cdbSDaniel Beauregard 	}
3170f33c1cdbSDaniel Beauregard 
3171f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
3172f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
3173f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3174f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3175f33c1cdbSDaniel Beauregard 		}
3176f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
3177f33c1cdbSDaniel Beauregard 	}
3178f33c1cdbSDaniel Beauregard 
3179f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
3180f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
3181f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3182f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3183f33c1cdbSDaniel Beauregard 		}
3184f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
3185f33c1cdbSDaniel Beauregard 	}
3186f33c1cdbSDaniel Beauregard 
3187f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT0 Data DMA Registers");
3188f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
3189f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3190f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3191f33c1cdbSDaniel Beauregard 		}
3192f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
3193f33c1cdbSDaniel Beauregard 	}
3194f33c1cdbSDaniel Beauregard 
3195f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT1 Data DMA Registers");
3196f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
3197f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3198f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3199f33c1cdbSDaniel Beauregard 		}
3200f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
3201f33c1cdbSDaniel Beauregard 	}
3202f33c1cdbSDaniel Beauregard 
3203f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT2 Data DMA Registers");
3204f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
3205f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3206f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3207f33c1cdbSDaniel Beauregard 		}
3208f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
3209f33c1cdbSDaniel Beauregard 	}
3210f33c1cdbSDaniel Beauregard 
3211f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT3 Data DMA Registers");
3212f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
3213f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3214f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3215f33c1cdbSDaniel Beauregard 		}
3216f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
3217f33c1cdbSDaniel Beauregard 	}
3218f33c1cdbSDaniel Beauregard 
3219f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT4 Data DMA Registers");
3220f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
3221f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3222f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3223f33c1cdbSDaniel Beauregard 		}
3224f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
3225f33c1cdbSDaniel Beauregard 	}
3226f33c1cdbSDaniel Beauregard 
3227f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nXMT Data DMA Common Registers");
3228f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
3229f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3230f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3231f33c1cdbSDaniel Beauregard 		}
3232f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
3233f33c1cdbSDaniel Beauregard 	}
3234f33c1cdbSDaniel Beauregard 
3235f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
3236f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
3237f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3238f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3239f33c1cdbSDaniel Beauregard 		}
3240f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
3241f33c1cdbSDaniel Beauregard 	}
3242f33c1cdbSDaniel Beauregard 
3243f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
3244f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
3245f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3246f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3247f33c1cdbSDaniel Beauregard 		}
3248f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
3249f33c1cdbSDaniel Beauregard 	}
3250f33c1cdbSDaniel Beauregard 
3251f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRISC GP Registers");
3252f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
3253f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3254f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3255f33c1cdbSDaniel Beauregard 		}
3256f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
3257f33c1cdbSDaniel Beauregard 	}
3258f33c1cdbSDaniel Beauregard 
3259f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
3260f33c1cdbSDaniel Beauregard 
3261f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nLMC Registers");
3262f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
3263f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3264f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3265f33c1cdbSDaniel Beauregard 		}
3266f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
3267f33c1cdbSDaniel Beauregard 	}
3268f33c1cdbSDaniel Beauregard 
3269f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nFPM Hardware Registers");
3270f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
3271f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3272f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3273f33c1cdbSDaniel Beauregard 		}
3274f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
3275f33c1cdbSDaniel Beauregard 	}
3276f33c1cdbSDaniel Beauregard 
3277f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nFB Hardware Registers");
3278f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
3279f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3280f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3281f33c1cdbSDaniel Beauregard 		}
3282f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
3283f33c1cdbSDaniel Beauregard 	}
3284f33c1cdbSDaniel Beauregard 
3285f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nCode RAM");
3286f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
3287f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3288f33c1cdbSDaniel Beauregard 			mdb_printf("\n%08x: ", cnt + 0x20000);
3289f33c1cdbSDaniel Beauregard 		}
3290f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->code_ram[cnt]);
3291f33c1cdbSDaniel Beauregard 	}
3292f33c1cdbSDaniel Beauregard 
3293f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nExternal Memory");
3294*4c3888b8SHans Rosenfeld 	dp = (uint32_t *)(void *)((caddr_t)fw->req_rsp_ext_mem +
3295*4c3888b8SHans Rosenfeld 	    fw->req_q_size[0] + fw->req_q_size[1] + fw->rsp_q_size +
3296*4c3888b8SHans Rosenfeld 	    (ha->rsp_queues_cnt * 16));
3297f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
3298f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3299f33c1cdbSDaniel Beauregard 			mdb_printf("\n%08x: ", cnt + 0x100000);
3300f33c1cdbSDaniel Beauregard 		}
3301*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", *dp++);
3302f33c1cdbSDaniel Beauregard 	}
3303f33c1cdbSDaniel Beauregard 
3304f33c1cdbSDaniel Beauregard 	mdb_printf("\n[<==END] ISP Debug Dump");
3305f33c1cdbSDaniel Beauregard 
3306f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nRequest Queue");
3307f33c1cdbSDaniel Beauregard 
3308*4c3888b8SHans Rosenfeld 	dp = fw->req_rsp_ext_mem + (ha->rsp_queues_cnt * 4);
3309*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < 2 && fw->req_q_size[cnt]; cnt++) {
3310*4c3888b8SHans Rosenfeld 		dp2 = dp;
3311*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
3312*4c3888b8SHans Rosenfeld 			if (*dp2++) {
3313*4c3888b8SHans Rosenfeld 				break;
3314*4c3888b8SHans Rosenfeld 			}
3315*4c3888b8SHans Rosenfeld 		}
3316*4c3888b8SHans Rosenfeld 		if (cnt1 == fw->req_q_size[cnt] / 4) {
3317*4c3888b8SHans Rosenfeld 			dp = dp2;
3318*4c3888b8SHans Rosenfeld 			continue;
3319*4c3888b8SHans Rosenfeld 		}
3320*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nRequest Queue\nQueue 0%d:", cnt);
3321*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
3322*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
3323*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
3324*4c3888b8SHans Rosenfeld 			}
3325*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
3326f33c1cdbSDaniel Beauregard 		}
3327f33c1cdbSDaniel Beauregard 	}
3328f33c1cdbSDaniel Beauregard 
3329*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < ha->rsp_queues_cnt; cnt++) {
3330*4c3888b8SHans Rosenfeld 		if (mdb_vread(rsp_q, sizeof (ql_response_q_t),
3331*4c3888b8SHans Rosenfeld 		    (uintptr_t)rsp_queues[cnt]) == -1) {
3332*4c3888b8SHans Rosenfeld 			mdb_warn("failed to read ha->rsp_queues[%d]", cnt);
3333*4c3888b8SHans Rosenfeld 			break;
3334*4c3888b8SHans Rosenfeld 		}
3335*4c3888b8SHans Rosenfeld 		dp2 = dp;
3336*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
3337*4c3888b8SHans Rosenfeld 			if (*dp2++) {
3338*4c3888b8SHans Rosenfeld 				break;
3339*4c3888b8SHans Rosenfeld 			}
3340*4c3888b8SHans Rosenfeld 		}
3341*4c3888b8SHans Rosenfeld 		if (cnt1 == rsp_q->rsp_ring.size / 4) {
3342*4c3888b8SHans Rosenfeld 			dp = dp2;
3343*4c3888b8SHans Rosenfeld 			continue;
3344*4c3888b8SHans Rosenfeld 		}
3345*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nResponse Queue\nQueue 0%d:", cnt);
3346f33c1cdbSDaniel Beauregard 
3347*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
3348*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
3349*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
3350*4c3888b8SHans Rosenfeld 			}
3351*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
3352f33c1cdbSDaniel Beauregard 		}
3353f33c1cdbSDaniel Beauregard 	}
3354f33c1cdbSDaniel Beauregard 
3355f33c1cdbSDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
3356f33c1cdbSDaniel Beauregard 	    (ha->fwexttracebuf.bp != NULL)) {
3357f33c1cdbSDaniel Beauregard 		uint32_t cnt_b = 0;
3358f33c1cdbSDaniel Beauregard 		uint32_t *w32 = ha->fwexttracebuf.bp;
3359f33c1cdbSDaniel Beauregard 
3360f33c1cdbSDaniel Beauregard 		mdb_printf("\n\nExtended Trace Buffer Memory");
3361f33c1cdbSDaniel Beauregard 		/* show data address as a byte address, data as long words */
3362f33c1cdbSDaniel Beauregard 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
3363f33c1cdbSDaniel Beauregard 			cnt_b = cnt * 4;
3364f33c1cdbSDaniel Beauregard 			if (cnt_b % 32 == 0) {
3365f33c1cdbSDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
3366f33c1cdbSDaniel Beauregard 			}
3367f33c1cdbSDaniel Beauregard 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
3368f33c1cdbSDaniel Beauregard 		}
3369f33c1cdbSDaniel Beauregard 	}
3370f33c1cdbSDaniel Beauregard 
3371f33c1cdbSDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
3372f33c1cdbSDaniel Beauregard 	    (ha->fwfcetracebuf.bp != NULL)) {
3373f33c1cdbSDaniel Beauregard 		uint32_t cnt_b = 0;
3374f33c1cdbSDaniel Beauregard 		uint32_t *w32 = ha->fwfcetracebuf.bp;
3375f33c1cdbSDaniel Beauregard 
3376f33c1cdbSDaniel Beauregard 		mdb_printf("\n\nFC Event Trace Buffer Memory");
3377f33c1cdbSDaniel Beauregard 		/* show data address as a byte address, data as long words */
3378f33c1cdbSDaniel Beauregard 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
3379f33c1cdbSDaniel Beauregard 			cnt_b = cnt * 4;
3380f33c1cdbSDaniel Beauregard 			if (cnt_b % 32 == 0) {
3381f33c1cdbSDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
3382f33c1cdbSDaniel Beauregard 			}
3383f33c1cdbSDaniel Beauregard 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
3384f33c1cdbSDaniel Beauregard 		}
3385f33c1cdbSDaniel Beauregard 	}
3386f33c1cdbSDaniel Beauregard 
3387*4c3888b8SHans Rosenfeld 	mdb_free(rsp_q, sizeof (ql_response_q_t));
3388*4c3888b8SHans Rosenfeld 	mdb_free(rsp_queues, ha->rsp_queues_cnt * sizeof (ql_response_q_t *));
3389f33c1cdbSDaniel Beauregard 	mdb_free(fw, ha->ql_dump_size);
3390f33c1cdbSDaniel Beauregard 
3391f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nreturn exit\n");
3392f33c1cdbSDaniel Beauregard 
3393f33c1cdbSDaniel Beauregard 	return (DCMD_OK);
3394f33c1cdbSDaniel Beauregard }
3395f33c1cdbSDaniel Beauregard 
3396f33c1cdbSDaniel Beauregard /*
3397f33c1cdbSDaniel Beauregard  * ql_81xx_dump_dcmd
3398f33c1cdbSDaniel Beauregard  *	prints out a firmware dump buffer
3399f33c1cdbSDaniel Beauregard  *
3400f33c1cdbSDaniel Beauregard  * Input:
3401f33c1cdbSDaniel Beauregard  *	addr  = User supplied address. (NB: nust be an ha)
3402f33c1cdbSDaniel Beauregard  *	flags = mdb flags.
3403f33c1cdbSDaniel Beauregard  *	argc  = Number of user supplied args.
3404f33c1cdbSDaniel Beauregard  *	argv  = Arg array.
3405f33c1cdbSDaniel Beauregard  *
3406f33c1cdbSDaniel Beauregard  * Returns:
3407f33c1cdbSDaniel Beauregard  *	DCMD_OK or DCMD_ERR
3408f33c1cdbSDaniel Beauregard  *
3409f33c1cdbSDaniel Beauregard  * Context:
3410f33c1cdbSDaniel Beauregard  *	User context.
3411f33c1cdbSDaniel Beauregard  *
3412f33c1cdbSDaniel Beauregard  */
3413f33c1cdbSDaniel Beauregard /*ARGSUSED*/
3414f33c1cdbSDaniel Beauregard static int
ql_81xx_dump_dcmd(ql_adapter_state_t * ha,uint_t flags,int argc,const mdb_arg_t * argv)3415f33c1cdbSDaniel Beauregard ql_81xx_dump_dcmd(ql_adapter_state_t *ha, uint_t flags, int argc,
3416f33c1cdbSDaniel Beauregard     const mdb_arg_t *argv)
3417f33c1cdbSDaniel Beauregard {
3418f33c1cdbSDaniel Beauregard 	ql_81xx_fw_dump_t	*fw;
3419*4c3888b8SHans Rosenfeld 	ql_response_q_t		**rsp_queues, *rsp_q;
3420*4c3888b8SHans Rosenfeld 	uint32_t		cnt, cnt1, *dp, *dp2;
3421f33c1cdbSDaniel Beauregard 
3422f33c1cdbSDaniel Beauregard 	fw = (ql_81xx_fw_dump_t *)mdb_alloc(ha->ql_dump_size, UM_SLEEP);
3423*4c3888b8SHans Rosenfeld 	rsp_queues = mdb_alloc(ha->rsp_queues_cnt *
3424*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), UM_SLEEP);
3425*4c3888b8SHans Rosenfeld 	rsp_q = mdb_alloc(sizeof (ql_response_q_t), UM_SLEEP);
3426f33c1cdbSDaniel Beauregard 
3427f33c1cdbSDaniel Beauregard 	if (mdb_vread(fw, ha->ql_dump_size,
3428*4c3888b8SHans Rosenfeld 	    (uintptr_t)ha->ql_dump_ptr) == -1 ||
3429*4c3888b8SHans Rosenfeld 	    mdb_vread(rsp_queues, ha->rsp_queues_cnt *
3430*4c3888b8SHans Rosenfeld 	    sizeof (ql_response_q_t *), (uintptr_t)ha->rsp_queues) == -1) {
3431f33c1cdbSDaniel Beauregard 		mdb_warn("failed to read ql_dump_ptr (no f/w dump active?)");
3432*4c3888b8SHans Rosenfeld 		mdb_free(rsp_q, sizeof (ql_response_q_t));
3433*4c3888b8SHans Rosenfeld 		mdb_free(rsp_queues, ha->rsp_queues_cnt *
3434*4c3888b8SHans Rosenfeld 		    sizeof (ql_response_q_t *));
3435f33c1cdbSDaniel Beauregard 		mdb_free(fw, ha->ql_dump_size);
3436f33c1cdbSDaniel Beauregard 		return (DCMD_OK);
3437f33c1cdbSDaniel Beauregard 	}
3438f33c1cdbSDaniel Beauregard 
3439f33c1cdbSDaniel Beauregard 	mdb_printf("\nISP FW Version %d.%02d.%02d Attributes %X\n",
3440f33c1cdbSDaniel Beauregard 	    ha->fw_major_version, ha->fw_minor_version,
3441f33c1cdbSDaniel Beauregard 	    ha->fw_subminor_version, ha->fw_attributes);
3442f33c1cdbSDaniel Beauregard 
3443*4c3888b8SHans Rosenfeld 	mdb_printf("\nHCCR Register\n%08x\n", fw->hccr);
3444*4c3888b8SHans Rosenfeld 
3445f33c1cdbSDaniel Beauregard 	mdb_printf("\nR2H Register\n%08x\n", fw->r2h_status);
3446f33c1cdbSDaniel Beauregard 
3447*4c3888b8SHans Rosenfeld 	mdb_printf("\nAER Uncorrectable Error Status Register\n%08x\n",
3448*4c3888b8SHans Rosenfeld 	    fw->aer_ues);
3449*4c3888b8SHans Rosenfeld 
3450f33c1cdbSDaniel Beauregard 	mdb_printf("\n\nHostRisc Registers");
3451f33c1cdbSDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->hostrisc_reg) / 4; cnt++) {
3452f33c1cdbSDaniel Beauregard 		if (cnt % 8 == 0) {
3453f33c1cdbSDaniel Beauregard 			mdb_printf("\n");
3454f33c1cdbSDaniel Beauregard 		}
3455f33c1cdbSDaniel Beauregard 		mdb_printf("%08x ", fw->hostrisc_reg[cnt]);
3456f33c1cdbSDaniel Beauregard 	}
3457f33c1cdbSDaniel Beauregard 
345816dd44c2SDaniel Beauregard 	mdb_printf("\n\nPCIe Registers");
3459fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->pcie_reg) / 4; cnt++) {
3460fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3461fcf3ce44SJohn Forte 			mdb_printf("\n");
3462fcf3ce44SJohn Forte 		}
3463fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->pcie_reg[cnt]);
3464fcf3ce44SJohn Forte 	}
3465fcf3ce44SJohn Forte 
346616dd44c2SDaniel Beauregard 	mdb_printf("\n\nHost Interface Registers");
3467fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->host_reg) / 4; cnt++) {
3468fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3469fcf3ce44SJohn Forte 			mdb_printf("\n");
3470fcf3ce44SJohn Forte 		}
3471fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->host_reg[cnt]);
3472fcf3ce44SJohn Forte 	}
3473fcf3ce44SJohn Forte 
347416dd44c2SDaniel Beauregard 	mdb_printf("\n\nShadow Registers");
347516dd44c2SDaniel Beauregard 	for (cnt = 0; cnt < sizeof (fw->shadow_reg) / 4; cnt++) {
347616dd44c2SDaniel Beauregard 		if (cnt % 8 == 0) {
347716dd44c2SDaniel Beauregard 			mdb_printf("\n");
347816dd44c2SDaniel Beauregard 		}
347916dd44c2SDaniel Beauregard 
348016dd44c2SDaniel Beauregard 		mdb_printf("%08x ", fw->shadow_reg[cnt]);
348116dd44c2SDaniel Beauregard 	}
348216dd44c2SDaniel Beauregard 
3483fcf3ce44SJohn Forte 	mdb_printf("\n\nMailbox Registers");
3484fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
3485fcf3ce44SJohn Forte 		if (cnt % 16 == 0) {
3486fcf3ce44SJohn Forte 			mdb_printf("\n");
3487fcf3ce44SJohn Forte 		}
3488fcf3ce44SJohn Forte 		mdb_printf("%04x ", fw->mailbox_reg[cnt]);
3489fcf3ce44SJohn Forte 	}
3490fcf3ce44SJohn Forte 
3491fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ GP Registers");
3492fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_gp_reg) / 4; cnt++) {
3493fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3494fcf3ce44SJohn Forte 			mdb_printf("\n");
3495fcf3ce44SJohn Forte 		}
3496fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_gp_reg[cnt]);
3497fcf3ce44SJohn Forte 	}
3498fcf3ce44SJohn Forte 
3499fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ-0 Registers");
3500fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_0_reg) / 4; cnt++) {
3501fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3502fcf3ce44SJohn Forte 			mdb_printf("\n");
3503fcf3ce44SJohn Forte 		}
3504fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_0_reg[cnt]);
3505fcf3ce44SJohn Forte 	}
3506fcf3ce44SJohn Forte 
3507fcf3ce44SJohn Forte 	mdb_printf("\n\nXSEQ-1 Registers");
3508fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xseq_1_reg) / 4; cnt++) {
3509fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3510fcf3ce44SJohn Forte 			mdb_printf("\n");
3511fcf3ce44SJohn Forte 		}
3512fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xseq_1_reg[cnt]);
3513fcf3ce44SJohn Forte 	}
3514fcf3ce44SJohn Forte 
3515fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ GP Registers");
3516fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_gp_reg) / 4; cnt++) {
3517fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3518fcf3ce44SJohn Forte 			mdb_printf("\n");
3519fcf3ce44SJohn Forte 		}
3520fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_gp_reg[cnt]);
3521fcf3ce44SJohn Forte 	}
3522fcf3ce44SJohn Forte 
3523fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-0 Registers");
3524fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_0_reg) / 4; cnt++) {
3525fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3526fcf3ce44SJohn Forte 			mdb_printf("\n");
3527fcf3ce44SJohn Forte 		}
3528fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_0_reg[cnt]);
3529fcf3ce44SJohn Forte 	}
3530fcf3ce44SJohn Forte 
3531fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-1 Registers");
3532fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_1_reg) / 4; cnt++) {
3533fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3534fcf3ce44SJohn Forte 			mdb_printf("\n");
3535fcf3ce44SJohn Forte 		}
3536fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_1_reg[cnt]);
3537fcf3ce44SJohn Forte 	}
3538fcf3ce44SJohn Forte 
3539fcf3ce44SJohn Forte 	mdb_printf("\n\nRSEQ-2 Registers");
3540fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rseq_2_reg) / 4; cnt++) {
3541fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3542fcf3ce44SJohn Forte 			mdb_printf("\n");
3543fcf3ce44SJohn Forte 		}
3544fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rseq_2_reg[cnt]);
3545fcf3ce44SJohn Forte 	}
3546fcf3ce44SJohn Forte 
3547fcf3ce44SJohn Forte 	mdb_printf("\n\nASEQ GP Registers");
3548fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->aseq_gp_reg) / 4; cnt++) {
3549fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3550fcf3ce44SJohn Forte 			mdb_printf("\n");
3551fcf3ce44SJohn Forte 		}
3552fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->aseq_gp_reg[cnt]);
3553fcf3ce44SJohn Forte 	}
3554fcf3ce44SJohn Forte 
3555fcf3ce44SJohn Forte 	mdb_printf("\n\nASEQ-0 GP Registers");
3556fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->aseq_0_reg) / 4; cnt++) {
3557fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3558fcf3ce44SJohn Forte 			mdb_printf("\n");
3559fcf3ce44SJohn Forte 		}
3560fcf3ce44SJohn Forte 
3561fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->aseq_0_reg[cnt]);
3562fcf3ce44SJohn Forte 	}
3563fcf3ce44SJohn Forte 
3564fcf3ce44SJohn Forte 	mdb_printf("\n\nASEQ-1 GP Registers");
3565fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->aseq_1_reg) / 4; cnt++) {
3566fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3567fcf3ce44SJohn Forte 			mdb_printf("\n");
3568fcf3ce44SJohn Forte 		}
3569fcf3ce44SJohn Forte 
3570fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->aseq_1_reg[cnt]);
3571fcf3ce44SJohn Forte 	}
3572fcf3ce44SJohn Forte 
3573fcf3ce44SJohn Forte 	mdb_printf("\n\nASEQ-2 GP Registers");
3574fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->aseq_2_reg) / 4; cnt++) {
3575fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3576fcf3ce44SJohn Forte 			mdb_printf("\n");
3577fcf3ce44SJohn Forte 		}
3578fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->aseq_2_reg[cnt]);
3579fcf3ce44SJohn Forte 	}
3580fcf3ce44SJohn Forte 
3581fcf3ce44SJohn Forte 	mdb_printf("\n\nCommand DMA Registers");
3582fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->cmd_dma_reg) / 4; cnt++) {
3583fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3584fcf3ce44SJohn Forte 			mdb_printf("\n");
3585fcf3ce44SJohn Forte 		}
3586fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->cmd_dma_reg[cnt]);
3587fcf3ce44SJohn Forte 	}
3588fcf3ce44SJohn Forte 
3589fcf3ce44SJohn Forte 	mdb_printf("\n\nRequest0 Queue DMA Channel Registers");
3590fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->req0_dma_reg) / 4; cnt++) {
3591fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3592fcf3ce44SJohn Forte 			mdb_printf("\n");
3593fcf3ce44SJohn Forte 		}
3594fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->req0_dma_reg[cnt]);
3595fcf3ce44SJohn Forte 	}
3596fcf3ce44SJohn Forte 
3597fcf3ce44SJohn Forte 	mdb_printf("\n\nResponse0 Queue DMA Channel Registers");
3598fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->resp0_dma_reg) / 4; cnt++) {
3599fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3600fcf3ce44SJohn Forte 			mdb_printf("\n");
3601fcf3ce44SJohn Forte 		}
3602fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->resp0_dma_reg[cnt]);
3603fcf3ce44SJohn Forte 	}
3604fcf3ce44SJohn Forte 
3605fcf3ce44SJohn Forte 	mdb_printf("\n\nRequest1 Queue DMA Channel Registers");
3606fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->req1_dma_reg) / 4; cnt++) {
3607fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3608fcf3ce44SJohn Forte 			mdb_printf("\n");
3609fcf3ce44SJohn Forte 		}
3610fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->req1_dma_reg[cnt]);
3611fcf3ce44SJohn Forte 	}
3612fcf3ce44SJohn Forte 
3613fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT0 Data DMA Registers");
3614fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt0_dma_reg) / 4; cnt++) {
3615fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3616fcf3ce44SJohn Forte 			mdb_printf("\n");
3617fcf3ce44SJohn Forte 		}
3618fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt0_dma_reg[cnt]);
3619fcf3ce44SJohn Forte 	}
3620fcf3ce44SJohn Forte 
3621fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT1 Data DMA Registers");
3622fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt1_dma_reg) / 4; cnt++) {
3623fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3624fcf3ce44SJohn Forte 			mdb_printf("\n");
3625fcf3ce44SJohn Forte 		}
3626fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt1_dma_reg[cnt]);
3627fcf3ce44SJohn Forte 	}
3628fcf3ce44SJohn Forte 
3629fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT2 Data DMA Registers");
3630fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt2_dma_reg) / 4; cnt++) {
3631fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3632fcf3ce44SJohn Forte 			mdb_printf("\n");
3633fcf3ce44SJohn Forte 		}
3634fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt2_dma_reg[cnt]);
3635fcf3ce44SJohn Forte 	}
3636fcf3ce44SJohn Forte 
3637fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT3 Data DMA Registers");
3638fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt3_dma_reg) / 4; cnt++) {
3639fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3640fcf3ce44SJohn Forte 			mdb_printf("\n");
3641fcf3ce44SJohn Forte 		}
3642fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt3_dma_reg[cnt]);
3643fcf3ce44SJohn Forte 	}
3644fcf3ce44SJohn Forte 
3645fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT4 Data DMA Registers");
3646fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt4_dma_reg) / 4; cnt++) {
3647fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3648fcf3ce44SJohn Forte 			mdb_printf("\n");
3649fcf3ce44SJohn Forte 		}
3650fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt4_dma_reg[cnt]);
3651fcf3ce44SJohn Forte 	}
3652fcf3ce44SJohn Forte 
3653fcf3ce44SJohn Forte 	mdb_printf("\n\nXMT Data DMA Common Registers");
3654fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->xmt_data_dma_reg) / 4; cnt++) {
3655fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3656fcf3ce44SJohn Forte 			mdb_printf("\n");
3657fcf3ce44SJohn Forte 		}
3658fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->xmt_data_dma_reg[cnt]);
3659fcf3ce44SJohn Forte 	}
3660fcf3ce44SJohn Forte 
3661fcf3ce44SJohn Forte 	mdb_printf("\n\nRCV Thread 0 Data DMA Registers");
3662fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rcvt0_data_dma_reg) / 4; cnt++) {
3663fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3664fcf3ce44SJohn Forte 			mdb_printf("\n");
3665fcf3ce44SJohn Forte 		}
3666fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rcvt0_data_dma_reg[cnt]);
3667fcf3ce44SJohn Forte 	}
3668fcf3ce44SJohn Forte 
3669fcf3ce44SJohn Forte 	mdb_printf("\n\nRCV Thread 1 Data DMA Registers");
3670fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->rcvt1_data_dma_reg) / 4; cnt++) {
3671fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3672fcf3ce44SJohn Forte 			mdb_printf("\n");
3673fcf3ce44SJohn Forte 		}
3674fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->rcvt1_data_dma_reg[cnt]);
3675fcf3ce44SJohn Forte 	}
3676fcf3ce44SJohn Forte 
3677fcf3ce44SJohn Forte 	mdb_printf("\n\nRISC GP Registers");
3678fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->risc_gp_reg) / 4; cnt++) {
3679fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3680fcf3ce44SJohn Forte 			mdb_printf("\n");
3681fcf3ce44SJohn Forte 		}
3682fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->risc_gp_reg[cnt]);
3683fcf3ce44SJohn Forte 	}
3684fcf3ce44SJohn Forte 
3685fcf3ce44SJohn Forte 	mdb_printf("\n\nRISC IO Register\n%08x", fw->risc_io);
3686fcf3ce44SJohn Forte 
3687fcf3ce44SJohn Forte 	mdb_printf("\n\nLMC Registers");
3688fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->lmc_reg) / 4; cnt++) {
3689fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3690fcf3ce44SJohn Forte 			mdb_printf("\n");
3691fcf3ce44SJohn Forte 		}
3692fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->lmc_reg[cnt]);
3693fcf3ce44SJohn Forte 	}
3694fcf3ce44SJohn Forte 
3695fcf3ce44SJohn Forte 	mdb_printf("\n\nFPM Hardware Registers");
3696fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->fpm_hdw_reg) / 4; cnt++) {
3697fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3698fcf3ce44SJohn Forte 			mdb_printf("\n");
3699fcf3ce44SJohn Forte 		}
3700fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->fpm_hdw_reg[cnt]);
3701fcf3ce44SJohn Forte 	}
3702fcf3ce44SJohn Forte 
3703fcf3ce44SJohn Forte 	mdb_printf("\n\nFB Hardware Registers");
3704fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->fb_hdw_reg) / 4; cnt++) {
3705fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3706fcf3ce44SJohn Forte 			mdb_printf("\n");
3707fcf3ce44SJohn Forte 		}
3708fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->fb_hdw_reg[cnt]);
3709fcf3ce44SJohn Forte 	}
3710fcf3ce44SJohn Forte 
3711fcf3ce44SJohn Forte 	mdb_printf("\n\nCode RAM");
3712fcf3ce44SJohn Forte 	for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
3713fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3714fcf3ce44SJohn Forte 			mdb_printf("\n%08x: ", cnt + 0x20000);
3715fcf3ce44SJohn Forte 		}
3716fcf3ce44SJohn Forte 		mdb_printf("%08x ", fw->code_ram[cnt]);
3717fcf3ce44SJohn Forte 	}
3718fcf3ce44SJohn Forte 
3719fcf3ce44SJohn Forte 	mdb_printf("\n\nExternal Memory");
3720*4c3888b8SHans Rosenfeld 	dp = (uint32_t *)(void *)((caddr_t)fw->req_rsp_ext_mem +
3721*4c3888b8SHans Rosenfeld 	    fw->req_q_size[0] + fw->req_q_size[1] + fw->rsp_q_size +
3722*4c3888b8SHans Rosenfeld 	    (ha->rsp_queues_cnt * 16));
3723fcf3ce44SJohn Forte 	for (cnt = 0; cnt < ha->fw_ext_memory_size / 4; cnt++) {
3724fcf3ce44SJohn Forte 		if (cnt % 8 == 0) {
3725fcf3ce44SJohn Forte 			mdb_printf("\n%08x: ", cnt + 0x100000);
3726fcf3ce44SJohn Forte 		}
3727*4c3888b8SHans Rosenfeld 		mdb_printf("%08x ", *dp++);
3728fcf3ce44SJohn Forte 	}
3729fcf3ce44SJohn Forte 
3730fcf3ce44SJohn Forte 	mdb_printf("\n[<==END] ISP Debug Dump");
3731fcf3ce44SJohn Forte 
373216dd44c2SDaniel Beauregard 	mdb_printf("\n\nRequest Queue");
373316dd44c2SDaniel Beauregard 
3734*4c3888b8SHans Rosenfeld 	dp = fw->req_rsp_ext_mem + (ha->rsp_queues_cnt * 4);
3735*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < 2 && fw->req_q_size[cnt]; cnt++) {
3736*4c3888b8SHans Rosenfeld 		dp2 = dp;
3737*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
3738*4c3888b8SHans Rosenfeld 			if (*dp2++) {
3739*4c3888b8SHans Rosenfeld 				break;
3740*4c3888b8SHans Rosenfeld 			}
3741*4c3888b8SHans Rosenfeld 		}
3742*4c3888b8SHans Rosenfeld 		if (cnt1 == fw->req_q_size[cnt] / 4) {
3743*4c3888b8SHans Rosenfeld 			dp = dp2;
3744*4c3888b8SHans Rosenfeld 			continue;
3745*4c3888b8SHans Rosenfeld 		}
3746*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nRequest Queue\nQueue 0%d:", cnt);
3747*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < fw->req_q_size[cnt] / 4; cnt1++) {
3748*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
3749*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
3750*4c3888b8SHans Rosenfeld 			}
3751*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
375216dd44c2SDaniel Beauregard 		}
375316dd44c2SDaniel Beauregard 	}
375416dd44c2SDaniel Beauregard 
3755*4c3888b8SHans Rosenfeld 	for (cnt = 0; cnt < ha->rsp_queues_cnt; cnt++) {
3756*4c3888b8SHans Rosenfeld 		if (mdb_vread(rsp_q, sizeof (ql_response_q_t),
3757*4c3888b8SHans Rosenfeld 		    (uintptr_t)rsp_queues[cnt]) == -1) {
3758*4c3888b8SHans Rosenfeld 			mdb_warn("failed to read ha->rsp_queues[%d]", cnt);
3759*4c3888b8SHans Rosenfeld 			break;
3760*4c3888b8SHans Rosenfeld 		}
3761*4c3888b8SHans Rosenfeld 		dp2 = dp;
3762*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
3763*4c3888b8SHans Rosenfeld 			if (*dp2++) {
3764*4c3888b8SHans Rosenfeld 				break;
3765*4c3888b8SHans Rosenfeld 			}
3766*4c3888b8SHans Rosenfeld 		}
3767*4c3888b8SHans Rosenfeld 		if (cnt1 == rsp_q->rsp_ring.size / 4) {
3768*4c3888b8SHans Rosenfeld 			dp = dp2;
3769*4c3888b8SHans Rosenfeld 			continue;
3770*4c3888b8SHans Rosenfeld 		}
3771*4c3888b8SHans Rosenfeld 		mdb_printf("\n\nResponse Queue\nQueue 0%d:", cnt);
377216dd44c2SDaniel Beauregard 
3773*4c3888b8SHans Rosenfeld 		for (cnt1 = 0; cnt1 < rsp_q->rsp_ring.size / 4; cnt1++) {
3774*4c3888b8SHans Rosenfeld 			if (cnt1 % 8 == 0) {
3775*4c3888b8SHans Rosenfeld 				mdb_printf("\n%08x: ", cnt1);
3776*4c3888b8SHans Rosenfeld 			}
3777*4c3888b8SHans Rosenfeld 			mdb_printf("%08x ", *dp++);
377816dd44c2SDaniel Beauregard 		}
377916dd44c2SDaniel Beauregard 	}
378016dd44c2SDaniel Beauregard 
378116dd44c2SDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWEXTTRACE) &&
378216dd44c2SDaniel Beauregard 	    (ha->fwexttracebuf.bp != NULL)) {
378316dd44c2SDaniel Beauregard 		uint32_t cnt_b = 0;
378416dd44c2SDaniel Beauregard 		uint32_t *w32 = ha->fwexttracebuf.bp;
378516dd44c2SDaniel Beauregard 
378616dd44c2SDaniel Beauregard 		mdb_printf("\n\nExtended Trace Buffer Memory");
378716dd44c2SDaniel Beauregard 		/* show data address as a byte address, data as long words */
378816dd44c2SDaniel Beauregard 		for (cnt = 0; cnt < FWEXTSIZE / 4; cnt++) {
378916dd44c2SDaniel Beauregard 			cnt_b = cnt * 4;
379016dd44c2SDaniel Beauregard 			if (cnt_b % 32 == 0) {
379116dd44c2SDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
379216dd44c2SDaniel Beauregard 			}
379316dd44c2SDaniel Beauregard 			mdb_printf("%08x ", fw->ext_trace_buf[cnt]);
379416dd44c2SDaniel Beauregard 		}
379516dd44c2SDaniel Beauregard 	}
379616dd44c2SDaniel Beauregard 
379716dd44c2SDaniel Beauregard 	if ((ha->cfg_flags & CFG_ENABLE_FWFCETRACE) &&
379816dd44c2SDaniel Beauregard 	    (ha->fwfcetracebuf.bp != NULL)) {
379916dd44c2SDaniel Beauregard 		uint32_t cnt_b = 0;
380016dd44c2SDaniel Beauregard 		uint32_t *w32 = ha->fwfcetracebuf.bp;
380116dd44c2SDaniel Beauregard 
380216dd44c2SDaniel Beauregard 		mdb_printf("\n\nFC Event Trace Buffer Memory");
380316dd44c2SDaniel Beauregard 		/* show data address as a byte address, data as long words */
380416dd44c2SDaniel Beauregard 		for (cnt = 0; cnt < FWFCESIZE / 4; cnt++) {
380516dd44c2SDaniel Beauregard 			cnt_b = cnt * 4;
380616dd44c2SDaniel Beauregard 			if (cnt_b % 32 == 0) {
380716dd44c2SDaniel Beauregard 				mdb_printf("\n%08x: ", w32 + cnt_b);
380816dd44c2SDaniel Beauregard 			}
380916dd44c2SDaniel Beauregard 			mdb_printf("%08x ", fw->fce_trace_buf[cnt]);
381016dd44c2SDaniel Beauregard 		}
381116dd44c2SDaniel Beauregard 	}
381216dd44c2SDaniel Beauregard 
3813*4c3888b8SHans Rosenfeld 	mdb_free(rsp_q, sizeof (ql_response_q_t));
3814*4c3888b8SHans Rosenfeld 	mdb_free(rsp_queues, ha->rsp_queues_cnt * sizeof (ql_response_q_t *));
381516dd44c2SDaniel Beauregard 	mdb_free(fw, ha->ql_dump_size);
3816fcf3ce44SJohn Forte 
381716dd44c2SDaniel Beauregard 	mdb_printf("\n\nreturn exit\n");
3818fcf3ce44SJohn Forte 
3819fcf3ce44SJohn Forte 	return (DCMD_OK);
3820fcf3ce44SJohn Forte }
3821fcf3ce44SJohn Forte 
382216dd44c2SDaniel Beauregard /*
382316dd44c2SDaniel Beauregard  * ql_gettrace_dcmd
382416dd44c2SDaniel Beauregard  *	prints out the Extended Logging trace buffer
382516dd44c2SDaniel Beauregard  *
382616dd44c2SDaniel Beauregard  * Input:
382716dd44c2SDaniel Beauregard  *	addr  = User supplied address. (NB: must be an ha)
382816dd44c2SDaniel Beauregard  *	flags = mdb flags.
382916dd44c2SDaniel Beauregard  *	argc  = Number of user supplied args.
383016dd44c2SDaniel Beauregard  *	argv  = Arg array.
383116dd44c2SDaniel Beauregard  *
383216dd44c2SDaniel Beauregard  * Returns:
383316dd44c2SDaniel Beauregard  *	DCMD_OK or DCMD_ERR
383416dd44c2SDaniel Beauregard  *
383516dd44c2SDaniel Beauregard  * Context:
383616dd44c2SDaniel Beauregard  *	User context.
383716dd44c2SDaniel Beauregard  *
383816dd44c2SDaniel Beauregard  */
383916dd44c2SDaniel Beauregard static int
qlc_gettrace_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)384016dd44c2SDaniel Beauregard qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
384116dd44c2SDaniel Beauregard {
384216dd44c2SDaniel Beauregard 	ql_adapter_state_t	*ha;
3843*4c3888b8SHans Rosenfeld 	ql_trace_desc_t		*trace_desc;
3844*4c3888b8SHans Rosenfeld 	ql_trace_entry_t	entry;
3845*4c3888b8SHans Rosenfeld 	uint32_t		i = 0;
3846*4c3888b8SHans Rosenfeld 	char			merge[1024];
384716dd44c2SDaniel Beauregard 
3848892ad162SToomas Soome 	if ((!(flags & DCMD_ADDRSPEC)) || addr == 0) {
384916dd44c2SDaniel Beauregard 		mdb_warn("ql_adapter_state structure addr is required");
385016dd44c2SDaniel Beauregard 		return (DCMD_USAGE);
385116dd44c2SDaniel Beauregard 	}
385216dd44c2SDaniel Beauregard 
3853*4c3888b8SHans Rosenfeld 	if (argc != 0) {
3854*4c3888b8SHans Rosenfeld 		return (DCMD_USAGE);
3855*4c3888b8SHans Rosenfeld 	}
3856*4c3888b8SHans Rosenfeld 
3857*4c3888b8SHans Rosenfeld 	if (mdb_getopts(argc, argv, NULL) != argc) {
385816dd44c2SDaniel Beauregard 		return (DCMD_USAGE);
385916dd44c2SDaniel Beauregard 	}
386016dd44c2SDaniel Beauregard 
386116dd44c2SDaniel Beauregard 	/*
386216dd44c2SDaniel Beauregard 	 * Get the adapter state struct which was passed
386316dd44c2SDaniel Beauregard 	 */
386416dd44c2SDaniel Beauregard 	if ((ha = (ql_adapter_state_t *)mdb_alloc(sizeof (ql_adapter_state_t),
386516dd44c2SDaniel Beauregard 	    UM_SLEEP)) == NULL) {
386616dd44c2SDaniel Beauregard 		mdb_warn("failed to allocate memory for ql_adapter_state\n");
386716dd44c2SDaniel Beauregard 		return (DCMD_OK);
386816dd44c2SDaniel Beauregard 	}
386916dd44c2SDaniel Beauregard 
387016dd44c2SDaniel Beauregard 	if (mdb_vread(ha, sizeof (ql_adapter_state_t), addr) == -1) {
387116dd44c2SDaniel Beauregard 		mdb_warn("failed to read ql_adapter_state at %p", addr);
387216dd44c2SDaniel Beauregard 		mdb_free(ha, sizeof (ql_adapter_state_t));
387316dd44c2SDaniel Beauregard 		return (DCMD_OK);
387416dd44c2SDaniel Beauregard 	}
387516dd44c2SDaniel Beauregard 
3876*4c3888b8SHans Rosenfeld 	if (ha->ql_trace_desc == NULL) {
387716dd44c2SDaniel Beauregard 		mdb_warn("trace descriptor does not exist for instance %d\n",
387816dd44c2SDaniel Beauregard 		    ha->instance);
387916dd44c2SDaniel Beauregard 		mdb_free(ha, sizeof (ql_adapter_state_t));
388016dd44c2SDaniel Beauregard 		return (DCMD_OK);
3881*4c3888b8SHans Rosenfeld 
388216dd44c2SDaniel Beauregard 	} else {
3883*4c3888b8SHans Rosenfeld 		trace_desc = (ql_trace_desc_t *)
3884*4c3888b8SHans Rosenfeld 		    mdb_alloc(sizeof (ql_trace_desc_t), UM_SLEEP);
3885*4c3888b8SHans Rosenfeld 
3886*4c3888b8SHans Rosenfeld 		if (mdb_vread(trace_desc, sizeof (ql_trace_desc_t),
3887*4c3888b8SHans Rosenfeld 		    (uintptr_t)ha->ql_trace_desc) == -1) {
388816dd44c2SDaniel Beauregard 			mdb_warn("failed to read ql_adapter_state at %p",
388916dd44c2SDaniel Beauregard 			    addr);
3890*4c3888b8SHans Rosenfeld 			mdb_free(trace_desc, sizeof (ql_trace_desc_t));
389116dd44c2SDaniel Beauregard 			mdb_free(ha, sizeof (ql_adapter_state_t));
389216dd44c2SDaniel Beauregard 			return (DCMD_OK);
389316dd44c2SDaniel Beauregard 		}
3894*4c3888b8SHans Rosenfeld 
389516dd44c2SDaniel Beauregard 		if (trace_desc->trace_buffer == NULL) {
389616dd44c2SDaniel Beauregard 			mdb_warn("trace buffer does not exist for "
389716dd44c2SDaniel Beauregard 			    "instance %d\n", ha->instance);
3898*4c3888b8SHans Rosenfeld 
3899*4c3888b8SHans Rosenfeld 			mdb_free(trace_desc, sizeof (ql_trace_desc_t));
390016dd44c2SDaniel Beauregard 			mdb_free(ha, sizeof (ql_adapter_state_t));
390116dd44c2SDaniel Beauregard 			return (DCMD_OK);
390216dd44c2SDaniel Beauregard 		}
390316dd44c2SDaniel Beauregard 	}
390416dd44c2SDaniel Beauregard 
3905*4c3888b8SHans Rosenfeld 	/* Check if anything logged or not */
3906*4c3888b8SHans Rosenfeld 	if (trace_desc->csize == 0) {
3907*4c3888b8SHans Rosenfeld 		mdb_warn("Extended log buffer is empty.\n");
3908*4c3888b8SHans Rosenfeld 		mdb_free(trace_desc, sizeof (ql_trace_desc_t));
390916dd44c2SDaniel Beauregard 		mdb_free(ha, sizeof (ql_adapter_state_t));
391016dd44c2SDaniel Beauregard 		return (DCMD_OK);
391116dd44c2SDaniel Beauregard 	}
391216dd44c2SDaniel Beauregard 
391316dd44c2SDaniel Beauregard 	/*
3914*4c3888b8SHans Rosenfeld 	 * Locate the start and end point. If ever wrapped, then
3915*4c3888b8SHans Rosenfeld 	 * always print from start to end in the circular buffer
391616dd44c2SDaniel Beauregard 	 */
391716dd44c2SDaniel Beauregard 
3918*4c3888b8SHans Rosenfeld 	/* always print from start to end */
3919*4c3888b8SHans Rosenfeld 	for (i = trace_desc->start; i < trace_desc->csize; i++) {
3920*4c3888b8SHans Rosenfeld 		if (mdb_vread(&entry, sizeof (ql_trace_entry_t),
3921*4c3888b8SHans Rosenfeld 		    (uintptr_t)&trace_desc->trace_buffer[i]) !=
3922*4c3888b8SHans Rosenfeld 		    sizeof (ql_trace_entry_t)) {
3923*4c3888b8SHans Rosenfeld 			mdb_warn("Cannot read trace entry. %xh", i);
3924*4c3888b8SHans Rosenfeld 			mdb_free(trace_desc, sizeof (ql_trace_desc_t));
3925*4c3888b8SHans Rosenfeld 			mdb_free(ha, sizeof (ql_adapter_state_t));
3926*4c3888b8SHans Rosenfeld 			return (DCMD_ERR);
3927*4c3888b8SHans Rosenfeld 		}
3928*4c3888b8SHans Rosenfeld 		if (entry.buf[0] != '\0') {
3929*4c3888b8SHans Rosenfeld 			(void) mdb_snprintf(merge, sizeof (merge),
3930*4c3888b8SHans Rosenfeld 			    "[%Y:%03d:%03d:%03d] "
3931*4c3888b8SHans Rosenfeld 			    "%s",
3932*4c3888b8SHans Rosenfeld 			    entry.hs_time.tv_sec,
3933*4c3888b8SHans Rosenfeld 			    (int)entry.hs_time.tv_nsec / 1000000,
3934*4c3888b8SHans Rosenfeld 			    (int)(entry.hs_time.tv_nsec / 1000) % 1000,
3935*4c3888b8SHans Rosenfeld 			    (int)entry.hs_time.tv_nsec % 1000,
3936*4c3888b8SHans Rosenfeld 			    entry.buf + 1);
3937*4c3888b8SHans Rosenfeld 		}
3938*4c3888b8SHans Rosenfeld 		mdb_printf("%s", merge);
3939*4c3888b8SHans Rosenfeld 	}
3940*4c3888b8SHans Rosenfeld 
3941*4c3888b8SHans Rosenfeld 	if (trace_desc->start != 0) {
3942*4c3888b8SHans Rosenfeld 		for (i = 0; i < trace_desc->start; i++) {
3943*4c3888b8SHans Rosenfeld 			if (mdb_vread(&entry, sizeof (ql_trace_entry_t),
3944*4c3888b8SHans Rosenfeld 			    (uintptr_t)&trace_desc->trace_buffer[i]) !=
3945*4c3888b8SHans Rosenfeld 			    sizeof (ql_trace_entry_t)) {
3946*4c3888b8SHans Rosenfeld 				mdb_warn("Cannot read trace entry. %xh", i);
3947*4c3888b8SHans Rosenfeld 				mdb_free(trace_desc, sizeof (ql_trace_desc_t));
3948*4c3888b8SHans Rosenfeld 				mdb_free(ha, sizeof (ql_adapter_state_t));
3949*4c3888b8SHans Rosenfeld 				return (DCMD_ERR);
395016dd44c2SDaniel Beauregard 			}
3951*4c3888b8SHans Rosenfeld 			if (entry.buf[0] != '\0') {
3952*4c3888b8SHans Rosenfeld 				(void) mdb_snprintf(merge, sizeof (merge),
3953*4c3888b8SHans Rosenfeld 				    "[%Y:%03d:%03d:%03d] "
3954*4c3888b8SHans Rosenfeld 				    "%s",
3955*4c3888b8SHans Rosenfeld 				    entry.hs_time.tv_sec,
3956*4c3888b8SHans Rosenfeld 				    (int)entry.hs_time.tv_nsec / 1000000,
3957*4c3888b8SHans Rosenfeld 				    (int)(entry.hs_time.tv_nsec / 1000) % 1000,
3958*4c3888b8SHans Rosenfeld 				    (int)entry.hs_time.tv_nsec % 1000,
3959*4c3888b8SHans Rosenfeld 				    entry.buf + 1);
3960*4c3888b8SHans Rosenfeld 			}
3961*4c3888b8SHans Rosenfeld 			mdb_printf("%s", merge);
396216dd44c2SDaniel Beauregard 		}
396316dd44c2SDaniel Beauregard 	}
396416dd44c2SDaniel Beauregard 
3965*4c3888b8SHans Rosenfeld 	mdb_printf("\n");
3966*4c3888b8SHans Rosenfeld 	mdb_free(trace_desc, sizeof (ql_trace_desc_t));
396716dd44c2SDaniel Beauregard 	mdb_free(ha, sizeof (ql_adapter_state_t));
396816dd44c2SDaniel Beauregard 	return (DCMD_OK);
396916dd44c2SDaniel Beauregard }
3970*4c3888b8SHans Rosenfeld 
3971fcf3ce44SJohn Forte /*
3972fcf3ce44SJohn Forte  * ql_doprint
3973fcf3ce44SJohn Forte  *	ql generic function to call the print dcmd
3974fcf3ce44SJohn Forte  *
3975fcf3ce44SJohn Forte  * Input:
3976fcf3ce44SJohn Forte  *	addr - address to struct
3977fcf3ce44SJohn Forte  *	prtsting - address to string
3978fcf3ce44SJohn Forte  *
3979fcf3ce44SJohn Forte  * Returns:
3980fcf3ce44SJohn Forte  *	WALK_DONE
3981fcf3ce44SJohn Forte  *
3982fcf3ce44SJohn Forte  * Context:
3983fcf3ce44SJohn Forte  *	User context.
3984fcf3ce44SJohn Forte  *
3985fcf3ce44SJohn Forte  */
3986fcf3ce44SJohn Forte static int32_t
ql_doprint(uintptr_t addr,int8_t * prtstring)3987fcf3ce44SJohn Forte ql_doprint(uintptr_t addr, int8_t *prtstring)
3988fcf3ce44SJohn Forte {
3989fcf3ce44SJohn Forte 	struct	mdb_arg		printarg;
3990fcf3ce44SJohn Forte 
3991fcf3ce44SJohn Forte 	printarg.a_un.a_str = (int8_t *)(mdb_zalloc(strlen(prtstring),
3992fcf3ce44SJohn Forte 	    UM_SLEEP));
3993fcf3ce44SJohn Forte 	printarg.a_type = MDB_TYPE_STRING;
3994fcf3ce44SJohn Forte 	(void) strcpy((int8_t *)(printarg.a_un.a_str), prtstring);
3995fcf3ce44SJohn Forte 
3996fcf3ce44SJohn Forte 	if ((mdb_call_dcmd("print", addr, DCMD_ADDRSPEC, 1,
3997fcf3ce44SJohn Forte 	    &printarg)) == -1) {
3998fcf3ce44SJohn Forte 		mdb_warn("ql_doprint: failed print dcmd: %s"
3999fcf3ce44SJohn Forte 		    "at addr: %llxh", prtstring, addr);
4000fcf3ce44SJohn Forte 	}
4001fcf3ce44SJohn Forte 
4002fcf3ce44SJohn Forte 	mdb_free((void *)(printarg.a_un.a_str), strlen(prtstring));
4003fcf3ce44SJohn Forte 	return (WALK_DONE);
4004fcf3ce44SJohn Forte }
4005fcf3ce44SJohn Forte 
4006fcf3ce44SJohn Forte /*
4007fcf3ce44SJohn Forte  * ql_dump_flags
4008fcf3ce44SJohn Forte  *	mdb utility to print the flag string
4009fcf3ce44SJohn Forte  *
4010fcf3ce44SJohn Forte  * Input:
4011fcf3ce44SJohn Forte  *	flags - flags to print
4012fcf3ce44SJohn Forte  *	strings - text to print when flag is set
4013fcf3ce44SJohn Forte  *
4014fcf3ce44SJohn Forte  * Returns:
4015fcf3ce44SJohn Forte  *
4016fcf3ce44SJohn Forte  *
4017fcf3ce44SJohn Forte  * Context:
4018fcf3ce44SJohn Forte  *	User context.
4019fcf3ce44SJohn Forte  *
4020fcf3ce44SJohn Forte  */
4021fcf3ce44SJohn Forte static void
ql_dump_flags(uint64_t flags,int8_t ** strings)4022fcf3ce44SJohn Forte ql_dump_flags(uint64_t flags, int8_t **strings)
4023fcf3ce44SJohn Forte {
4024fcf3ce44SJohn Forte 	int		i, linel, first = 1;
4025fcf3ce44SJohn Forte 	uint64_t	mask = 1;
4026fcf3ce44SJohn Forte 
4027fcf3ce44SJohn Forte 	linel = 8;
4028fcf3ce44SJohn Forte 	mdb_printf("\t");
4029fcf3ce44SJohn Forte 	for (i = 0; i < 64; i++) {
4030fcf3ce44SJohn Forte 		if (strings[i] == NULL)
4031fcf3ce44SJohn Forte 			break;
4032fcf3ce44SJohn Forte 		if (flags & mask) {
4033fcf3ce44SJohn Forte 			if (!first) {
4034fcf3ce44SJohn Forte 				mdb_printf(" | ");
4035fcf3ce44SJohn Forte 			} else {
4036fcf3ce44SJohn Forte 				first = 0;
4037fcf3ce44SJohn Forte 			}
4038fcf3ce44SJohn Forte 			linel += (int32_t)strlen(strings[i]) + 3;
4039fcf3ce44SJohn Forte 			if (linel > 80) {
4040fcf3ce44SJohn Forte 				mdb_printf("\n\t");
4041fcf3ce44SJohn Forte 				linel = (int32_t)strlen(strings[i]) + 1 + 8;
4042fcf3ce44SJohn Forte 			}
4043fcf3ce44SJohn Forte 			mdb_printf("%s", strings[i]);
4044fcf3ce44SJohn Forte 		}
4045fcf3ce44SJohn Forte 		mask <<= 1;
4046fcf3ce44SJohn Forte 	}
4047fcf3ce44SJohn Forte 	mdb_printf("\n");
4048fcf3ce44SJohn Forte }
4049fcf3ce44SJohn Forte 
4050fcf3ce44SJohn Forte /*
4051fcf3ce44SJohn Forte  * MDB module linkage information
4052fcf3ce44SJohn Forte  *
4053fcf3ce44SJohn Forte  *
4054fcf3ce44SJohn Forte  * dcmd structures for the _mdb_init function
4055fcf3ce44SJohn Forte  */
4056fcf3ce44SJohn Forte static const mdb_dcmd_t dcmds[] = {
4057fcf3ce44SJohn Forte 	{ "qlclinks", NULL, "Prints qlc link information", qlclinks_dcmd },
4058fcf3ce44SJohn Forte 	{ "qlcosc", NULL, "Prints outstanding cmd info", qlc_osc_dcmd },
4059fcf3ce44SJohn Forte 	{ "qlcver", NULL, "Prints driver/mdb version", qlcver_dcmd },
4060fcf3ce44SJohn Forte 	{ "qlc_elog", "[on|off] [<inst #>|all]", "Turns qlc extended logging "
4061fcf3ce44SJohn Forte 	    "on / off", qlc_el_dcmd },
4062fcf3ce44SJohn Forte 	{ "qlcstate", ":[-v]", "Prints qlc adapter state information",
4063fcf3ce44SJohn Forte 	    qlcstate_dcmd },
4064fcf3ce44SJohn Forte 	{ "qlctgtq", NULL, "Prints qlc target queues", qltgtq_dcmd },
4065fcf3ce44SJohn Forte 	{ "qlcwdog", NULL, "Prints out watchdog linked list", qlc_wdog_dcmd},
406616dd44c2SDaniel Beauregard 	{ "qlcgetdump", ":[-v]", "Retrieves the ASCII f/w dump",
406716dd44c2SDaniel Beauregard 	    qlc_getdump_dcmd },
4068*4c3888b8SHans Rosenfeld 	{ "qlcgettrace", ":", "Retrieves the ASCII Extended Logging trace",
406916dd44c2SDaniel Beauregard 	    qlc_gettrace_dcmd },
4070fcf3ce44SJohn Forte 	{ NULL }
4071fcf3ce44SJohn Forte };
4072fcf3ce44SJohn Forte 
4073fcf3ce44SJohn Forte /*
4074fcf3ce44SJohn Forte  * walker structures for the _mdb_init function
4075fcf3ce44SJohn Forte  */
4076fcf3ce44SJohn Forte static const mdb_walker_t walkers[] = {
4077fcf3ce44SJohn Forte 	{ "qlcstates", "walk list of qlc ql_state_t structures",
4078fcf3ce44SJohn Forte 	    qlstates_walk_init, qlstates_walk_step, qlstates_walk_fini },
4079fcf3ce44SJohn Forte 	{ "qlcsrbs", "walk list of qlc ql_srb_t strctures",
4080fcf3ce44SJohn Forte 	    qlsrb_walk_init, qlsrb_walk_step, qlsrb_walk_fini },
4081fcf3ce44SJohn Forte 	{ "qlclunq", "walk list of qlc ql_lun_t strctures",
4082fcf3ce44SJohn Forte 	    qllunq_walk_init, qllunq_walk_step, qllunq_walk_fini },
4083fcf3ce44SJohn Forte 	{ NULL }
4084fcf3ce44SJohn Forte };
4085fcf3ce44SJohn Forte 
4086fcf3ce44SJohn Forte static const mdb_modinfo_t ql_mdb_modinfo = {
4087fcf3ce44SJohn Forte 	MDB_API_VERSION, dcmds, walkers
4088fcf3ce44SJohn Forte };
4089fcf3ce44SJohn Forte 
4090fcf3ce44SJohn Forte /*
4091fcf3ce44SJohn Forte  * Registration function which lists the dcmds and walker structures
4092fcf3ce44SJohn Forte  */
4093fcf3ce44SJohn Forte const mdb_modinfo_t *
_mdb_init(void)4094fcf3ce44SJohn Forte _mdb_init(void)
4095fcf3ce44SJohn Forte {
4096fcf3ce44SJohn Forte 	return (&ql_mdb_modinfo);
4097fcf3ce44SJohn Forte }
4098