xref: /titanic_41/usr/src/cmd/mdb/common/modules/sdbc/sdbc.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte #include <sys/mdb_modapi.h>
27*fcf3ce44SJohn Forte #include <sys/nsc_thread.h>
28*fcf3ce44SJohn Forte 
29*fcf3ce44SJohn Forte /* needed to maintain identical _sd_bitmap_t sizes */
30*fcf3ce44SJohn Forte #define	_SD_8K_BLKSIZE
31*fcf3ce44SJohn Forte #include <sys/nsctl/sd_bcache.h>
32*fcf3ce44SJohn Forte 
33*fcf3ce44SJohn Forte #include <ns/sdbc/sd_io.h>
34*fcf3ce44SJohn Forte #include <ns/sdbc/sd_ft.h>
35*fcf3ce44SJohn Forte #include <ns/sdbc/safestore.h>
36*fcf3ce44SJohn Forte 
37*fcf3ce44SJohn Forte /*
38*fcf3ce44SJohn Forte  * initialize cd filter options to this
39*fcf3ce44SJohn Forte  * to differentiate with kernel values in range [-1, sdbc_max_devs]
40*fcf3ce44SJohn Forte  */
41*fcf3ce44SJohn Forte #define	MDB_CD ((uintptr_t)~1)
42*fcf3ce44SJohn Forte #define	OPT_C_SELECTED (opt_c != MDB_CD)
43*fcf3ce44SJohn Forte 
44*fcf3ce44SJohn Forte /* initialize block filters to this */
45*fcf3ce44SJohn Forte #define	MDB_BLKNUM ((uintptr_t)~1)
46*fcf3ce44SJohn Forte #define	OPT_B_SELECTED (opt_b != MDB_BLKNUM)
47*fcf3ce44SJohn Forte 
48*fcf3ce44SJohn Forte enum vartype { UINTTYPE = 0, ADDRTYPE, LOCKTYPE, CVTYPE };
49*fcf3ce44SJohn Forte 
50*fcf3ce44SJohn Forte static void display_var(char *, enum vartype);
51*fcf3ce44SJohn Forte #ifdef SAFESTORE
52*fcf3ce44SJohn Forte static void print_wrq(_sd_writeq_t *, uint_t);
53*fcf3ce44SJohn Forte #endif
54*fcf3ce44SJohn Forte 
55*fcf3ce44SJohn Forte struct walk_info {
56*fcf3ce44SJohn Forte 		uintptr_t w_start;
57*fcf3ce44SJohn Forte 		uintptr_t w_end;
58*fcf3ce44SJohn Forte };
59*fcf3ce44SJohn Forte 
60*fcf3ce44SJohn Forte 
61*fcf3ce44SJohn Forte mdb_bitmask_t host_states[] = {
62*fcf3ce44SJohn Forte 	{ "HOST_NONE", 0xff, _SD_HOST_NONE },
63*fcf3ce44SJohn Forte 	{ "HOST_CONFIGURED", 0xff, _SD_HOST_CONFIGURED },
64*fcf3ce44SJohn Forte 	{ "HOST_DECONFIGURED", 0xff, _SD_HOST_DECONFIGURED },
65*fcf3ce44SJohn Forte 	{ "HOST_NOCACHE", 0xff, _SD_HOST_NOCACHE },
66*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
67*fcf3ce44SJohn Forte 
68*fcf3ce44SJohn Forte };
69*fcf3ce44SJohn Forte 
70*fcf3ce44SJohn Forte mdb_bitmask_t cache_hints[] = {
71*fcf3ce44SJohn Forte 	{ "WRTHRU", NSC_WRTHRU, NSC_WRTHRU },
72*fcf3ce44SJohn Forte 	{ "FORCED_WRTHRU", NSC_FORCED_WRTHRU, NSC_FORCED_WRTHRU },
73*fcf3ce44SJohn Forte 	{ "NOCACHE", NSC_NOCACHE, NSC_NOCACHE },
74*fcf3ce44SJohn Forte 	{ "QUEUE", NSC_QUEUE, NSC_QUEUE },
75*fcf3ce44SJohn Forte 	{ "RDAHEAD", NSC_RDAHEAD, NSC_RDAHEAD },
76*fcf3ce44SJohn Forte 	{ "NO_FORCED_WRTHRU", NSC_NO_FORCED_WRTHRU, NSC_NO_FORCED_WRTHRU },
77*fcf3ce44SJohn Forte 	{ "METADATA", NSC_METADATA, NSC_METADATA },
78*fcf3ce44SJohn Forte 	{ "SEQ_IO", NSC_SEQ_IO, NSC_SEQ_IO },
79*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
80*fcf3ce44SJohn Forte 
81*fcf3ce44SJohn Forte };
82*fcf3ce44SJohn Forte 
83*fcf3ce44SJohn Forte 
84*fcf3ce44SJohn Forte /*
85*fcf3ce44SJohn Forte  * some cache general dcmds that do not use walkers
86*fcf3ce44SJohn Forte  */
87*fcf3ce44SJohn Forte /*ARGSUSED*/
88*fcf3ce44SJohn Forte static int
sdbc_config(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)89*fcf3ce44SJohn Forte sdbc_config(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
90*fcf3ce44SJohn Forte {
91*fcf3ce44SJohn Forte 	_sd_cache_param_t _sd_cache_config;
92*fcf3ce44SJohn Forte 	_sd_net_t _sd_net_config;
93*fcf3ce44SJohn Forte 	_sd_ft_info_t  _sd_ft_data;
94*fcf3ce44SJohn Forte 	uint_t _sd_node_hint;
95*fcf3ce44SJohn Forte 	char sdbc_version[17];
96*fcf3ce44SJohn Forte 
97*fcf3ce44SJohn Forte 	if (mdb_readvar(sdbc_version, "sdbc_version") == -1) {
98*fcf3ce44SJohn Forte 		mdb_warn("failed to read sdbc_version symbol");
99*fcf3ce44SJohn Forte 	} else {
100*fcf3ce44SJohn Forte 		sdbc_version[16] = '\0';  /* make sure string is terminated */
101*fcf3ce44SJohn Forte 		mdb_printf("sdbc_version %s\n", sdbc_version);
102*fcf3ce44SJohn Forte 	}
103*fcf3ce44SJohn Forte 
104*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_cache_config, "_sd_cache_config") == -1) {
105*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_cache_config symbol");
106*fcf3ce44SJohn Forte 	} else {
107*fcf3ce44SJohn Forte 
108*fcf3ce44SJohn Forte 		mdb_printf("SDBC Configuration:\n");
109*fcf3ce44SJohn Forte 		mdb_inc_indent(4);
110*fcf3ce44SJohn Forte 		mdb_printf("user magic: %X kernel magic: %X (should match)\n",
111*fcf3ce44SJohn Forte 			    _SD_MAGIC, _sd_cache_config.magic);
112*fcf3ce44SJohn Forte 		mdb_printf(
113*fcf3ce44SJohn Forte 		    "mirror host: %2d Block size: %4d threads %4d "
114*fcf3ce44SJohn Forte 		    "write cache: %4dM\n",
115*fcf3ce44SJohn Forte 			    _sd_cache_config.mirror_host,
116*fcf3ce44SJohn Forte 			    _sd_cache_config.blk_size,
117*fcf3ce44SJohn Forte 			    _sd_cache_config.threads,
118*fcf3ce44SJohn Forte 			    _sd_cache_config.write_cache);
119*fcf3ce44SJohn Forte 		mdb_printf("num_handles %4-d cache_mem %4dM prot_lru %d\n",
120*fcf3ce44SJohn Forte 			    _sd_cache_config.num_handles,
121*fcf3ce44SJohn Forte 			    _sd_cache_config.cache_mem[0],
122*fcf3ce44SJohn Forte 			    _sd_cache_config.prot_lru);
123*fcf3ce44SJohn Forte 		mdb_printf("gen_pattern %d fill_pattern %?-p num_nodes %d\n",
124*fcf3ce44SJohn Forte 			    _sd_cache_config.gen_pattern,
125*fcf3ce44SJohn Forte 			    _sd_cache_config.fill_pattern,
126*fcf3ce44SJohn Forte 			    _sd_cache_config.num_nodes);
127*fcf3ce44SJohn Forte 		mdb_dec_indent(4);
128*fcf3ce44SJohn Forte 	}
129*fcf3ce44SJohn Forte 
130*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_net_config, "_sd_net_config") == -1) {
131*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_net_config symbol");
132*fcf3ce44SJohn Forte 	} else {
133*fcf3ce44SJohn Forte 		mdb_inc_indent(4);
134*fcf3ce44SJohn Forte 		mdb_printf(
135*fcf3ce44SJohn Forte 	"psize %4-d configured %d csize %10-d wsize %10-d cpages %6d\n",
136*fcf3ce44SJohn Forte 			_sd_net_config.sn_psize,
137*fcf3ce44SJohn Forte 			_sd_net_config.sn_configured,
138*fcf3ce44SJohn Forte 			_sd_net_config.sn_csize,
139*fcf3ce44SJohn Forte 			_sd_net_config.sn_wsize,
140*fcf3ce44SJohn Forte 			_sd_net_config.sn_cpages);
141*fcf3ce44SJohn Forte 
142*fcf3ce44SJohn Forte 		mdb_dec_indent(4);
143*fcf3ce44SJohn Forte #ifdef SAFESTORE
144*fcf3ce44SJohn Forte 		print_wrq(&(_sd_net_config.sn_wr_queue), FALSE);
145*fcf3ce44SJohn Forte #endif
146*fcf3ce44SJohn Forte 	}
147*fcf3ce44SJohn Forte 
148*fcf3ce44SJohn Forte 
149*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_ft_data, "_sd_ft_data") == -1) {
150*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_ft_data symbol");
151*fcf3ce44SJohn Forte 
152*fcf3ce44SJohn Forte 	} else {
153*fcf3ce44SJohn Forte 		mdb_printf("FT data:\n");
154*fcf3ce44SJohn Forte 		mdb_inc_indent(4);
155*fcf3ce44SJohn Forte 		mdb_printf("crashed %d host_state <%b> numio %d\n",
156*fcf3ce44SJohn Forte 			_sd_ft_data.fi_crashed,
157*fcf3ce44SJohn Forte 			_sd_ft_data.fi_host_state, host_states,
158*fcf3ce44SJohn Forte 			_sd_ft_data.fi_numio);
159*fcf3ce44SJohn Forte 		mdb_printf("lock %?-p (owner) rem_sv %h-x sleep %?-p (owner)\n",
160*fcf3ce44SJohn Forte 			_sd_ft_data.fi_lock._opaque[0],
161*fcf3ce44SJohn Forte 			_sd_ft_data.fi_rem_sv._opaque,
162*fcf3ce44SJohn Forte 			_sd_ft_data.fi_sleep._opaque[0]);
163*fcf3ce44SJohn Forte 		mdb_dec_indent(4);
164*fcf3ce44SJohn Forte 	}
165*fcf3ce44SJohn Forte 
166*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_node_hint, "_sd_node_hint") == -1) {
167*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_node_hint symbol");
168*fcf3ce44SJohn Forte 
169*fcf3ce44SJohn Forte 	} else
170*fcf3ce44SJohn Forte 		mdb_printf("Node Hints: %08x <%b>\n",
171*fcf3ce44SJohn Forte 			_sd_node_hint, cache_hints);
172*fcf3ce44SJohn Forte 
173*fcf3ce44SJohn Forte 	display_var("sdbc_wrthru_len", UINTTYPE);
174*fcf3ce44SJohn Forte 	display_var("_sd_debug_level", UINTTYPE);
175*fcf3ce44SJohn Forte 	display_var("_sdbc_attached", UINTTYPE);
176*fcf3ce44SJohn Forte 
177*fcf3ce44SJohn Forte 	return (DCMD_OK);
178*fcf3ce44SJohn Forte }
179*fcf3ce44SJohn Forte 
180*fcf3ce44SJohn Forte static void
sdbc_hit_percent(uint_t hits,uint_t misses,char * type)181*fcf3ce44SJohn Forte sdbc_hit_percent(uint_t hits, uint_t misses, char *type)
182*fcf3ce44SJohn Forte {
183*fcf3ce44SJohn Forte 	uint64_t dhits, dmisses;
184*fcf3ce44SJohn Forte 	uint64_t hit_rate = 0;
185*fcf3ce44SJohn Forte 
186*fcf3ce44SJohn Forte 	mdb_printf("%s hits: %u\t %s misses: %u\n", type, hits, type, misses);
187*fcf3ce44SJohn Forte 
188*fcf3ce44SJohn Forte 	/* a little crude. anything less than 1 percent will show as 0 */
189*fcf3ce44SJohn Forte 	if (hits > 0 || misses > 0) {
190*fcf3ce44SJohn Forte 		dhits = (uint64_t)hits;
191*fcf3ce44SJohn Forte 		dmisses = (uint64_t)misses;
192*fcf3ce44SJohn Forte 		hit_rate = (dhits * 100)/ (dhits + dmisses);
193*fcf3ce44SJohn Forte 		mdb_printf("%s hit rate: %lld %%\n", type, hit_rate);
194*fcf3ce44SJohn Forte 	}
195*fcf3ce44SJohn Forte 	mdb_printf("\n");
196*fcf3ce44SJohn Forte }
197*fcf3ce44SJohn Forte 
198*fcf3ce44SJohn Forte /*ARGSUSED*/
199*fcf3ce44SJohn Forte static int
sdbc_stats(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)200*fcf3ce44SJohn Forte sdbc_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
201*fcf3ce44SJohn Forte {
202*fcf3ce44SJohn Forte 	int i;
203*fcf3ce44SJohn Forte 	char *fn;
204*fcf3ce44SJohn Forte 	_sd_stats_t *_sd_cache_stats; /* local memory */
205*fcf3ce44SJohn Forte 	uintptr_t _sd_cache_statsp; /* kernel pointer */
206*fcf3ce44SJohn Forte 	_sd_shared_t *sh;
207*fcf3ce44SJohn Forte 	int statssize;
208*fcf3ce44SJohn Forte 	GElf_Sym sym;
209*fcf3ce44SJohn Forte 	int maxdevs;
210*fcf3ce44SJohn Forte 
211*fcf3ce44SJohn Forte 	if (argc != 0)
212*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
213*fcf3ce44SJohn Forte 
214*fcf3ce44SJohn Forte 	/* get the number of volumes */
215*fcf3ce44SJohn Forte 	if (mdb_readvar(&maxdevs, "sdbc_max_devs") == -1) {
216*fcf3ce44SJohn Forte 		mdb_warn("failed to read  sdbc_max_devs");
217*fcf3ce44SJohn Forte 		return (DCMD_ERR);
218*fcf3ce44SJohn Forte 	}
219*fcf3ce44SJohn Forte 
220*fcf3ce44SJohn Forte 	statssize = sizeof (_sd_stats_t) + (maxdevs - 1) *
221*fcf3ce44SJohn Forte 						sizeof (_sd_shared_t);
222*fcf3ce44SJohn Forte 
223*fcf3ce44SJohn Forte 	_sd_cache_stats = mdb_zalloc(statssize, UM_SLEEP);
224*fcf3ce44SJohn Forte 
225*fcf3ce44SJohn Forte 	if (mdb_lookup_by_obj("sdbc", "_sd_cache_stats", &sym) == -1) {
226*fcf3ce44SJohn Forte 		mdb_warn("failed to lookup _sd_cache_stats symbol");
227*fcf3ce44SJohn Forte 		return (DCMD_ERR);
228*fcf3ce44SJohn Forte 	}
229*fcf3ce44SJohn Forte 
230*fcf3ce44SJohn Forte 	if (mdb_vread(&_sd_cache_statsp, sizeof (uintptr_t),
231*fcf3ce44SJohn Forte 						sym.st_value) == -1) {
232*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_stats_t pointer");
233*fcf3ce44SJohn Forte 		return (DCMD_ERR);
234*fcf3ce44SJohn Forte 	}
235*fcf3ce44SJohn Forte 
236*fcf3ce44SJohn Forte 	if (mdb_vread(_sd_cache_stats, statssize, _sd_cache_statsp) == -1) {
237*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_stats_t structure");
238*fcf3ce44SJohn Forte 		return (DCMD_ERR);
239*fcf3ce44SJohn Forte 	}
240*fcf3ce44SJohn Forte 
241*fcf3ce44SJohn Forte 	mdb_printf("Storage Device Block Cache Statistics\n");
242*fcf3ce44SJohn Forte 	mdb_printf("-------------------------------------\n");
243*fcf3ce44SJohn Forte 
244*fcf3ce44SJohn Forte 	i = _sd_cache_stats->st_blksize;
245*fcf3ce44SJohn Forte 	mdb_printf("Blocksize: 0x%x (%d)\n", i, i);
246*fcf3ce44SJohn Forte 
247*fcf3ce44SJohn Forte 	mdb_printf("\n");
248*fcf3ce44SJohn Forte 	sdbc_hit_percent(_sd_cache_stats->st_rdhits, _sd_cache_stats->st_rdmiss,
249*fcf3ce44SJohn Forte 				"Read");
250*fcf3ce44SJohn Forte 	sdbc_hit_percent(_sd_cache_stats->st_wrhits, _sd_cache_stats->st_wrmiss,
251*fcf3ce44SJohn Forte 				"Write");
252*fcf3ce44SJohn Forte 
253*fcf3ce44SJohn Forte 	mdb_printf("%3s %10s %8s %8s %8s %8s %8s %7s %4s %4s %s\n",
254*fcf3ce44SJohn Forte 		"Cd", "Dev", "Size",
255*fcf3ce44SJohn Forte 		"CacheRd", "CacheWr", "DiskRd", "DiskWr",
256*fcf3ce44SJohn Forte 		"DirtyBl", "#IO", "Fail", "F");
257*fcf3ce44SJohn Forte 	for (i = 0; i < maxdevs; i++) {
258*fcf3ce44SJohn Forte 		sh = &_sd_cache_stats->st_shared[i];
259*fcf3ce44SJohn Forte 		if (!sh->sh_alloc)
260*fcf3ce44SJohn Forte 			continue;
261*fcf3ce44SJohn Forte 		fn = strrchr(sh->sh_filename, '/');
262*fcf3ce44SJohn Forte 		fn = fn ? fn+1 : sh->sh_filename;
263*fcf3ce44SJohn Forte 		mdb_printf("%3d %10s %7d %8d %8d %8d %8d %7d %4d %4d %d\n",
264*fcf3ce44SJohn Forte 			sh->sh_cd, fn, sh->sh_filesize,
265*fcf3ce44SJohn Forte 			sh->sh_cache_read, sh->sh_cache_write,
266*fcf3ce44SJohn Forte 			sh->sh_disk_read, sh->sh_disk_write,
267*fcf3ce44SJohn Forte 			sh->sh_numdirty, sh->sh_numio, sh->sh_numfail,
268*fcf3ce44SJohn Forte 			sh->sh_failed);
269*fcf3ce44SJohn Forte 	}
270*fcf3ce44SJohn Forte 
271*fcf3ce44SJohn Forte 	mdb_free(_sd_cache_stats, statssize);
272*fcf3ce44SJohn Forte 	return (DCMD_OK);
273*fcf3ce44SJohn Forte }
274*fcf3ce44SJohn Forte 
275*fcf3ce44SJohn Forte /*
276*fcf3ce44SJohn Forte  * display some variables and counters
277*fcf3ce44SJohn Forte  */
278*fcf3ce44SJohn Forte static void
display_var(char * name,enum vartype type)279*fcf3ce44SJohn Forte display_var(char *name, enum vartype type)
280*fcf3ce44SJohn Forte {
281*fcf3ce44SJohn Forte 	uint_t		uintval;
282*fcf3ce44SJohn Forte 	uintptr_t	addrval;
283*fcf3ce44SJohn Forte 	kmutex_t	lockval;
284*fcf3ce44SJohn Forte 	kcondvar_t	cvval;
285*fcf3ce44SJohn Forte 
286*fcf3ce44SJohn Forte 	switch (type) {
287*fcf3ce44SJohn Forte 		case UINTTYPE:
288*fcf3ce44SJohn Forte 			if (mdb_readvar(&uintval, name) == -1) {
289*fcf3ce44SJohn Forte 				mdb_warn("failed to read %s variable", name);
290*fcf3ce44SJohn Forte 			} else
291*fcf3ce44SJohn Forte 				mdb_printf("%s =\t%8x %12u\n",
292*fcf3ce44SJohn Forte 						    name, uintval, uintval);
293*fcf3ce44SJohn Forte 			break;
294*fcf3ce44SJohn Forte 		case ADDRTYPE:
295*fcf3ce44SJohn Forte 			if (mdb_readvar(&addrval, name) == -1) {
296*fcf3ce44SJohn Forte 				mdb_warn("failed to read %s variable", name);
297*fcf3ce44SJohn Forte 			} else
298*fcf3ce44SJohn Forte 				mdb_printf("%s =\t%?-p\n",
299*fcf3ce44SJohn Forte 						    name, addrval);
300*fcf3ce44SJohn Forte 			break;
301*fcf3ce44SJohn Forte 		case LOCKTYPE:
302*fcf3ce44SJohn Forte 			if (mdb_readvar(&lockval, name) == -1) {
303*fcf3ce44SJohn Forte 				mdb_warn("failed to read %s lock variable",
304*fcf3ce44SJohn Forte 								name);
305*fcf3ce44SJohn Forte 			} else
306*fcf3ce44SJohn Forte 				mdb_printf("%s =\t%-p (owner)\n",
307*fcf3ce44SJohn Forte 						name, lockval._opaque[0]);
308*fcf3ce44SJohn Forte 			break;
309*fcf3ce44SJohn Forte 		case CVTYPE:
310*fcf3ce44SJohn Forte 			if (mdb_readvar(&cvval, name) == -1) {
311*fcf3ce44SJohn Forte 				mdb_warn("failed to read %s condvar variable",
312*fcf3ce44SJohn Forte 								name);
313*fcf3ce44SJohn Forte 			} else
314*fcf3ce44SJohn Forte 				mdb_printf("%s = \t%h-x\n",
315*fcf3ce44SJohn Forte 						name, cvval._opaque);
316*fcf3ce44SJohn Forte 			break;
317*fcf3ce44SJohn Forte 		default:
318*fcf3ce44SJohn Forte 			mdb_warn("display_var: unknown type");
319*fcf3ce44SJohn Forte 	}
320*fcf3ce44SJohn Forte }
321*fcf3ce44SJohn Forte 
322*fcf3ce44SJohn Forte mdb_bitmask_t dealloc_flag_vals[] = {
323*fcf3ce44SJohn Forte 	{ "PROCESS_CACHE_DM", (u_longlong_t)~0, PROCESS_CACHE_DM },
324*fcf3ce44SJohn Forte 	{ "CACHE_SHUTDOWN_DM", (u_longlong_t)~0, CACHE_SHUTDOWN_DM },
325*fcf3ce44SJohn Forte 	{ "CACHE_THREAD_TERMINATED_DM",
326*fcf3ce44SJohn Forte 	    (u_longlong_t)~0, CACHE_THREAD_TERMINATED_DM },
327*fcf3ce44SJohn Forte 	{ "TIME_DELAY_LVL0", (u_longlong_t)~0, TIME_DELAY_LVL0 },
328*fcf3ce44SJohn Forte 	{ "TIME_DELAY_LVL1", (u_longlong_t)~0, TIME_DELAY_LVL1 },
329*fcf3ce44SJohn Forte 	{ "TIME_DELAY_LVL2", (u_longlong_t)~0, TIME_DELAY_LVL2 },
330*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
331*fcf3ce44SJohn Forte };
332*fcf3ce44SJohn Forte 
333*fcf3ce44SJohn Forte mdb_bitmask_t mdp_bits[] = {
334*fcf3ce44SJohn Forte 	{ "MONITOR_DYNMEM_PROCESS_DEFAULT",
335*fcf3ce44SJohn Forte 	    (u_longlong_t)~0, MONITOR_DYNMEM_PROCESS_DEFAULT},
336*fcf3ce44SJohn Forte 	{ "RPT_SHUTDOWN_PROCESS_DM",
337*fcf3ce44SJohn Forte 	    RPT_SHUTDOWN_PROCESS_DM, RPT_SHUTDOWN_PROCESS_DM },
338*fcf3ce44SJohn Forte 	{ "RPT_DEALLOC_STATS1_DM",
339*fcf3ce44SJohn Forte 	    RPT_DEALLOC_STATS1_DM, RPT_DEALLOC_STATS1_DM },
340*fcf3ce44SJohn Forte 	{ "RPT_DEALLOC_STATS2_DM",
341*fcf3ce44SJohn Forte 	    RPT_DEALLOC_STATS2_DM, RPT_DEALLOC_STATS2_DM },
342*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
343*fcf3ce44SJohn Forte };
344*fcf3ce44SJohn Forte 
345*fcf3ce44SJohn Forte mdb_bitmask_t process_directive_bits[] = {
346*fcf3ce44SJohn Forte 	{ "PROCESS_DIRECTIVE_DEFAULT",
347*fcf3ce44SJohn Forte 	    (u_longlong_t)~0, PROCESS_DIRECTIVE_DEFAULT },
348*fcf3ce44SJohn Forte 	{ "WAKE_DEALLOC_THREAD_DM",
349*fcf3ce44SJohn Forte 	    WAKE_DEALLOC_THREAD_DM, WAKE_DEALLOC_THREAD_DM },
350*fcf3ce44SJohn Forte 	{ "MAX_OUT_ACCEL_HIST_FLAG_DM",
351*fcf3ce44SJohn Forte 	    MAX_OUT_ACCEL_HIST_FLAG_DM, MAX_OUT_ACCEL_HIST_FLAG_DM},
352*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
353*fcf3ce44SJohn Forte };
354*fcf3ce44SJohn Forte 
355*fcf3ce44SJohn Forte /*ARGSUSED*/
356*fcf3ce44SJohn Forte static int
sdbc_vars(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)357*fcf3ce44SJohn Forte sdbc_vars(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
358*fcf3ce44SJohn Forte {
359*fcf3ce44SJohn Forte 	int sd_dealloc_flag_dm;
360*fcf3ce44SJohn Forte 	_dm_process_vars_t dynmem_processing_dm;
361*fcf3ce44SJohn Forte 
362*fcf3ce44SJohn Forte 	if (argc != 0)
363*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
364*fcf3ce44SJohn Forte 
365*fcf3ce44SJohn Forte 	mdb_printf("counters and other variables:\n");
366*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
367*fcf3ce44SJohn Forte 
368*fcf3ce44SJohn Forte 	display_var("xmem_inval_hit", UINTTYPE);
369*fcf3ce44SJohn Forte 	display_var("xmem_inval_miss", UINTTYPE);
370*fcf3ce44SJohn Forte 	display_var("xmem_inval_inuse", UINTTYPE);
371*fcf3ce44SJohn Forte 
372*fcf3ce44SJohn Forte 	display_var("sdbc_allocb_pageio1", UINTTYPE);
373*fcf3ce44SJohn Forte 	display_var("sdbc_allocb_pageio2", UINTTYPE);
374*fcf3ce44SJohn Forte 	display_var("sdbc_allocb_inuse", UINTTYPE);
375*fcf3ce44SJohn Forte 	display_var("sdbc_allocb_hit", UINTTYPE);
376*fcf3ce44SJohn Forte 	display_var("sdbc_allocb_lost", UINTTYPE);
377*fcf3ce44SJohn Forte 	display_var("sdbc_pageio_always", UINTTYPE);
378*fcf3ce44SJohn Forte 	display_var("sdbc_do_page", UINTTYPE);
379*fcf3ce44SJohn Forte 	display_var("sdbc_flush_pageio", UINTTYPE);
380*fcf3ce44SJohn Forte 
381*fcf3ce44SJohn Forte 	display_var("sdbc_centry_hit", UINTTYPE);
382*fcf3ce44SJohn Forte 	display_var("sdbc_centry_inuse", UINTTYPE);
383*fcf3ce44SJohn Forte 	display_var("sdbc_centry_lost", UINTTYPE);
384*fcf3ce44SJohn Forte 	display_var("sdbc_centry_deallocd", UINTTYPE);
385*fcf3ce44SJohn Forte 
386*fcf3ce44SJohn Forte 	display_var("_sd_prefetch_opt", UINTTYPE);
387*fcf3ce44SJohn Forte 
388*fcf3ce44SJohn Forte 	display_var("sdbc_ra_hash", UINTTYPE);
389*fcf3ce44SJohn Forte 	display_var("sdbc_ra_none", UINTTYPE);
390*fcf3ce44SJohn Forte 
391*fcf3ce44SJohn Forte 	display_var("sdbc_static_cache", UINTTYPE);
392*fcf3ce44SJohn Forte 	display_var("sdbc_use_dmchain", UINTTYPE);
393*fcf3ce44SJohn Forte 
394*fcf3ce44SJohn Forte 	/* in no particular order ... */
395*fcf3ce44SJohn Forte 	display_var("sdbc_check_cot", UINTTYPE);
396*fcf3ce44SJohn Forte 	display_var("_sd_cctl_groupsz", UINTTYPE);
397*fcf3ce44SJohn Forte 	display_var("CBLOCKS", UINTTYPE);
398*fcf3ce44SJohn Forte 	display_var("_SD_SELF_HOST", UINTTYPE);
399*fcf3ce44SJohn Forte 	display_var("_SD_MIRROR_HOST", UINTTYPE);
400*fcf3ce44SJohn Forte 	display_var("sdbc_bio_count", UINTTYPE);
401*fcf3ce44SJohn Forte 	display_var("_sd_cblock_shift", UINTTYPE);
402*fcf3ce44SJohn Forte 	display_var("_sd_nodes_configured", UINTTYPE);
403*fcf3ce44SJohn Forte 	display_var("nv_alloc_factor", UINTTYPE);
404*fcf3ce44SJohn Forte 	display_var("_sd_ft_exit", UINTTYPE);
405*fcf3ce44SJohn Forte 	display_var("_sd_flush_exit", UINTTYPE);
406*fcf3ce44SJohn Forte 	display_var("_sd_node_recovery", UINTTYPE);
407*fcf3ce44SJohn Forte 	display_var("_sd_async_recovery", UINTTYPE);
408*fcf3ce44SJohn Forte 	display_var("_sdbc_ft_hold_io", UINTTYPE);
409*fcf3ce44SJohn Forte 	display_var("mirror_clean_shutdown", UINTTYPE);
410*fcf3ce44SJohn Forte 	display_var("_sd_ft_warm_start", UINTTYPE);
411*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
412*fcf3ce44SJohn Forte 	mdb_printf("\n");
413*fcf3ce44SJohn Forte 
414*fcf3ce44SJohn Forte 	/* some addresses of various lists and tables */
415*fcf3ce44SJohn Forte 	mdb_printf("Addresses:\n");
416*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
417*fcf3ce44SJohn Forte 	display_var("_sd_htable", ADDRTYPE);
418*fcf3ce44SJohn Forte 	display_var("_sdbc_gl_centry_info", ADDRTYPE);
419*fcf3ce44SJohn Forte 	display_var("_sdbc_gl_centry_info_nvmem", ADDRTYPE);
420*fcf3ce44SJohn Forte 	display_var("_sdbc_gl_centry_info_size", ADDRTYPE); /* size_t */
421*fcf3ce44SJohn Forte 	display_var("_sdbc_gl_file_info", ADDRTYPE);
422*fcf3ce44SJohn Forte 	display_var("_sdbc_gl_file_info_size", ADDRTYPE); /* size_t */
423*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
424*fcf3ce44SJohn Forte 	mdb_printf("\n");
425*fcf3ce44SJohn Forte 
426*fcf3ce44SJohn Forte 	/* dynamic memory variables */
427*fcf3ce44SJohn Forte 	mdb_printf("Dynamic Memory variables and stats:\n");
428*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
429*fcf3ce44SJohn Forte 	display_var("_sdbc_memtype_deconfigure_delayed", UINTTYPE);
430*fcf3ce44SJohn Forte 
431*fcf3ce44SJohn Forte 	if (mdb_readvar(&sd_dealloc_flag_dm, "sd_dealloc_flag_dm") == -1) {
432*fcf3ce44SJohn Forte 		mdb_warn("failed to read sd_dealloc_flag_dm symbol");
433*fcf3ce44SJohn Forte 	} else
434*fcf3ce44SJohn Forte 		mdb_printf("sd_dealloc_flag_dm %08x <%b>\n",
435*fcf3ce44SJohn Forte 				sd_dealloc_flag_dm,
436*fcf3ce44SJohn Forte 				sd_dealloc_flag_dm, dealloc_flag_vals);
437*fcf3ce44SJohn Forte 
438*fcf3ce44SJohn Forte 	if (mdb_readvar(&dynmem_processing_dm, "dynmem_processing_dm") == -1) {
439*fcf3ce44SJohn Forte 		mdb_warn("failed to read dynmem_processing_dm structure");
440*fcf3ce44SJohn Forte 	} else {
441*fcf3ce44SJohn Forte 		_dm_process_vars_t *dp;
442*fcf3ce44SJohn Forte 
443*fcf3ce44SJohn Forte 		dp = &dynmem_processing_dm;
444*fcf3ce44SJohn Forte 
445*fcf3ce44SJohn Forte 		mdb_printf(
446*fcf3ce44SJohn Forte 		"thread_dm_cv %h-x thread_dm_lock %?-p (owner)\n",
447*fcf3ce44SJohn Forte 			dp->thread_dm_cv._opaque,
448*fcf3ce44SJohn Forte 			dp->thread_dm_lock._opaque[0]);
449*fcf3ce44SJohn Forte 
450*fcf3ce44SJohn Forte 		mdb_printf("sd_dealloc_flagx %x %8Tmax_dyn_list %3-d\n",
451*fcf3ce44SJohn Forte 			dp->sd_dealloc_flagx,
452*fcf3ce44SJohn Forte 			dp->max_dyn_list);
453*fcf3ce44SJohn Forte 
454*fcf3ce44SJohn Forte 		mdb_printf("monitor_dynmem_process <%b>\n",
455*fcf3ce44SJohn Forte 			dp->monitor_dynmem_process, mdp_bits);
456*fcf3ce44SJohn Forte 
457*fcf3ce44SJohn Forte 		mdb_printf(
458*fcf3ce44SJohn Forte 	"cache_aging_ct1 %3-d  %8Tcache_aging_ct2 %3-d cache_aging_ct3 %3-d\n",
459*fcf3ce44SJohn Forte 			dp->cache_aging_ct1,
460*fcf3ce44SJohn Forte 			dp->cache_aging_ct2,
461*fcf3ce44SJohn Forte 			dp->cache_aging_ct3);
462*fcf3ce44SJohn Forte 
463*fcf3ce44SJohn Forte 		mdb_printf(
464*fcf3ce44SJohn Forte 			"cache_aging_sec1 %3-d %8Tcache_aging_sec2 %3-d"
465*fcf3ce44SJohn Forte 			" cache_aging_sec3 %3-d\n",
466*fcf3ce44SJohn Forte 			dp->cache_aging_sec1,
467*fcf3ce44SJohn Forte 			dp->cache_aging_sec2,
468*fcf3ce44SJohn Forte 			dp->cache_aging_sec3);
469*fcf3ce44SJohn Forte 
470*fcf3ce44SJohn Forte 		mdb_printf("cache_aging_pcnt1 %3-d %8Tcache_aging_pcnt2 %3-d\n",
471*fcf3ce44SJohn Forte 			dp->cache_aging_pcnt1,
472*fcf3ce44SJohn Forte 			dp->cache_aging_pcnt2);
473*fcf3ce44SJohn Forte 
474*fcf3ce44SJohn Forte 		mdb_printf(
475*fcf3ce44SJohn Forte 		    "max_holds_pcnt %3-d %8Talloc_ct %8-d dealloc_ct %8-d\n",
476*fcf3ce44SJohn Forte 			dp->max_holds_pcnt,
477*fcf3ce44SJohn Forte 			dp->alloc_ct,
478*fcf3ce44SJohn Forte 			dp->dealloc_ct);
479*fcf3ce44SJohn Forte 
480*fcf3ce44SJohn Forte 		mdb_printf(
481*fcf3ce44SJohn Forte 		"history %4x %8Tnodatas %8-d notavail %8-d candidates %8-d\n",
482*fcf3ce44SJohn Forte 			dp->history,
483*fcf3ce44SJohn Forte 			dp->nodatas,
484*fcf3ce44SJohn Forte 			dp->notavail,
485*fcf3ce44SJohn Forte 			dp->candidates);
486*fcf3ce44SJohn Forte 
487*fcf3ce44SJohn Forte 		mdb_printf(
488*fcf3ce44SJohn Forte 			"deallocs %8-d %8Thosts %8-d pests %8-d metas %8-d\n",
489*fcf3ce44SJohn Forte 			dp->deallocs,
490*fcf3ce44SJohn Forte 			dp->hosts,
491*fcf3ce44SJohn Forte 			dp->pests,
492*fcf3ce44SJohn Forte 			dp->metas);
493*fcf3ce44SJohn Forte 
494*fcf3ce44SJohn Forte 		mdb_printf("holds %8-d %8Tothers %8-d\n",
495*fcf3ce44SJohn Forte 			dp->holds,
496*fcf3ce44SJohn Forte 			dp->others);
497*fcf3ce44SJohn Forte 
498*fcf3ce44SJohn Forte 		mdb_printf("process_directive <%b>\n",
499*fcf3ce44SJohn Forte 			dp->process_directive, process_directive_bits);
500*fcf3ce44SJohn Forte 
501*fcf3ce44SJohn Forte 		mdb_printf("read_hits %8-d %8Tread_misses %8-d\n",
502*fcf3ce44SJohn Forte 			dp->read_hits,
503*fcf3ce44SJohn Forte 			dp->read_misses);
504*fcf3ce44SJohn Forte 
505*fcf3ce44SJohn Forte 		mdb_printf(
506*fcf3ce44SJohn Forte 		    "write_thru %8-d %8Twrite_hits %8-d write_misses %8-d\n",
507*fcf3ce44SJohn Forte 			dp->write_hits,
508*fcf3ce44SJohn Forte 			dp->write_misses,
509*fcf3ce44SJohn Forte 			dp->write_thru);
510*fcf3ce44SJohn Forte 
511*fcf3ce44SJohn Forte 		mdb_printf("prefetch_hits %8-d prefetch_misses %8-d\n",
512*fcf3ce44SJohn Forte 			dp->prefetch_hits,
513*fcf3ce44SJohn Forte 			dp->prefetch_misses);
514*fcf3ce44SJohn Forte 	}
515*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
516*fcf3ce44SJohn Forte 	mdb_printf("\n");
517*fcf3ce44SJohn Forte 
518*fcf3ce44SJohn Forte 	/* some locks and condition variables */
519*fcf3ce44SJohn Forte 	mdb_printf("Locks:\n");
520*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
521*fcf3ce44SJohn Forte 	display_var("mutex_and_condvar_flag", UINTTYPE);
522*fcf3ce44SJohn Forte 	display_var("_sd_cache_lock", LOCKTYPE);
523*fcf3ce44SJohn Forte 	display_var("_sd_block_lk", LOCKTYPE);
524*fcf3ce44SJohn Forte 	display_var("_sdbc_config_lock", LOCKTYPE);
525*fcf3ce44SJohn Forte 	display_var("_sdbc_ft_hold_io_lk", LOCKTYPE);
526*fcf3ce44SJohn Forte 	display_var("_sd_flush_cv", CVTYPE);
527*fcf3ce44SJohn Forte 	display_var("_sdbc_ft_hold_io_cv", CVTYPE);
528*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
529*fcf3ce44SJohn Forte 	mdb_printf("\n");
530*fcf3ce44SJohn Forte 
531*fcf3ce44SJohn Forte 	return (DCMD_OK);
532*fcf3ce44SJohn Forte }
533*fcf3ce44SJohn Forte 
534*fcf3ce44SJohn Forte const mdb_bitmask_t nsc_buf_bits[] = {
535*fcf3ce44SJohn Forte 	{"HALLOCATED", NSC_HALLOCATED, NSC_HALLOCATED},
536*fcf3ce44SJohn Forte 	{"HACTIVE", NSC_HACTIVE, NSC_HACTIVE},
537*fcf3ce44SJohn Forte 	{"RDBUF", NSC_RDBUF, NSC_RDBUF},
538*fcf3ce44SJohn Forte 	{"WRBUF", NSC_WRBUF, NSC_WRBUF},
539*fcf3ce44SJohn Forte 	{"NOBLOCK", NSC_NOBLOCK, NSC_NOBLOCK},
540*fcf3ce44SJohn Forte 	{"WRTHRU", NSC_WRTHRU, NSC_WRTHRU},
541*fcf3ce44SJohn Forte 	{"NOCACHE", NSC_NOCACHE, NSC_NOCACHE},
542*fcf3ce44SJohn Forte 	{"BCOPY", NSC_BCOPY, NSC_BCOPY},
543*fcf3ce44SJohn Forte 	{"PAGEIO", NSC_PAGEIO, NSC_PAGEIO},
544*fcf3ce44SJohn Forte 	{"PINNABLE", NSC_PINNABLE, NSC_PINNABLE},
545*fcf3ce44SJohn Forte 	{"FORCED_WRTHRU", NSC_FORCED_WRTHRU, NSC_FORCED_WRTHRU},
546*fcf3ce44SJohn Forte 	{"METADATA", NSC_METADATA, NSC_METADATA},
547*fcf3ce44SJohn Forte 	{"MIXED", NSC_MIXED, NSC_MIXED},
548*fcf3ce44SJohn Forte 	{NULL, 0, 0}
549*fcf3ce44SJohn Forte };
550*fcf3ce44SJohn Forte 
551*fcf3ce44SJohn Forte 
552*fcf3ce44SJohn Forte /*
553*fcf3ce44SJohn Forte  * HELP functions for cache ctl type dcmds
554*fcf3ce44SJohn Forte  */
555*fcf3ce44SJohn Forte 
556*fcf3ce44SJohn Forte static void
cctl_help_common(char * name)557*fcf3ce44SJohn Forte cctl_help_common(char *name)
558*fcf3ce44SJohn Forte {
559*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
560*fcf3ce44SJohn Forte 	mdb_printf("-c cd displays cctls for cache descriptor 'cd'\n");
561*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
562*fcf3ce44SJohn Forte 	mdb_printf("inclusive filters:\n");
563*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
564*fcf3ce44SJohn Forte 	mdb_printf("-b blk displays cctls for cache block number 'blk'\n");
565*fcf3ce44SJohn Forte 	mdb_printf("-d displays cctls with dirty bits\n");
566*fcf3ce44SJohn Forte 	mdb_printf("-h displays cctls that are hashed\n");
567*fcf3ce44SJohn Forte 	mdb_printf("-i displays cctls that are inuse\n");
568*fcf3ce44SJohn Forte 	mdb_printf("-o displays cctls that have I/O in progress\n");
569*fcf3ce44SJohn Forte 	mdb_printf("-p displays cctls that have pagio set\n");
570*fcf3ce44SJohn Forte 	mdb_printf("-B displays cctls that are marked BAD\n");
571*fcf3ce44SJohn Forte 	mdb_printf("-H displays cctls that are HOSTS\n");
572*fcf3ce44SJohn Forte 	mdb_printf("-P displays cctls that are PARASITES\n");
573*fcf3ce44SJohn Forte 	mdb_printf("-R displays cctls that are explicit (NSC_RDAHEAD) "
574*fcf3ce44SJohn Forte 			"Prefetch bufs\n");
575*fcf3ce44SJohn Forte 	mdb_printf("-r displays cctls that are implicit Prefetch bufs\n");
576*fcf3ce44SJohn Forte 	mdb_printf("-V displays cctls that have valid bits set\n");
577*fcf3ce44SJohn Forte 	mdb_printf("-v verbose\n");
578*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
579*fcf3ce44SJohn Forte 
580*fcf3ce44SJohn Forte 	mdb_printf("Default: %s displays all cctls in the list\n", name);
581*fcf3ce44SJohn Forte 	mdb_printf("\n");
582*fcf3ce44SJohn Forte 
583*fcf3ce44SJohn Forte 	mdb_printf("Example:\n");
584*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
585*fcf3ce44SJohn Forte 
586*fcf3ce44SJohn Forte 	mdb_printf("%s -io -c 5 displays all cctls for cd 5 that are\n"
587*fcf3ce44SJohn Forte 			"in use or have I/O in progress\n", name);
588*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
589*fcf3ce44SJohn Forte }
590*fcf3ce44SJohn Forte 
591*fcf3ce44SJohn Forte #define	CCTL_OPTIONSTRING "[-vdhiopBHPV][-c cd][-b blknum]"
592*fcf3ce44SJohn Forte void
cctl_help()593*fcf3ce44SJohn Forte cctl_help()
594*fcf3ce44SJohn Forte {
595*fcf3ce44SJohn Forte 	mdb_printf("sdbc_cctl displays cache ctl structures\n");
596*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_cctl " CCTL_OPTIONSTRING "\n");
597*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_cctl");
598*fcf3ce44SJohn Forte }
599*fcf3ce44SJohn Forte 
600*fcf3ce44SJohn Forte void
cchain_help()601*fcf3ce44SJohn Forte cchain_help()
602*fcf3ce44SJohn Forte {
603*fcf3ce44SJohn Forte 	mdb_printf("sdbc_cchain displays cache ctl structures in a"
604*fcf3ce44SJohn Forte 			" (alloc) cc_chain\n");
605*fcf3ce44SJohn Forte 	mdb_printf("Usage: address::sdbc_cchain " CCTL_OPTIONSTRING "\n");
606*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_cchain");
607*fcf3ce44SJohn Forte }
608*fcf3ce44SJohn Forte 
609*fcf3ce44SJohn Forte void
dchain_help()610*fcf3ce44SJohn Forte dchain_help()
611*fcf3ce44SJohn Forte {
612*fcf3ce44SJohn Forte 	mdb_printf("sdbc_dchain displays cache ctl structures in a"
613*fcf3ce44SJohn Forte 			" dirty chain\n");
614*fcf3ce44SJohn Forte 	mdb_printf("Usage: address::sdbc_dchain " CCTL_OPTIONSTRING "\n");
615*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_dchain");
616*fcf3ce44SJohn Forte }
617*fcf3ce44SJohn Forte 
618*fcf3ce44SJohn Forte void
dmchain_help()619*fcf3ce44SJohn Forte dmchain_help()
620*fcf3ce44SJohn Forte {
621*fcf3ce44SJohn Forte 	mdb_printf("sdbc_dmchain displays cache ctl structures in a"
622*fcf3ce44SJohn Forte 			" dynamic memory allocation chain\n");
623*fcf3ce44SJohn Forte 	mdb_printf("order of display is:\n"
624*fcf3ce44SJohn Forte 		    "the cctl represented by the given address,\n"
625*fcf3ce44SJohn Forte 		    "the cc_head_dm cctl,\n"
626*fcf3ce44SJohn Forte 		    "the chain starting at cc_next_dm of the head cctl\n");
627*fcf3ce44SJohn Forte 	mdb_printf("Usage: address::sdbc_dmchain " CCTL_OPTIONSTRING "\n");
628*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_dmchain");
629*fcf3ce44SJohn Forte }
630*fcf3ce44SJohn Forte 
631*fcf3ce44SJohn Forte void
hashchain_help()632*fcf3ce44SJohn Forte hashchain_help()
633*fcf3ce44SJohn Forte {
634*fcf3ce44SJohn Forte 	mdb_printf("sdbc_hashchain displays cache ctl structures in a"
635*fcf3ce44SJohn Forte 			" hash chain\n");
636*fcf3ce44SJohn Forte 	mdb_printf("Usage: address::sdbc_hashchain " CCTL_OPTIONSTRING "\n");
637*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_hashchain");
638*fcf3ce44SJohn Forte }
639*fcf3ce44SJohn Forte 
640*fcf3ce44SJohn Forte void
hashtable_help()641*fcf3ce44SJohn Forte hashtable_help()
642*fcf3ce44SJohn Forte {
643*fcf3ce44SJohn Forte 	mdb_printf("sdbc_hashtable displays the hash table and its chains\n");
644*fcf3ce44SJohn Forte 	mdb_printf("Usage: address::sdbc_hashtable " CCTL_OPTIONSTRING "\n");
645*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_hashtable");
646*fcf3ce44SJohn Forte }
647*fcf3ce44SJohn Forte 
648*fcf3ce44SJohn Forte 
649*fcf3ce44SJohn Forte void
lru_help()650*fcf3ce44SJohn Forte lru_help()
651*fcf3ce44SJohn Forte {
652*fcf3ce44SJohn Forte 	mdb_printf("sdbc_lru displays cache ctl structures in the LRU queue\n");
653*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_lru " CCTL_OPTIONSTRING "\n");
654*fcf3ce44SJohn Forte 	cctl_help_common("sdbc_lru");
655*fcf3ce44SJohn Forte }
656*fcf3ce44SJohn Forte 
657*fcf3ce44SJohn Forte /*
658*fcf3ce44SJohn Forte  * help functions for write ctl dcmds
659*fcf3ce44SJohn Forte  */
660*fcf3ce44SJohn Forte void
wctl_help_common(char * name)661*fcf3ce44SJohn Forte wctl_help_common(char *name)
662*fcf3ce44SJohn Forte {
663*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
664*fcf3ce44SJohn Forte 	mdb_printf("-v verbose\n");
665*fcf3ce44SJohn Forte 	mdb_printf("-c cd show ctl structs for cache descriptor 'cd'\n");
666*fcf3ce44SJohn Forte 	mdb_printf("-d show ctl structs that have dirty bits set\n");
667*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
668*fcf3ce44SJohn Forte 	mdb_printf("Default: %s displays all write ctl in the list\n", name);
669*fcf3ce44SJohn Forte }
670*fcf3ce44SJohn Forte 
671*fcf3ce44SJohn Forte void
wctl_help()672*fcf3ce44SJohn Forte wctl_help()
673*fcf3ce44SJohn Forte {
674*fcf3ce44SJohn Forte 	mdb_printf(
675*fcf3ce44SJohn Forte 	    "sdbc_wctl displays the allocated array of write ctl structures\n");
676*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_wctl [-vd][-c cd]\n");
677*fcf3ce44SJohn Forte 	wctl_help_common("sdbc_wctl");
678*fcf3ce44SJohn Forte }
679*fcf3ce44SJohn Forte 
680*fcf3ce44SJohn Forte void
wrq_help()681*fcf3ce44SJohn Forte wrq_help()
682*fcf3ce44SJohn Forte {
683*fcf3ce44SJohn Forte 	mdb_printf("sdbc_wrq displays the write ctl queue (wctl free list)\n");
684*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_wrq [-vd][-c cd]\n");
685*fcf3ce44SJohn Forte 	wctl_help_common("sdbc_wrq");
686*fcf3ce44SJohn Forte }
687*fcf3ce44SJohn Forte 
688*fcf3ce44SJohn Forte /* help function for the sdbc_cdinfo dcmd */
689*fcf3ce44SJohn Forte void
cdinfo_help()690*fcf3ce44SJohn Forte cdinfo_help()
691*fcf3ce44SJohn Forte {
692*fcf3ce44SJohn Forte 	mdb_printf(
693*fcf3ce44SJohn Forte 	"sdbc_cdinfo displays cd information from the _sd_cache_files table\n");
694*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_cdfinfo [-av][-c cd]\n");
695*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
696*fcf3ce44SJohn Forte 	mdb_printf("-a displays info for all cd_info structures\n");
697*fcf3ce44SJohn Forte 	mdb_printf("-c cd displays info for cache descriptor 'cd'\n");
698*fcf3ce44SJohn Forte 	mdb_printf("-v verbose\n");
699*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
700*fcf3ce44SJohn Forte 	mdb_printf("Default: display info for cd's that are allocated\n");
701*fcf3ce44SJohn Forte }
702*fcf3ce44SJohn Forte 
703*fcf3ce44SJohn Forte void
ftctl_help()704*fcf3ce44SJohn Forte ftctl_help()
705*fcf3ce44SJohn Forte {
706*fcf3ce44SJohn Forte 	mdb_printf(
707*fcf3ce44SJohn Forte 	    "sdbc_ftctl displays the array of fault tolerant structures \n");
708*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_ftctl [-vd][-c cd]\n");
709*fcf3ce44SJohn Forte 	wctl_help_common("sdbc_ftctl");
710*fcf3ce44SJohn Forte }
711*fcf3ce44SJohn Forte 
712*fcf3ce44SJohn Forte /*
713*fcf3ce44SJohn Forte  * help function for the sdbc_handles dcmd
714*fcf3ce44SJohn Forte  */
715*fcf3ce44SJohn Forte void
handle_help()716*fcf3ce44SJohn Forte handle_help()
717*fcf3ce44SJohn Forte {
718*fcf3ce44SJohn Forte 	mdb_printf("sdbc_handles displays active or allocated"
719*fcf3ce44SJohn Forte 			" cache buffer handles\n");
720*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_handles [-avC][-c cd]\n");
721*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
722*fcf3ce44SJohn Forte 	mdb_printf("-a displays all handles\n");
723*fcf3ce44SJohn Forte 	mdb_printf("-c n displays handle for cd n\n");
724*fcf3ce44SJohn Forte 	mdb_printf("-v displays detailed handle data\n");
725*fcf3ce44SJohn Forte 	mdb_printf("-C displays the handle cc_chain\n");
726*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
727*fcf3ce44SJohn Forte 	mdb_printf("Default: display only allocated or active handles\n");
728*fcf3ce44SJohn Forte }
729*fcf3ce44SJohn Forte 
730*fcf3ce44SJohn Forte /*
731*fcf3ce44SJohn Forte  * help functions for the "global" memory dcmds
732*fcf3ce44SJohn Forte  */
733*fcf3ce44SJohn Forte void
glcinfo_help()734*fcf3ce44SJohn Forte glcinfo_help()
735*fcf3ce44SJohn Forte {
736*fcf3ce44SJohn Forte 	mdb_printf("sdbc_glcinfo displays the global cache entry info\n");
737*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_glcinfo [-adC][-c cd][-b fbapos]\n");
738*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
739*fcf3ce44SJohn Forte 	mdb_printf("-a displays all global info structs\n");
740*fcf3ce44SJohn Forte 	mdb_printf("-b fbapos displays structs that match FBA block"
741*fcf3ce44SJohn Forte 			"(not cache block) 'fbapos'\n");
742*fcf3ce44SJohn Forte 	mdb_printf("-c cd displays structs that match cache descriptor 'cd'\n");
743*fcf3ce44SJohn Forte 	mdb_printf("-d displays structs with dirty bits set\n");
744*fcf3ce44SJohn Forte 	mdb_printf("-C does consistency check against nvram copy\n");
745*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
746*fcf3ce44SJohn Forte 	mdb_printf("Default: display entries with a valid cd\n");
747*fcf3ce44SJohn Forte }
748*fcf3ce44SJohn Forte 
749*fcf3ce44SJohn Forte void
glfinfo_help()750*fcf3ce44SJohn Forte glfinfo_help()
751*fcf3ce44SJohn Forte {
752*fcf3ce44SJohn Forte 	mdb_printf("sdbc_glfinfo displays the global file info\n");
753*fcf3ce44SJohn Forte 	mdb_printf("Usage: [address]::sdbc_glfinfo [-aptC]\n");
754*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
755*fcf3ce44SJohn Forte 	mdb_printf("-a displays all global info structs\n");
756*fcf3ce44SJohn Forte 	mdb_printf("-p displays structs for pinned volumes\n");
757*fcf3ce44SJohn Forte 	mdb_printf("-t displays structs for attached volumes\n");
758*fcf3ce44SJohn Forte 	mdb_printf("-C does consistency check against nvram copy\n");
759*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
760*fcf3ce44SJohn Forte 	mdb_printf("Default: display entries with non-null filename\n");
761*fcf3ce44SJohn Forte }
762*fcf3ce44SJohn Forte 
763*fcf3ce44SJohn Forte 
764*fcf3ce44SJohn Forte /*
765*fcf3ce44SJohn Forte  * WALKERS
766*fcf3ce44SJohn Forte  */
767*fcf3ce44SJohn Forte 
768*fcf3ce44SJohn Forte /*
769*fcf3ce44SJohn Forte  * walker for the cctl list using the cc_link_list_dm pointers
770*fcf3ce44SJohn Forte  */
771*fcf3ce44SJohn Forte static int
sdbc_cctl_winit(mdb_walk_state_t * wsp)772*fcf3ce44SJohn Forte sdbc_cctl_winit(mdb_walk_state_t *wsp)
773*fcf3ce44SJohn Forte {
774*fcf3ce44SJohn Forte 	_sd_cctl_t *_sd_cctl[_SD_CCTL_GROUPS]; /* for getting first entry */
775*fcf3ce44SJohn Forte 	struct walk_info *winfo;
776*fcf3ce44SJohn Forte 
777*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
778*fcf3ce44SJohn Forte 
779*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) {
780*fcf3ce44SJohn Forte 		/*
781*fcf3ce44SJohn Forte 		 * we get the "first" cctl from memory and then traverse
782*fcf3ce44SJohn Forte 		 * the cc_link_list_dm pointers.
783*fcf3ce44SJohn Forte 		 * this traversal could start from any cctl.  here we start with
784*fcf3ce44SJohn Forte 		 * the first cctl in the _sd_cctl[] array.
785*fcf3ce44SJohn Forte 		 */
786*fcf3ce44SJohn Forte 		if (mdb_readvar(_sd_cctl, "_sd_cctl") == -1) {
787*fcf3ce44SJohn Forte 			mdb_warn("failed to read _sd_cctl array");
788*fcf3ce44SJohn Forte 			return (DCMD_ERR);
789*fcf3ce44SJohn Forte 		}
790*fcf3ce44SJohn Forte 
791*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)_sd_cctl[0];
792*fcf3ce44SJohn Forte 	}
793*fcf3ce44SJohn Forte 
794*fcf3ce44SJohn Forte 	winfo->w_start = 0;
795*fcf3ce44SJohn Forte 	winfo->w_end = wsp->walk_addr;
796*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
797*fcf3ce44SJohn Forte 
798*fcf3ce44SJohn Forte 	return (WALK_NEXT);
799*fcf3ce44SJohn Forte }
800*fcf3ce44SJohn Forte 
801*fcf3ce44SJohn Forte static int
sdbc_cctl_wstep(mdb_walk_state_t * wsp)802*fcf3ce44SJohn Forte sdbc_cctl_wstep(mdb_walk_state_t *wsp)
803*fcf3ce44SJohn Forte {
804*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
805*fcf3ce44SJohn Forte 	_sd_cctl_t centry;
806*fcf3ce44SJohn Forte 	int status;
807*fcf3ce44SJohn Forte 
808*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) /* should not happen */
809*fcf3ce44SJohn Forte 		return (WALK_DONE);
810*fcf3ce44SJohn Forte 
811*fcf3ce44SJohn Forte 	/*
812*fcf3ce44SJohn Forte 	 * w_start is 0 on the first iteration so the test
813*fcf3ce44SJohn Forte 	 * will fail, allowing the first centry to be processed
814*fcf3ce44SJohn Forte 	 */
815*fcf3ce44SJohn Forte 	if (wsp->walk_addr == winfo->w_start)
816*fcf3ce44SJohn Forte 		return (WALK_DONE);
817*fcf3ce44SJohn Forte 
818*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
819*fcf3ce44SJohn Forte 		wsp->walk_cbdata);
820*fcf3ce44SJohn Forte 
821*fcf3ce44SJohn Forte 	if (mdb_vread(&centry, sizeof (_sd_cctl_t), wsp->walk_addr) == -1) {
822*fcf3ce44SJohn Forte 		mdb_warn("failed to read centry at %p", wsp->walk_addr);
823*fcf3ce44SJohn Forte 		return (WALK_ERR);
824*fcf3ce44SJohn Forte 	}
825*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)(centry.cc_link_list_dm);
826*fcf3ce44SJohn Forte 	/* set termination condition. only needs to be done once */
827*fcf3ce44SJohn Forte 	winfo->w_start = winfo->w_end;
828*fcf3ce44SJohn Forte 
829*fcf3ce44SJohn Forte 	return (status);
830*fcf3ce44SJohn Forte }
831*fcf3ce44SJohn Forte 
832*fcf3ce44SJohn Forte static void
sdbc_cctl_wfini(mdb_walk_state_t * wsp)833*fcf3ce44SJohn Forte sdbc_cctl_wfini(mdb_walk_state_t *wsp)
834*fcf3ce44SJohn Forte {
835*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
836*fcf3ce44SJohn Forte }
837*fcf3ce44SJohn Forte 
838*fcf3ce44SJohn Forte /*
839*fcf3ce44SJohn Forte  * walk the cc_chain list of a _sd_cctl_t
840*fcf3ce44SJohn Forte  * no global walks -- must be called with an address
841*fcf3ce44SJohn Forte  */
842*fcf3ce44SJohn Forte static int
sdbc_cchain_winit(mdb_walk_state_t * wsp)843*fcf3ce44SJohn Forte sdbc_cchain_winit(mdb_walk_state_t *wsp)
844*fcf3ce44SJohn Forte {
845*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
846*fcf3ce44SJohn Forte 		return (WALK_ERR);
847*fcf3ce44SJohn Forte 
848*fcf3ce44SJohn Forte 	wsp->walk_data = mdb_zalloc(sizeof (_sd_cctl_t), UM_SLEEP);
849*fcf3ce44SJohn Forte 
850*fcf3ce44SJohn Forte 	return (WALK_NEXT);
851*fcf3ce44SJohn Forte }
852*fcf3ce44SJohn Forte 
853*fcf3ce44SJohn Forte static int
sdbc_cchain_wstep(mdb_walk_state_t * wsp)854*fcf3ce44SJohn Forte sdbc_cchain_wstep(mdb_walk_state_t *wsp)
855*fcf3ce44SJohn Forte {
856*fcf3ce44SJohn Forte 	int status;
857*fcf3ce44SJohn Forte 
858*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
859*fcf3ce44SJohn Forte 		return (WALK_DONE);
860*fcf3ce44SJohn Forte 
861*fcf3ce44SJohn Forte 	if (mdb_vread(wsp->walk_data, sizeof (_sd_cctl_t), wsp->walk_addr)
862*fcf3ce44SJohn Forte 				== -1) {
863*fcf3ce44SJohn Forte 		mdb_warn("sdbc_cchain_wstep failed to read centry at %p",
864*fcf3ce44SJohn Forte 			wsp->walk_addr);
865*fcf3ce44SJohn Forte 		return (WALK_ERR);
866*fcf3ce44SJohn Forte 	}
867*fcf3ce44SJohn Forte 
868*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
869*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
870*fcf3ce44SJohn Forte 
871*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)(((_sd_cctl_t *)
872*fcf3ce44SJohn Forte 				(wsp->walk_data))->cc_chain);
873*fcf3ce44SJohn Forte 	return (status);
874*fcf3ce44SJohn Forte }
875*fcf3ce44SJohn Forte 
876*fcf3ce44SJohn Forte static void
sdbc_cchain_wfini(mdb_walk_state_t * wsp)877*fcf3ce44SJohn Forte sdbc_cchain_wfini(mdb_walk_state_t *wsp)
878*fcf3ce44SJohn Forte {
879*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (_sd_cctl_t));
880*fcf3ce44SJohn Forte }
881*fcf3ce44SJohn Forte 
882*fcf3ce44SJohn Forte 
883*fcf3ce44SJohn Forte /*
884*fcf3ce44SJohn Forte  * walk the dirty chain list of a _sd_cctl_t
885*fcf3ce44SJohn Forte  * no global walks -- must be called with an address
886*fcf3ce44SJohn Forte  */
887*fcf3ce44SJohn Forte static int
sdbc_dchain_winit(mdb_walk_state_t * wsp)888*fcf3ce44SJohn Forte sdbc_dchain_winit(mdb_walk_state_t *wsp)
889*fcf3ce44SJohn Forte {
890*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
891*fcf3ce44SJohn Forte 		return (WALK_ERR);
892*fcf3ce44SJohn Forte 
893*fcf3ce44SJohn Forte 	wsp->walk_data = mdb_zalloc(sizeof (_sd_cctl_t), UM_SLEEP);
894*fcf3ce44SJohn Forte 
895*fcf3ce44SJohn Forte 	/* walk data stores the first and subsequent cc_dirty_link */
896*fcf3ce44SJohn Forte 	if (mdb_vread(wsp->walk_data, sizeof (_sd_cctl_t), wsp->walk_addr)
897*fcf3ce44SJohn Forte 				== -1) {
898*fcf3ce44SJohn Forte 		mdb_warn("sdbc_dchain_winit failed to read centry at %p",
899*fcf3ce44SJohn Forte 			wsp->walk_addr);
900*fcf3ce44SJohn Forte 		return (WALK_ERR);
901*fcf3ce44SJohn Forte 	}
902*fcf3ce44SJohn Forte 
903*fcf3ce44SJohn Forte 	return (WALK_NEXT);
904*fcf3ce44SJohn Forte }
905*fcf3ce44SJohn Forte 
906*fcf3ce44SJohn Forte static int
sdbc_dchain_wstep(mdb_walk_state_t * wsp)907*fcf3ce44SJohn Forte sdbc_dchain_wstep(mdb_walk_state_t *wsp)
908*fcf3ce44SJohn Forte {
909*fcf3ce44SJohn Forte 	_sd_cctl_t centry;
910*fcf3ce44SJohn Forte 	int status;
911*fcf3ce44SJohn Forte 
912*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
913*fcf3ce44SJohn Forte 		return (WALK_DONE);
914*fcf3ce44SJohn Forte 
915*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
916*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
917*fcf3ce44SJohn Forte 
918*fcf3ce44SJohn Forte 
919*fcf3ce44SJohn Forte 	if (mdb_vread(&centry, sizeof (_sd_cctl_t), wsp->walk_addr)
920*fcf3ce44SJohn Forte 				== -1) {
921*fcf3ce44SJohn Forte 		mdb_warn("sdbc_dchain_wstep failed to read centry at %p",
922*fcf3ce44SJohn Forte 			wsp->walk_addr);
923*fcf3ce44SJohn Forte 		return (WALK_ERR);
924*fcf3ce44SJohn Forte 	}
925*fcf3ce44SJohn Forte 
926*fcf3ce44SJohn Forte 	wsp->walk_addr =
927*fcf3ce44SJohn Forte 		(uintptr_t)(centry.cc_dirty_next);
928*fcf3ce44SJohn Forte 
929*fcf3ce44SJohn Forte 	/* end of dirty_next chain?  start on subsequent dirty_link */
930*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) {
931*fcf3ce44SJohn Forte 		wsp->walk_addr =
932*fcf3ce44SJohn Forte 		(uintptr_t)(((_sd_cctl_t *)(wsp->walk_data))->cc_dirty_link);
933*fcf3ce44SJohn Forte 
934*fcf3ce44SJohn Forte 		/* update dirty link */
935*fcf3ce44SJohn Forte 		/* walk data stores the first and subsequent cc_dirty_link */
936*fcf3ce44SJohn Forte 		if (wsp->walk_addr) {
937*fcf3ce44SJohn Forte 			if (mdb_vread(wsp->walk_data, sizeof (_sd_cctl_t),
938*fcf3ce44SJohn Forte 					wsp->walk_addr) == -1) {
939*fcf3ce44SJohn Forte 
940*fcf3ce44SJohn Forte 				mdb_warn(
941*fcf3ce44SJohn Forte 				"sdbc_dchain_wstep failed to read centry at %p",
942*fcf3ce44SJohn Forte 					wsp->walk_addr);
943*fcf3ce44SJohn Forte 
944*fcf3ce44SJohn Forte 				return (WALK_ERR);
945*fcf3ce44SJohn Forte 			}
946*fcf3ce44SJohn Forte 		}
947*fcf3ce44SJohn Forte 	}
948*fcf3ce44SJohn Forte 
949*fcf3ce44SJohn Forte 	return (status);
950*fcf3ce44SJohn Forte }
951*fcf3ce44SJohn Forte 
952*fcf3ce44SJohn Forte static void
sdbc_dchain_wfini(mdb_walk_state_t * wsp)953*fcf3ce44SJohn Forte sdbc_dchain_wfini(mdb_walk_state_t *wsp)
954*fcf3ce44SJohn Forte {
955*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (_sd_cctl_t));
956*fcf3ce44SJohn Forte }
957*fcf3ce44SJohn Forte 
958*fcf3ce44SJohn Forte /* for stepping thru the dynmem chain */
959*fcf3ce44SJohn Forte #define	GET_HEAD_DM 0x1
960*fcf3ce44SJohn Forte #define	GET_NEXT_DM 0x2
961*fcf3ce44SJohn Forte 
962*fcf3ce44SJohn Forte /*
963*fcf3ce44SJohn Forte  * walk the dm chain of a cctl
964*fcf3ce44SJohn Forte  * start with current address, then cc_head_dm, then the cc_next_dm chain
965*fcf3ce44SJohn Forte  */
966*fcf3ce44SJohn Forte static int
sdbc_dmchain_winit(mdb_walk_state_t * wsp)967*fcf3ce44SJohn Forte sdbc_dmchain_winit(mdb_walk_state_t *wsp)
968*fcf3ce44SJohn Forte {
969*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
970*fcf3ce44SJohn Forte 		return (WALK_ERR);
971*fcf3ce44SJohn Forte 
972*fcf3ce44SJohn Forte 	wsp->walk_data = (void *)GET_HEAD_DM;
973*fcf3ce44SJohn Forte 
974*fcf3ce44SJohn Forte 	return (WALK_NEXT);
975*fcf3ce44SJohn Forte }
976*fcf3ce44SJohn Forte 
977*fcf3ce44SJohn Forte static int
sdbc_dmchain_wstep(mdb_walk_state_t * wsp)978*fcf3ce44SJohn Forte sdbc_dmchain_wstep(mdb_walk_state_t *wsp)
979*fcf3ce44SJohn Forte {
980*fcf3ce44SJohn Forte 	_sd_cctl_t centry;
981*fcf3ce44SJohn Forte 	int status;
982*fcf3ce44SJohn Forte 
983*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
984*fcf3ce44SJohn Forte 		return (WALK_DONE);
985*fcf3ce44SJohn Forte 
986*fcf3ce44SJohn Forte 	if (mdb_vread(&centry, sizeof (_sd_cctl_t), wsp->walk_addr)
987*fcf3ce44SJohn Forte 				== -1) {
988*fcf3ce44SJohn Forte 		mdb_warn("sdbc_dmchain_wstep failed to read centry at %p",
989*fcf3ce44SJohn Forte 			wsp->walk_addr);
990*fcf3ce44SJohn Forte 		return (WALK_ERR);
991*fcf3ce44SJohn Forte 	}
992*fcf3ce44SJohn Forte 
993*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
994*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
995*fcf3ce44SJohn Forte 
996*fcf3ce44SJohn Forte 	if (wsp->walk_data == (void *)GET_HEAD_DM) {
997*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)centry.cc_head_dm;
998*fcf3ce44SJohn Forte 		wsp->walk_data = (void *)GET_NEXT_DM;
999*fcf3ce44SJohn Forte 	} else
1000*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)centry.cc_next_dm;
1001*fcf3ce44SJohn Forte 
1002*fcf3ce44SJohn Forte 	return (status);
1003*fcf3ce44SJohn Forte }
1004*fcf3ce44SJohn Forte 
1005*fcf3ce44SJohn Forte /*ARGSUSED*/
1006*fcf3ce44SJohn Forte static void
sdbc_dmchain_wfini(mdb_walk_state_t * wsp)1007*fcf3ce44SJohn Forte sdbc_dmchain_wfini(mdb_walk_state_t *wsp)
1008*fcf3ce44SJohn Forte {
1009*fcf3ce44SJohn Forte }
1010*fcf3ce44SJohn Forte 
1011*fcf3ce44SJohn Forte /*
1012*fcf3ce44SJohn Forte  * walk a hash chain
1013*fcf3ce44SJohn Forte  * requires an address
1014*fcf3ce44SJohn Forte  */
1015*fcf3ce44SJohn Forte /*ARGSUSED*/
1016*fcf3ce44SJohn Forte static int
sdbc_hashchain_winit(mdb_walk_state_t * wsp)1017*fcf3ce44SJohn Forte sdbc_hashchain_winit(mdb_walk_state_t *wsp)
1018*fcf3ce44SJohn Forte {
1019*fcf3ce44SJohn Forte 
1020*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1021*fcf3ce44SJohn Forte 		return (WALK_ERR);
1022*fcf3ce44SJohn Forte 
1023*fcf3ce44SJohn Forte 
1024*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1025*fcf3ce44SJohn Forte }
1026*fcf3ce44SJohn Forte 
1027*fcf3ce44SJohn Forte static int
sdbc_hashchain_wstep(mdb_walk_state_t * wsp)1028*fcf3ce44SJohn Forte sdbc_hashchain_wstep(mdb_walk_state_t *wsp)
1029*fcf3ce44SJohn Forte {
1030*fcf3ce44SJohn Forte 	int status;
1031*fcf3ce44SJohn Forte 	_sd_hash_hd_t hash_entry;
1032*fcf3ce44SJohn Forte 
1033*fcf3ce44SJohn Forte 
1034*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1035*fcf3ce44SJohn Forte 		return (WALK_DONE);
1036*fcf3ce44SJohn Forte 
1037*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1038*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1039*fcf3ce44SJohn Forte 
1040*fcf3ce44SJohn Forte 	if (mdb_vread(&hash_entry, sizeof (_sd_hash_hd_t),
1041*fcf3ce44SJohn Forte 					wsp->walk_addr) == -1) {
1042*fcf3ce44SJohn Forte 		mdb_warn(
1043*fcf3ce44SJohn Forte 			"sdbc_hashchain_wstep failed to read hash_entry at %p",
1044*fcf3ce44SJohn Forte 			wsp->walk_addr);
1045*fcf3ce44SJohn Forte 		return (WALK_ERR); /* will upper layer continue ? */
1046*fcf3ce44SJohn Forte 	}
1047*fcf3ce44SJohn Forte 
1048*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)hash_entry.hh_next;
1049*fcf3ce44SJohn Forte 
1050*fcf3ce44SJohn Forte 	return (status);
1051*fcf3ce44SJohn Forte }
1052*fcf3ce44SJohn Forte 
1053*fcf3ce44SJohn Forte /*ARGSUSED*/
1054*fcf3ce44SJohn Forte static void
sdbc_hashchain_wfini(mdb_walk_state_t * wsp)1055*fcf3ce44SJohn Forte sdbc_hashchain_wfini(mdb_walk_state_t *wsp)
1056*fcf3ce44SJohn Forte {
1057*fcf3ce44SJohn Forte }
1058*fcf3ce44SJohn Forte 
1059*fcf3ce44SJohn Forte /*
1060*fcf3ce44SJohn Forte  * walk the sdbc lru list
1061*fcf3ce44SJohn Forte  */
1062*fcf3ce44SJohn Forte static int
sdbc_lru_winit(mdb_walk_state_t * wsp)1063*fcf3ce44SJohn Forte sdbc_lru_winit(mdb_walk_state_t *wsp)
1064*fcf3ce44SJohn Forte {
1065*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1066*fcf3ce44SJohn Forte 	GElf_Sym sym;
1067*fcf3ce44SJohn Forte 
1068*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1069*fcf3ce44SJohn Forte 
1070*fcf3ce44SJohn Forte 	/* if called without an address, start at the head of the queue */
1071*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) {
1072*fcf3ce44SJohn Forte 
1073*fcf3ce44SJohn Forte 		if (mdb_lookup_by_obj("sdbc", "_sd_lru_q", &sym) == -1) {
1074*fcf3ce44SJohn Forte 			mdb_warn("failed to lookup _sd_lru_q symbol");
1075*fcf3ce44SJohn Forte 			return (WALK_ERR);
1076*fcf3ce44SJohn Forte 		}
1077*fcf3ce44SJohn Forte 
1078*fcf3ce44SJohn Forte 		/* &(_sd_lru_q.sq_qhead) */
1079*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(sym.st_value);
1080*fcf3ce44SJohn Forte 	}
1081*fcf3ce44SJohn Forte 
1082*fcf3ce44SJohn Forte 	winfo->w_start = 0;
1083*fcf3ce44SJohn Forte 	winfo->w_end = wsp->walk_addr;
1084*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1085*fcf3ce44SJohn Forte 
1086*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1087*fcf3ce44SJohn Forte }
1088*fcf3ce44SJohn Forte 
1089*fcf3ce44SJohn Forte static int
sdbc_lru_wstep(mdb_walk_state_t * wsp)1090*fcf3ce44SJohn Forte sdbc_lru_wstep(mdb_walk_state_t *wsp)
1091*fcf3ce44SJohn Forte {
1092*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1093*fcf3ce44SJohn Forte 	_sd_cctl_t centry;
1094*fcf3ce44SJohn Forte 	int status;
1095*fcf3ce44SJohn Forte 
1096*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) /* should not happen */
1097*fcf3ce44SJohn Forte 		return (WALK_DONE);
1098*fcf3ce44SJohn Forte 
1099*fcf3ce44SJohn Forte 	/*
1100*fcf3ce44SJohn Forte 	 * w_start is 0 on the first iteration so the test
1101*fcf3ce44SJohn Forte 	 * will fail, allowing the first centry to be processed
1102*fcf3ce44SJohn Forte 	 */
1103*fcf3ce44SJohn Forte 	if (wsp->walk_addr == winfo->w_start)
1104*fcf3ce44SJohn Forte 		return (WALK_DONE);
1105*fcf3ce44SJohn Forte 
1106*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1107*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1108*fcf3ce44SJohn Forte 
1109*fcf3ce44SJohn Forte 	if (mdb_vread(&centry, sizeof (_sd_cctl_t), wsp->walk_addr) == -1) {
1110*fcf3ce44SJohn Forte 		mdb_warn("failed to read centry at %p", wsp->walk_addr);
1111*fcf3ce44SJohn Forte 		return (WALK_ERR);
1112*fcf3ce44SJohn Forte 	}
1113*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)(centry.cc_next);
1114*fcf3ce44SJohn Forte 
1115*fcf3ce44SJohn Forte 	/* set termination condition. only needs to be done once */
1116*fcf3ce44SJohn Forte 	winfo->w_start = winfo->w_end;
1117*fcf3ce44SJohn Forte 
1118*fcf3ce44SJohn Forte 	return (status);
1119*fcf3ce44SJohn Forte }
1120*fcf3ce44SJohn Forte 
1121*fcf3ce44SJohn Forte static void
sdbc_lru_wfini(mdb_walk_state_t * wsp)1122*fcf3ce44SJohn Forte sdbc_lru_wfini(mdb_walk_state_t *wsp)
1123*fcf3ce44SJohn Forte {
1124*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1125*fcf3ce44SJohn Forte }
1126*fcf3ce44SJohn Forte 
1127*fcf3ce44SJohn Forte 
1128*fcf3ce44SJohn Forte #ifdef SAFESTORE
1129*fcf3ce44SJohn Forte /*
1130*fcf3ce44SJohn Forte  * walk the array of allocated write control structures
1131*fcf3ce44SJohn Forte  */
1132*fcf3ce44SJohn Forte 
1133*fcf3ce44SJohn Forte static int
sdbc_wctl_winit(mdb_walk_state_t * wsp)1134*fcf3ce44SJohn Forte sdbc_wctl_winit(mdb_walk_state_t *wsp)
1135*fcf3ce44SJohn Forte {
1136*fcf3ce44SJohn Forte 	_sd_net_t  _sd_net_config;
1137*fcf3ce44SJohn Forte 	_sd_writeq_t wrq;
1138*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1139*fcf3ce44SJohn Forte 	int blk_shft;
1140*fcf3ce44SJohn Forte 	int count;
1141*fcf3ce44SJohn Forte 
1142*fcf3ce44SJohn Forte 
1143*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1144*fcf3ce44SJohn Forte 
1145*fcf3ce44SJohn Forte 	/* need to calculate the end of the array */
1146*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_net_config, "_sd_net_config") == -1) {
1147*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_net_config structure");
1148*fcf3ce44SJohn Forte 		return (WALK_ERR);
1149*fcf3ce44SJohn Forte 	}
1150*fcf3ce44SJohn Forte 
1151*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1152*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(_sd_net_config.sn_wr_cctl);
1153*fcf3ce44SJohn Forte 
1154*fcf3ce44SJohn Forte 	/*
1155*fcf3ce44SJohn Forte 	 * this module assumes 8k block size so this code can
1156*fcf3ce44SJohn Forte 	 * be commented out if necessary.
1157*fcf3ce44SJohn Forte 	 */
1158*fcf3ce44SJohn Forte 	if (mdb_readvar(&blk_shft, "_sd_cblock_shift") == -1) {
1159*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_cblock_shift."
1160*fcf3ce44SJohn Forte 			"assuming 8k cache block size");
1161*fcf3ce44SJohn Forte 		blk_shft = 13;
1162*fcf3ce44SJohn Forte 	}
1163*fcf3ce44SJohn Forte 
1164*fcf3ce44SJohn Forte 	count = (_sd_net_config.sn_wpages * _sd_net_config.sn_psize) /
1165*fcf3ce44SJohn Forte 						    (1 << blk_shft);
1166*fcf3ce44SJohn Forte 
1167*fcf3ce44SJohn Forte 	winfo->w_end = (uintptr_t)(_sd_net_config.sn_wr_cctl + count);
1168*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1169*fcf3ce44SJohn Forte 
1170*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1171*fcf3ce44SJohn Forte }
1172*fcf3ce44SJohn Forte 
1173*fcf3ce44SJohn Forte static int
sdbc_wctl_wstep(mdb_walk_state_t * wsp)1174*fcf3ce44SJohn Forte sdbc_wctl_wstep(mdb_walk_state_t *wsp)
1175*fcf3ce44SJohn Forte {
1176*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1177*fcf3ce44SJohn Forte 	int status;
1178*fcf3ce44SJohn Forte 
1179*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1180*fcf3ce44SJohn Forte 		return (WALK_DONE);
1181*fcf3ce44SJohn Forte 
1182*fcf3ce44SJohn Forte 	if (wsp->walk_addr >= winfo->w_end)
1183*fcf3ce44SJohn Forte 		return (WALK_DONE);
1184*fcf3ce44SJohn Forte 
1185*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1186*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1187*fcf3ce44SJohn Forte 
1188*fcf3ce44SJohn Forte 	wsp->walk_addr += sizeof (_sd_wr_cctl_t);
1189*fcf3ce44SJohn Forte 
1190*fcf3ce44SJohn Forte 	return (status);
1191*fcf3ce44SJohn Forte 
1192*fcf3ce44SJohn Forte }
1193*fcf3ce44SJohn Forte 
1194*fcf3ce44SJohn Forte static void
sdbc_wctl_wfini(mdb_walk_state_t * wsp)1195*fcf3ce44SJohn Forte sdbc_wctl_wfini(mdb_walk_state_t *wsp)
1196*fcf3ce44SJohn Forte {
1197*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1198*fcf3ce44SJohn Forte }
1199*fcf3ce44SJohn Forte 
1200*fcf3ce44SJohn Forte /*
1201*fcf3ce44SJohn Forte  * walk the queue (free list) of write control structures
1202*fcf3ce44SJohn Forte  */
1203*fcf3ce44SJohn Forte 
1204*fcf3ce44SJohn Forte static int
sdbc_wrq_winit(mdb_walk_state_t * wsp)1205*fcf3ce44SJohn Forte sdbc_wrq_winit(mdb_walk_state_t *wsp)
1206*fcf3ce44SJohn Forte {
1207*fcf3ce44SJohn Forte 	_sd_net_t  _sd_net_config;
1208*fcf3ce44SJohn Forte 	_sd_writeq_t wrq;
1209*fcf3ce44SJohn Forte 
1210*fcf3ce44SJohn Forte 	/* if called without an address, start at the head of the queue */
1211*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) {
1212*fcf3ce44SJohn Forte 
1213*fcf3ce44SJohn Forte 		if (mdb_readvar(&_sd_net_config, "_sd_net_config") == -1) {
1214*fcf3ce44SJohn Forte 			mdb_warn("failed to read _sd_net_config structure");
1215*fcf3ce44SJohn Forte 			return (WALK_ERR);
1216*fcf3ce44SJohn Forte 		}
1217*fcf3ce44SJohn Forte 
1218*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)
1219*fcf3ce44SJohn Forte 					(_sd_net_config.sn_wr_queue.wq_qtop);
1220*fcf3ce44SJohn Forte 	}
1221*fcf3ce44SJohn Forte 
1222*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1223*fcf3ce44SJohn Forte }
1224*fcf3ce44SJohn Forte 
1225*fcf3ce44SJohn Forte static int
sdbc_wrq_wstep(mdb_walk_state_t * wsp)1226*fcf3ce44SJohn Forte sdbc_wrq_wstep(mdb_walk_state_t *wsp)
1227*fcf3ce44SJohn Forte {
1228*fcf3ce44SJohn Forte 	_sd_wr_cctl_t wctl;
1229*fcf3ce44SJohn Forte 	int status;
1230*fcf3ce44SJohn Forte 
1231*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1232*fcf3ce44SJohn Forte 		return (WALK_DONE);
1233*fcf3ce44SJohn Forte 
1234*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1235*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1236*fcf3ce44SJohn Forte 
1237*fcf3ce44SJohn Forte 	if (mdb_vread(&wctl, sizeof (_sd_wr_cctl_t), wsp->walk_addr)
1238*fcf3ce44SJohn Forte 				== -1) {
1239*fcf3ce44SJohn Forte 		mdb_warn("sdbc_cchain_wstep failed to read wctl at %p",
1240*fcf3ce44SJohn Forte 			wsp->walk_addr);
1241*fcf3ce44SJohn Forte 		return (WALK_ERR);
1242*fcf3ce44SJohn Forte 	}
1243*fcf3ce44SJohn Forte 
1244*fcf3ce44SJohn Forte 	/* special case -- mini-DSP fake wr_cctl */
1245*fcf3ce44SJohn Forte 	if (wsp->walk_addr == (uintptr_t)wctl.wc_next)
1246*fcf3ce44SJohn Forte 		return (WALK_DONE);
1247*fcf3ce44SJohn Forte 
1248*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)(wctl.wc_next);
1249*fcf3ce44SJohn Forte 
1250*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1251*fcf3ce44SJohn Forte }
1252*fcf3ce44SJohn Forte 
1253*fcf3ce44SJohn Forte static void
sdbc_wrq_wfini(mdb_walk_state_t * wsp)1254*fcf3ce44SJohn Forte sdbc_wrq_wfini(mdb_walk_state_t *wsp)
1255*fcf3ce44SJohn Forte {
1256*fcf3ce44SJohn Forte }
1257*fcf3ce44SJohn Forte #endif /* SAFESTORE */
1258*fcf3ce44SJohn Forte /*
1259*fcf3ce44SJohn Forte  * walk the _sd_cache_files array of cd_info structures
1260*fcf3ce44SJohn Forte  */
1261*fcf3ce44SJohn Forte static int
sdbc_cdinfo_winit(mdb_walk_state_t * wsp)1262*fcf3ce44SJohn Forte sdbc_cdinfo_winit(mdb_walk_state_t *wsp)
1263*fcf3ce44SJohn Forte {
1264*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1265*fcf3ce44SJohn Forte 	_sd_cd_info_t	*_sd_cache_files_addr;
1266*fcf3ce44SJohn Forte 	int maxdevs;
1267*fcf3ce44SJohn Forte 
1268*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1269*fcf3ce44SJohn Forte 
1270*fcf3ce44SJohn Forte 
1271*fcf3ce44SJohn Forte 	/* get the address of the cdinfo table */
1272*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_cache_files_addr, "_sd_cache_files") == -1) {
1273*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_cache_files address\n");
1274*fcf3ce44SJohn Forte 		return (WALK_ERR);
1275*fcf3ce44SJohn Forte 	}
1276*fcf3ce44SJohn Forte 
1277*fcf3ce44SJohn Forte 	/* if called without an address, start at the head of the queue */
1278*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL) {
1279*fcf3ce44SJohn Forte 		/* address of first _sd_cd_info_t */
1280*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(_sd_cache_files_addr);
1281*fcf3ce44SJohn Forte 	}
1282*fcf3ce44SJohn Forte 
1283*fcf3ce44SJohn Forte 	/* get the number of volumes */
1284*fcf3ce44SJohn Forte 	if (mdb_readvar(&maxdevs, "sdbc_max_devs") == -1) {
1285*fcf3ce44SJohn Forte 		mdb_warn("failed to read  sdbc_max_devs");
1286*fcf3ce44SJohn Forte 		return (WALK_ERR);
1287*fcf3ce44SJohn Forte 	}
1288*fcf3ce44SJohn Forte 
1289*fcf3ce44SJohn Forte 	winfo->w_end = (uintptr_t)(_sd_cache_files_addr + maxdevs);
1290*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1291*fcf3ce44SJohn Forte 
1292*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1293*fcf3ce44SJohn Forte }
1294*fcf3ce44SJohn Forte 
1295*fcf3ce44SJohn Forte static int
sdbc_cdinfo_wstep(mdb_walk_state_t * wsp)1296*fcf3ce44SJohn Forte sdbc_cdinfo_wstep(mdb_walk_state_t *wsp)
1297*fcf3ce44SJohn Forte {
1298*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1299*fcf3ce44SJohn Forte 	int status;
1300*fcf3ce44SJohn Forte 
1301*fcf3ce44SJohn Forte 	if (wsp->walk_addr >= winfo->w_end)
1302*fcf3ce44SJohn Forte 		return (WALK_DONE);
1303*fcf3ce44SJohn Forte 
1304*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1305*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1306*fcf3ce44SJohn Forte 
1307*fcf3ce44SJohn Forte 	wsp->walk_addr += sizeof (_sd_cd_info_t);
1308*fcf3ce44SJohn Forte 
1309*fcf3ce44SJohn Forte 	return (status);
1310*fcf3ce44SJohn Forte }
1311*fcf3ce44SJohn Forte 
1312*fcf3ce44SJohn Forte static void
sdbc_cdinfo_wfini(mdb_walk_state_t * wsp)1313*fcf3ce44SJohn Forte sdbc_cdinfo_wfini(mdb_walk_state_t *wsp)
1314*fcf3ce44SJohn Forte {
1315*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1316*fcf3ce44SJohn Forte }
1317*fcf3ce44SJohn Forte 
1318*fcf3ce44SJohn Forte #ifdef SAFESTORE
1319*fcf3ce44SJohn Forte /*
1320*fcf3ce44SJohn Forte  * walk the array of allocated fault tolerant control structures
1321*fcf3ce44SJohn Forte  */
1322*fcf3ce44SJohn Forte static int
sdbc_ftctl_winit(mdb_walk_state_t * wsp)1323*fcf3ce44SJohn Forte sdbc_ftctl_winit(mdb_walk_state_t *wsp)
1324*fcf3ce44SJohn Forte {
1325*fcf3ce44SJohn Forte 	_sd_net_t  _sd_net_config;
1326*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1327*fcf3ce44SJohn Forte 	int blk_shft = 13; /* 8k default */
1328*fcf3ce44SJohn Forte 	int count;
1329*fcf3ce44SJohn Forte 
1330*fcf3ce44SJohn Forte 
1331*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1332*fcf3ce44SJohn Forte 
1333*fcf3ce44SJohn Forte 	/* need to calculate the end of the array */
1334*fcf3ce44SJohn Forte 	if (mdb_readvar(&_sd_net_config, "_sd_net_config") == -1) {
1335*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_net_config structure");
1336*fcf3ce44SJohn Forte 		return (WALK_ERR);
1337*fcf3ce44SJohn Forte 	}
1338*fcf3ce44SJohn Forte 
1339*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1340*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(_sd_net_config.sn_ft_cctl);
1341*fcf3ce44SJohn Forte 
1342*fcf3ce44SJohn Forte 	/*
1343*fcf3ce44SJohn Forte 	 * this module assumes 8k block size so this code can
1344*fcf3ce44SJohn Forte 	 * be commented out if necessary.
1345*fcf3ce44SJohn Forte 	 */
1346*fcf3ce44SJohn Forte 	if (mdb_readvar(&blk_shft, "_sd_cblock_shift") == -1) {
1347*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_cblock_shift."
1348*fcf3ce44SJohn Forte 			"assuming 8k cache block size");
1349*fcf3ce44SJohn Forte 		blk_shft = 13;
1350*fcf3ce44SJohn Forte 	}
1351*fcf3ce44SJohn Forte 
1352*fcf3ce44SJohn Forte 	count = (_sd_net_config.sn_wpages * _sd_net_config.sn_psize) /
1353*fcf3ce44SJohn Forte 						    (1 << blk_shft);
1354*fcf3ce44SJohn Forte 
1355*fcf3ce44SJohn Forte 	winfo->w_end = (uintptr_t)(_sd_net_config.sn_ft_cctl + count);
1356*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1357*fcf3ce44SJohn Forte 
1358*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1359*fcf3ce44SJohn Forte }
1360*fcf3ce44SJohn Forte 
1361*fcf3ce44SJohn Forte static int
sdbc_ftctl_wstep(mdb_walk_state_t * wsp)1362*fcf3ce44SJohn Forte sdbc_ftctl_wstep(mdb_walk_state_t *wsp)
1363*fcf3ce44SJohn Forte {
1364*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1365*fcf3ce44SJohn Forte 	int status;
1366*fcf3ce44SJohn Forte 
1367*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1368*fcf3ce44SJohn Forte 		return (WALK_DONE);
1369*fcf3ce44SJohn Forte 
1370*fcf3ce44SJohn Forte 	if (wsp->walk_addr >= winfo->w_end)
1371*fcf3ce44SJohn Forte 		return (WALK_DONE);
1372*fcf3ce44SJohn Forte 
1373*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1374*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1375*fcf3ce44SJohn Forte 
1376*fcf3ce44SJohn Forte 	wsp->walk_addr += sizeof (_sd_ft_cctl_t);
1377*fcf3ce44SJohn Forte 
1378*fcf3ce44SJohn Forte 	return (status);
1379*fcf3ce44SJohn Forte }
1380*fcf3ce44SJohn Forte 
1381*fcf3ce44SJohn Forte static void
sdbc_ftctl_wfini(mdb_walk_state_t * wsp)1382*fcf3ce44SJohn Forte sdbc_ftctl_wfini(mdb_walk_state_t *wsp)
1383*fcf3ce44SJohn Forte {
1384*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1385*fcf3ce44SJohn Forte }
1386*fcf3ce44SJohn Forte #endif /* SAFESTORE */
1387*fcf3ce44SJohn Forte 
1388*fcf3ce44SJohn Forte /*
1389*fcf3ce44SJohn Forte  * walk the handle list
1390*fcf3ce44SJohn Forte  */
1391*fcf3ce44SJohn Forte static int
sdbc_handle_winit(mdb_walk_state_t * wsp)1392*fcf3ce44SJohn Forte sdbc_handle_winit(mdb_walk_state_t *wsp)
1393*fcf3ce44SJohn Forte {
1394*fcf3ce44SJohn Forte 	_sd_buf_hlist_t hl;
1395*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1396*fcf3ce44SJohn Forte 	GElf_Sym sym;
1397*fcf3ce44SJohn Forte 
1398*fcf3ce44SJohn Forte 	if (mdb_readvar(&hl, "_sd_handle_list") == -1) {
1399*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_handle_list structure");
1400*fcf3ce44SJohn Forte 		return (WALK_ERR);
1401*fcf3ce44SJohn Forte 	}
1402*fcf3ce44SJohn Forte 
1403*fcf3ce44SJohn Forte 	if (mdb_lookup_by_obj("sdbc", "_sd_handle_list", &sym) == -1) {
1404*fcf3ce44SJohn Forte 		mdb_warn("failed to lookup _sd_handle_list symbol");
1405*fcf3ce44SJohn Forte 		return (WALK_ERR);
1406*fcf3ce44SJohn Forte 	}
1407*fcf3ce44SJohn Forte 
1408*fcf3ce44SJohn Forte 	/* if called without an address, start at first element in list */
1409*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1410*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(hl.hl_top.bh_next);
1411*fcf3ce44SJohn Forte 
1412*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1413*fcf3ce44SJohn Forte 
1414*fcf3ce44SJohn Forte 	winfo->w_end = (uintptr_t)(sym.st_value); /* &_sd_handle_list.hl_top */
1415*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1416*fcf3ce44SJohn Forte 
1417*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1418*fcf3ce44SJohn Forte }
1419*fcf3ce44SJohn Forte 
1420*fcf3ce44SJohn Forte static int
sdbc_handle_wstep(mdb_walk_state_t * wsp)1421*fcf3ce44SJohn Forte sdbc_handle_wstep(mdb_walk_state_t *wsp)
1422*fcf3ce44SJohn Forte {
1423*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1424*fcf3ce44SJohn Forte 	_sd_buf_handle_t handle;
1425*fcf3ce44SJohn Forte 	int status;
1426*fcf3ce44SJohn Forte 
1427*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1428*fcf3ce44SJohn Forte 		return (WALK_DONE);
1429*fcf3ce44SJohn Forte 
1430*fcf3ce44SJohn Forte 	if (wsp->walk_addr == winfo->w_end)
1431*fcf3ce44SJohn Forte 		return (WALK_DONE);
1432*fcf3ce44SJohn Forte 
1433*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1434*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1435*fcf3ce44SJohn Forte 
1436*fcf3ce44SJohn Forte 	if (mdb_vread(&handle, sizeof (_sd_buf_handle_t), wsp->walk_addr)
1437*fcf3ce44SJohn Forte 								== -1) {
1438*fcf3ce44SJohn Forte 		mdb_warn("failed to read handle at %p", wsp->walk_addr);
1439*fcf3ce44SJohn Forte 		return (WALK_ERR);
1440*fcf3ce44SJohn Forte 	}
1441*fcf3ce44SJohn Forte 
1442*fcf3ce44SJohn Forte 	wsp->walk_addr = (uintptr_t)(handle.bh_next);
1443*fcf3ce44SJohn Forte 
1444*fcf3ce44SJohn Forte 	return (status);
1445*fcf3ce44SJohn Forte }
1446*fcf3ce44SJohn Forte 
1447*fcf3ce44SJohn Forte static void
sdbc_handle_wfini(mdb_walk_state_t * wsp)1448*fcf3ce44SJohn Forte sdbc_handle_wfini(mdb_walk_state_t *wsp)
1449*fcf3ce44SJohn Forte {
1450*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1451*fcf3ce44SJohn Forte }
1452*fcf3ce44SJohn Forte 
1453*fcf3ce44SJohn Forte /*
1454*fcf3ce44SJohn Forte  * walk the global info array (dirty bits)
1455*fcf3ce44SJohn Forte  */
1456*fcf3ce44SJohn Forte 
1457*fcf3ce44SJohn Forte static int
sdbc_glcinfo_winit(mdb_walk_state_t * wsp)1458*fcf3ce44SJohn Forte sdbc_glcinfo_winit(mdb_walk_state_t *wsp)
1459*fcf3ce44SJohn Forte {
1460*fcf3ce44SJohn Forte 	ss_centry_info_t *gl_centry_info;
1461*fcf3ce44SJohn Forte 	size_t gl_centry_info_size;
1462*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1463*fcf3ce44SJohn Forte 
1464*fcf3ce44SJohn Forte 
1465*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1466*fcf3ce44SJohn Forte 
1467*fcf3ce44SJohn Forte 	/* get start of the cache entry metadata */
1468*fcf3ce44SJohn Forte 	if (mdb_readvar(&gl_centry_info, "_sdbc_gl_centry_info") == -1) {
1469*fcf3ce44SJohn Forte 		mdb_warn("failed to read  _sdbc_gl_centry_info");
1470*fcf3ce44SJohn Forte 		return (WALK_ERR);
1471*fcf3ce44SJohn Forte 	}
1472*fcf3ce44SJohn Forte 
1473*fcf3ce44SJohn Forte 	/* need to calculate the end of the array */
1474*fcf3ce44SJohn Forte 	if (mdb_readvar(&gl_centry_info_size,
1475*fcf3ce44SJohn Forte 				"_sdbc_gl_centry_info_size") == -1) {
1476*fcf3ce44SJohn Forte 		mdb_warn("failed to read  _sdbc_gl_centry_info_size");
1477*fcf3ce44SJohn Forte 		return (WALK_ERR);
1478*fcf3ce44SJohn Forte 	}
1479*fcf3ce44SJohn Forte 
1480*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1481*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(gl_centry_info);
1482*fcf3ce44SJohn Forte 
1483*fcf3ce44SJohn Forte 
1484*fcf3ce44SJohn Forte 
1485*fcf3ce44SJohn Forte 	winfo->w_end = ((uintptr_t)(gl_centry_info)) + gl_centry_info_size;
1486*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1487*fcf3ce44SJohn Forte 
1488*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1489*fcf3ce44SJohn Forte }
1490*fcf3ce44SJohn Forte 
1491*fcf3ce44SJohn Forte static int
sdbc_glcinfo_wstep(mdb_walk_state_t * wsp)1492*fcf3ce44SJohn Forte sdbc_glcinfo_wstep(mdb_walk_state_t *wsp)
1493*fcf3ce44SJohn Forte {
1494*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1495*fcf3ce44SJohn Forte 	int status;
1496*fcf3ce44SJohn Forte 
1497*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1498*fcf3ce44SJohn Forte 		return (WALK_DONE);
1499*fcf3ce44SJohn Forte 
1500*fcf3ce44SJohn Forte 	if (wsp->walk_addr >= winfo->w_end)
1501*fcf3ce44SJohn Forte 		return (WALK_DONE);
1502*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1503*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1504*fcf3ce44SJohn Forte 
1505*fcf3ce44SJohn Forte 	wsp->walk_addr += sizeof (ss_centry_info_t);
1506*fcf3ce44SJohn Forte 
1507*fcf3ce44SJohn Forte 	return (status);
1508*fcf3ce44SJohn Forte }
1509*fcf3ce44SJohn Forte 
1510*fcf3ce44SJohn Forte static void
sdbc_glcinfo_wfini(mdb_walk_state_t * wsp)1511*fcf3ce44SJohn Forte sdbc_glcinfo_wfini(mdb_walk_state_t *wsp)
1512*fcf3ce44SJohn Forte {
1513*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1514*fcf3ce44SJohn Forte }
1515*fcf3ce44SJohn Forte 
1516*fcf3ce44SJohn Forte /*
1517*fcf3ce44SJohn Forte  * walk the global file info array
1518*fcf3ce44SJohn Forte  */
1519*fcf3ce44SJohn Forte static int
sdbc_glfinfo_winit(mdb_walk_state_t * wsp)1520*fcf3ce44SJohn Forte sdbc_glfinfo_winit(mdb_walk_state_t *wsp)
1521*fcf3ce44SJohn Forte {
1522*fcf3ce44SJohn Forte 	ss_voldata_t *gl_file_info;
1523*fcf3ce44SJohn Forte 	struct walk_info *winfo;
1524*fcf3ce44SJohn Forte 	int maxdevs;
1525*fcf3ce44SJohn Forte 
1526*fcf3ce44SJohn Forte 
1527*fcf3ce44SJohn Forte 	winfo = mdb_zalloc(sizeof (struct walk_info), UM_SLEEP);
1528*fcf3ce44SJohn Forte 
1529*fcf3ce44SJohn Forte 	/* get start of the cache entry metadata */
1530*fcf3ce44SJohn Forte 	if (mdb_readvar(&gl_file_info, "_sdbc_gl_file_info") == -1) {
1531*fcf3ce44SJohn Forte 		mdb_warn("failed to read  _sdbc_gl_file_info");
1532*fcf3ce44SJohn Forte 		return (WALK_ERR);
1533*fcf3ce44SJohn Forte 	}
1534*fcf3ce44SJohn Forte 
1535*fcf3ce44SJohn Forte 
1536*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1537*fcf3ce44SJohn Forte 		wsp->walk_addr = (uintptr_t)(gl_file_info);
1538*fcf3ce44SJohn Forte 
1539*fcf3ce44SJohn Forte 	/* get the number of volumes */
1540*fcf3ce44SJohn Forte 	if (mdb_readvar(&maxdevs, "sdbc_max_devs") == -1) {
1541*fcf3ce44SJohn Forte 		mdb_warn("failed to read  sdbc_max_devs");
1542*fcf3ce44SJohn Forte 		return (WALK_ERR);
1543*fcf3ce44SJohn Forte 	}
1544*fcf3ce44SJohn Forte 
1545*fcf3ce44SJohn Forte 	/* end of the array */
1546*fcf3ce44SJohn Forte 	winfo->w_end = (uintptr_t)((gl_file_info) + maxdevs);
1547*fcf3ce44SJohn Forte 
1548*fcf3ce44SJohn Forte 	wsp->walk_data = winfo;
1549*fcf3ce44SJohn Forte 
1550*fcf3ce44SJohn Forte 	return (WALK_NEXT);
1551*fcf3ce44SJohn Forte }
1552*fcf3ce44SJohn Forte 
1553*fcf3ce44SJohn Forte static int
sdbc_glfinfo_wstep(mdb_walk_state_t * wsp)1554*fcf3ce44SJohn Forte sdbc_glfinfo_wstep(mdb_walk_state_t *wsp)
1555*fcf3ce44SJohn Forte {
1556*fcf3ce44SJohn Forte 	struct walk_info *winfo = wsp->walk_data;
1557*fcf3ce44SJohn Forte 	int status;
1558*fcf3ce44SJohn Forte 
1559*fcf3ce44SJohn Forte 	if (wsp->walk_addr == NULL)
1560*fcf3ce44SJohn Forte 		return (WALK_DONE);
1561*fcf3ce44SJohn Forte 
1562*fcf3ce44SJohn Forte 	if (wsp->walk_addr >= winfo->w_end)
1563*fcf3ce44SJohn Forte 		return (WALK_DONE);
1564*fcf3ce44SJohn Forte 
1565*fcf3ce44SJohn Forte 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
1566*fcf3ce44SJohn Forte 						wsp->walk_cbdata);
1567*fcf3ce44SJohn Forte 
1568*fcf3ce44SJohn Forte 	wsp->walk_addr += sizeof (ss_voldata_t);
1569*fcf3ce44SJohn Forte 
1570*fcf3ce44SJohn Forte 	return (status);
1571*fcf3ce44SJohn Forte 
1572*fcf3ce44SJohn Forte }
1573*fcf3ce44SJohn Forte 
1574*fcf3ce44SJohn Forte static void
sdbc_glfinfo_wfini(mdb_walk_state_t * wsp)1575*fcf3ce44SJohn Forte sdbc_glfinfo_wfini(mdb_walk_state_t *wsp)
1576*fcf3ce44SJohn Forte {
1577*fcf3ce44SJohn Forte 	mdb_free(wsp->walk_data, sizeof (struct walk_info));
1578*fcf3ce44SJohn Forte }
1579*fcf3ce44SJohn Forte 
1580*fcf3ce44SJohn Forte /* end of WALKERS section */
1581*fcf3ce44SJohn Forte 
1582*fcf3ce44SJohn Forte 
1583*fcf3ce44SJohn Forte const mdb_bitmask_t cc_flag_bits[] = {
1584*fcf3ce44SJohn Forte 	{"PEND_DIRTY", CC_PEND_DIRTY, CC_PEND_DIRTY},
1585*fcf3ce44SJohn Forte 	{"PINNED", CC_PINNED, CC_PINNED},
1586*fcf3ce44SJohn Forte 	{"PINNABLE", CC_PINNABLE, CC_PINNABLE},
1587*fcf3ce44SJohn Forte 	{"QHEAD", CC_QHEAD, CC_QHEAD},
1588*fcf3ce44SJohn Forte 	{NULL, 0, 0}
1589*fcf3ce44SJohn Forte };
1590*fcf3ce44SJohn Forte 
1591*fcf3ce44SJohn Forte const mdb_bitmask_t io_status_bits[] = {
1592*fcf3ce44SJohn Forte 	{"IO_NONE", 0xff, _SD_IO_NONE},
1593*fcf3ce44SJohn Forte 	{"IO_INITIATE", 0xff, _SD_IO_INITIATE},
1594*fcf3ce44SJohn Forte 	{"IO_DONE", 0xff, _SD_IO_DONE},
1595*fcf3ce44SJohn Forte 	{"IO_FAILED", 0xff, _SD_IO_FAILED},
1596*fcf3ce44SJohn Forte 	{"IO_DISCARDED", 0xff, _SD_IO_DISCARDED},
1597*fcf3ce44SJohn Forte 	{NULL, 0, 0}
1598*fcf3ce44SJohn Forte };
1599*fcf3ce44SJohn Forte 
1600*fcf3ce44SJohn Forte const mdb_bitmask_t cc_aging_bits[] = {
1601*fcf3ce44SJohn Forte 	{"FOUND_IN_HASH", FOUND_IN_HASH_DM, FOUND_IN_HASH_DM},
1602*fcf3ce44SJohn Forte 	{"FOUND_HOLD_OVER", FOUND_HOLD_OVER_DM, FOUND_HOLD_OVER_DM},
1603*fcf3ce44SJohn Forte 	{"HOST_ENTRY", HOST_ENTRY_DM, HOST_ENTRY_DM},
1604*fcf3ce44SJohn Forte 	{"PARASITIC_ENTRY", PARASITIC_ENTRY_DM, PARASITIC_ENTRY_DM},
1605*fcf3ce44SJohn Forte 	{"STICKY_METADATA", STICKY_METADATA_DM, STICKY_METADATA_DM},
1606*fcf3ce44SJohn Forte 	{"ELIGIBLE_ENTRY", ELIGIBLE_ENTRY_DM, ELIGIBLE_ENTRY_DM},
1607*fcf3ce44SJohn Forte 	{"HASH_ENTRY", HASH_ENTRY_DM, HASH_ENTRY_DM},
1608*fcf3ce44SJohn Forte 	{"HOLD_ENTRY", HOLD_ENTRY_DM, HOLD_ENTRY_DM},
1609*fcf3ce44SJohn Forte 	{"AVAIL_ENTRY", AVAIL_ENTRY_DM, AVAIL_ENTRY_DM},
1610*fcf3ce44SJohn Forte 	{"BAD_CHAIN", BAD_CHAIN_DM, BAD_CHAIN_DM},
1611*fcf3ce44SJohn Forte 	{"BAD_ENTRY", BAD_ENTRY_DM, BAD_ENTRY_DM},
1612*fcf3ce44SJohn Forte 	{"PREFETCH_I", PREFETCH_BUF_I, PREFETCH_BUF_I},
1613*fcf3ce44SJohn Forte 	{"PREFETCH_E", PREFETCH_BUF_E, PREFETCH_BUF_E},
1614*fcf3ce44SJohn Forte 	{NULL, 0, 0}
1615*fcf3ce44SJohn Forte };
1616*fcf3ce44SJohn Forte 
1617*fcf3ce44SJohn Forte 
1618*fcf3ce44SJohn Forte /* DCMDS that use walkers */
1619*fcf3ce44SJohn Forte 
1620*fcf3ce44SJohn Forte /*
1621*fcf3ce44SJohn Forte  * dcmd to display cache entry control structures
1622*fcf3ce44SJohn Forte  */
1623*fcf3ce44SJohn Forte static int
sdbc_cctl(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1624*fcf3ce44SJohn Forte sdbc_cctl(uintptr_t addr, uint_t flags, int argc,
1625*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
1626*fcf3ce44SJohn Forte {
1627*fcf3ce44SJohn Forte 	uint_t opt_a = FALSE;
1628*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;    /* cd */
1629*fcf3ce44SJohn Forte 	uintptr_t opt_b = MDB_BLKNUM;    /* block num */
1630*fcf3ce44SJohn Forte 	uint_t opt_B = FALSE;    /* BAD CHAIN or ENTRY */
1631*fcf3ce44SJohn Forte 	uint_t opt_d = FALSE;    /* dirty */
1632*fcf3ce44SJohn Forte 	uint_t opt_H = FALSE;    /* HOST */
1633*fcf3ce44SJohn Forte 	uint_t opt_h = FALSE;    /* hashed */
1634*fcf3ce44SJohn Forte 	uint_t opt_i = FALSE;    /* inuse */
1635*fcf3ce44SJohn Forte 	uint_t opt_p = FALSE;    /* pageio */
1636*fcf3ce44SJohn Forte 	uint_t opt_P = FALSE;    /* PARASITE */
1637*fcf3ce44SJohn Forte 	uint_t opt_R = FALSE;    /* explicit read-ahead (prefetch) */
1638*fcf3ce44SJohn Forte 	uint_t opt_r = FALSE;    /* implicit read-ahead (prefetch) */
1639*fcf3ce44SJohn Forte 	uint_t opt_o = FALSE;    /* io in progress */
1640*fcf3ce44SJohn Forte 	uint_t opt_m = FALSE;	 /* has memory allocated */
1641*fcf3ce44SJohn Forte 	uint_t opt_V = FALSE;    /* valid bits */
1642*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;    /* verbose */
1643*fcf3ce44SJohn Forte 	uint_t nofilter = FALSE; /* true if b, d, h, i, o, p, V are all false */
1644*fcf3ce44SJohn Forte 	_sd_cctl_t centry;
1645*fcf3ce44SJohn Forte 	_sd_cctl_sync_t cc_sync;
1646*fcf3ce44SJohn Forte 
1647*fcf3ce44SJohn Forte 	/*
1648*fcf3ce44SJohn Forte 	 * possible enhancements -- option to filter on flag bits
1649*fcf3ce44SJohn Forte 	 * option that toggles other options.
1650*fcf3ce44SJohn Forte 	 */
1651*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
1652*fcf3ce44SJohn Forte 			'a', MDB_OPT_SETBITS, TRUE, &opt_a,
1653*fcf3ce44SJohn Forte 			'B', MDB_OPT_SETBITS, TRUE, &opt_B,
1654*fcf3ce44SJohn Forte 			'b', MDB_OPT_UINTPTR, &opt_b,
1655*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
1656*fcf3ce44SJohn Forte 			'd', MDB_OPT_SETBITS, TRUE, &opt_d,
1657*fcf3ce44SJohn Forte 			'H', MDB_OPT_SETBITS, TRUE, &opt_H,
1658*fcf3ce44SJohn Forte 			'h', MDB_OPT_SETBITS, TRUE, &opt_h,
1659*fcf3ce44SJohn Forte 			'i', MDB_OPT_SETBITS, TRUE, &opt_i,
1660*fcf3ce44SJohn Forte 			'o', MDB_OPT_SETBITS, TRUE, &opt_o,
1661*fcf3ce44SJohn Forte 			'm', MDB_OPT_SETBITS, TRUE, &opt_m,
1662*fcf3ce44SJohn Forte 			'P', MDB_OPT_SETBITS, TRUE, &opt_P,
1663*fcf3ce44SJohn Forte 			'p', MDB_OPT_SETBITS, TRUE, &opt_p,
1664*fcf3ce44SJohn Forte 			'R', MDB_OPT_SETBITS, TRUE, &opt_R,
1665*fcf3ce44SJohn Forte 			'r', MDB_OPT_SETBITS, TRUE, &opt_r,
1666*fcf3ce44SJohn Forte 			'V', MDB_OPT_SETBITS, TRUE, &opt_V,
1667*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
1668*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1669*fcf3ce44SJohn Forte 
1670*fcf3ce44SJohn Forte 
1671*fcf3ce44SJohn Forte 	nofilter = (!OPT_B_SELECTED && !opt_d && !opt_h && !opt_i &&
1672*fcf3ce44SJohn Forte 			!opt_o && !opt_m && !opt_p && !opt_V && !opt_B &&
1673*fcf3ce44SJohn Forte 			!opt_P && !opt_H && !opt_R && !opt_r); /* no options */
1674*fcf3ce44SJohn Forte 
1675*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
1676*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_cctl", "sdbc`sdbc_cctl",
1677*fcf3ce44SJohn Forte 					argc, argv) == -1) {
1678*fcf3ce44SJohn Forte 			mdb_warn("failed to walk 'cctl' list");
1679*fcf3ce44SJohn Forte 			return (DCMD_ERR);
1680*fcf3ce44SJohn Forte 		}
1681*fcf3ce44SJohn Forte 		return (DCMD_OK);
1682*fcf3ce44SJohn Forte 	}
1683*fcf3ce44SJohn Forte 
1684*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
1685*fcf3ce44SJohn Forte 		mdb_printf("sdbc cache ctl structures:\n");
1686*fcf3ce44SJohn Forte 	}
1687*fcf3ce44SJohn Forte 
1688*fcf3ce44SJohn Forte 
1689*fcf3ce44SJohn Forte 	if (mdb_vread(&centry, sizeof (_sd_cctl_t), addr) == -1) {
1690*fcf3ce44SJohn Forte 		mdb_warn("dcmd failed to read centry at %p", addr);
1691*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1692*fcf3ce44SJohn Forte 	}
1693*fcf3ce44SJohn Forte 
1694*fcf3ce44SJohn Forte 	/* filter exclusively on a cd number if specified */
1695*fcf3ce44SJohn Forte 	if (OPT_C_SELECTED && (centry.cc_head.hh_cd != opt_c))
1696*fcf3ce44SJohn Forte 		return (DCMD_OK);
1697*fcf3ce44SJohn Forte 
1698*fcf3ce44SJohn Forte 	/* all other filters are inclusive */
1699*fcf3ce44SJohn Forte 	if ((nofilter) ||
1700*fcf3ce44SJohn Forte 		(OPT_B_SELECTED && (centry.cc_head.hh_blk_num == opt_b)) ||
1701*fcf3ce44SJohn Forte 		(opt_B && (centry.cc_aging_dm &
1702*fcf3ce44SJohn Forte 			(BAD_ENTRY_DM | BAD_CHAIN_DM))) ||
1703*fcf3ce44SJohn Forte 		(opt_d && (centry.cc_dirty)) ||
1704*fcf3ce44SJohn Forte 		(opt_H && (centry.cc_aging_dm & HOST_ENTRY_DM)) ||
1705*fcf3ce44SJohn Forte 		(opt_h && (centry.cc_head.hh_hashed)) ||
1706*fcf3ce44SJohn Forte 		(opt_i && (centry.cc_inuse)) ||
1707*fcf3ce44SJohn Forte 		(opt_p && (centry.cc_pageio)) ||
1708*fcf3ce44SJohn Forte 		(opt_P && (centry.cc_aging_dm & PARASITIC_ENTRY_DM)) ||
1709*fcf3ce44SJohn Forte 		(opt_R && (centry.cc_aging_dm & PREFETCH_BUF_E)) ||
1710*fcf3ce44SJohn Forte 		(opt_r && (centry.cc_aging_dm & PREFETCH_BUF_I)) ||
1711*fcf3ce44SJohn Forte 		(opt_V && (centry.cc_valid)) ||
1712*fcf3ce44SJohn Forte 		(opt_m && (centry.cc_alloc_size_dm)) ||
1713*fcf3ce44SJohn Forte 		(opt_o && (centry.cc_iostatus != _SD_IO_NONE)))
1714*fcf3ce44SJohn Forte 		/*EMPTY*/;
1715*fcf3ce44SJohn Forte 	else
1716*fcf3ce44SJohn Forte 		return (DCMD_OK);
1717*fcf3ce44SJohn Forte 
1718*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1719*fcf3ce44SJohn Forte 	mdb_printf(
1720*fcf3ce44SJohn Forte 	"%-?p cd %3-d blk_num %10-d valid %04hx dirty %04hx flag %02x\n",
1721*fcf3ce44SJohn Forte 			addr, centry.cc_head.hh_cd,
1722*fcf3ce44SJohn Forte 			centry.cc_head.hh_blk_num, centry.cc_valid,
1723*fcf3ce44SJohn Forte 			centry.cc_dirty, centry.cc_flag);
1724*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1725*fcf3ce44SJohn Forte 
1726*fcf3ce44SJohn Forte 	if (!opt_v)
1727*fcf3ce44SJohn Forte 		return (DCMD_OK);
1728*fcf3ce44SJohn Forte 
1729*fcf3ce44SJohn Forte 	/* verbose */
1730*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1731*fcf3ce44SJohn Forte 	mdb_printf(
1732*fcf3ce44SJohn Forte 	"hashed %d seq %4-d toflush %04hx %8Tawait_use %4-d await_page %4-d\n",
1733*fcf3ce44SJohn Forte 		centry.cc_head.hh_hashed, centry.cc_seq,
1734*fcf3ce44SJohn Forte 		centry.cc_toflush, centry.cc_await_use,
1735*fcf3ce44SJohn Forte 		centry.cc_await_page);
1736*fcf3ce44SJohn Forte 
1737*fcf3ce44SJohn Forte 	mdb_printf("inuse %d pageio %d cc_flag <%b>\n",
1738*fcf3ce44SJohn Forte 		centry.cc_inuse, centry.cc_pageio,
1739*fcf3ce44SJohn Forte 		centry.cc_flag, cc_flag_bits);
1740*fcf3ce44SJohn Forte 
1741*fcf3ce44SJohn Forte 	mdb_printf("iocount %2d iostatus <%b>\n",
1742*fcf3ce44SJohn Forte 		    centry.cc_iocount, centry.cc_iostatus, io_status_bits);
1743*fcf3ce44SJohn Forte 
1744*fcf3ce44SJohn Forte 	if (mdb_vread(&cc_sync, sizeof (struct _sd_cctl_sync),
1745*fcf3ce44SJohn Forte 					(uintptr_t)centry.cc_sync)
1746*fcf3ce44SJohn Forte 		== -1)
1747*fcf3ce44SJohn Forte 		mdb_warn("failed to read cc_sync"); /* not catastophic */
1748*fcf3ce44SJohn Forte 
1749*fcf3ce44SJohn Forte 	else
1750*fcf3ce44SJohn Forte 		mdb_printf("cc_sync blkcv: %h-x %8Tlock: 0x%p (owner)\n",
1751*fcf3ce44SJohn Forte 				cc_sync._cc_blkcv._opaque,
1752*fcf3ce44SJohn Forte 				cc_sync._cc_lock._opaque[0]);
1753*fcf3ce44SJohn Forte 
1754*fcf3ce44SJohn Forte 	mdb_printf("dynamic memory allocation:\n");
1755*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1756*fcf3ce44SJohn Forte 	mdb_printf("aging_dm age %3d %4Tage flags: <%b> 0x%x\n",
1757*fcf3ce44SJohn Forte 			centry.cc_aging_dm & 0xff,
1758*fcf3ce44SJohn Forte 			centry.cc_aging_dm, cc_aging_bits, centry.cc_aging_dm);
1759*fcf3ce44SJohn Forte 
1760*fcf3ce44SJohn Forte 	mdb_printf("alloc_size_dm %10-d head_dm %?-p\n",
1761*fcf3ce44SJohn Forte 		centry.cc_alloc_size_dm, centry.cc_head_dm);
1762*fcf3ce44SJohn Forte 	mdb_printf("next_dm %?-p link_list_dm %?-p\n",
1763*fcf3ce44SJohn Forte 		centry.cc_next_dm, centry.cc_link_list_dm);
1764*fcf3ce44SJohn Forte 
1765*fcf3ce44SJohn Forte 	mdb_printf("alloc_ct_dm %10-d dealloc_ct_dm %10-d\n",
1766*fcf3ce44SJohn Forte 		centry.cc_alloc_ct_dm, centry.cc_dealloc_ct_dm);
1767*fcf3ce44SJohn Forte 
1768*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1769*fcf3ce44SJohn Forte 	/* pointers */
1770*fcf3ce44SJohn Forte 	mdb_printf("cctl pointers:\n");
1771*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1772*fcf3ce44SJohn Forte 
1773*fcf3ce44SJohn Forte 	mdb_printf("next %?-p prev %?-p chain %?-p\n",
1774*fcf3ce44SJohn Forte 		centry.cc_next, centry.cc_prev, centry.cc_chain);
1775*fcf3ce44SJohn Forte 	mdb_printf("dirty_next %?-p dirty_link %?-p\n",
1776*fcf3ce44SJohn Forte 		centry.cc_dirty_next, centry.cc_dirty_link);
1777*fcf3ce44SJohn Forte 	mdb_printf("data %?-p write ctl %?-p\n",
1778*fcf3ce44SJohn Forte 		centry.cc_data, centry.cc_write);
1779*fcf3ce44SJohn Forte 
1780*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1781*fcf3ce44SJohn Forte 
1782*fcf3ce44SJohn Forte 	/* dynmem chain */
1783*fcf3ce44SJohn Forte 	mdb_printf("cctl dmqueue index cc_blocks %4-d\n", centry.cc_cblocks);
1784*fcf3ce44SJohn Forte 
1785*fcf3ce44SJohn Forte 	mdb_printf("anon_addr %?-p anon_len %8-d\n",
1786*fcf3ce44SJohn Forte 			centry.cc_anon_addr.sa_virt, centry.cc_anon_len);
1787*fcf3ce44SJohn Forte 
1788*fcf3ce44SJohn Forte 	/* stats */
1789*fcf3ce44SJohn Forte 	mdb_printf("cctl stats:	");
1790*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1791*fcf3ce44SJohn Forte 	mdb_printf("hits %8-d creat time %?-p\n", centry.cc_hits,
1792*fcf3ce44SJohn Forte 			centry.cc_creat);
1793*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1794*fcf3ce44SJohn Forte 
1795*fcf3ce44SJohn Forte 	mdb_printf("\n");
1796*fcf3ce44SJohn Forte 
1797*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1798*fcf3ce44SJohn Forte 
1799*fcf3ce44SJohn Forte 	return (DCMD_OK);
1800*fcf3ce44SJohn Forte }
1801*fcf3ce44SJohn Forte 
1802*fcf3ce44SJohn Forte 
1803*fcf3ce44SJohn Forte /*
1804*fcf3ce44SJohn Forte  * convenience dcmd to display the _sd_cctl cc_chain list (alloc list)
1805*fcf3ce44SJohn Forte  * Must be called with an address of a cache entry (_sd_cctl_t)
1806*fcf3ce44SJohn Forte  * same options as sdbc_cctl().
1807*fcf3ce44SJohn Forte  * alternatively the user can call the sdbc_cchain walker
1808*fcf3ce44SJohn Forte  * and pipe the addresses to sdbc_cctl dcmd.
1809*fcf3ce44SJohn Forte  */
1810*fcf3ce44SJohn Forte static int
sdbc_cchain(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1811*fcf3ce44SJohn Forte sdbc_cchain(uintptr_t addr, uint_t flags, int argc,
1812*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
1813*fcf3ce44SJohn Forte {
1814*fcf3ce44SJohn Forte 
1815*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
1816*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1817*fcf3ce44SJohn Forte 
1818*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_cchain", "sdbc`sdbc_cctl",
1819*fcf3ce44SJohn Forte 						argc, argv, addr)
1820*fcf3ce44SJohn Forte 			== -1) {
1821*fcf3ce44SJohn Forte 		mdb_warn("failed to walk cc_chain at addr %p", addr);
1822*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1823*fcf3ce44SJohn Forte 	}
1824*fcf3ce44SJohn Forte 
1825*fcf3ce44SJohn Forte 	return (DCMD_OK);
1826*fcf3ce44SJohn Forte }
1827*fcf3ce44SJohn Forte 
1828*fcf3ce44SJohn Forte 
1829*fcf3ce44SJohn Forte /*
1830*fcf3ce44SJohn Forte  * convenience dcmd to cdisplay the _sd_cctl dirty chain
1831*fcf3ce44SJohn Forte  * (which is really a 2d chain).
1832*fcf3ce44SJohn Forte  * Must be called with an address of a cache entry (_sd_cctl_t)
1833*fcf3ce44SJohn Forte  * same options as sdbc_cctl().
1834*fcf3ce44SJohn Forte  * alternatively the user can call the sdbc_dchain walker
1835*fcf3ce44SJohn Forte  * and pipe the addresses to sdbc_cctl dcmd.
1836*fcf3ce44SJohn Forte  */
1837*fcf3ce44SJohn Forte static int
sdbc_dchain(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1838*fcf3ce44SJohn Forte sdbc_dchain(uintptr_t addr, uint_t flags, int argc,
1839*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
1840*fcf3ce44SJohn Forte {
1841*fcf3ce44SJohn Forte 
1842*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
1843*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1844*fcf3ce44SJohn Forte 
1845*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_dchain", "sdbc`sdbc_cctl",
1846*fcf3ce44SJohn Forte 						argc, argv, addr)
1847*fcf3ce44SJohn Forte 			== -1) {
1848*fcf3ce44SJohn Forte 		mdb_warn("failed to walk dirty chain at addr %p", addr);
1849*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1850*fcf3ce44SJohn Forte 	}
1851*fcf3ce44SJohn Forte 
1852*fcf3ce44SJohn Forte 	return (DCMD_OK);
1853*fcf3ce44SJohn Forte }
1854*fcf3ce44SJohn Forte 
1855*fcf3ce44SJohn Forte /*
1856*fcf3ce44SJohn Forte  * convenience dcmd to display the _sd_cctl dm chain list
1857*fcf3ce44SJohn Forte  * Must be called with an address of a cache entry (_sd_cctl_t)
1858*fcf3ce44SJohn Forte  * same options as sdbc_cctl().
1859*fcf3ce44SJohn Forte  * alternatively the user can call the sdbc_dmchain walker
1860*fcf3ce44SJohn Forte  * and pipe the addresses to sdbc_cctl dcmd.
1861*fcf3ce44SJohn Forte  */
1862*fcf3ce44SJohn Forte static int
sdbc_dmchain(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1863*fcf3ce44SJohn Forte sdbc_dmchain(uintptr_t addr, uint_t flags, int argc,
1864*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
1865*fcf3ce44SJohn Forte {
1866*fcf3ce44SJohn Forte 
1867*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
1868*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1869*fcf3ce44SJohn Forte 
1870*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_dmchain", "sdbc`sdbc_cctl",
1871*fcf3ce44SJohn Forte 						argc, argv, addr)
1872*fcf3ce44SJohn Forte 			== -1) {
1873*fcf3ce44SJohn Forte 		mdb_warn("failed to walk dm chain at addr %p", addr);
1874*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1875*fcf3ce44SJohn Forte 	}
1876*fcf3ce44SJohn Forte 
1877*fcf3ce44SJohn Forte 	return (DCMD_OK);
1878*fcf3ce44SJohn Forte }
1879*fcf3ce44SJohn Forte 
1880*fcf3ce44SJohn Forte /*
1881*fcf3ce44SJohn Forte  * dcmd to walk a hash chain
1882*fcf3ce44SJohn Forte  * requires an address. same options as sdbc_cctl dcmd
1883*fcf3ce44SJohn Forte  */
1884*fcf3ce44SJohn Forte static int
sdbc_hashchain(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1885*fcf3ce44SJohn Forte sdbc_hashchain(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1886*fcf3ce44SJohn Forte {
1887*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
1888*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
1889*fcf3ce44SJohn Forte 
1890*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_hashchain", "sdbc`sdbc_cctl",
1891*fcf3ce44SJohn Forte 					argc, argv, addr) == -1) {
1892*fcf3ce44SJohn Forte 		mdb_warn("failed to walk hashchain at %p", addr);
1893*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1894*fcf3ce44SJohn Forte 	}
1895*fcf3ce44SJohn Forte 
1896*fcf3ce44SJohn Forte 	return (DCMD_OK);
1897*fcf3ce44SJohn Forte }
1898*fcf3ce44SJohn Forte 
1899*fcf3ce44SJohn Forte 
1900*fcf3ce44SJohn Forte static void
display_hash_table(_sd_hash_table_t * addr,_sd_hash_table_t * ht)1901*fcf3ce44SJohn Forte display_hash_table(_sd_hash_table_t *addr, _sd_hash_table_t *ht)
1902*fcf3ce44SJohn Forte {
1903*fcf3ce44SJohn Forte 	mdb_printf("hash table (%p):\n", addr);
1904*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1905*fcf3ce44SJohn Forte 	mdb_printf("size %7-d bits %2-d mask %8-x nmask %8-x buckets %p\n",
1906*fcf3ce44SJohn Forte 		ht->ht_size, ht->ht_bits, ht->ht_mask,
1907*fcf3ce44SJohn Forte 		ht->ht_nmask, ht->ht_buckets);
1908*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1909*fcf3ce44SJohn Forte }
1910*fcf3ce44SJohn Forte 
1911*fcf3ce44SJohn Forte static void
display_hash_bucket(_sd_hash_bucket_t * addr,_sd_hash_bucket_t * hb)1912*fcf3ce44SJohn Forte display_hash_bucket(_sd_hash_bucket_t *addr, _sd_hash_bucket_t *hb)
1913*fcf3ce44SJohn Forte {
1914*fcf3ce44SJohn Forte 	kmutex_t lock;
1915*fcf3ce44SJohn Forte 	int rc;
1916*fcf3ce44SJohn Forte 
1917*fcf3ce44SJohn Forte 	if ((rc = mdb_vread(&lock, sizeof (kmutex_t),
1918*fcf3ce44SJohn Forte 				(uintptr_t)hb->hb_lock)) == -1)
1919*fcf3ce44SJohn Forte 		mdb_warn("failed to read bucket lock at %p", hb->hb_lock);
1920*fcf3ce44SJohn Forte 
1921*fcf3ce44SJohn Forte 	mdb_printf("hash bucket (%p):\n", addr);
1922*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
1923*fcf3ce44SJohn Forte 	mdb_printf("head %?-p tail %?-p lock %?-p %s\n",
1924*fcf3ce44SJohn Forte 		hb->hb_head, hb->hb_tail,
1925*fcf3ce44SJohn Forte 		(rc == -1) ? hb->hb_lock : lock._opaque[0],
1926*fcf3ce44SJohn Forte 		(rc == -1) ? "" : "(owner)");
1927*fcf3ce44SJohn Forte 	mdb_printf("inlist %d seq %d\n", hb->hb_inlist, hb->hb_seq);
1928*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
1929*fcf3ce44SJohn Forte }
1930*fcf3ce44SJohn Forte 
1931*fcf3ce44SJohn Forte /*
1932*fcf3ce44SJohn Forte  * dcmd to walk the hash table
1933*fcf3ce44SJohn Forte  * defaults to _sd_htable the cache hash table,
1934*fcf3ce44SJohn Forte  * but wil accept an address which is probably only useful
1935*fcf3ce44SJohn Forte  * in the event that other hash tables are implemented in
1936*fcf3ce44SJohn Forte  * the cache.
1937*fcf3ce44SJohn Forte  *
1938*fcf3ce44SJohn Forte  * calls sdbc_hashchain dcmd.  same options as sdbc_cctl dcmd.
1939*fcf3ce44SJohn Forte  */
1940*fcf3ce44SJohn Forte static int
sdbc_hashtable(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1941*fcf3ce44SJohn Forte sdbc_hashtable(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1942*fcf3ce44SJohn Forte {
1943*fcf3ce44SJohn Forte 	_sd_hash_table_t *sd_htable_addr;
1944*fcf3ce44SJohn Forte 	_sd_hash_table_t _sd_htable;
1945*fcf3ce44SJohn Forte 	_sd_hash_bucket_t hash_bucket;
1946*fcf3ce44SJohn Forte 	int i;
1947*fcf3ce44SJohn Forte 
1948*fcf3ce44SJohn Forte 
1949*fcf3ce44SJohn Forte 
1950*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
1951*fcf3ce44SJohn Forte 		/* get the address of the standard cache hash table */
1952*fcf3ce44SJohn Forte 		if (mdb_readvar(&sd_htable_addr, "_sd_htable") == -1) {
1953*fcf3ce44SJohn Forte 			mdb_warn("failed to read _sd_htable address\n");
1954*fcf3ce44SJohn Forte 			return (DCMD_ERR);
1955*fcf3ce44SJohn Forte 		}
1956*fcf3ce44SJohn Forte 	} else
1957*fcf3ce44SJohn Forte 		sd_htable_addr = (_sd_hash_table_t *)addr;
1958*fcf3ce44SJohn Forte 
1959*fcf3ce44SJohn Forte 	/* read in the hash table structure */
1960*fcf3ce44SJohn Forte 	if (mdb_vread(&_sd_htable, sizeof (_sd_hash_table_t),
1961*fcf3ce44SJohn Forte 		(uintptr_t)sd_htable_addr) == -1) {
1962*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_htable structure at %p\n",
1963*fcf3ce44SJohn Forte 						    sd_htable_addr);
1964*fcf3ce44SJohn Forte 		return (DCMD_ERR);
1965*fcf3ce44SJohn Forte 	}
1966*fcf3ce44SJohn Forte 
1967*fcf3ce44SJohn Forte 	display_hash_table(sd_htable_addr, &_sd_htable);
1968*fcf3ce44SJohn Forte 
1969*fcf3ce44SJohn Forte 	/*
1970*fcf3ce44SJohn Forte 	 * read in the hash buckets
1971*fcf3ce44SJohn Forte 	 * and display chains if there are any
1972*fcf3ce44SJohn Forte 	 */
1973*fcf3ce44SJohn Forte 	for (i = 0; i < _sd_htable.ht_size; ++i) {
1974*fcf3ce44SJohn Forte 		if (mdb_vread(&hash_bucket, sizeof (_sd_hash_bucket_t),
1975*fcf3ce44SJohn Forte 			    (uintptr_t)(_sd_htable.ht_buckets + i)) == -1) {
1976*fcf3ce44SJohn Forte 			mdb_warn("failed to read ht_buckets at %p\n",
1977*fcf3ce44SJohn Forte 					    _sd_htable.ht_buckets + i);
1978*fcf3ce44SJohn Forte 			return (DCMD_ERR);
1979*fcf3ce44SJohn Forte 		}
1980*fcf3ce44SJohn Forte 
1981*fcf3ce44SJohn Forte 		if (hash_bucket.hb_head != NULL) {
1982*fcf3ce44SJohn Forte 			display_hash_bucket(_sd_htable.ht_buckets + i,
1983*fcf3ce44SJohn Forte 							&hash_bucket);
1984*fcf3ce44SJohn Forte 			/*
1985*fcf3ce44SJohn Forte 			 * if this walk fails, continue trying
1986*fcf3ce44SJohn Forte 			 * to read hash buckets
1987*fcf3ce44SJohn Forte 			 */
1988*fcf3ce44SJohn Forte 			if (mdb_call_dcmd("sdbc`sdbc_hashchain",
1989*fcf3ce44SJohn Forte 					(uintptr_t)hash_bucket.hb_head,
1990*fcf3ce44SJohn Forte 					flags|DCMD_ADDRSPEC, argc, argv)
1991*fcf3ce44SJohn Forte 								    == -1)
1992*fcf3ce44SJohn Forte 				    mdb_warn(
1993*fcf3ce44SJohn Forte 					    "failed to walk hash chain at %p",
1994*fcf3ce44SJohn Forte 					hash_bucket.hb_head);
1995*fcf3ce44SJohn Forte 			    mdb_printf("\n");
1996*fcf3ce44SJohn Forte 		    }
1997*fcf3ce44SJohn Forte 	}
1998*fcf3ce44SJohn Forte 
1999*fcf3ce44SJohn Forte 	return (DCMD_OK);
2000*fcf3ce44SJohn Forte }
2001*fcf3ce44SJohn Forte /*
2002*fcf3ce44SJohn Forte  * dcmd to display the sdbc lru queue
2003*fcf3ce44SJohn Forte  * same options as sdbc_cctl().
2004*fcf3ce44SJohn Forte  * alternatively the user can call the sdbc_lru walker
2005*fcf3ce44SJohn Forte  * and pipe the addresses to sdbc_cctl dcmd.
2006*fcf3ce44SJohn Forte  */
2007*fcf3ce44SJohn Forte static int
sdbc_lru(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2008*fcf3ce44SJohn Forte sdbc_lru(uintptr_t addr, uint_t flags, int argc,
2009*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2010*fcf3ce44SJohn Forte {
2011*fcf3ce44SJohn Forte 	_sd_queue_t _sd_lru_q;
2012*fcf3ce44SJohn Forte 	GElf_Sym sym;
2013*fcf3ce44SJohn Forte 
2014*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2015*fcf3ce44SJohn Forte 		if (mdb_lookup_by_obj("sdbc", "_sd_lru_q", &sym) == -1) {
2016*fcf3ce44SJohn Forte 			mdb_warn("failed to lookup _sd_lru_q symbol");
2017*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2018*fcf3ce44SJohn Forte 		}
2019*fcf3ce44SJohn Forte 
2020*fcf3ce44SJohn Forte 		if (mdb_vread(&_sd_lru_q, sizeof (_sd_queue_t),
2021*fcf3ce44SJohn Forte 						sym.st_value) == -1) {
2022*fcf3ce44SJohn Forte 			mdb_warn("failed to read _sd_lru_q structure");
2023*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2024*fcf3ce44SJohn Forte 		}
2025*fcf3ce44SJohn Forte 
2026*fcf3ce44SJohn Forte 		mdb_printf("Cache LRU Queue\n");
2027*fcf3ce44SJohn Forte 		mdb_inc_indent(4);
2028*fcf3ce44SJohn Forte 		mdb_printf(
2029*fcf3ce44SJohn Forte 		"qlock: 0x%-p (owner) await %d seq %d inq %d req %d noreq %d\n",
2030*fcf3ce44SJohn Forte 			_sd_lru_q.sq_qlock._opaque[0],
2031*fcf3ce44SJohn Forte 			_sd_lru_q.sq_await,
2032*fcf3ce44SJohn Forte 			_sd_lru_q.sq_seq,
2033*fcf3ce44SJohn Forte 			_sd_lru_q.sq_inq,
2034*fcf3ce44SJohn Forte 			_sd_lru_q.sq_req_stat,
2035*fcf3ce44SJohn Forte 			_sd_lru_q.sq_noreq_stat);
2036*fcf3ce44SJohn Forte 
2037*fcf3ce44SJohn Forte 		addr = (uintptr_t)(sym.st_value);
2038*fcf3ce44SJohn Forte 	}
2039*fcf3ce44SJohn Forte 
2040*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_lru", "sdbc`sdbc_cctl",
2041*fcf3ce44SJohn Forte 					argc, argv, addr) == -1) {
2042*fcf3ce44SJohn Forte 		mdb_warn("failed to walk lru at addr %p", addr);
2043*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2044*fcf3ce44SJohn Forte 	}
2045*fcf3ce44SJohn Forte 
2046*fcf3ce44SJohn Forte 	return (DCMD_OK);
2047*fcf3ce44SJohn Forte }
2048*fcf3ce44SJohn Forte 
2049*fcf3ce44SJohn Forte #ifdef SAFESTORE
2050*fcf3ce44SJohn Forte static void
print_wrq(_sd_writeq_t * wrq,uint_t verbose)2051*fcf3ce44SJohn Forte print_wrq(_sd_writeq_t *wrq, uint_t verbose)
2052*fcf3ce44SJohn Forte {
2053*fcf3ce44SJohn Forte 	int i;
2054*fcf3ce44SJohn Forte 
2055*fcf3ce44SJohn Forte 	mdb_printf("Cache Write Ctl Queue:\n");
2056*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2057*fcf3ce44SJohn Forte 	mdb_printf("qtop %-p qlock: %-p (owner) inq %d\n",
2058*fcf3ce44SJohn Forte 		wrq->wq_qtop,
2059*fcf3ce44SJohn Forte 		wrq->wq_qlock._opaque[0],
2060*fcf3ce44SJohn Forte 		wrq->wq_inq);
2061*fcf3ce44SJohn Forte 
2062*fcf3ce44SJohn Forte 	mdb_printf("slp_top %3-d slp_index %3-d slp_inq %3-d\n",
2063*fcf3ce44SJohn Forte 		wrq->wq_slp_top,
2064*fcf3ce44SJohn Forte 		wrq->wq_slp_index,
2065*fcf3ce44SJohn Forte 		wrq->wq_slp_inq);
2066*fcf3ce44SJohn Forte 
2067*fcf3ce44SJohn Forte 	for (i = 0; verbose && i < SD_WR_SLP_Q_MAX; i += 2) {
2068*fcf3ce44SJohn Forte 		mdb_printf("%3d: cv %h-x wq_need %3-d wq_held %3-d%4T",
2069*fcf3ce44SJohn Forte 			i,
2070*fcf3ce44SJohn Forte 			wrq->wq_slp[i].slp_wqcv._opaque,
2071*fcf3ce44SJohn Forte 			wrq->wq_slp[i].slp_wqneed,
2072*fcf3ce44SJohn Forte 			wrq->wq_slp[i].slp_wqheld);
2073*fcf3ce44SJohn Forte 		if (SD_WR_SLP_Q_MAX > (i + 1)) {
2074*fcf3ce44SJohn Forte 			mdb_printf(
2075*fcf3ce44SJohn Forte 			"%3d: cv %h-x wq_need %3-d wq_held %3-d%\n",
2076*fcf3ce44SJohn Forte 			    i+1,
2077*fcf3ce44SJohn Forte 			    wrq->wq_slp[i+1].slp_wqcv._opaque,
2078*fcf3ce44SJohn Forte 			    wrq->wq_slp[i+1].slp_wqneed,
2079*fcf3ce44SJohn Forte 			    wrq->wq_slp[i+1].slp_wqheld);
2080*fcf3ce44SJohn Forte 		}
2081*fcf3ce44SJohn Forte 	}
2082*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2083*fcf3ce44SJohn Forte }
2084*fcf3ce44SJohn Forte 
2085*fcf3ce44SJohn Forte /*
2086*fcf3ce44SJohn Forte  * dcmd to display write control structures
2087*fcf3ce44SJohn Forte  */
2088*fcf3ce44SJohn Forte 
2089*fcf3ce44SJohn Forte static int
sdbc_wctl(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2090*fcf3ce44SJohn Forte sdbc_wctl(uintptr_t addr, uint_t flags, int argc,
2091*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2092*fcf3ce44SJohn Forte {
2093*fcf3ce44SJohn Forte 	_sd_wr_cctl_t wctl;
2094*fcf3ce44SJohn Forte 	ss_centry_info_t gl_info;
2095*fcf3ce44SJohn Forte 	ss_centry_info_t nv_gl_info;
2096*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2097*fcf3ce44SJohn Forte 	uint_t opt_d = FALSE;
2098*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;
2099*fcf3ce44SJohn Forte 
2100*fcf3ce44SJohn Forte 
2101*fcf3ce44SJohn Forte 	/* TODO option for fba pos */
2102*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2103*fcf3ce44SJohn Forte 			'd', MDB_OPT_SETBITS, TRUE, &opt_d,
2104*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2105*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
2106*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2107*fcf3ce44SJohn Forte 
2108*fcf3ce44SJohn Forte 
2109*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2110*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_wctl", "sdbc`sdbc_wctl",
2111*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2112*fcf3ce44SJohn Forte 			mdb_warn("failed to walk write ctl array");
2113*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2114*fcf3ce44SJohn Forte 		}
2115*fcf3ce44SJohn Forte 		return (DCMD_OK);
2116*fcf3ce44SJohn Forte 	}
2117*fcf3ce44SJohn Forte 
2118*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2119*fcf3ce44SJohn Forte 		mdb_printf("write control block structures:\n");
2120*fcf3ce44SJohn Forte 	}
2121*fcf3ce44SJohn Forte 
2122*fcf3ce44SJohn Forte 	if (mdb_vread(&wctl, sizeof (_sd_wr_cctl_t), addr) == -1) {
2123*fcf3ce44SJohn Forte 		mdb_warn("failed to read wctl at 0x%p", addr);
2124*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2125*fcf3ce44SJohn Forte 	}
2126*fcf3ce44SJohn Forte 
2127*fcf3ce44SJohn Forte 
2128*fcf3ce44SJohn Forte 	/*
2129*fcf3ce44SJohn Forte 	 * print "all" is the default.
2130*fcf3ce44SJohn Forte 	 * filter conditions can only be checked by reading in wc_gl_info
2131*fcf3ce44SJohn Forte 	 */
2132*fcf3ce44SJohn Forte 	if (opt_c || opt_d || opt_v)
2133*fcf3ce44SJohn Forte 	    if (mdb_vread(&gl_info, sizeof (ss_centry_info_t),
2134*fcf3ce44SJohn Forte 				(uintptr_t)wctl.wc_gl_info) == -1) {
2135*fcf3ce44SJohn Forte 		    mdb_warn("failed to read at wc_gl_info 0x%p", addr);
2136*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2137*fcf3ce44SJohn Forte 	}
2138*fcf3ce44SJohn Forte 
2139*fcf3ce44SJohn Forte 
2140*fcf3ce44SJohn Forte 	if (OPT_C_SELECTED && (gl_info.gl_cd != opt_c))
2141*fcf3ce44SJohn Forte 		return (DCMD_OK);
2142*fcf3ce44SJohn Forte 
2143*fcf3ce44SJohn Forte 	if (opt_d && !(gl_info.gl_dirty))
2144*fcf3ce44SJohn Forte 		return (DCMD_OK);
2145*fcf3ce44SJohn Forte 
2146*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2147*fcf3ce44SJohn Forte 	mdb_printf("%-p data %-p gl_info %-p Ngl_info %-p flg %02x\n",
2148*fcf3ce44SJohn Forte 		addr,
2149*fcf3ce44SJohn Forte 		wctl.wc_data,
2150*fcf3ce44SJohn Forte 		wctl.wc_gl_info,
2151*fcf3ce44SJohn Forte 		wctl.wc_nvmem_gl_info,
2152*fcf3ce44SJohn Forte 		wctl.wc_flag);
2153*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2154*fcf3ce44SJohn Forte 
2155*fcf3ce44SJohn Forte 	/* verbose */
2156*fcf3ce44SJohn Forte 	if (!opt_v)
2157*fcf3ce44SJohn Forte 		return (DCMD_OK);
2158*fcf3ce44SJohn Forte 
2159*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2160*fcf3ce44SJohn Forte 	mdb_printf("next %?-p prev %?-p\n", wctl.wc_next, wctl.wc_prev);
2161*fcf3ce44SJohn Forte 	mdb_printf("      gl_info: ");
2162*fcf3ce44SJohn Forte 	mdb_printf("cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2163*fcf3ce44SJohn Forte 		gl_info.gl_cd, gl_info.gl_fpos, gl_info.gl_dirty & 0xffff,
2164*fcf3ce44SJohn Forte 		gl_info.gl_flag, cc_flag_bits);
2165*fcf3ce44SJohn Forte 
2166*fcf3ce44SJohn Forte 	if (wctl.wc_nvmem_gl_info) {
2167*fcf3ce44SJohn Forte 	    if (mdb_vread(&nv_gl_info, sizeof (ss_centry_info_t),
2168*fcf3ce44SJohn Forte 				(uintptr_t)wctl.wc_nvmem_gl_info) == -1) {
2169*fcf3ce44SJohn Forte 		    mdb_warn("failed to read at wc_nvmem_gl_info 0x%p",
2170*fcf3ce44SJohn Forte 		    wctl.wc_nvmem_gl_info);  /* not catastophic, continue */
2171*fcf3ce44SJohn Forte 	    } else {
2172*fcf3ce44SJohn Forte 
2173*fcf3ce44SJohn Forte 		    /* consistency check */
2174*fcf3ce44SJohn Forte 			if (memcmp(&gl_info, &nv_gl_info,
2175*fcf3ce44SJohn Forte 					sizeof (ss_centry_info_t) != 0)) {
2176*fcf3ce44SJohn Forte 			mdb_warn("nvram and host memory are NOT identical!");
2177*fcf3ce44SJohn Forte 			mdb_printf("nvmem_gl_info: ");
2178*fcf3ce44SJohn Forte 			mdb_printf("cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2179*fcf3ce44SJohn Forte 			nv_gl_info.gl_cd, nv_gl_info.gl_fpos,
2180*fcf3ce44SJohn Forte 			nv_gl_info.gl_dirty & 0xffff,
2181*fcf3ce44SJohn Forte 			nv_gl_info.gl_flag, cc_flag_bits);
2182*fcf3ce44SJohn Forte 		    }
2183*fcf3ce44SJohn Forte 
2184*fcf3ce44SJohn Forte 	    }
2185*fcf3ce44SJohn Forte 	}
2186*fcf3ce44SJohn Forte 
2187*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2188*fcf3ce44SJohn Forte 	mdb_printf("\n");
2189*fcf3ce44SJohn Forte 	return (DCMD_OK);
2190*fcf3ce44SJohn Forte }
2191*fcf3ce44SJohn Forte 
2192*fcf3ce44SJohn Forte /*
2193*fcf3ce44SJohn Forte  * dcmd to display write control structures in the free list
2194*fcf3ce44SJohn Forte  * same options as sdbc_wctl
2195*fcf3ce44SJohn Forte  */
2196*fcf3ce44SJohn Forte 
2197*fcf3ce44SJohn Forte static int
sdbc_wrq(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2198*fcf3ce44SJohn Forte sdbc_wrq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2199*fcf3ce44SJohn Forte {
2200*fcf3ce44SJohn Forte 	_sd_net_t _sd_net_config;
2201*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2202*fcf3ce44SJohn Forte 	uint_t opt_d = FALSE;
2203*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;
2204*fcf3ce44SJohn Forte 
2205*fcf3ce44SJohn Forte 
2206*fcf3ce44SJohn Forte 	/* look for verbose option */
2207*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2208*fcf3ce44SJohn Forte 			'd', MDB_OPT_SETBITS, TRUE, &opt_d,
2209*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2210*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
2211*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2212*fcf3ce44SJohn Forte 
2213*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2214*fcf3ce44SJohn Forte 		if (mdb_readvar(&_sd_net_config, "_sd_net_config") == -1) {
2215*fcf3ce44SJohn Forte 			mdb_warn("failed to read _sd_net_config structure");
2216*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2217*fcf3ce44SJohn Forte 		}
2218*fcf3ce44SJohn Forte 
2219*fcf3ce44SJohn Forte 		print_wrq(&(_sd_net_config.sn_wr_queue), opt_v);
2220*fcf3ce44SJohn Forte 
2221*fcf3ce44SJohn Forte 		addr = (uintptr_t)(_sd_net_config.sn_wr_queue.wq_qtop);
2222*fcf3ce44SJohn Forte 	}
2223*fcf3ce44SJohn Forte 
2224*fcf3ce44SJohn Forte 	if (mdb_pwalk_dcmd("sdbc`sdbc_wrq", "sdbc`sdbc_wctl",
2225*fcf3ce44SJohn Forte 					argc, argv, addr) == -1) {
2226*fcf3ce44SJohn Forte 		mdb_warn("failed to walk write ctl queue at addr %p", addr);
2227*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2228*fcf3ce44SJohn Forte 	}
2229*fcf3ce44SJohn Forte 	return (DCMD_OK);
2230*fcf3ce44SJohn Forte }
2231*fcf3ce44SJohn Forte #endif
2232*fcf3ce44SJohn Forte 
2233*fcf3ce44SJohn Forte /*
2234*fcf3ce44SJohn Forte  * dcmd to display the dm queues
2235*fcf3ce44SJohn Forte  * use sdbc_lru walker to walk each queue.
2236*fcf3ce44SJohn Forte  */
2237*fcf3ce44SJohn Forte /*ARGSUSED*/
2238*fcf3ce44SJohn Forte static int
sdbc_dmqueues(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2239*fcf3ce44SJohn Forte sdbc_dmqueues(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2240*fcf3ce44SJohn Forte {
2241*fcf3ce44SJohn Forte 	_sd_queue_t *sdbc_dm_queues; /* kernel address of dm queues */
2242*fcf3ce44SJohn Forte 	int max_dm_queues;
2243*fcf3ce44SJohn Forte 	_sd_queue_t *queues = NULL; /* local copy */
2244*fcf3ce44SJohn Forte 	int i;
2245*fcf3ce44SJohn Forte 
2246*fcf3ce44SJohn Forte 
2247*fcf3ce44SJohn Forte 	if (argc != 0)
2248*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2249*fcf3ce44SJohn Forte 
2250*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2251*fcf3ce44SJohn Forte 		if (mdb_readvar(&sdbc_dm_queues, "sdbc_dm_queues") == -1) {
2252*fcf3ce44SJohn Forte 			mdb_warn("failed to read sdbc_dm_queues address\n");
2253*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2254*fcf3ce44SJohn Forte 		}
2255*fcf3ce44SJohn Forte 
2256*fcf3ce44SJohn Forte 		if (mdb_readvar(&max_dm_queues, "max_dm_queues") == -1) {
2257*fcf3ce44SJohn Forte 			mdb_warn("failed to read max_dm_queues variable\n");
2258*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2259*fcf3ce44SJohn Forte 		}
2260*fcf3ce44SJohn Forte 
2261*fcf3ce44SJohn Forte 		queues = mdb_zalloc(max_dm_queues * sizeof (_sd_queue_t),
2262*fcf3ce44SJohn Forte 					UM_SLEEP);
2263*fcf3ce44SJohn Forte mdb_printf("max_dm_queues %d sdbc_dm_queues %p queues %p\n",
2264*fcf3ce44SJohn Forte 		max_dm_queues, sdbc_dm_queues, queues);
2265*fcf3ce44SJohn Forte 
2266*fcf3ce44SJohn Forte 		if (mdb_vread(queues, max_dm_queues * sizeof (_sd_queue_t),
2267*fcf3ce44SJohn Forte 					(uintptr_t)sdbc_dm_queues) == -1) {
2268*fcf3ce44SJohn Forte 			mdb_warn("failed to read sdbc_dm_queues");
2269*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2270*fcf3ce44SJohn Forte 		}
2271*fcf3ce44SJohn Forte 
2272*fcf3ce44SJohn Forte 		for (i = 0;  i < max_dm_queues; ++i) {
2273*fcf3ce44SJohn Forte 			mdb_printf("Cache DM Queue %d %p\n",
2274*fcf3ce44SJohn Forte 					queues[i].sq_dmchain_cblocks,
2275*fcf3ce44SJohn Forte 					sdbc_dm_queues +i);
2276*fcf3ce44SJohn Forte 			mdb_inc_indent(4);
2277*fcf3ce44SJohn Forte 			mdb_printf("qlock: 0x%-p (owner) await %d "
2278*fcf3ce44SJohn Forte 					"seq %d inq %d req %d noreq %d\n",
2279*fcf3ce44SJohn Forte 					queues[i].sq_qlock._opaque[0],
2280*fcf3ce44SJohn Forte 					queues[i].sq_await,
2281*fcf3ce44SJohn Forte 					queues[i].sq_seq,
2282*fcf3ce44SJohn Forte 					queues[i].sq_inq,
2283*fcf3ce44SJohn Forte 					queues[i].sq_req_stat,
2284*fcf3ce44SJohn Forte 					queues[i].sq_noreq_stat);
2285*fcf3ce44SJohn Forte 
2286*fcf3ce44SJohn Forte 			mdb_dec_indent(4);
2287*fcf3ce44SJohn Forte 		}
2288*fcf3ce44SJohn Forte 	}
2289*fcf3ce44SJohn Forte 
2290*fcf3ce44SJohn Forte 	return (DCMD_OK);
2291*fcf3ce44SJohn Forte }
2292*fcf3ce44SJohn Forte 
2293*fcf3ce44SJohn Forte 
2294*fcf3ce44SJohn Forte mdb_bitmask_t cd_writer_bits[] = {
2295*fcf3ce44SJohn Forte 	{ "NONE   ", (u_longlong_t)~0, _SD_WRITER_NONE },
2296*fcf3ce44SJohn Forte 	{ "CREATE ", (u_longlong_t)~0, _SD_WRITER_CREATE },
2297*fcf3ce44SJohn Forte 	{ "RUNNING", (u_longlong_t)~0, _SD_WRITER_RUNNING },
2298*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
2299*fcf3ce44SJohn Forte };
2300*fcf3ce44SJohn Forte 
2301*fcf3ce44SJohn Forte mdb_bitmask_t sh_failed_status[] = {
2302*fcf3ce44SJohn Forte 	{ "STATUS OK", (u_longlong_t)~0, 0 },
2303*fcf3ce44SJohn Forte 	{ "I/O ERROR", (u_longlong_t)~0, 1 },
2304*fcf3ce44SJohn Forte 	{ "OPEN FAIL", (u_longlong_t)~0, 2 },
2305*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
2306*fcf3ce44SJohn Forte };
2307*fcf3ce44SJohn Forte 
2308*fcf3ce44SJohn Forte mdb_bitmask_t sh_flag_bits[] = {
2309*fcf3ce44SJohn Forte 	{ "ATTACHED", CD_ATTACHED, CD_ATTACHED },
2310*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
2311*fcf3ce44SJohn Forte };
2312*fcf3ce44SJohn Forte 
2313*fcf3ce44SJohn Forte mdb_bitmask_t sh_alloc_bits[] = {
2314*fcf3ce44SJohn Forte 	{ "ALLOC_IN_PROGRESS", CD_ALLOC_IN_PROGRESS, CD_ALLOC_IN_PROGRESS },
2315*fcf3ce44SJohn Forte 	{ "ALLOCATED", CD_ALLOCATED, CD_ALLOCATED },
2316*fcf3ce44SJohn Forte 	{ "CLOSE_IN_PROGRESS", CD_CLOSE_IN_PROGRESS, CD_CLOSE_IN_PROGRESS },
2317*fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
2318*fcf3ce44SJohn Forte };
2319*fcf3ce44SJohn Forte 
2320*fcf3ce44SJohn Forte /*
2321*fcf3ce44SJohn Forte  * dcmd to display cd information
2322*fcf3ce44SJohn Forte  */
2323*fcf3ce44SJohn Forte static int
sdbc_cdinfo(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2324*fcf3ce44SJohn Forte sdbc_cdinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2325*fcf3ce44SJohn Forte {
2326*fcf3ce44SJohn Forte 	_sd_shared_t sd_shared;
2327*fcf3ce44SJohn Forte 	_sd_cd_info_t cdi;
2328*fcf3ce44SJohn Forte 	ss_voldata_t gl_file;
2329*fcf3ce44SJohn Forte 	char *fn = "nopath"; /* filename if sd_shared info cannot be read */
2330*fcf3ce44SJohn Forte 	uchar_t sh_alloc = 0; /* assume not alloc'd if sd_shared info unavail */
2331*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2332*fcf3ce44SJohn Forte 	uint_t opt_a = FALSE;
2333*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;
2334*fcf3ce44SJohn Forte 	int dev_t_chars;
2335*fcf3ce44SJohn Forte 
2336*fcf3ce44SJohn Forte 	dev_t_chars = sizeof (dev_t) * 2;	/* # chars to display dev_t */
2337*fcf3ce44SJohn Forte 
2338*fcf3ce44SJohn Forte 
2339*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2340*fcf3ce44SJohn Forte 			'a', MDB_OPT_SETBITS, TRUE, &opt_a,
2341*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2342*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
2343*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2344*fcf3ce44SJohn Forte 
2345*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2346*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_cdinfo", "sdbc`sdbc_cdinfo",
2347*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2348*fcf3ce44SJohn Forte 			mdb_warn("failed to walk cd info array");
2349*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2350*fcf3ce44SJohn Forte 		}
2351*fcf3ce44SJohn Forte 		return (DCMD_OK);
2352*fcf3ce44SJohn Forte 	}
2353*fcf3ce44SJohn Forte 
2354*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2355*fcf3ce44SJohn Forte 		mdb_printf("cd info structures:\n");
2356*fcf3ce44SJohn Forte 	}
2357*fcf3ce44SJohn Forte 
2358*fcf3ce44SJohn Forte 	if (mdb_vread(&cdi, sizeof (_sd_cd_info_t), addr) == -1) {
2359*fcf3ce44SJohn Forte 		mdb_warn("failed to read cd info at 0x%p", addr);
2360*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2361*fcf3ce44SJohn Forte 	}
2362*fcf3ce44SJohn Forte 
2363*fcf3ce44SJohn Forte 	/*
2364*fcf3ce44SJohn Forte 	 * need to do this read even for non-verbose option to
2365*fcf3ce44SJohn Forte 	 * get the filename and the sh_alloc field
2366*fcf3ce44SJohn Forte 	 */
2367*fcf3ce44SJohn Forte 	if (cdi.cd_info) {
2368*fcf3ce44SJohn Forte 	    if (mdb_vread(&sd_shared, sizeof (_sd_shared_t),
2369*fcf3ce44SJohn Forte 				    (uintptr_t)cdi.cd_info) == -1) {
2370*fcf3ce44SJohn Forte 		    mdb_warn("failed to read shared cd info at 0x%p",
2371*fcf3ce44SJohn Forte 						    cdi.cd_info);
2372*fcf3ce44SJohn Forte 		    /* not catastrophic, keep truckin' */
2373*fcf3ce44SJohn Forte 	    } else {
2374*fcf3ce44SJohn Forte 		    fn = sd_shared.sh_filename;
2375*fcf3ce44SJohn Forte 		    sh_alloc = sd_shared.sh_alloc;
2376*fcf3ce44SJohn Forte 	    }
2377*fcf3ce44SJohn Forte 	}
2378*fcf3ce44SJohn Forte 
2379*fcf3ce44SJohn Forte 	if (!opt_a && (sh_alloc == 0))
2380*fcf3ce44SJohn Forte 		return (DCMD_OK);
2381*fcf3ce44SJohn Forte 
2382*fcf3ce44SJohn Forte 	if (OPT_C_SELECTED && (opt_c != cdi.cd_desc))
2383*fcf3ce44SJohn Forte 		return (DCMD_OK);
2384*fcf3ce44SJohn Forte 
2385*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2386*fcf3ce44SJohn Forte 	mdb_printf("%p cd %3-d filename %s\n",
2387*fcf3ce44SJohn Forte 		addr, cdi.cd_desc, fn);
2388*fcf3ce44SJohn Forte 	mdb_printf("alloc <%b> hint <%b>\n",
2389*fcf3ce44SJohn Forte 		sh_alloc, sh_alloc_bits,
2390*fcf3ce44SJohn Forte 		cdi.cd_hint, cache_hints);
2391*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2392*fcf3ce44SJohn Forte 
2393*fcf3ce44SJohn Forte 	if (!opt_v)
2394*fcf3ce44SJohn Forte 		return (DCMD_OK);
2395*fcf3ce44SJohn Forte 
2396*fcf3ce44SJohn Forte 	/* verbose */
2397*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2398*fcf3ce44SJohn Forte 	mdb_printf("rawfd %?-p crdev %0*lx iodev %?-p\n",
2399*fcf3ce44SJohn Forte 		cdi.cd_rawfd,
2400*fcf3ce44SJohn Forte 		dev_t_chars,
2401*fcf3ce44SJohn Forte 		cdi.cd_crdev,
2402*fcf3ce44SJohn Forte 		cdi.cd_iodev);
2403*fcf3ce44SJohn Forte 	mdb_printf("flag %x %8Tlock %?-p writer <%b>\n",
2404*fcf3ce44SJohn Forte 		cdi.cd_flag,
2405*fcf3ce44SJohn Forte 		cdi.cd_lock._opaque[0],
2406*fcf3ce44SJohn Forte 		cdi.cd_writer, cd_writer_bits);
2407*fcf3ce44SJohn Forte 	mdb_printf("global %?-p dirty_head %?-p\n",
2408*fcf3ce44SJohn Forte 		cdi.cd_global, cdi.cd_dirty_head);
2409*fcf3ce44SJohn Forte 	mdb_printf("last_ent %?-p lastchain_ptr %?-p lastchain %d\n",
2410*fcf3ce44SJohn Forte 		cdi.cd_last_ent, cdi.cd_lastchain_ptr,
2411*fcf3ce44SJohn Forte 		cdi.cd_lastchain);
2412*fcf3ce44SJohn Forte 	mdb_printf("io_head %?-p io_tail %?-p fail_head %?-p\n",
2413*fcf3ce44SJohn Forte 		cdi.cd_io_head, cdi.cd_io_tail, cdi.cd_fail_head);
2414*fcf3ce44SJohn Forte 	mdb_printf(
2415*fcf3ce44SJohn Forte 	    "cd_info %?-p failover %d recovering %d write_inprogress %d\n",
2416*fcf3ce44SJohn Forte 		cdi.cd_info, cdi.cd_failover,
2417*fcf3ce44SJohn Forte 		cdi.cd_recovering,
2418*fcf3ce44SJohn Forte 		cdi.cd_write_inprogress);
2419*fcf3ce44SJohn Forte 
2420*fcf3ce44SJohn Forte 	if (cdi.cd_global != NULL) {
2421*fcf3ce44SJohn Forte 		if (mdb_vread(&gl_file, sizeof (ss_voldata_t),
2422*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_global) == -1)
2423*fcf3ce44SJohn Forte 			mdb_warn("failed to read cd_global at %p",
2424*fcf3ce44SJohn Forte 						    cdi.cd_global);
2425*fcf3ce44SJohn Forte 		else {
2426*fcf3ce44SJohn Forte 			mdb_printf("cd_global: %s\n", gl_file.sv_volname);
2427*fcf3ce44SJohn Forte 			mdb_printf("pinned %2-d attached %2-d devidsz %3-d\n",
2428*fcf3ce44SJohn Forte 				gl_file.sv_pinned, gl_file.sv_attached,
2429*fcf3ce44SJohn Forte 				gl_file.sv_devidsz);
2430*fcf3ce44SJohn Forte 			mdb_printf("devid %s\n", gl_file.sv_devid);
2431*fcf3ce44SJohn Forte 			mdb_printf("vol %?p\n", gl_file.sv_vol);
2432*fcf3ce44SJohn Forte 		}
2433*fcf3ce44SJohn Forte 		/* TODO do a consistency check here against the nvram copy */
2434*fcf3ce44SJohn Forte 	}
2435*fcf3ce44SJohn Forte 
2436*fcf3ce44SJohn Forte 	if (cdi.cd_info == NULL) {
2437*fcf3ce44SJohn Forte 		mdb_printf("no shared info\n");
2438*fcf3ce44SJohn Forte 	} else {
2439*fcf3ce44SJohn Forte 		mdb_printf("shared:\n");
2440*fcf3ce44SJohn Forte 		mdb_printf("failed <%b> cd %3-d",
2441*fcf3ce44SJohn Forte 		    sd_shared.sh_failed, sh_failed_status,
2442*fcf3ce44SJohn Forte 		    sd_shared.sh_cd);
2443*fcf3ce44SJohn Forte 		mdb_printf("cache_read %10-d cache_write %10-d\n",
2444*fcf3ce44SJohn Forte 		    sd_shared.sh_cache_read, sd_shared.sh_cache_write);
2445*fcf3ce44SJohn Forte 		mdb_printf("disk_read %10-d disk_write %10-d filesize %10-d\n",
2446*fcf3ce44SJohn Forte 		    sd_shared.sh_disk_read, sd_shared.sh_disk_write,
2447*fcf3ce44SJohn Forte 		    sd_shared.sh_filesize);
2448*fcf3ce44SJohn Forte 		mdb_printf("numdirty %8-d numio %8-d numfail %8-d\n",
2449*fcf3ce44SJohn Forte 		    sd_shared.sh_numdirty,
2450*fcf3ce44SJohn Forte 		    sd_shared.sh_numio,
2451*fcf3ce44SJohn Forte 		    sd_shared.sh_numfail);
2452*fcf3ce44SJohn Forte 		mdb_printf("flushloop %2-d sh_flag <%b>\n",
2453*fcf3ce44SJohn Forte 		    sd_shared.sh_flushloop, sd_shared.sh_flag, sh_flag_bits);
2454*fcf3ce44SJohn Forte 
2455*fcf3ce44SJohn Forte 		/* this can be really verbose */
2456*fcf3ce44SJohn Forte 		if (cdi.cd_dirty_head) {
2457*fcf3ce44SJohn Forte 			mdb_printf("Dirty Chain (cd_dirty_head):");
2458*fcf3ce44SJohn Forte 			/* TODO reconstruct argv without opt_a */
2459*fcf3ce44SJohn Forte 			if (!opt_a)
2460*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2461*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_dirty_head,
2462*fcf3ce44SJohn Forte 					flags, argc, argv);
2463*fcf3ce44SJohn Forte 			else /* print with no options */
2464*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2465*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_dirty_head,
2466*fcf3ce44SJohn Forte 					flags, 0, NULL);
2467*fcf3ce44SJohn Forte 		}
2468*fcf3ce44SJohn Forte 
2469*fcf3ce44SJohn Forte 		if (cdi.cd_io_head) {
2470*fcf3ce44SJohn Forte 			mdb_printf("I/O Pending Chain (cd_io_head):");
2471*fcf3ce44SJohn Forte 			/* TODO reconstruct argv without opt_a */
2472*fcf3ce44SJohn Forte 			if (!opt_a)
2473*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2474*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_io_head,
2475*fcf3ce44SJohn Forte 					flags, argc, argv);
2476*fcf3ce44SJohn Forte 			else /* print with no options */
2477*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2478*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_dirty_head,
2479*fcf3ce44SJohn Forte 					flags, 0, NULL);
2480*fcf3ce44SJohn Forte 		}
2481*fcf3ce44SJohn Forte 
2482*fcf3ce44SJohn Forte 		if (cdi.cd_fail_head) {
2483*fcf3ce44SJohn Forte 			mdb_printf("Failed Chain (cd_fail_head):");
2484*fcf3ce44SJohn Forte 			/* TODO reconstruct argv without opt_a */
2485*fcf3ce44SJohn Forte 			if (!opt_a)
2486*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2487*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_fail_head,
2488*fcf3ce44SJohn Forte 					flags, argc, argv);
2489*fcf3ce44SJohn Forte 			else /* print with no options */
2490*fcf3ce44SJohn Forte 				mdb_call_dcmd("sdbc_dchain",
2491*fcf3ce44SJohn Forte 					(uintptr_t)cdi.cd_dirty_head,
2492*fcf3ce44SJohn Forte 					flags, 0, NULL);
2493*fcf3ce44SJohn Forte 		}
2494*fcf3ce44SJohn Forte 	}
2495*fcf3ce44SJohn Forte 
2496*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2497*fcf3ce44SJohn Forte 
2498*fcf3ce44SJohn Forte 	mdb_printf("\n");
2499*fcf3ce44SJohn Forte 
2500*fcf3ce44SJohn Forte 	return (DCMD_OK);
2501*fcf3ce44SJohn Forte }
2502*fcf3ce44SJohn Forte 
2503*fcf3ce44SJohn Forte #ifdef SAFESTORE
2504*fcf3ce44SJohn Forte /*
2505*fcf3ce44SJohn Forte  * dcmd to display fault tolerant control structures
2506*fcf3ce44SJohn Forte  */
2507*fcf3ce44SJohn Forte static int
sdbc_ftctl(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2508*fcf3ce44SJohn Forte sdbc_ftctl(uintptr_t addr, uint_t flags, int argc,
2509*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2510*fcf3ce44SJohn Forte {
2511*fcf3ce44SJohn Forte 	_sd_ft_cctl_t ft_cent;
2512*fcf3ce44SJohn Forte 	ss_centry_info_t gl_info;
2513*fcf3ce44SJohn Forte 	ss_centry_info_t nv_gl_info;
2514*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2515*fcf3ce44SJohn Forte 	uint_t opt_d = FALSE;
2516*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;
2517*fcf3ce44SJohn Forte 
2518*fcf3ce44SJohn Forte 
2519*fcf3ce44SJohn Forte 	/* TODO option to select on fpos */
2520*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2521*fcf3ce44SJohn Forte 			'd', MDB_OPT_SETBITS, TRUE, &opt_d,
2522*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2523*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
2524*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2525*fcf3ce44SJohn Forte 
2526*fcf3ce44SJohn Forte 
2527*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2528*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_ftctl", "sdbc`sdbc_ftctl",
2529*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2530*fcf3ce44SJohn Forte 			mdb_warn("failed to walk write ctl array");
2531*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2532*fcf3ce44SJohn Forte 		}
2533*fcf3ce44SJohn Forte 		return (DCMD_OK);
2534*fcf3ce44SJohn Forte 	}
2535*fcf3ce44SJohn Forte 
2536*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2537*fcf3ce44SJohn Forte 		mdb_printf("Ft control block structures:\n");
2538*fcf3ce44SJohn Forte 	}
2539*fcf3ce44SJohn Forte 
2540*fcf3ce44SJohn Forte 	if (mdb_vread(&ft_cent, sizeof (_sd_ft_cctl_t), addr) == -1) {
2541*fcf3ce44SJohn Forte 		mdb_warn("failed to read ft_cent at 0x%p", addr);
2542*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2543*fcf3ce44SJohn Forte 	}
2544*fcf3ce44SJohn Forte 
2545*fcf3ce44SJohn Forte 
2546*fcf3ce44SJohn Forte 	/*
2547*fcf3ce44SJohn Forte 	 * print "all" is the default.
2548*fcf3ce44SJohn Forte 	 * filter conditions can only be checked by reading in wc_gl_info
2549*fcf3ce44SJohn Forte 	 */
2550*fcf3ce44SJohn Forte 	if (opt_c || opt_d || opt_v)
2551*fcf3ce44SJohn Forte 	    if (mdb_vread(&gl_info, sizeof (ss_centry_info_t),
2552*fcf3ce44SJohn Forte 				(uintptr_t)ft_cent.ft_gl_info) == -1) {
2553*fcf3ce44SJohn Forte 		mdb_warn("failed to read at wc_gl_info 0x%p", addr);
2554*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2555*fcf3ce44SJohn Forte 	}
2556*fcf3ce44SJohn Forte 
2557*fcf3ce44SJohn Forte 
2558*fcf3ce44SJohn Forte 	if (OPT_C_SELECTED && (gl_info.gl_cd != opt_c))
2559*fcf3ce44SJohn Forte 		return (DCMD_OK);
2560*fcf3ce44SJohn Forte 
2561*fcf3ce44SJohn Forte 	if (opt_d && !(gl_info.gl_dirty))
2562*fcf3ce44SJohn Forte 		return (DCMD_OK);
2563*fcf3ce44SJohn Forte 
2564*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2565*fcf3ce44SJohn Forte 	mdb_printf("%-p data %?-p qnext %?-p\n",
2566*fcf3ce44SJohn Forte 		addr,
2567*fcf3ce44SJohn Forte 		ft_cent.ft_qnext,
2568*fcf3ce44SJohn Forte 		ft_cent.ft_data);
2569*fcf3ce44SJohn Forte 	mdb_printf("gl_info %?-p nvmem_gl_info %?-p\n",
2570*fcf3ce44SJohn Forte 		ft_cent.ft_gl_info,
2571*fcf3ce44SJohn Forte 		ft_cent.ft_nvmem_gl_info);
2572*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2573*fcf3ce44SJohn Forte 
2574*fcf3ce44SJohn Forte 	/* verbose */
2575*fcf3ce44SJohn Forte 	if (!opt_v) {
2576*fcf3ce44SJohn Forte 		mdb_printf("\n");
2577*fcf3ce44SJohn Forte 		return (DCMD_OK);
2578*fcf3ce44SJohn Forte 	}
2579*fcf3ce44SJohn Forte 
2580*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2581*fcf3ce44SJohn Forte 	mdb_printf("      gl_info: ");
2582*fcf3ce44SJohn Forte 	mdb_printf("cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2583*fcf3ce44SJohn Forte 		gl_info.gl_cd, gl_info.gl_fpos, gl_info.gl_dirty & 0xffff,
2584*fcf3ce44SJohn Forte 		gl_info.gl_flag, cc_flag_bits);
2585*fcf3ce44SJohn Forte 
2586*fcf3ce44SJohn Forte 	if (ft_cent.ft_nvmem_gl_info) {
2587*fcf3ce44SJohn Forte 	    if (mdb_vread(&nv_gl_info, sizeof (ss_centry_info_t),
2588*fcf3ce44SJohn Forte 				(uintptr_t)ft_cent.ft_nvmem_gl_info) == -1) {
2589*fcf3ce44SJohn Forte 		    mdb_warn("failed to read at ft_nvmem_gl_info 0x%p",
2590*fcf3ce44SJohn Forte 		    ft_cent.ft_nvmem_gl_info);  /* not catastophic, continue */
2591*fcf3ce44SJohn Forte 	    } else {
2592*fcf3ce44SJohn Forte 		    mdb_printf("nvmem_gl_info: ");
2593*fcf3ce44SJohn Forte 		    mdb_printf("cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2594*fcf3ce44SJohn Forte 		    nv_gl_info.gl_cd, nv_gl_info.gl_fpos,
2595*fcf3ce44SJohn Forte 		    nv_gl_info.gl_dirty & 0xffff,
2596*fcf3ce44SJohn Forte 		    nv_gl_info.gl_flag, cc_flag_bits);
2597*fcf3ce44SJohn Forte 
2598*fcf3ce44SJohn Forte 		    /* consistency check */
2599*fcf3ce44SJohn Forte 		    if (memcmp(&gl_info, &nv_gl_info, sizeof (ss_centry_info_t))
2600*fcf3ce44SJohn Forte 								!= 0) {
2601*fcf3ce44SJohn Forte 			mdb_warn("nvram and host memory are NOT identical!");
2602*fcf3ce44SJohn Forte 		    }
2603*fcf3ce44SJohn Forte 
2604*fcf3ce44SJohn Forte 	    }
2605*fcf3ce44SJohn Forte 	}
2606*fcf3ce44SJohn Forte 
2607*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2608*fcf3ce44SJohn Forte 	mdb_printf("\n");
2609*fcf3ce44SJohn Forte 	return (DCMD_OK);
2610*fcf3ce44SJohn Forte }
2611*fcf3ce44SJohn Forte #endif /* SAFESTORE */
2612*fcf3ce44SJohn Forte 
2613*fcf3ce44SJohn Forte 
2614*fcf3ce44SJohn Forte /* dcmd to display buffer handles */
2615*fcf3ce44SJohn Forte static int
sdbc_handles(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2616*fcf3ce44SJohn Forte sdbc_handles(uintptr_t addr, uint_t flags, int argc,
2617*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2618*fcf3ce44SJohn Forte {
2619*fcf3ce44SJohn Forte 	uint_t opt_a = FALSE;
2620*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2621*fcf3ce44SJohn Forte 	uint_t opt_v = FALSE;
2622*fcf3ce44SJohn Forte 	uint_t opt_C = FALSE;
2623*fcf3ce44SJohn Forte 	_sd_buf_hlist_t hl;
2624*fcf3ce44SJohn Forte 	_sd_buf_handle_t bh;
2625*fcf3ce44SJohn Forte 
2626*fcf3ce44SJohn Forte 
2627*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2628*fcf3ce44SJohn Forte 			'a', MDB_OPT_SETBITS, TRUE, &opt_a,
2629*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2630*fcf3ce44SJohn Forte 			'C', MDB_OPT_SETBITS, TRUE, &opt_C,
2631*fcf3ce44SJohn Forte 			'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
2632*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2633*fcf3ce44SJohn Forte 
2634*fcf3ce44SJohn Forte 
2635*fcf3ce44SJohn Forte 	if (mdb_readvar(&hl, "_sd_handle_list") == -1) {
2636*fcf3ce44SJohn Forte 		mdb_warn("failed to read _sd_handle_list structure");
2637*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2638*fcf3ce44SJohn Forte 	}
2639*fcf3ce44SJohn Forte 
2640*fcf3ce44SJohn Forte 
2641*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2642*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_handles", "sdbc`sdbc_handles",
2643*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2644*fcf3ce44SJohn Forte 			mdb_warn("failed to walk 'sdbc_handle_list'");
2645*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2646*fcf3ce44SJohn Forte 		}
2647*fcf3ce44SJohn Forte 		return (DCMD_OK);
2648*fcf3ce44SJohn Forte 	}
2649*fcf3ce44SJohn Forte 
2650*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2651*fcf3ce44SJohn Forte 		mdb_printf("Handle List Info:\n");
2652*fcf3ce44SJohn Forte 
2653*fcf3ce44SJohn Forte 		mdb_inc_indent(4);
2654*fcf3ce44SJohn Forte 		mdb_printf("hl_top.bh_next: 0x%p\n", hl.hl_top.bh_next);
2655*fcf3ce44SJohn Forte 		mdb_printf("hl_lock: 0x%p (owner)\n", hl.hl_lock._opaque[0]);
2656*fcf3ce44SJohn Forte 		mdb_printf("hl_count: %hd\n", hl.hl_count);
2657*fcf3ce44SJohn Forte 		mdb_dec_indent(4);
2658*fcf3ce44SJohn Forte 		mdb_printf("buf handles:\n");
2659*fcf3ce44SJohn Forte 	}
2660*fcf3ce44SJohn Forte 
2661*fcf3ce44SJohn Forte 	if (mdb_vread(&bh, sizeof (bh), addr) == -1) {
2662*fcf3ce44SJohn Forte 		mdb_warn("failed to read buf handle at 0x%p", addr);
2663*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2664*fcf3ce44SJohn Forte 	}
2665*fcf3ce44SJohn Forte 
2666*fcf3ce44SJohn Forte 	if (!opt_a && !(bh.bh_flag & (NSC_HALLOCATED | NSC_HACTIVE)))
2667*fcf3ce44SJohn Forte 		return (DCMD_OK);
2668*fcf3ce44SJohn Forte 
2669*fcf3ce44SJohn Forte 	/*
2670*fcf3ce44SJohn Forte 	 * may get false matches on cd option --
2671*fcf3ce44SJohn Forte 	 * a cleared bh_cd field will match if user specified cd 0
2672*fcf3ce44SJohn Forte 	 */
2673*fcf3ce44SJohn Forte 	if (OPT_C_SELECTED && (bh.bh_cd != opt_c))
2674*fcf3ce44SJohn Forte 		return (DCMD_OK);
2675*fcf3ce44SJohn Forte 
2676*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2677*fcf3ce44SJohn Forte 	mdb_printf("%p %8T cd %3-d %4T<%b> %x\n", addr, bh.bh_cd,
2678*fcf3ce44SJohn Forte 					bh.bh_flag, nsc_buf_bits, bh.bh_flag);
2679*fcf3ce44SJohn Forte 
2680*fcf3ce44SJohn Forte 	/* check for verbose, avoid printing twice */
2681*fcf3ce44SJohn Forte 	if (!opt_v && opt_C) {
2682*fcf3ce44SJohn Forte 		mdb_printf("cc_chain: ");
2683*fcf3ce44SJohn Forte 		if (bh.bh_centry)
2684*fcf3ce44SJohn Forte 			mdb_call_dcmd("sdbc`sdbc_cchain",
2685*fcf3ce44SJohn Forte 			    (uintptr_t)bh.bh_centry, DCMD_ADDRSPEC, 0, NULL);
2686*fcf3ce44SJohn Forte 	}
2687*fcf3ce44SJohn Forte 
2688*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2689*fcf3ce44SJohn Forte 
2690*fcf3ce44SJohn Forte 	if (!opt_v)
2691*fcf3ce44SJohn Forte 		return (DCMD_OK);
2692*fcf3ce44SJohn Forte 
2693*fcf3ce44SJohn Forte 	/* verbose */
2694*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2695*fcf3ce44SJohn Forte 
2696*fcf3ce44SJohn Forte 	mdb_printf("callbacks: %-20a%-20a%-20a\n",
2697*fcf3ce44SJohn Forte 	    bh.bh_disconnect_cb, bh.bh_read_cb, bh.bh_write_cb);
2698*fcf3ce44SJohn Forte 
2699*fcf3ce44SJohn Forte 	mdb_printf("centry %?p %8T next %?p\n",
2700*fcf3ce44SJohn Forte 				bh.bh_centry, bh.bh_next);
2701*fcf3ce44SJohn Forte 	mdb_printf("buffer:\n");
2702*fcf3ce44SJohn Forte 
2703*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2704*fcf3ce44SJohn Forte 	mdb_printf("fd 0x%p pos %10d len %6d flag 0x%x\n",
2705*fcf3ce44SJohn Forte 		    bh.bh_buf.sb_fd, bh.bh_fba_pos, bh.bh_fba_len, bh.bh_flag);
2706*fcf3ce44SJohn Forte 
2707*fcf3ce44SJohn Forte 	mdb_printf("alloc_thread %p busy_thread %p\n", bh.bh_alloc_thread,
2708*fcf3ce44SJohn Forte 			bh.bh_busy_thread);
2709*fcf3ce44SJohn Forte 
2710*fcf3ce44SJohn Forte 	mdb_printf("err %4d %8T bh_vec 0x%p\n", bh.bh_error, bh.bh_vec);
2711*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2712*fcf3ce44SJohn Forte 
2713*fcf3ce44SJohn Forte 	mdb_printf("bufvec (scatter gather list): %-?s %8T%-s\n",
2714*fcf3ce44SJohn Forte 						"ADDR", "LEN");
2715*fcf3ce44SJohn Forte 	{
2716*fcf3ce44SJohn Forte 		_sd_bufvec_t *bv, *endvec;
2717*fcf3ce44SJohn Forte 
2718*fcf3ce44SJohn Forte 
2719*fcf3ce44SJohn Forte 		/* todo check for (bh_vec != bh_bufvec) => readahead? */
2720*fcf3ce44SJohn Forte 
2721*fcf3ce44SJohn Forte 		bv = bh.bh_bufvec;
2722*fcf3ce44SJohn Forte 		endvec = bv + _SD_MAX_BLKS;
2723*fcf3ce44SJohn Forte 		mdb_inc_indent(30);
2724*fcf3ce44SJohn Forte 		while (bv->bufaddr) {
2725*fcf3ce44SJohn Forte 			mdb_printf("%p    %8T%d\n", bv->bufaddr, bv->buflen);
2726*fcf3ce44SJohn Forte 			++bv;
2727*fcf3ce44SJohn Forte 			if (bv > endvec) {
2728*fcf3ce44SJohn Forte 				mdb_warn("END of bh_bufvec ARRAY");
2729*fcf3ce44SJohn Forte 				break;
2730*fcf3ce44SJohn Forte 			}
2731*fcf3ce44SJohn Forte 		}
2732*fcf3ce44SJohn Forte 		mdb_dec_indent(30);
2733*fcf3ce44SJohn Forte 	}
2734*fcf3ce44SJohn Forte 
2735*fcf3ce44SJohn Forte 	if (opt_C) {
2736*fcf3ce44SJohn Forte 		mdb_printf("cc_chain: ");
2737*fcf3ce44SJohn Forte 		if (bh.bh_centry)
2738*fcf3ce44SJohn Forte 			mdb_call_dcmd("sdbc`sdbc_cchain",
2739*fcf3ce44SJohn Forte 			    (uintptr_t)bh.bh_centry, DCMD_ADDRSPEC, 0, NULL);
2740*fcf3ce44SJohn Forte 	}
2741*fcf3ce44SJohn Forte 
2742*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2743*fcf3ce44SJohn Forte 	mdb_printf("\n");
2744*fcf3ce44SJohn Forte 
2745*fcf3ce44SJohn Forte 	return (DCMD_OK);
2746*fcf3ce44SJohn Forte }
2747*fcf3ce44SJohn Forte /*
2748*fcf3ce44SJohn Forte  * dcmd to display ss_centry_info_t structures and
2749*fcf3ce44SJohn Forte  * do optional consistency check with the nvram copy
2750*fcf3ce44SJohn Forte  * if configured for nvram safe storage.
2751*fcf3ce44SJohn Forte  */
2752*fcf3ce44SJohn Forte 
2753*fcf3ce44SJohn Forte static int
sdbc_glcinfo(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2754*fcf3ce44SJohn Forte sdbc_glcinfo(uintptr_t addr, uint_t flags, int argc,
2755*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2756*fcf3ce44SJohn Forte {
2757*fcf3ce44SJohn Forte 	ss_centry_info_t gl_centry_info;
2758*fcf3ce44SJohn Forte 	/* for doing consistency check */
2759*fcf3ce44SJohn Forte 
2760*fcf3ce44SJohn Forte 	ss_centry_info_t *gl_centry_info_start;
2761*fcf3ce44SJohn Forte 	ss_centry_info_t *nv_gl_centry_info_start;
2762*fcf3ce44SJohn Forte 	uintptr_t nv_addr;
2763*fcf3ce44SJohn Forte 	ss_centry_info_t nv_gl_centry_info;
2764*fcf3ce44SJohn Forte 
2765*fcf3ce44SJohn Forte 	/* options */
2766*fcf3ce44SJohn Forte 	uint_t opt_a = FALSE;
2767*fcf3ce44SJohn Forte 	uintptr_t opt_b = MDB_BLKNUM;	/* fba pos match */
2768*fcf3ce44SJohn Forte 	uintptr_t opt_c = MDB_CD;
2769*fcf3ce44SJohn Forte 	uintptr_t opt_C = FALSE; /* consistency check */
2770*fcf3ce44SJohn Forte 	uint_t opt_d = FALSE;
2771*fcf3ce44SJohn Forte 
2772*fcf3ce44SJohn Forte 
2773*fcf3ce44SJohn Forte 
2774*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2775*fcf3ce44SJohn Forte 			'a', MDB_OPT_SETBITS, TRUE, &opt_a,
2776*fcf3ce44SJohn Forte 			'b', MDB_OPT_UINTPTR, &opt_b,
2777*fcf3ce44SJohn Forte 			'c', MDB_OPT_UINTPTR, &opt_c,
2778*fcf3ce44SJohn Forte 			'C', MDB_OPT_SETBITS, TRUE, &opt_C,
2779*fcf3ce44SJohn Forte 			'd', MDB_OPT_SETBITS, TRUE, &opt_d) != argc)
2780*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2781*fcf3ce44SJohn Forte 
2782*fcf3ce44SJohn Forte 
2783*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2784*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_glcinfo", "sdbc`sdbc_glcinfo",
2785*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2786*fcf3ce44SJohn Forte 			mdb_warn("failed to walk global centry info array");
2787*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2788*fcf3ce44SJohn Forte 		}
2789*fcf3ce44SJohn Forte 		return (DCMD_OK);
2790*fcf3ce44SJohn Forte 	}
2791*fcf3ce44SJohn Forte 
2792*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2793*fcf3ce44SJohn Forte 		mdb_printf("global cache entry info:\n");
2794*fcf3ce44SJohn Forte 	}
2795*fcf3ce44SJohn Forte 
2796*fcf3ce44SJohn Forte 	if (mdb_vread(&gl_centry_info, sizeof (ss_centry_info_t), addr) == -1) {
2797*fcf3ce44SJohn Forte 		mdb_warn("failed to read gl_centry_info at 0x%p", addr);
2798*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2799*fcf3ce44SJohn Forte 	}
2800*fcf3ce44SJohn Forte 
2801*fcf3ce44SJohn Forte 
2802*fcf3ce44SJohn Forte 	/*
2803*fcf3ce44SJohn Forte 	 * default is to print entries initialized with a cd.  return if
2804*fcf3ce44SJohn Forte 	 * no options are selected and cd is invalid.
2805*fcf3ce44SJohn Forte 	 */
2806*fcf3ce44SJohn Forte 	if (!opt_a && (!OPT_B_SELECTED) && (!OPT_C_SELECTED) && !opt_d &&
2807*fcf3ce44SJohn Forte 		(gl_centry_info.sc_cd == -1))
2808*fcf3ce44SJohn Forte 		return (DCMD_OK);
2809*fcf3ce44SJohn Forte 
2810*fcf3ce44SJohn Forte 
2811*fcf3ce44SJohn Forte 	/*
2812*fcf3ce44SJohn Forte 	 * opt_c is exclusive filter. if opt_c is selected and there
2813*fcf3ce44SJohn Forte 	 * is no match on the cd then return
2814*fcf3ce44SJohn Forte 	 */
2815*fcf3ce44SJohn Forte 	if (!opt_a &&
2816*fcf3ce44SJohn Forte 		(OPT_C_SELECTED && (gl_centry_info.sc_cd != opt_c)))
2817*fcf3ce44SJohn Forte 		return (DCMD_OK);
2818*fcf3ce44SJohn Forte 
2819*fcf3ce44SJohn Forte 	/*
2820*fcf3ce44SJohn Forte 	 * opt_d and opt_b are inclusive. print if either one is chosen
2821*fcf3ce44SJohn Forte 	 * and the selection condition is true.
2822*fcf3ce44SJohn Forte 	 */
2823*fcf3ce44SJohn Forte 	if (opt_a ||
2824*fcf3ce44SJohn Forte 	    (!opt_d && (!OPT_B_SELECTED)) || /* no options chosen */
2825*fcf3ce44SJohn Forte 	    (opt_d && gl_centry_info.sc_dirty) ||
2826*fcf3ce44SJohn Forte 	    (OPT_B_SELECTED && (gl_centry_info.sc_fpos == opt_b)))
2827*fcf3ce44SJohn Forte 		/*EMPTY*/;
2828*fcf3ce44SJohn Forte 	else
2829*fcf3ce44SJohn Forte 		return (DCMD_OK);
2830*fcf3ce44SJohn Forte 
2831*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2832*fcf3ce44SJohn Forte 	mdb_printf("%?-p cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2833*fcf3ce44SJohn Forte 		addr,
2834*fcf3ce44SJohn Forte 		gl_centry_info.sc_cd,
2835*fcf3ce44SJohn Forte 		gl_centry_info.sc_fpos,
2836*fcf3ce44SJohn Forte 		gl_centry_info.sc_dirty & 0xffff,
2837*fcf3ce44SJohn Forte 		gl_centry_info.sc_flag, cc_flag_bits);
2838*fcf3ce44SJohn Forte 
2839*fcf3ce44SJohn Forte 	if (opt_C) {
2840*fcf3ce44SJohn Forte 		/* get start of the cache entry metadata */
2841*fcf3ce44SJohn Forte 		if (mdb_readvar(&gl_centry_info_start,
2842*fcf3ce44SJohn Forte 				"_sdbc_gl_centry_info") == -1) {
2843*fcf3ce44SJohn Forte 			mdb_warn("failed to read  _sdbc_gl_centry_info");
2844*fcf3ce44SJohn Forte 			/* not catastrophic */
2845*fcf3ce44SJohn Forte 			goto end;
2846*fcf3ce44SJohn Forte 		}
2847*fcf3ce44SJohn Forte 
2848*fcf3ce44SJohn Forte 		/* get start of the nvram copy cache entry metadata */
2849*fcf3ce44SJohn Forte 		if (mdb_readvar(&nv_gl_centry_info_start,
2850*fcf3ce44SJohn Forte 				"_sdbc_gl_centry_info_nvmem") == -1) {
2851*fcf3ce44SJohn Forte 			mdb_warn("failed to read  _sdbc_gl_centry_info_nvmem");
2852*fcf3ce44SJohn Forte 			/* not catastrophic */
2853*fcf3ce44SJohn Forte 			goto end;
2854*fcf3ce44SJohn Forte 		}
2855*fcf3ce44SJohn Forte 
2856*fcf3ce44SJohn Forte 		nv_addr = (addr - (uintptr_t)gl_centry_info_start) +
2857*fcf3ce44SJohn Forte 				(uintptr_t)nv_gl_centry_info_start;
2858*fcf3ce44SJohn Forte 
2859*fcf3ce44SJohn Forte 		if (mdb_vread(&nv_gl_centry_info, sizeof (ss_centry_info_t),
2860*fcf3ce44SJohn Forte 						    nv_addr) == -1) {
2861*fcf3ce44SJohn Forte 			mdb_warn("failed to read at nvmem_gl_info 0x%p",
2862*fcf3ce44SJohn Forte 					nv_addr);
2863*fcf3ce44SJohn Forte 		    /* not catastophic, continue */
2864*fcf3ce44SJohn Forte 	    } else {
2865*fcf3ce44SJohn Forte 
2866*fcf3ce44SJohn Forte 			/* consistency check */
2867*fcf3ce44SJohn Forte 			mdb_inc_indent(4);
2868*fcf3ce44SJohn Forte 			if (memcmp(&gl_centry_info, &nv_gl_centry_info,
2869*fcf3ce44SJohn Forte 					sizeof (ss_centry_info_t) != 0)) {
2870*fcf3ce44SJohn Forte 				mdb_warn(
2871*fcf3ce44SJohn Forte 				"nvram and host memory are NOT identical!");
2872*fcf3ce44SJohn Forte 				mdb_printf("nvmem_gl_centry_info: ");
2873*fcf3ce44SJohn Forte 				mdb_printf(
2874*fcf3ce44SJohn Forte 			    "%?-p cd %3-d fpos %10-d dirty %04x flag <%b>\n",
2875*fcf3ce44SJohn Forte 				nv_addr,
2876*fcf3ce44SJohn Forte 				nv_gl_centry_info.sc_cd,
2877*fcf3ce44SJohn Forte 				nv_gl_centry_info.sc_fpos,
2878*fcf3ce44SJohn Forte 				nv_gl_centry_info.sc_dirty & 0xffff,
2879*fcf3ce44SJohn Forte 				nv_gl_centry_info.sc_flag, cc_flag_bits);
2880*fcf3ce44SJohn Forte 				mdb_printf("\n");
2881*fcf3ce44SJohn Forte 		    } else
2882*fcf3ce44SJohn Forte 				mdb_printf("NVRAM ok\n");
2883*fcf3ce44SJohn Forte 
2884*fcf3ce44SJohn Forte 		    mdb_dec_indent(4);
2885*fcf3ce44SJohn Forte 
2886*fcf3ce44SJohn Forte 	    }
2887*fcf3ce44SJohn Forte 	}
2888*fcf3ce44SJohn Forte 
2889*fcf3ce44SJohn Forte 	end:
2890*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
2891*fcf3ce44SJohn Forte 	return (DCMD_OK);
2892*fcf3ce44SJohn Forte }
2893*fcf3ce44SJohn Forte 
2894*fcf3ce44SJohn Forte /*
2895*fcf3ce44SJohn Forte  * dcmd to display ss_voldata_t structures and
2896*fcf3ce44SJohn Forte  * do optional consistency check with the nvram copy
2897*fcf3ce44SJohn Forte  * if configured for nvram safe storage.
2898*fcf3ce44SJohn Forte  */
2899*fcf3ce44SJohn Forte 
2900*fcf3ce44SJohn Forte static int
sdbc_glfinfo(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2901*fcf3ce44SJohn Forte sdbc_glfinfo(uintptr_t addr, uint_t flags, int argc,
2902*fcf3ce44SJohn Forte 					const mdb_arg_t *argv)
2903*fcf3ce44SJohn Forte {
2904*fcf3ce44SJohn Forte 	ss_voldata_t gl_file_info;
2905*fcf3ce44SJohn Forte 	/* for doing consistency check */
2906*fcf3ce44SJohn Forte 
2907*fcf3ce44SJohn Forte 	ss_voldata_t *gl_file_info_start;
2908*fcf3ce44SJohn Forte 	ss_voldata_t *nv_gl_file_info_start;
2909*fcf3ce44SJohn Forte 	uintptr_t nv_addr;
2910*fcf3ce44SJohn Forte 	ss_voldata_t nv_gl_file_info;
2911*fcf3ce44SJohn Forte 
2912*fcf3ce44SJohn Forte 	/* options  default: valid filename */
2913*fcf3ce44SJohn Forte 	uint_t opt_a = FALSE; /* all */
2914*fcf3ce44SJohn Forte 	uint_t opt_p = FALSE; /* PINNED */
2915*fcf3ce44SJohn Forte 	uint_t opt_t = FALSE; /* attached */
2916*fcf3ce44SJohn Forte 	uint_t opt_C = FALSE; /* consistency check */
2917*fcf3ce44SJohn Forte 
2918*fcf3ce44SJohn Forte 
2919*fcf3ce44SJohn Forte 
2920*fcf3ce44SJohn Forte 	/*
2921*fcf3ce44SJohn Forte 	 * possible enhancement -- match on filename,
2922*fcf3ce44SJohn Forte 	 * or filename part (e.g. controller number)
2923*fcf3ce44SJohn Forte 	 */
2924*fcf3ce44SJohn Forte 	if (mdb_getopts(argc, argv,
2925*fcf3ce44SJohn Forte 			'a', MDB_OPT_SETBITS, TRUE, &opt_a,
2926*fcf3ce44SJohn Forte 			'C', MDB_OPT_SETBITS, TRUE, &opt_C,
2927*fcf3ce44SJohn Forte 			'p', MDB_OPT_SETBITS, TRUE, &opt_p,
2928*fcf3ce44SJohn Forte 			't', MDB_OPT_SETBITS, TRUE, &opt_t) != argc)
2929*fcf3ce44SJohn Forte 		return (DCMD_USAGE);
2930*fcf3ce44SJohn Forte 
2931*fcf3ce44SJohn Forte 
2932*fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC)) {
2933*fcf3ce44SJohn Forte 		if (mdb_walk_dcmd("sdbc`sdbc_glfinfo", "sdbc`sdbc_glfinfo",
2934*fcf3ce44SJohn Forte 					argc, argv) == -1) {
2935*fcf3ce44SJohn Forte 			mdb_warn("failed to walk global file info array");
2936*fcf3ce44SJohn Forte 			return (DCMD_ERR);
2937*fcf3ce44SJohn Forte 		}
2938*fcf3ce44SJohn Forte 		return (DCMD_OK);
2939*fcf3ce44SJohn Forte 	}
2940*fcf3ce44SJohn Forte 
2941*fcf3ce44SJohn Forte 	if (DCMD_HDRSPEC(flags)) {
2942*fcf3ce44SJohn Forte 		mdb_printf("global file entry info:\n");
2943*fcf3ce44SJohn Forte 	}
2944*fcf3ce44SJohn Forte 
2945*fcf3ce44SJohn Forte 	if (mdb_vread(&gl_file_info, sizeof (ss_voldata_t), addr) == -1) {
2946*fcf3ce44SJohn Forte 		mdb_warn("failed to read gl_file_info at 0x%p", addr);
2947*fcf3ce44SJohn Forte 		return (DCMD_ERR);
2948*fcf3ce44SJohn Forte 	}
2949*fcf3ce44SJohn Forte 
2950*fcf3ce44SJohn Forte 
2951*fcf3ce44SJohn Forte 	/*
2952*fcf3ce44SJohn Forte 	 * default is to print entries initialized with non-null filename.
2953*fcf3ce44SJohn Forte 	 * return if no options are selected and filename is invalid.
2954*fcf3ce44SJohn Forte 	 */
2955*fcf3ce44SJohn Forte 	if (!opt_a && !opt_p && !opt_t &&
2956*fcf3ce44SJohn Forte 		(strlen(gl_file_info.sv_volname) == 0))
2957*fcf3ce44SJohn Forte 		return (DCMD_OK);
2958*fcf3ce44SJohn Forte 
2959*fcf3ce44SJohn Forte 
2960*fcf3ce44SJohn Forte 	if (opt_a ||
2961*fcf3ce44SJohn Forte 		(!opt_p && !opt_t) || /* no options chosen */
2962*fcf3ce44SJohn Forte 		(opt_p && (gl_file_info.sv_pinned != _SD_NO_HOST)) ||
2963*fcf3ce44SJohn Forte 		(opt_t && (gl_file_info.sv_attached != _SD_NO_HOST)))
2964*fcf3ce44SJohn Forte 		/*EMPTY*/;
2965*fcf3ce44SJohn Forte 	else
2966*fcf3ce44SJohn Forte 		return (DCMD_OK);
2967*fcf3ce44SJohn Forte 
2968*fcf3ce44SJohn Forte 	mdb_inc_indent(4);
2969*fcf3ce44SJohn Forte 	mdb_printf("%?-p %s\n", addr, gl_file_info.sv_volname);
2970*fcf3ce44SJohn Forte 	mdb_printf("pinned %2-d attached %2-d devidsz %3-d\n",
2971*fcf3ce44SJohn Forte 		gl_file_info.sv_pinned,
2972*fcf3ce44SJohn Forte 		gl_file_info.sv_attached,
2973*fcf3ce44SJohn Forte 		gl_file_info.sv_devidsz);
2974*fcf3ce44SJohn Forte 	mdb_printf("devid %s\n", gl_file_info.sv_devid);
2975*fcf3ce44SJohn Forte 
2976*fcf3ce44SJohn Forte 	if (opt_C) {
2977*fcf3ce44SJohn Forte 		/* get start of the cache entry metadata */
2978*fcf3ce44SJohn Forte 		if (mdb_readvar(&gl_file_info_start,
2979*fcf3ce44SJohn Forte 				"_sdbc_gl_file_info") == -1) {
2980*fcf3ce44SJohn Forte 			mdb_warn("failed to read  _sdbc_gl_file_info");
2981*fcf3ce44SJohn Forte 			/* not catastrophic */
2982*fcf3ce44SJohn Forte 			goto end;
2983*fcf3ce44SJohn Forte 		}
2984*fcf3ce44SJohn Forte 
2985*fcf3ce44SJohn Forte 		/* get start of the nvram copy cache entry metadata */
2986*fcf3ce44SJohn Forte 		if (mdb_readvar(&nv_gl_file_info_start,
2987*fcf3ce44SJohn Forte 				"_sdbc_gl_file_info_nvmem") == -1) {
2988*fcf3ce44SJohn Forte 			mdb_warn("failed to read  _sdbc_gl_file_info_nvmem");
2989*fcf3ce44SJohn Forte 			/* not catastrophic */
2990*fcf3ce44SJohn Forte 			goto end;
2991*fcf3ce44SJohn Forte 		}
2992*fcf3ce44SJohn Forte 
2993*fcf3ce44SJohn Forte 		nv_addr = (addr - (uintptr_t)gl_file_info_start) +
2994*fcf3ce44SJohn Forte 				(uintptr_t)nv_gl_file_info_start;
2995*fcf3ce44SJohn Forte 
2996*fcf3ce44SJohn Forte 		if (mdb_vread(&nv_gl_file_info, sizeof (ss_voldata_t),
2997*fcf3ce44SJohn Forte 						    nv_addr) == -1) {
2998*fcf3ce44SJohn Forte 			mdb_warn("failed to read nvmem_gl_info at 0x%p",
2999*fcf3ce44SJohn Forte 					nv_addr);
3000*fcf3ce44SJohn Forte 		    /* not catastophic, continue */
3001*fcf3ce44SJohn Forte 	    } else {
3002*fcf3ce44SJohn Forte 
3003*fcf3ce44SJohn Forte 		    /* consistency check */
3004*fcf3ce44SJohn Forte 		    mdb_inc_indent(4);
3005*fcf3ce44SJohn Forte 		    if (memcmp(&gl_file_info, &nv_gl_file_info,
3006*fcf3ce44SJohn Forte 				sizeof (ss_centry_info_t) != 0)) {
3007*fcf3ce44SJohn Forte 			mdb_warn("nvram and host memory are NOT identical!");
3008*fcf3ce44SJohn Forte 			mdb_printf("nvmem_gl_file_info: ");
3009*fcf3ce44SJohn Forte 			mdb_printf("%?-p %s\n", nv_addr,
3010*fcf3ce44SJohn Forte 					nv_gl_file_info.sv_volname);
3011*fcf3ce44SJohn Forte 			mdb_printf("pinned %2-d attached %2-d devidsz %3-d\n",
3012*fcf3ce44SJohn Forte 				nv_gl_file_info.sv_pinned,
3013*fcf3ce44SJohn Forte 				nv_gl_file_info.sv_attached,
3014*fcf3ce44SJohn Forte 				nv_gl_file_info.sv_devidsz);
3015*fcf3ce44SJohn Forte 			mdb_printf("devid %s\n", nv_gl_file_info.sv_devid);
3016*fcf3ce44SJohn Forte 		    } else
3017*fcf3ce44SJohn Forte 			mdb_printf("NVRAM ok\n");
3018*fcf3ce44SJohn Forte 
3019*fcf3ce44SJohn Forte 		    mdb_dec_indent(4);
3020*fcf3ce44SJohn Forte 
3021*fcf3ce44SJohn Forte 	    }
3022*fcf3ce44SJohn Forte 	}
3023*fcf3ce44SJohn Forte 
3024*fcf3ce44SJohn Forte 	end:
3025*fcf3ce44SJohn Forte 	mdb_dec_indent(4);
3026*fcf3ce44SJohn Forte 	mdb_printf("\n");
3027*fcf3ce44SJohn Forte 	return (DCMD_OK);
3028*fcf3ce44SJohn Forte }
3029*fcf3ce44SJohn Forte 
3030*fcf3ce44SJohn Forte 
3031*fcf3ce44SJohn Forte /*
3032*fcf3ce44SJohn Forte  * MDB module linkage information:
3033*fcf3ce44SJohn Forte  *
3034*fcf3ce44SJohn Forte  * We declare a list of structures describing our dcmds, and a function
3035*fcf3ce44SJohn Forte  * named _mdb_init to return a pointer to our module information.
3036*fcf3ce44SJohn Forte  */
3037*fcf3ce44SJohn Forte 
3038*fcf3ce44SJohn Forte static const mdb_dcmd_t dcmds[] = {
3039*fcf3ce44SJohn Forte 	/* general dcmds */
3040*fcf3ce44SJohn Forte 	{ "sdbc_config", NULL,
3041*fcf3ce44SJohn Forte 		"display sdbc configuration information",
3042*fcf3ce44SJohn Forte 		sdbc_config },
3043*fcf3ce44SJohn Forte 	{ "sdbc_stats", NULL,
3044*fcf3ce44SJohn Forte 		"display sdbc stats information",
3045*fcf3ce44SJohn Forte 		sdbc_stats },
3046*fcf3ce44SJohn Forte 	{ "sdbc_vars", NULL,
3047*fcf3ce44SJohn Forte 		"display some sdbc variables, counters and addresses",
3048*fcf3ce44SJohn Forte 		sdbc_vars },
3049*fcf3ce44SJohn Forte 
3050*fcf3ce44SJohn Forte 	/* cctl dcmds */
3051*fcf3ce44SJohn Forte 	{"sdbc_cctl", "?[-vdhioV][-c cd][-b blknum]",
3052*fcf3ce44SJohn Forte 		"display sdbc cache ctl structures",
3053*fcf3ce44SJohn Forte 		sdbc_cctl, cctl_help },
3054*fcf3ce44SJohn Forte 	{"sdbc_cchain", ":[-vdhioV][-c cd][-b blknum]",
3055*fcf3ce44SJohn Forte 		"display cache ctl structure cc_chain",
3056*fcf3ce44SJohn Forte 		sdbc_cchain, cchain_help },
3057*fcf3ce44SJohn Forte 	{"sdbc_dchain", ":[-vdhioV][-c cd][-b blknum]",
3058*fcf3ce44SJohn Forte 		"display cache ctl structure dirty chain",
3059*fcf3ce44SJohn Forte 		sdbc_dchain, dchain_help },
3060*fcf3ce44SJohn Forte 	{"sdbc_dmchain", ":[-vdhioV][-c cd][-b blknum]",
3061*fcf3ce44SJohn Forte 		"display dynamic memory cache ctl chain",
3062*fcf3ce44SJohn Forte 		sdbc_dmchain, dmchain_help },
3063*fcf3ce44SJohn Forte 	{"sdbc_hashchain", ":[-vdhioV][-c cd][-b blknum]",
3064*fcf3ce44SJohn Forte 		"display a hash chain", sdbc_hashchain, hashchain_help },
3065*fcf3ce44SJohn Forte 	{"sdbc_hashtable", "?[-vdhioV][-c cd][-b blknum]",
3066*fcf3ce44SJohn Forte 		"display hash table", sdbc_hashtable, hashtable_help },
3067*fcf3ce44SJohn Forte 	{"sdbc_lru", "?[-vdhioV][-c cd][-b blknum]",
3068*fcf3ce44SJohn Forte 		"display the cache lru queue",
3069*fcf3ce44SJohn Forte 		sdbc_lru, lru_help },
3070*fcf3ce44SJohn Forte #ifdef SAFESTORE
3071*fcf3ce44SJohn Forte 	/* wctl dcmds */
3072*fcf3ce44SJohn Forte 	{"sdbc_wctl", "?[-vd][-c cd]",
3073*fcf3ce44SJohn Forte 		"display the write control structures",
3074*fcf3ce44SJohn Forte 		sdbc_wctl, wctl_help },
3075*fcf3ce44SJohn Forte 	{"sdbc_wrq", "?[-vd][-c cd]",
3076*fcf3ce44SJohn Forte 		"display the write control queue",
3077*fcf3ce44SJohn Forte 		sdbc_wrq, wrq_help },
3078*fcf3ce44SJohn Forte #endif /* SAFESTORE */
3079*fcf3ce44SJohn Forte 
3080*fcf3ce44SJohn Forte 	/* others */
3081*fcf3ce44SJohn Forte 	{"sdbc_cdinfo", "?[-av][-c cd]",
3082*fcf3ce44SJohn Forte 		"display cache descriptor information",
3083*fcf3ce44SJohn Forte 		sdbc_cdinfo, cdinfo_help },
3084*fcf3ce44SJohn Forte #ifdef SAFESTORE
3085*fcf3ce44SJohn Forte 	{"sdbc_ftctl", "?[-vd][-c cd]",
3086*fcf3ce44SJohn Forte 		"display the fault tolerant control structures",
3087*fcf3ce44SJohn Forte 		sdbc_ftctl, ftctl_help },
3088*fcf3ce44SJohn Forte #endif /* SAFESTORE */
3089*fcf3ce44SJohn Forte 	{"sdbc_handles", "?[-avC][-c cd]",
3090*fcf3ce44SJohn Forte 		"display sdbc buffer handle information",
3091*fcf3ce44SJohn Forte 		sdbc_handles, handle_help },
3092*fcf3ce44SJohn Forte 
3093*fcf3ce44SJohn Forte 	{ "sdbc_dmqueues", NULL,
3094*fcf3ce44SJohn Forte 		"display sdbc dynamic memory buffer queues information",
3095*fcf3ce44SJohn Forte 		sdbc_dmqueues },
3096*fcf3ce44SJohn Forte 
3097*fcf3ce44SJohn Forte 	/* "global" metadata dcmds */
3098*fcf3ce44SJohn Forte 	{"sdbc_glcinfo", "?[-adC][-c cd][-b fbapos]",
3099*fcf3ce44SJohn Forte 		"display the global cache entry info structures",
3100*fcf3ce44SJohn Forte 		sdbc_glcinfo, glcinfo_help },
3101*fcf3ce44SJohn Forte 	{"sdbc_glfinfo", "?[-aptC]",
3102*fcf3ce44SJohn Forte 		"display the global file info structures",
3103*fcf3ce44SJohn Forte 		sdbc_glfinfo, glfinfo_help },
3104*fcf3ce44SJohn Forte 	{ NULL }
3105*fcf3ce44SJohn Forte };
3106*fcf3ce44SJohn Forte 
3107*fcf3ce44SJohn Forte static const mdb_walker_t walkers[] = {
3108*fcf3ce44SJohn Forte 	/* walkers of cctl list and arrays */
3109*fcf3ce44SJohn Forte 	{ "sdbc_cchain", "walk the cc_chain (alloc chain) of a cache ctl",
3110*fcf3ce44SJohn Forte 		sdbc_cchain_winit, sdbc_cchain_wstep, sdbc_cchain_wfini },
3111*fcf3ce44SJohn Forte 	{ "sdbc_cctl", "walk the cache ctl structure list",
3112*fcf3ce44SJohn Forte 		sdbc_cctl_winit, sdbc_cctl_wstep, sdbc_cctl_wfini },
3113*fcf3ce44SJohn Forte 	{ "sdbc_dchain", "walk the dirty chain of a cache ctl",
3114*fcf3ce44SJohn Forte 		sdbc_dchain_winit, sdbc_dchain_wstep, sdbc_dchain_wfini },
3115*fcf3ce44SJohn Forte 	{ "sdbc_dmchain", "walk the dynamic memory chain of a cache cctl",
3116*fcf3ce44SJohn Forte 		sdbc_dmchain_winit, sdbc_dmchain_wstep, sdbc_dmchain_wfini },
3117*fcf3ce44SJohn Forte 	{ "sdbc_hashchain", "walk a hash chain",
3118*fcf3ce44SJohn Forte 		sdbc_hashchain_winit, sdbc_hashchain_wstep,
3119*fcf3ce44SJohn Forte 					sdbc_hashchain_wfini },
3120*fcf3ce44SJohn Forte 	{ "sdbc_lru", "walk the cache lru queue",
3121*fcf3ce44SJohn Forte 		sdbc_lru_winit, sdbc_lru_wstep, sdbc_lru_wfini },
3122*fcf3ce44SJohn Forte 
3123*fcf3ce44SJohn Forte #ifdef SAFESTORE
3124*fcf3ce44SJohn Forte 	/* walkers of wctl lists and arrays */
3125*fcf3ce44SJohn Forte 	{ "sdbc_wctl", "walk the allocated write ctl array",
3126*fcf3ce44SJohn Forte 		sdbc_wctl_winit, sdbc_wctl_wstep, sdbc_wctl_wfini },
3127*fcf3ce44SJohn Forte 	{ "sdbc_wrq", "walk the write ctl queue (free list)",
3128*fcf3ce44SJohn Forte 		sdbc_wrq_winit, sdbc_wrq_wstep, sdbc_wrq_wfini },
3129*fcf3ce44SJohn Forte #endif /* SAFESTORE */
3130*fcf3ce44SJohn Forte 	/* others */
3131*fcf3ce44SJohn Forte 	{ "sdbc_cdinfo",
3132*fcf3ce44SJohn Forte 	    "walk the _sd_cache_files array of cache descriptor information",
3133*fcf3ce44SJohn Forte 		sdbc_cdinfo_winit, sdbc_cdinfo_wstep, sdbc_cdinfo_wfini },
3134*fcf3ce44SJohn Forte #ifdef SAFESTORE
3135*fcf3ce44SJohn Forte 	{ "sdbc_ftctl",
3136*fcf3ce44SJohn Forte 	    "walk the allocated array of fault tolerant structures",
3137*fcf3ce44SJohn Forte 		sdbc_ftctl_winit, sdbc_ftctl_wstep, sdbc_ftctl_wfini },
3138*fcf3ce44SJohn Forte #endif /* SAFESTORE */
3139*fcf3ce44SJohn Forte 	{ "sdbc_handles", "walk array of _sd_buf_handle_t structures",
3140*fcf3ce44SJohn Forte 		sdbc_handle_winit, sdbc_handle_wstep, sdbc_handle_wfini },
3141*fcf3ce44SJohn Forte 
3142*fcf3ce44SJohn Forte 	/* walkers for metadata arrays */
3143*fcf3ce44SJohn Forte 	{ "sdbc_glcinfo", "walk the allocated global cache entry info array",
3144*fcf3ce44SJohn Forte 		sdbc_glcinfo_winit, sdbc_glcinfo_wstep, sdbc_glcinfo_wfini },
3145*fcf3ce44SJohn Forte 	{ "sdbc_glfinfo", "walk the allocated global file info array",
3146*fcf3ce44SJohn Forte 		sdbc_glfinfo_winit, sdbc_glfinfo_wstep, sdbc_glfinfo_wfini },
3147*fcf3ce44SJohn Forte 	{ NULL }
3148*fcf3ce44SJohn Forte };
3149*fcf3ce44SJohn Forte 
3150*fcf3ce44SJohn Forte static const mdb_modinfo_t modinfo = {
3151*fcf3ce44SJohn Forte 	MDB_API_VERSION, dcmds, walkers
3152*fcf3ce44SJohn Forte };
3153*fcf3ce44SJohn Forte 
3154*fcf3ce44SJohn Forte const mdb_modinfo_t *
_mdb_init(void)3155*fcf3ce44SJohn Forte _mdb_init(void)
3156*fcf3ce44SJohn Forte {
3157*fcf3ce44SJohn Forte 	return (&modinfo);
3158*fcf3ce44SJohn Forte }
3159