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, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include "mdinclude.h"
30
31 extern int active_sets;
32 md_set_io_t md_setio[MD_MAXSETS];
33
34 /* IO array status: io_state */
35 static const mdb_bitmask_t io_state_bits[] = {
36 { "MD_SET_ACTIVE", MD_SET_ACTIVE, MD_SET_ACTIVE },
37 { "MD_SET_RELEASE", MD_SET_RELEASE, MD_SET_RELEASE },
38 { NULL, 0, 0 }
39 };
40
41
42 void
set_io_help(void)43 set_io_help(void)
44 {
45 mdb_printf("::set_io [-s name] [-a num] [-m num]\n");
46 mdb_printf("-a num - print out num elements in the md_set_io array\n");
47 mdb_printf("-s name - print out the information for set named name\n");
48 mdb_printf("-m num - only print out element num\n");
49 }
50
51 /* ARGSUSED */
52 int
set_io(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)53 set_io(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
54 {
55 GElf_Sym setiosym;
56 uint64_t i;
57 size_t offset = 0;
58 uint64_t opt_a = 0; /* up to active_sets */
59 char *opt_s = (char *)NULL; /* a named set */
60 uint64_t opt_m = 0; /* array element */
61 int setno = 0;
62 int argnum = 0;
63
64 argnum = mdb_getopts(argc, argv,
65 'a', MDB_OPT_UINT64, &opt_a,
66 's', MDB_OPT_STR, &opt_s,
67 'm', MDB_OPT_UINT64, &opt_m, NULL);
68
69 if (argnum != argc) {
70 mdb_printf("invalid arguments\n");
71 return (DCMD_USAGE);
72 }
73
74 if ((opt_s != 0) && (opt_m != 0)) {
75 mdb_printf("-s and -m cannot both be specified\n");
76 return (DCMD_USAGE);
77 }
78
79 snarf_sets();
80
81 if (opt_a == 0)
82 opt_a = active_sets;
83
84 /* find the array */
85 if (mdb_lookup_by_name("md_set_io", &setiosym) == -1) {
86 mdb_warn("SVM - no set io counts set\n");
87 return (DCMD_ERR);
88 }
89
90 if (md_verbose) {
91 mdb_printf("Base address for the md_set_io array: %p\n",
92 setiosym.st_value);
93 }
94 if (opt_s != NULL) {
95 setno = findset(opt_s);
96 if (setno == -1) {
97 mdb_warn("no such set: %s\n", opt_s);
98 return (DCMD_ERR);
99 }
100 opt_m = setno;
101 }
102
103 if (opt_m > 0) {
104 mdb_printf("%lld]\t%ld\t%ld", opt_m,
105 md_setio[opt_m].io_cnt, md_setio[opt_m].io_state);
106 mdb_printf("\t%hb\n", io_state_bits);
107 return (DCMD_OK);
108 }
109
110 if (opt_a == 0) {
111 mdb_warn("No active set!\n");
112 return (DCMD_ERR);
113 }
114
115 for (i = 0; i < opt_a; i++) {
116 if (mdb_vread(&md_setio[i], sizeof (md_set_io_t),
117 setiosym.st_value + offset) == -1) {
118 mdb_warn("failed to read md_set_io_t at 0x%x\n",
119 setiosym.st_value + offset);
120 }
121 mdb_printf("%lld]\t%ld\t%ld", i, md_setio[i].io_cnt,
122 md_setio[i].io_state);
123 mdb_printf("\t%hb", io_state_bits);
124 if (md_verbose) {
125 mdb_printf(" - io_cnt: %p",
126 setiosym.st_value + offset + sizeof (kmutex_t) +
127 sizeof (kcondvar_t));
128 mdb_printf(" %d", sizeof (md_set_io_t));
129 }
130 mdb_printf("\n");
131 offset += sizeof (md_set_io_t);
132 }
133 return (DCMD_OK);
134 }
135