xref: /titanic_41/usr/src/cmd/mdb/common/modules/md/md.c (revision 36e852a172cba914383d7341c988128b2c667fbd)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/mdb_modapi.h>
27 
28 
29 int	md_verbose = 0;		/* be verbose about the addresses */
30 
31 extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *);
32 extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *);
33 extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *);
34 extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *);
35 extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *);
36 extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *);
37 extern int printmmbm(uintptr_t, uint_t, int, const mdb_arg_t *);
38 extern void set_io_help();
39 
40 /* from mdbgen */
41 extern int mddb_db_walk_init(mdb_walk_state_t *);
42 extern int mddb_db_walk_step(mdb_walk_state_t *);
43 extern int mddb_de_ic_walk_init(mdb_walk_state_t *);
44 extern int mddb_de_ic_walk_step(mdb_walk_state_t *);
45 extern int hotsparepool_walk_init(mdb_walk_state_t *);
46 extern int hotsparepool_walk_step(mdb_walk_state_t *);
47 extern void hotsparepool_walk_fini(mdb_walk_state_t *);
48 extern int didnamespace_walk_init(mdb_walk_state_t *);
49 extern int didnamespace_walk_step(mdb_walk_state_t *);
50 extern void didnamespace_walk_fini(mdb_walk_state_t *);
51 extern int namespace_walk_init(mdb_walk_state_t *);
52 extern int namespace_walk_step(mdb_walk_state_t *);
53 extern void namespace_walk_fini(mdb_walk_state_t *);
54 extern int sets_walk_init(mdb_walk_state_t *);
55 extern int sets_walk_step(mdb_walk_state_t *);
56 extern void sets_walk_fini(mdb_walk_state_t *);
57 extern int units_walk_init(mdb_walk_state_t *);
58 extern int units_walk_step(mdb_walk_state_t *);
59 extern void units_walk_fini(mdb_walk_state_t *);
60 extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *);
61 int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *);
62 
63 
64 const mdb_dcmd_t dcmds[] = {
65 	{ "md_verbose", NULL, "toggle verbose mode for SVM dcmds",
66 	    md_set_verbose },
67 	{ "metaset", NULL, "list SVM metasets", metaset },
68 	{ "metastat", "[-v]", "list SVM metadevices",
69 	    metastat },
70 	{ "set_io", NULL, "show the pending IO counts", set_io,
71 	    set_io_help },
72 	{ "dumpnamespace", "[-s setname]", "dump the SVM name space",
73 	    dumpnamespace },
74 	{ "dumphotspare", NULL, "dump the hot spare pools",
75 	    dumphotspare },
76 	{ "dumpsetaddr", "[-s setname]", "dump the SVM set addresses",
77 	    dumpsetaddr },
78 	{ "simple_de_ic", NULL, "simple mddb_de_ic_t",
79 	    simple_de_ic },
80 	{ "printmmbm", NULL, "print bitmaps for given mm_unit_t",
81 	    printmmbm },
82 	{ NULL }
83 };
84 
85 static const mdb_walker_t walkers[] = {
86 	{ "mddb_db", "walk list of mddb_db_t structures",
87 	    mddb_db_walk_init, mddb_db_walk_step, NULL, NULL },
88 	{ "mddb_de_ic", "walk list of mddb_de_t structures",
89 	    mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL },
90 	{ "hotsparepool", "walk list of hotspare pools",
91 	    hotsparepool_walk_init, hotsparepool_walk_step,
92 	    hotsparepool_walk_fini, NULL },
93 	{ "didnamespace", "walk the did namespace",
94 	    didnamespace_walk_init, didnamespace_walk_step,
95 	    didnamespace_walk_fini, NULL },
96 	{ "namespace", "walk the namespace",
97 	    namespace_walk_init, namespace_walk_step, namespace_walk_fini,
98 	    NULL },
99 	{ "md_sets", "walk list of sets",
100 	    sets_walk_init, sets_walk_step, sets_walk_fini, NULL },
101 	{ "md_units", "walk list of unit structures",
102 	    units_walk_init, units_walk_step, units_walk_fini, NULL },
103 	{ NULL }
104 };
105 
106 static const mdb_modinfo_t modinfo = {
107 	MDB_API_VERSION, dcmds, walkers
108 };
109 
110 const mdb_modinfo_t *
111 _mdb_init(void)
112 {
113 	return (&modinfo);
114 }
115 
116 
117 /* ARGSUSED */
118 int
119 md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
120 {
121 	md_verbose = !md_verbose;
122 
123 	if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0)
124 		return (DCMD_USAGE);
125 
126 	mdb_printf("Verbose mode is now %d\n", md_verbose);
127 	return (DCMD_OK);
128 }
129