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