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/types.h>
27*7836SJohn.Forte@Sun.COM #include <sys/mdb_modapi.h>
28*7836SJohn.Forte@Sun.COM
29*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h>
30*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s.h>
31*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s_k.h>
32*7836SJohn.Forte@Sun.COM
33*7836SJohn.Forte@Sun.COM #include <rpc/auth.h>
34*7836SJohn.Forte@Sun.COM #include <rpc/auth_unix.h>
35*7836SJohn.Forte@Sun.COM #include <rpc/auth_des.h>
36*7836SJohn.Forte@Sun.COM #include <rpc/svc.h>
37*7836SJohn.Forte@Sun.COM #include <rpc/xdr.h>
38*7836SJohn.Forte@Sun.COM #include <rpc/svc_soc.h>
39*7836SJohn.Forte@Sun.COM
40*7836SJohn.Forte@Sun.COM /* HACK HACK so we can bring in rdc_io.h and friends */
41*7836SJohn.Forte@Sun.COM #define nstset_t char
42*7836SJohn.Forte@Sun.COM
43*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc.h>
44*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_prot.h>
45*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_ioctl.h>
46*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_io.h>
47*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_bitmap.h>
48*7836SJohn.Forte@Sun.COM
49*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsvers.h>
50*7836SJohn.Forte@Sun.COM
51*7836SJohn.Forte@Sun.COM
52*7836SJohn.Forte@Sun.COM /*
53*7836SJohn.Forte@Sun.COM * Walker for an array of rdc_k_info_t structures.
54*7836SJohn.Forte@Sun.COM * A global walk is assumed to start at rdc_k_info.
55*7836SJohn.Forte@Sun.COM */
56*7836SJohn.Forte@Sun.COM
57*7836SJohn.Forte@Sun.COM struct rdc_kinfo_winfo {
58*7836SJohn.Forte@Sun.COM uintptr_t start;
59*7836SJohn.Forte@Sun.COM uintptr_t end;
60*7836SJohn.Forte@Sun.COM };
61*7836SJohn.Forte@Sun.COM
62*7836SJohn.Forte@Sun.COM char bitstr[33] = { '0' };
63*7836SJohn.Forte@Sun.COM
64*7836SJohn.Forte@Sun.COM static int
rdc_k_info_winit(mdb_walk_state_t * wsp)65*7836SJohn.Forte@Sun.COM rdc_k_info_winit(mdb_walk_state_t *wsp)
66*7836SJohn.Forte@Sun.COM {
67*7836SJohn.Forte@Sun.COM struct rdc_kinfo_winfo *winfo;
68*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info;
69*7836SJohn.Forte@Sun.COM int rdc_max_sets;
70*7836SJohn.Forte@Sun.COM
71*7836SJohn.Forte@Sun.COM winfo = mdb_zalloc(sizeof (struct rdc_kinfo_winfo), UM_SLEEP);
72*7836SJohn.Forte@Sun.COM
73*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
74*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
75*7836SJohn.Forte@Sun.COM mdb_free(winfo, sizeof (struct rdc_kinfo_winfo));
76*7836SJohn.Forte@Sun.COM return (WALK_ERR);
77*7836SJohn.Forte@Sun.COM }
78*7836SJohn.Forte@Sun.COM
79*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_max_sets, "rdc_max_sets") == -1) {
80*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_max_sets'");
81*7836SJohn.Forte@Sun.COM mdb_free(winfo, sizeof (struct rdc_kinfo_winfo));
82*7836SJohn.Forte@Sun.COM return (WALK_ERR);
83*7836SJohn.Forte@Sun.COM }
84*7836SJohn.Forte@Sun.COM
85*7836SJohn.Forte@Sun.COM winfo->start = (uintptr_t)rdc_k_info;
86*7836SJohn.Forte@Sun.COM winfo->end = (uintptr_t)(rdc_k_info + rdc_max_sets);
87*7836SJohn.Forte@Sun.COM
88*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL)
89*7836SJohn.Forte@Sun.COM wsp->walk_addr = winfo->start;
90*7836SJohn.Forte@Sun.COM
91*7836SJohn.Forte@Sun.COM wsp->walk_data = winfo;
92*7836SJohn.Forte@Sun.COM return (WALK_NEXT);
93*7836SJohn.Forte@Sun.COM }
94*7836SJohn.Forte@Sun.COM
95*7836SJohn.Forte@Sun.COM
96*7836SJohn.Forte@Sun.COM static int
rdc_k_info_wstep(mdb_walk_state_t * wsp)97*7836SJohn.Forte@Sun.COM rdc_k_info_wstep(mdb_walk_state_t *wsp)
98*7836SJohn.Forte@Sun.COM {
99*7836SJohn.Forte@Sun.COM struct rdc_kinfo_winfo *winfo = wsp->walk_data;
100*7836SJohn.Forte@Sun.COM int status;
101*7836SJohn.Forte@Sun.COM
102*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL)
103*7836SJohn.Forte@Sun.COM return (WALK_DONE);
104*7836SJohn.Forte@Sun.COM
105*7836SJohn.Forte@Sun.COM if (wsp->walk_addr >= winfo->end)
106*7836SJohn.Forte@Sun.COM return (WALK_DONE);
107*7836SJohn.Forte@Sun.COM
108*7836SJohn.Forte@Sun.COM status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
109*7836SJohn.Forte@Sun.COM wsp->walk_cbdata);
110*7836SJohn.Forte@Sun.COM
111*7836SJohn.Forte@Sun.COM wsp->walk_addr += sizeof (rdc_k_info_t);
112*7836SJohn.Forte@Sun.COM return (status);
113*7836SJohn.Forte@Sun.COM }
114*7836SJohn.Forte@Sun.COM
115*7836SJohn.Forte@Sun.COM
116*7836SJohn.Forte@Sun.COM static void
rdc_k_info_wfini(mdb_walk_state_t * wsp)117*7836SJohn.Forte@Sun.COM rdc_k_info_wfini(mdb_walk_state_t *wsp)
118*7836SJohn.Forte@Sun.COM {
119*7836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (struct rdc_kinfo_winfo));
120*7836SJohn.Forte@Sun.COM }
121*7836SJohn.Forte@Sun.COM
122*7836SJohn.Forte@Sun.COM /*
123*7836SJohn.Forte@Sun.COM * Walker for an array of rdc_u_info_t structures.
124*7836SJohn.Forte@Sun.COM * A global walk is assumed to start at rdc_u_info.
125*7836SJohn.Forte@Sun.COM */
126*7836SJohn.Forte@Sun.COM
127*7836SJohn.Forte@Sun.COM struct rdc_uinfo_winfo {
128*7836SJohn.Forte@Sun.COM uintptr_t start;
129*7836SJohn.Forte@Sun.COM uintptr_t end;
130*7836SJohn.Forte@Sun.COM };
131*7836SJohn.Forte@Sun.COM
132*7836SJohn.Forte@Sun.COM
133*7836SJohn.Forte@Sun.COM static int
rdc_u_info_winit(mdb_walk_state_t * wsp)134*7836SJohn.Forte@Sun.COM rdc_u_info_winit(mdb_walk_state_t *wsp)
135*7836SJohn.Forte@Sun.COM {
136*7836SJohn.Forte@Sun.COM struct rdc_uinfo_winfo *winfo;
137*7836SJohn.Forte@Sun.COM rdc_u_info_t *rdc_u_info;
138*7836SJohn.Forte@Sun.COM int rdc_max_sets;
139*7836SJohn.Forte@Sun.COM
140*7836SJohn.Forte@Sun.COM winfo = mdb_zalloc(sizeof (struct rdc_uinfo_winfo), UM_SLEEP);
141*7836SJohn.Forte@Sun.COM
142*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_u_info, "rdc_u_info") == -1) {
143*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_u_info'");
144*7836SJohn.Forte@Sun.COM mdb_free(winfo, sizeof (struct rdc_uinfo_winfo));
145*7836SJohn.Forte@Sun.COM return (WALK_ERR);
146*7836SJohn.Forte@Sun.COM }
147*7836SJohn.Forte@Sun.COM
148*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_max_sets, "rdc_max_sets") == -1) {
149*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_max_sets'");
150*7836SJohn.Forte@Sun.COM mdb_free(winfo, sizeof (struct rdc_uinfo_winfo));
151*7836SJohn.Forte@Sun.COM return (WALK_ERR);
152*7836SJohn.Forte@Sun.COM }
153*7836SJohn.Forte@Sun.COM
154*7836SJohn.Forte@Sun.COM winfo->start = (uintptr_t)rdc_u_info;
155*7836SJohn.Forte@Sun.COM winfo->end = (uintptr_t)(rdc_u_info + rdc_max_sets);
156*7836SJohn.Forte@Sun.COM
157*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL)
158*7836SJohn.Forte@Sun.COM wsp->walk_addr = winfo->start;
159*7836SJohn.Forte@Sun.COM
160*7836SJohn.Forte@Sun.COM wsp->walk_data = winfo;
161*7836SJohn.Forte@Sun.COM return (WALK_NEXT);
162*7836SJohn.Forte@Sun.COM }
163*7836SJohn.Forte@Sun.COM
164*7836SJohn.Forte@Sun.COM
165*7836SJohn.Forte@Sun.COM static int
rdc_u_info_wstep(mdb_walk_state_t * wsp)166*7836SJohn.Forte@Sun.COM rdc_u_info_wstep(mdb_walk_state_t *wsp)
167*7836SJohn.Forte@Sun.COM {
168*7836SJohn.Forte@Sun.COM struct rdc_uinfo_winfo *winfo = wsp->walk_data;
169*7836SJohn.Forte@Sun.COM int status;
170*7836SJohn.Forte@Sun.COM
171*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL)
172*7836SJohn.Forte@Sun.COM return (WALK_DONE);
173*7836SJohn.Forte@Sun.COM
174*7836SJohn.Forte@Sun.COM if (wsp->walk_addr >= winfo->end)
175*7836SJohn.Forte@Sun.COM return (WALK_DONE);
176*7836SJohn.Forte@Sun.COM
177*7836SJohn.Forte@Sun.COM status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
178*7836SJohn.Forte@Sun.COM wsp->walk_cbdata);
179*7836SJohn.Forte@Sun.COM
180*7836SJohn.Forte@Sun.COM wsp->walk_addr += sizeof (rdc_u_info_t);
181*7836SJohn.Forte@Sun.COM return (status);
182*7836SJohn.Forte@Sun.COM }
183*7836SJohn.Forte@Sun.COM
184*7836SJohn.Forte@Sun.COM
185*7836SJohn.Forte@Sun.COM static void
rdc_u_info_wfini(mdb_walk_state_t * wsp)186*7836SJohn.Forte@Sun.COM rdc_u_info_wfini(mdb_walk_state_t *wsp)
187*7836SJohn.Forte@Sun.COM {
188*7836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (struct rdc_uinfo_winfo));
189*7836SJohn.Forte@Sun.COM }
190*7836SJohn.Forte@Sun.COM
191*7836SJohn.Forte@Sun.COM /*
192*7836SJohn.Forte@Sun.COM * Walker for the rdc_if chain.
193*7836SJohn.Forte@Sun.COM * A global walk is assumed to start at rdc_if_top.
194*7836SJohn.Forte@Sun.COM */
195*7836SJohn.Forte@Sun.COM
196*7836SJohn.Forte@Sun.COM static int
rdc_if_winit(mdb_walk_state_t * wsp)197*7836SJohn.Forte@Sun.COM rdc_if_winit(mdb_walk_state_t *wsp)
198*7836SJohn.Forte@Sun.COM {
199*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL &&
200*7836SJohn.Forte@Sun.COM mdb_readvar(&wsp->walk_addr, "rdc_if_top") == -1) {
201*7836SJohn.Forte@Sun.COM mdb_warn("unable to read 'rdc_if_top'");
202*7836SJohn.Forte@Sun.COM return (WALK_ERR);
203*7836SJohn.Forte@Sun.COM }
204*7836SJohn.Forte@Sun.COM
205*7836SJohn.Forte@Sun.COM wsp->walk_data = mdb_zalloc(sizeof (rdc_if_t), UM_SLEEP);
206*7836SJohn.Forte@Sun.COM
207*7836SJohn.Forte@Sun.COM return (WALK_NEXT);
208*7836SJohn.Forte@Sun.COM }
209*7836SJohn.Forte@Sun.COM
210*7836SJohn.Forte@Sun.COM
211*7836SJohn.Forte@Sun.COM static int
rdc_if_wstep(mdb_walk_state_t * wsp)212*7836SJohn.Forte@Sun.COM rdc_if_wstep(mdb_walk_state_t *wsp)
213*7836SJohn.Forte@Sun.COM {
214*7836SJohn.Forte@Sun.COM int status;
215*7836SJohn.Forte@Sun.COM
216*7836SJohn.Forte@Sun.COM if (wsp->walk_addr == NULL)
217*7836SJohn.Forte@Sun.COM return (WALK_DONE);
218*7836SJohn.Forte@Sun.COM
219*7836SJohn.Forte@Sun.COM if (mdb_vread(wsp->walk_data,
220*7836SJohn.Forte@Sun.COM sizeof (rdc_if_t), wsp->walk_addr) == -1) {
221*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_if at %p", wsp->walk_addr);
222*7836SJohn.Forte@Sun.COM return (WALK_DONE);
223*7836SJohn.Forte@Sun.COM }
224*7836SJohn.Forte@Sun.COM
225*7836SJohn.Forte@Sun.COM status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
226*7836SJohn.Forte@Sun.COM wsp->walk_cbdata);
227*7836SJohn.Forte@Sun.COM
228*7836SJohn.Forte@Sun.COM wsp->walk_addr = (uintptr_t)(((rdc_if_t *)wsp->walk_data)->next);
229*7836SJohn.Forte@Sun.COM return (status);
230*7836SJohn.Forte@Sun.COM }
231*7836SJohn.Forte@Sun.COM
232*7836SJohn.Forte@Sun.COM
233*7836SJohn.Forte@Sun.COM static void
rdc_if_wfini(mdb_walk_state_t * wsp)234*7836SJohn.Forte@Sun.COM rdc_if_wfini(mdb_walk_state_t *wsp)
235*7836SJohn.Forte@Sun.COM {
236*7836SJohn.Forte@Sun.COM mdb_free(wsp->walk_data, sizeof (rdc_if_t));
237*7836SJohn.Forte@Sun.COM }
238*7836SJohn.Forte@Sun.COM
239*7836SJohn.Forte@Sun.COM /*
240*7836SJohn.Forte@Sun.COM * Displays the asynchronous sleep q on the server.
241*7836SJohn.Forte@Sun.COM */
242*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
243*7836SJohn.Forte@Sun.COM static int
rdc_sleepq(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)244*7836SJohn.Forte@Sun.COM rdc_sleepq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
245*7836SJohn.Forte@Sun.COM {
246*7836SJohn.Forte@Sun.COM rdc_sleepq_t sq;
247*7836SJohn.Forte@Sun.COM
248*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
249*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
250*7836SJohn.Forte@Sun.COM while (addr) {
251*7836SJohn.Forte@Sun.COM if (mdb_vread(&sq, sizeof (sq), addr) != sizeof (sq)) {
252*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_sleepq at %p", addr);
253*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
254*7836SJohn.Forte@Sun.COM }
255*7836SJohn.Forte@Sun.COM mdb_printf("sequence number %u qpos %d \n", sq.seq, sq.qpos);
256*7836SJohn.Forte@Sun.COM addr = (uintptr_t)sq.next;
257*7836SJohn.Forte@Sun.COM }
258*7836SJohn.Forte@Sun.COM return (DCMD_OK);
259*7836SJohn.Forte@Sun.COM }
260*7836SJohn.Forte@Sun.COM
261*7836SJohn.Forte@Sun.COM /*
262*7836SJohn.Forte@Sun.COM * display the header info for the pending diskq requests
263*7836SJohn.Forte@Sun.COM */
264*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
265*7836SJohn.Forte@Sun.COM static int
rdc_iohdr(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)266*7836SJohn.Forte@Sun.COM rdc_iohdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
267*7836SJohn.Forte@Sun.COM {
268*7836SJohn.Forte@Sun.COM io_hdr hdr;
269*7836SJohn.Forte@Sun.COM
270*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
271*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
272*7836SJohn.Forte@Sun.COM
273*7836SJohn.Forte@Sun.COM while (addr) {
274*7836SJohn.Forte@Sun.COM if (mdb_vread(&hdr, sizeof (io_hdr), addr) != sizeof (io_hdr)) {
275*7836SJohn.Forte@Sun.COM mdb_warn("failed to read io_hdr at %p", addr);
276*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
277*7836SJohn.Forte@Sun.COM }
278*7836SJohn.Forte@Sun.COM mdb_printf("iohdr: type %d pos %d qpos %d len %d flag 0x%x"
279*7836SJohn.Forte@Sun.COM " iostatus %x setid %d next %p\n", hdr.dat.type, hdr.dat.pos,
280*7836SJohn.Forte@Sun.COM hdr.dat.qpos, hdr.dat.len, hdr.dat.flag, hdr.dat.iostatus,
281*7836SJohn.Forte@Sun.COM hdr.dat.setid, hdr.dat.next);
282*7836SJohn.Forte@Sun.COM
283*7836SJohn.Forte@Sun.COM addr = (uintptr_t)hdr.dat.next;
284*7836SJohn.Forte@Sun.COM }
285*7836SJohn.Forte@Sun.COM return (DCMD_OK);
286*7836SJohn.Forte@Sun.COM }
287*7836SJohn.Forte@Sun.COM
288*7836SJohn.Forte@Sun.COM /*
289*7836SJohn.Forte@Sun.COM * Display a krdc->group.
290*7836SJohn.Forte@Sun.COM * Requires an address.
291*7836SJohn.Forte@Sun.COM */
292*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
293*7836SJohn.Forte@Sun.COM static int
rdc_group(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)294*7836SJohn.Forte@Sun.COM rdc_group(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
295*7836SJohn.Forte@Sun.COM {
296*7836SJohn.Forte@Sun.COM struct rdc_group *group;
297*7836SJohn.Forte@Sun.COM disk_queue *dq;
298*7836SJohn.Forte@Sun.COM
299*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
300*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
301*7836SJohn.Forte@Sun.COM
302*7836SJohn.Forte@Sun.COM
303*7836SJohn.Forte@Sun.COM group = mdb_zalloc(sizeof (*group), UM_GC);
304*7836SJohn.Forte@Sun.COM
305*7836SJohn.Forte@Sun.COM if (mdb_vread(group, sizeof (*group), addr) != sizeof (*group)) {
306*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_group at %p", addr);
307*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
308*7836SJohn.Forte@Sun.COM }
309*7836SJohn.Forte@Sun.COM #ifdef XXXJET
310*7836SJohn.Forte@Sun.COM if (DCMD_HDRSPEC(flags)) {
311*7836SJohn.Forte@Sun.COM mdb_printf("%-?s %8T%-8s %8T%s\n", "ADDR", "MAJOR", "INUSE");
312*7836SJohn.Forte@Sun.COM }
313*7836SJohn.Forte@Sun.COM #endif
314*7836SJohn.Forte@Sun.COM mdb_printf("count: %d %8Twriter: %d %8T flags: %d\n",
315*7836SJohn.Forte@Sun.COM group->count, group->rdc_writer, group->flags);
316*7836SJohn.Forte@Sun.COM mdb_printf("thread num %d\n", group->rdc_thrnum);
317*7836SJohn.Forte@Sun.COM
318*7836SJohn.Forte@Sun.COM dq = &group->diskq;
319*7836SJohn.Forte@Sun.COM if (RDC_IS_MEMQ(group)) {
320*7836SJohn.Forte@Sun.COM mdb_printf("queue type: Memory based\n");
321*7836SJohn.Forte@Sun.COM } else if (RDC_IS_DISKQ(group)) {
322*7836SJohn.Forte@Sun.COM mdb_printf("queue type: Disk based %8Tqstate 0x%x\n",
323*7836SJohn.Forte@Sun.COM QSTATE(dq));
324*7836SJohn.Forte@Sun.COM }
325*7836SJohn.Forte@Sun.COM mdb_printf("ra_queue head: 0x%p %8Ttail 0x%p\n",
326*7836SJohn.Forte@Sun.COM group->ra_queue.net_qhead, group->ra_queue.net_qtail);
327*7836SJohn.Forte@Sun.COM mdb_printf("ra_queue blocks: %d %8Titems %d\n",
328*7836SJohn.Forte@Sun.COM group->ra_queue.blocks, group->ra_queue.nitems);
329*7836SJohn.Forte@Sun.COM mdb_printf("ra_queue blockhwm: %d itemhwm: %d\n",
330*7836SJohn.Forte@Sun.COM group->ra_queue.blocks_hwm, group->ra_queue.nitems_hwm);
331*7836SJohn.Forte@Sun.COM mdb_printf("ra_queue hwmhit: %d qfillsleep: %d\n",
332*7836SJohn.Forte@Sun.COM group->ra_queue.hwmhit, group->ra_queue.qfill_sleeping);
333*7836SJohn.Forte@Sun.COM mdb_printf("ra_queue throttle: %ld\n",
334*7836SJohn.Forte@Sun.COM group->ra_queue.throttle_delay);
335*7836SJohn.Forte@Sun.COM
336*7836SJohn.Forte@Sun.COM if (RDC_IS_DISKQ(group)) {
337*7836SJohn.Forte@Sun.COM mdb_printf("head: %d %8Tnxtio: %d %8Ttail %d %8Tlastail: %d\n",
338*7836SJohn.Forte@Sun.COM QHEAD(dq), QNXTIO(dq), QTAIL(dq), LASTQTAIL(dq));
339*7836SJohn.Forte@Sun.COM mdb_printf("coalbounds: %d %8Tqwrap: %d\n", QCOALBOUNDS(dq),
340*7836SJohn.Forte@Sun.COM QWRAP(dq));
341*7836SJohn.Forte@Sun.COM mdb_printf("blocks: %d %8Titems %d qfflags 0x%x \n",
342*7836SJohn.Forte@Sun.COM QBLOCKS(dq), QNITEMS(dq), group->ra_queue.qfflags);
343*7836SJohn.Forte@Sun.COM mdb_printf("diskq throttle: %ld %8Tflags: %x\n",
344*7836SJohn.Forte@Sun.COM dq->throttle_delay, group->flags);
345*7836SJohn.Forte@Sun.COM mdb_printf("disk queue nitems_hwm: %d %8Tblocks_hwm: %d\n",
346*7836SJohn.Forte@Sun.COM dq->nitems_hwm, dq->blocks_hwm);
347*7836SJohn.Forte@Sun.COM mdb_printf("diskqfd: 0x%p %8Tdisqrsrv: %d lastio: 0x%p\n",
348*7836SJohn.Forte@Sun.COM group->diskqfd, group->diskqrsrv, dq->lastio);
349*7836SJohn.Forte@Sun.COM mdb_printf("outstanding req %d iohdrs 0x%p iohdrs_last 0x%p\n",
350*7836SJohn.Forte@Sun.COM dq->hdrcnt, dq->iohdrs, dq->hdr_last);
351*7836SJohn.Forte@Sun.COM }
352*7836SJohn.Forte@Sun.COM mdb_printf("seq: %u\n", group->seq);
353*7836SJohn.Forte@Sun.COM mdb_printf("seqack: %u\n", group->seqack);
354*7836SJohn.Forte@Sun.COM mdb_printf("sleepq: 0x%p\n", group->sleepq);
355*7836SJohn.Forte@Sun.COM mdb_printf("asyncstall %d\n", group->asyncstall);
356*7836SJohn.Forte@Sun.COM mdb_printf("asyncdis %d\n", group->asyncdis);
357*7836SJohn.Forte@Sun.COM
358*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
359*7836SJohn.Forte@Sun.COM if (group->sleepq) {
360*7836SJohn.Forte@Sun.COM rdc_sleepq((uintptr_t)group->sleepq, DCMD_ADDRSPEC,
361*7836SJohn.Forte@Sun.COM 0, 0);
362*7836SJohn.Forte@Sun.COM }
363*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
364*7836SJohn.Forte@Sun.COM
365*7836SJohn.Forte@Sun.COM return (DCMD_OK);
366*7836SJohn.Forte@Sun.COM }
367*7836SJohn.Forte@Sun.COM
368*7836SJohn.Forte@Sun.COM
369*7836SJohn.Forte@Sun.COM /*
370*7836SJohn.Forte@Sun.COM * Display a krdc->lsrv.
371*7836SJohn.Forte@Sun.COM * Requires an address.
372*7836SJohn.Forte@Sun.COM */
373*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
374*7836SJohn.Forte@Sun.COM static int
rdc_srv(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)375*7836SJohn.Forte@Sun.COM rdc_srv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
376*7836SJohn.Forte@Sun.COM {
377*7836SJohn.Forte@Sun.COM rdc_srv_t *lsrv;
378*7836SJohn.Forte@Sun.COM char name[MAX_RDC_HOST_SIZE];
379*7836SJohn.Forte@Sun.COM
380*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
381*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
382*7836SJohn.Forte@Sun.COM
383*7836SJohn.Forte@Sun.COM
384*7836SJohn.Forte@Sun.COM lsrv = mdb_zalloc(sizeof (*lsrv), UM_GC);
385*7836SJohn.Forte@Sun.COM
386*7836SJohn.Forte@Sun.COM if (mdb_vread(lsrv, sizeof (*lsrv), addr) != sizeof (*lsrv)) {
387*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_srv at %p", addr);
388*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
389*7836SJohn.Forte@Sun.COM }
390*7836SJohn.Forte@Sun.COM
391*7836SJohn.Forte@Sun.COM if (mdb_readstr(name, sizeof (name),
392*7836SJohn.Forte@Sun.COM (uintptr_t)lsrv->ri_hostname) == -1) {
393*7836SJohn.Forte@Sun.COM mdb_warn("failed to read ri_hostname name at %p", addr);
394*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
395*7836SJohn.Forte@Sun.COM }
396*7836SJohn.Forte@Sun.COM
397*7836SJohn.Forte@Sun.COM mdb_printf("host: %s %16Tri_knconf 0x%p\n", name, lsrv->ri_knconf);
398*7836SJohn.Forte@Sun.COM
399*7836SJohn.Forte@Sun.COM mdb_printf("ri_addr: 0x%p %8Tsecdata 0x%p\n",
400*7836SJohn.Forte@Sun.COM addr + OFFSETOF(rdc_srv_t, ri_addr), lsrv->ri_secdata);
401*7836SJohn.Forte@Sun.COM
402*7836SJohn.Forte@Sun.COM return (DCMD_OK);
403*7836SJohn.Forte@Sun.COM }
404*7836SJohn.Forte@Sun.COM
405*7836SJohn.Forte@Sun.COM /*
406*7836SJohn.Forte@Sun.COM * Display a rdc_if_t.
407*7836SJohn.Forte@Sun.COM * Requires an address.
408*7836SJohn.Forte@Sun.COM */
409*7836SJohn.Forte@Sun.COM static int
rdc_if(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)410*7836SJohn.Forte@Sun.COM rdc_if(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
411*7836SJohn.Forte@Sun.COM {
412*7836SJohn.Forte@Sun.COM rdc_if_t *ifp;
413*7836SJohn.Forte@Sun.COM
414*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) {
415*7836SJohn.Forte@Sun.COM /*
416*7836SJohn.Forte@Sun.COM * paranoid mode on: qualify walker name with module name
417*7836SJohn.Forte@Sun.COM * using '`' syntax.
418*7836SJohn.Forte@Sun.COM */
419*7836SJohn.Forte@Sun.COM if (mdb_walk_dcmd("rdc`rdc_if",
420*7836SJohn.Forte@Sun.COM "rdc`rdc_if", argc, argv) == -1) {
421*7836SJohn.Forte@Sun.COM mdb_warn("failed to walk 'rdc_if'");
422*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
423*7836SJohn.Forte@Sun.COM }
424*7836SJohn.Forte@Sun.COM return (DCMD_OK);
425*7836SJohn.Forte@Sun.COM }
426*7836SJohn.Forte@Sun.COM
427*7836SJohn.Forte@Sun.COM ifp = mdb_zalloc(sizeof (*ifp), UM_GC);
428*7836SJohn.Forte@Sun.COM
429*7836SJohn.Forte@Sun.COM if (mdb_vread(ifp, sizeof (*ifp), addr) != sizeof (*ifp)) {
430*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_srv at %p", addr);
431*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
432*7836SJohn.Forte@Sun.COM }
433*7836SJohn.Forte@Sun.COM
434*7836SJohn.Forte@Sun.COM mdb_printf("next: 0x%p %8Tsrv 0x%p\n", ifp->next, ifp->srv);
435*7836SJohn.Forte@Sun.COM mdb_printf("if_addr: 0x%p %8Tr_ifaddr 0x%p\n",
436*7836SJohn.Forte@Sun.COM addr + OFFSETOF(rdc_if_t, ifaddr),
437*7836SJohn.Forte@Sun.COM addr + OFFSETOF(rdc_if_t, r_ifaddr));
438*7836SJohn.Forte@Sun.COM mdb_printf("if_down: %d %8Tprimary %d %8Tsecondary %d\n",
439*7836SJohn.Forte@Sun.COM ifp->if_down, ifp->isprimary, ifp->issecondary);
440*7836SJohn.Forte@Sun.COM mdb_printf("version %d %8Tnoping %d\n", ifp->rpc_version,
441*7836SJohn.Forte@Sun.COM ifp->no_ping);
442*7836SJohn.Forte@Sun.COM mdb_printf("\n");
443*7836SJohn.Forte@Sun.COM
444*7836SJohn.Forte@Sun.COM return (DCMD_OK);
445*7836SJohn.Forte@Sun.COM }
446*7836SJohn.Forte@Sun.COM
447*7836SJohn.Forte@Sun.COM
448*7836SJohn.Forte@Sun.COM /*
449*7836SJohn.Forte@Sun.COM * Display a rdc_buf_t
450*7836SJohn.Forte@Sun.COM * Requires an address.
451*7836SJohn.Forte@Sun.COM */
452*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
453*7836SJohn.Forte@Sun.COM static int
rdc_buf(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)454*7836SJohn.Forte@Sun.COM rdc_buf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
455*7836SJohn.Forte@Sun.COM {
456*7836SJohn.Forte@Sun.COM rdc_buf_t *buf;
457*7836SJohn.Forte@Sun.COM
458*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
459*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
460*7836SJohn.Forte@Sun.COM
461*7836SJohn.Forte@Sun.COM
462*7836SJohn.Forte@Sun.COM buf = mdb_zalloc(sizeof (*buf), UM_GC);
463*7836SJohn.Forte@Sun.COM
464*7836SJohn.Forte@Sun.COM if (mdb_vread(buf, sizeof (*buf), addr) != sizeof (*buf)) {
465*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_buf at %p", addr);
466*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
467*7836SJohn.Forte@Sun.COM }
468*7836SJohn.Forte@Sun.COM
469*7836SJohn.Forte@Sun.COM mdb_printf("nsc_buf fd: 0x%p %8Tvec 0x%p\n",
470*7836SJohn.Forte@Sun.COM buf->rdc_bufh.sb_fd, buf->rdc_bufh.sb_vec);
471*7836SJohn.Forte@Sun.COM
472*7836SJohn.Forte@Sun.COM mdb_printf("nsc_buf pos: %d %8Tlen %d\n",
473*7836SJohn.Forte@Sun.COM buf->rdc_bufh.sb_pos, buf->rdc_bufh.sb_len);
474*7836SJohn.Forte@Sun.COM
475*7836SJohn.Forte@Sun.COM mdb_printf("nsc_buf flag: 0x%x %8Terror %d\n",
476*7836SJohn.Forte@Sun.COM buf->rdc_bufh.sb_flag, buf->rdc_bufh.sb_error);
477*7836SJohn.Forte@Sun.COM
478*7836SJohn.Forte@Sun.COM mdb_printf("anon_buf : 0x%p %8Tfd 0x%p %8Tbufp 0x%p\n",
479*7836SJohn.Forte@Sun.COM buf->rdc_anon, buf->rdc_fd, buf->rdc_bufp);
480*7836SJohn.Forte@Sun.COM
481*7836SJohn.Forte@Sun.COM mdb_printf("vsize: %d %8Tflags 0x%x\n",
482*7836SJohn.Forte@Sun.COM buf->rdc_vsize, buf->rdc_flags);
483*7836SJohn.Forte@Sun.COM
484*7836SJohn.Forte@Sun.COM return (DCMD_OK);
485*7836SJohn.Forte@Sun.COM }
486*7836SJohn.Forte@Sun.COM
487*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
488*7836SJohn.Forte@Sun.COM static int
rdc_aio(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)489*7836SJohn.Forte@Sun.COM rdc_aio(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
490*7836SJohn.Forte@Sun.COM {
491*7836SJohn.Forte@Sun.COM rdc_aio_t *aio;
492*7836SJohn.Forte@Sun.COM
493*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
494*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
495*7836SJohn.Forte@Sun.COM
496*7836SJohn.Forte@Sun.COM aio = mdb_zalloc(sizeof (*aio), UM_GC);
497*7836SJohn.Forte@Sun.COM
498*7836SJohn.Forte@Sun.COM if (mdb_vread(aio, sizeof (*aio), addr) != sizeof (*aio)) {
499*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_aio at %p", addr);
500*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
501*7836SJohn.Forte@Sun.COM }
502*7836SJohn.Forte@Sun.COM mdb_printf("rdc_aio next: %p %8T nsc_buf: %p %8T nsc_qbuf %p\n",
503*7836SJohn.Forte@Sun.COM aio->next, aio->handle, aio->qhandle);
504*7836SJohn.Forte@Sun.COM mdb_printf("pos: %d len: %d qpos: %d flag: %x iostatus: %d index: %d"
505*7836SJohn.Forte@Sun.COM " seq: %d\n", aio->pos, aio->len, aio->qpos, aio->flag,
506*7836SJohn.Forte@Sun.COM aio->iostatus, aio->index, aio->seq);
507*7836SJohn.Forte@Sun.COM return (DCMD_OK);
508*7836SJohn.Forte@Sun.COM }
509*7836SJohn.Forte@Sun.COM
510*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
511*7836SJohn.Forte@Sun.COM static int
rdc_dset(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)512*7836SJohn.Forte@Sun.COM rdc_dset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
513*7836SJohn.Forte@Sun.COM {
514*7836SJohn.Forte@Sun.COM rdc_net_dataset_t *dset;
515*7836SJohn.Forte@Sun.COM
516*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
517*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
518*7836SJohn.Forte@Sun.COM
519*7836SJohn.Forte@Sun.COM dset = mdb_zalloc(sizeof (*dset), UM_GC);
520*7836SJohn.Forte@Sun.COM
521*7836SJohn.Forte@Sun.COM if (mdb_vread(dset, sizeof (*dset), addr) != sizeof (*dset)) {
522*7836SJohn.Forte@Sun.COM mdb_warn("failed to read dset at %p", addr);
523*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
524*7836SJohn.Forte@Sun.COM }
525*7836SJohn.Forte@Sun.COM mdb_printf("dset id: %d %8T dset inuse: %d %8T dset delpend: %d\n",
526*7836SJohn.Forte@Sun.COM dset->id, dset->inuse, dset->delpend);
527*7836SJohn.Forte@Sun.COM mdb_printf("dset items: %d %8T dset head %p %8T dset tail %p \n",
528*7836SJohn.Forte@Sun.COM dset->nitems, dset->head, dset->tail);
529*7836SJohn.Forte@Sun.COM mdb_printf("dset pos %d %8T dset len %d\n", dset->pos, dset->fbalen);
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 * Display a single rdc_k_info structure.
535*7836SJohn.Forte@Sun.COM * If called with no address, performs a global walk of all rdc_k_info.
536*7836SJohn.Forte@Sun.COM * -a : all (i.e. display all devices, even if disabled
537*7836SJohn.Forte@Sun.COM * -v : verbose
538*7836SJohn.Forte@Sun.COM */
539*7836SJohn.Forte@Sun.COM
540*7836SJohn.Forte@Sun.COM const mdb_bitmask_t sv_flag_bits[] = {
541*7836SJohn.Forte@Sun.COM { "NSC_DEVICE", NSC_DEVICE, NSC_DEVICE },
542*7836SJohn.Forte@Sun.COM { "NSC_CACHE", NSC_CACHE, NSC_CACHE },
543*7836SJohn.Forte@Sun.COM { NULL, 0, 0 }
544*7836SJohn.Forte@Sun.COM };
545*7836SJohn.Forte@Sun.COM
546*7836SJohn.Forte@Sun.COM static int
rdc_kinfo(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)547*7836SJohn.Forte@Sun.COM rdc_kinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
548*7836SJohn.Forte@Sun.COM {
549*7836SJohn.Forte@Sun.COM rdc_k_info_t *krdc;
550*7836SJohn.Forte@Sun.COM rdc_u_info_t *rdc_u_info, *urdc;
551*7836SJohn.Forte@Sun.COM int a_opt, v_opt;
552*7836SJohn.Forte@Sun.COM int dev_t_chars;
553*7836SJohn.Forte@Sun.COM
554*7836SJohn.Forte@Sun.COM a_opt = v_opt = FALSE;
555*7836SJohn.Forte@Sun.COM dev_t_chars = sizeof (dev_t) * 2; /* # chars to display dev_t */
556*7836SJohn.Forte@Sun.COM
557*7836SJohn.Forte@Sun.COM if (mdb_getopts(argc, argv,
558*7836SJohn.Forte@Sun.COM 'a', MDB_OPT_SETBITS, TRUE, &a_opt,
559*7836SJohn.Forte@Sun.COM 'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
560*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
561*7836SJohn.Forte@Sun.COM
562*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
563*7836SJohn.Forte@Sun.COM urdc = mdb_zalloc(sizeof (*urdc), UM_GC);
564*7836SJohn.Forte@Sun.COM
565*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) {
566*7836SJohn.Forte@Sun.COM /*
567*7836SJohn.Forte@Sun.COM * paranoid mode on: qualify walker name with module name
568*7836SJohn.Forte@Sun.COM * using '`' syntax.
569*7836SJohn.Forte@Sun.COM */
570*7836SJohn.Forte@Sun.COM if (mdb_walk_dcmd("rdc`rdc_kinfo",
571*7836SJohn.Forte@Sun.COM "rdc`rdc_kinfo", argc, argv) == -1) {
572*7836SJohn.Forte@Sun.COM mdb_warn("failed to walk 'rdc_kinfo'");
573*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
574*7836SJohn.Forte@Sun.COM }
575*7836SJohn.Forte@Sun.COM return (DCMD_OK);
576*7836SJohn.Forte@Sun.COM }
577*7836SJohn.Forte@Sun.COM if (DCMD_HDRSPEC(flags)) {
578*7836SJohn.Forte@Sun.COM mdb_printf("%-?s %8T%-*s %8T%s\n", "ADDR",
579*7836SJohn.Forte@Sun.COM dev_t_chars, "TFLAG", "STATE");
580*7836SJohn.Forte@Sun.COM }
581*7836SJohn.Forte@Sun.COM
582*7836SJohn.Forte@Sun.COM if (mdb_vread(krdc, sizeof (*krdc), addr) != sizeof (*krdc)) {
583*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_k_info at %p", addr);
584*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
585*7836SJohn.Forte@Sun.COM }
586*7836SJohn.Forte@Sun.COM
587*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_u_info, "rdc_u_info") == -1) {
588*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_u_info'");
589*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
590*7836SJohn.Forte@Sun.COM }
591*7836SJohn.Forte@Sun.COM
592*7836SJohn.Forte@Sun.COM urdc = &rdc_u_info[krdc->index];
593*7836SJohn.Forte@Sun.COM
594*7836SJohn.Forte@Sun.COM if (!a_opt && ((krdc->type_flag & RDC_CONFIGURED) == 0))
595*7836SJohn.Forte@Sun.COM return (DCMD_OK);
596*7836SJohn.Forte@Sun.COM
597*7836SJohn.Forte@Sun.COM mdb_printf("%?p %8T%0*lx %8T", addr, dev_t_chars, krdc->type_flag);
598*7836SJohn.Forte@Sun.COM
599*7836SJohn.Forte@Sun.COM
600*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_DISABLEPEND)
601*7836SJohn.Forte@Sun.COM mdb_printf(" disable pending");
602*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_ASYNCMODE)
603*7836SJohn.Forte@Sun.COM mdb_printf(" async");
604*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_RESUMEPEND)
605*7836SJohn.Forte@Sun.COM mdb_printf(" resume pending");
606*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_BUSYWAIT)
607*7836SJohn.Forte@Sun.COM mdb_printf(" busywait");
608*7836SJohn.Forte@Sun.COM #ifdef RDC_SMALLIO
609*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_SMALLIO)
610*7836SJohn.Forte@Sun.COM mdb_printf(" smallio");
611*7836SJohn.Forte@Sun.COM #endif
612*7836SJohn.Forte@Sun.COM
613*7836SJohn.Forte@Sun.COM mdb_printf("\n");
614*7836SJohn.Forte@Sun.COM
615*7836SJohn.Forte@Sun.COM if (!v_opt)
616*7836SJohn.Forte@Sun.COM return (DCMD_OK);
617*7836SJohn.Forte@Sun.COM
618*7836SJohn.Forte@Sun.COM /*
619*7836SJohn.Forte@Sun.COM * verbose - print the rest of the structure as well.
620*7836SJohn.Forte@Sun.COM */
621*7836SJohn.Forte@Sun.COM
622*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
623*7836SJohn.Forte@Sun.COM
624*7836SJohn.Forte@Sun.COM mdb_printf("index: %d %8Trindex: %d %8Tbusyc: %d %8Tmaxfbas: %d\n",
625*7836SJohn.Forte@Sun.COM krdc->index, krdc->remote_index, krdc->busy_count, krdc->maxfbas);
626*7836SJohn.Forte@Sun.COM
627*7836SJohn.Forte@Sun.COM mdb_printf("info_dev: 0x%p %8Tiodev: 0x%p %8T %8T vers %d\n",
628*7836SJohn.Forte@Sun.COM krdc->devices, krdc->iodev, krdc->rpc_version);
629*7836SJohn.Forte@Sun.COM
630*7836SJohn.Forte@Sun.COM mdb_printf("iokstats: 0x%p\n", krdc->io_kstats);
631*7836SJohn.Forte@Sun.COM mdb_printf("group: 0x%p %8Tgroup_next: 0x%p\n",
632*7836SJohn.Forte@Sun.COM krdc->group, krdc->group_next);
633*7836SJohn.Forte@Sun.COM mdb_printf("group lock: 0x%p aux_state: %d\n",
634*7836SJohn.Forte@Sun.COM &krdc->group->lock, krdc->aux_state);
635*7836SJohn.Forte@Sun.COM
636*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
637*7836SJohn.Forte@Sun.COM if (krdc->type_flag & RDC_ASYNCMODE) {
638*7836SJohn.Forte@Sun.COM rdc_group((uintptr_t)krdc->group, DCMD_ADDRSPEC, 0, 0);
639*7836SJohn.Forte@Sun.COM }
640*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
641*7836SJohn.Forte@Sun.COM
642*7836SJohn.Forte@Sun.COM mdb_printf("servinfo: 0x%p %8Tintf: 0x%p\nbitmap: 0x%p %8T"
643*7836SJohn.Forte@Sun.COM "bitmap_ref: 0x%p\n",
644*7836SJohn.Forte@Sun.COM krdc->lsrv, krdc->intf, krdc->dcio_bitmap, krdc->bitmap_ref);
645*7836SJohn.Forte@Sun.COM
646*7836SJohn.Forte@Sun.COM mdb_printf("bmap_size: %d %8Tbmaprsrv: %d%8T bmap_write: %d\n",
647*7836SJohn.Forte@Sun.COM krdc->bitmap_size, krdc->bmaprsrv, krdc->bitmap_write);
648*7836SJohn.Forte@Sun.COM
649*7836SJohn.Forte@Sun.COM mdb_printf("bitmapfd: 0x%p %8Tremote_fd: 0x%p %8T\n", krdc->bitmapfd,
650*7836SJohn.Forte@Sun.COM krdc->remote_fd);
651*7836SJohn.Forte@Sun.COM
652*7836SJohn.Forte@Sun.COM mdb_printf("net_dataset: 0x%p %8Tdisk_status: %d %8T\n",
653*7836SJohn.Forte@Sun.COM krdc->net_dataset, krdc->disk_status);
654*7836SJohn.Forte@Sun.COM
655*7836SJohn.Forte@Sun.COM mdb_printf("many: 0x%p %8Tmulti: 0x%p %8T\n", krdc->many_next,
656*7836SJohn.Forte@Sun.COM krdc->multi_next);
657*7836SJohn.Forte@Sun.COM
658*7836SJohn.Forte@Sun.COM mdb_printf("rdc_uinfo: 0x%p\n\n", urdc);
659*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
660*7836SJohn.Forte@Sun.COM return (DCMD_OK);
661*7836SJohn.Forte@Sun.COM }
662*7836SJohn.Forte@Sun.COM
663*7836SJohn.Forte@Sun.COM
664*7836SJohn.Forte@Sun.COM static int
rdc_uinfo(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)665*7836SJohn.Forte@Sun.COM rdc_uinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
666*7836SJohn.Forte@Sun.COM {
667*7836SJohn.Forte@Sun.COM rdc_u_info_t *urdc;
668*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info, *krdc, krdc1;
669*7836SJohn.Forte@Sun.COM rdc_group_t grp;
670*7836SJohn.Forte@Sun.COM disk_queue *dqp = NULL;
671*7836SJohn.Forte@Sun.COM int a_opt, v_opt;
672*7836SJohn.Forte@Sun.COM int dev_t_chars;
673*7836SJohn.Forte@Sun.COM int rdcflags;
674*7836SJohn.Forte@Sun.COM
675*7836SJohn.Forte@Sun.COM a_opt = v_opt = FALSE;
676*7836SJohn.Forte@Sun.COM dev_t_chars = sizeof (dev_t) * 2; /* # chars to display dev_t */
677*7836SJohn.Forte@Sun.COM
678*7836SJohn.Forte@Sun.COM if (mdb_getopts(argc, argv,
679*7836SJohn.Forte@Sun.COM 'a', MDB_OPT_SETBITS, TRUE, &a_opt,
680*7836SJohn.Forte@Sun.COM 'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
681*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
682*7836SJohn.Forte@Sun.COM
683*7836SJohn.Forte@Sun.COM urdc = mdb_zalloc(sizeof (*urdc), UM_GC);
684*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
685*7836SJohn.Forte@Sun.COM
686*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC)) {
687*7836SJohn.Forte@Sun.COM /*
688*7836SJohn.Forte@Sun.COM * paranoid mode on: qualify walker name with module name
689*7836SJohn.Forte@Sun.COM * using '`' syntax.
690*7836SJohn.Forte@Sun.COM */
691*7836SJohn.Forte@Sun.COM if (mdb_walk_dcmd("rdc`rdc_uinfo",
692*7836SJohn.Forte@Sun.COM "rdc`rdc_uinfo", argc, argv) == -1) {
693*7836SJohn.Forte@Sun.COM mdb_warn("failed to walk 'rdc_uinfo'");
694*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
695*7836SJohn.Forte@Sun.COM }
696*7836SJohn.Forte@Sun.COM return (DCMD_OK);
697*7836SJohn.Forte@Sun.COM }
698*7836SJohn.Forte@Sun.COM if (DCMD_HDRSPEC(flags)) {
699*7836SJohn.Forte@Sun.COM mdb_printf("%-?s %8T%-*s %8T%s\n", "ADDR",
700*7836SJohn.Forte@Sun.COM dev_t_chars, "FLAG", "STATE");
701*7836SJohn.Forte@Sun.COM }
702*7836SJohn.Forte@Sun.COM
703*7836SJohn.Forte@Sun.COM if (mdb_vread(urdc, sizeof (*urdc), addr) != sizeof (*urdc)) {
704*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_u_info at %p", addr);
705*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
706*7836SJohn.Forte@Sun.COM }
707*7836SJohn.Forte@Sun.COM
708*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
709*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
710*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
711*7836SJohn.Forte@Sun.COM }
712*7836SJohn.Forte@Sun.COM
713*7836SJohn.Forte@Sun.COM krdc = &rdc_k_info[urdc->index];
714*7836SJohn.Forte@Sun.COM
715*7836SJohn.Forte@Sun.COM if (!a_opt && ((urdc->flags & RDC_ENABLED) == 0))
716*7836SJohn.Forte@Sun.COM return (DCMD_OK);
717*7836SJohn.Forte@Sun.COM
718*7836SJohn.Forte@Sun.COM
719*7836SJohn.Forte@Sun.COM if (mdb_vread(&krdc1, sizeof (krdc1),
720*7836SJohn.Forte@Sun.COM (uintptr_t)krdc) != sizeof (krdc1)) {
721*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info1'");
722*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
723*7836SJohn.Forte@Sun.COM }
724*7836SJohn.Forte@Sun.COM
725*7836SJohn.Forte@Sun.COM if (krdc1.group) {
726*7836SJohn.Forte@Sun.COM if (mdb_vread(&grp, sizeof (grp),
727*7836SJohn.Forte@Sun.COM (uintptr_t)krdc1.group) != sizeof (grp)) {
728*7836SJohn.Forte@Sun.COM mdb_warn("failed to read group info ");
729*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
730*7836SJohn.Forte@Sun.COM }
731*7836SJohn.Forte@Sun.COM dqp = &grp.diskq;
732*7836SJohn.Forte@Sun.COM }
733*7836SJohn.Forte@Sun.COM
734*7836SJohn.Forte@Sun.COM rdcflags = (urdc->flags | urdc->sync_flags | urdc->bmap_flags);
735*7836SJohn.Forte@Sun.COM mdb_printf("%?p %8T%0*lx %8T", addr, dev_t_chars, rdcflags);
736*7836SJohn.Forte@Sun.COM
737*7836SJohn.Forte@Sun.COM
738*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_PRIMARY)
739*7836SJohn.Forte@Sun.COM mdb_printf(" primary");
740*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_SLAVE)
741*7836SJohn.Forte@Sun.COM mdb_printf(" slave");
742*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_SYNCING)
743*7836SJohn.Forte@Sun.COM mdb_printf(" syncing");
744*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_SYNC_NEEDED)
745*7836SJohn.Forte@Sun.COM mdb_printf(" sync_need");
746*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_RSYNC_NEEDED)
747*7836SJohn.Forte@Sun.COM mdb_printf(" rsync_need");
748*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_LOGGING)
749*7836SJohn.Forte@Sun.COM mdb_printf(" logging");
750*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_QUEUING)
751*7836SJohn.Forte@Sun.COM mdb_printf(" queuing");
752*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_DISKQ_FAILED)
753*7836SJohn.Forte@Sun.COM mdb_printf(" diskq failed");
754*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_VOL_FAILED)
755*7836SJohn.Forte@Sun.COM mdb_printf(" vol failed");
756*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_BMP_FAILED)
757*7836SJohn.Forte@Sun.COM mdb_printf(" bmp failed");
758*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_ASYNC)
759*7836SJohn.Forte@Sun.COM mdb_printf(" async");
760*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_CLR_AFTERSYNC)
761*7836SJohn.Forte@Sun.COM mdb_printf(" clr_bitmap_aftersync");
762*7836SJohn.Forte@Sun.COM if (dqp) {
763*7836SJohn.Forte@Sun.COM if (IS_QSTATE(dqp, RDC_QNOBLOCK))
764*7836SJohn.Forte@Sun.COM mdb_printf(" noblock");
765*7836SJohn.Forte@Sun.COM }
766*7836SJohn.Forte@Sun.COM #ifdef RDC_SMALLIO
767*7836SJohn.Forte@Sun.COM if (rdcflags & RDC_SMALLIO)
768*7836SJohn.Forte@Sun.COM mdb_printf(" smallio");
769*7836SJohn.Forte@Sun.COM #endif
770*7836SJohn.Forte@Sun.COM
771*7836SJohn.Forte@Sun.COM mdb_printf("\n");
772*7836SJohn.Forte@Sun.COM
773*7836SJohn.Forte@Sun.COM if (!v_opt)
774*7836SJohn.Forte@Sun.COM return (DCMD_OK);
775*7836SJohn.Forte@Sun.COM
776*7836SJohn.Forte@Sun.COM /*
777*7836SJohn.Forte@Sun.COM * verbose - print the rest of the structure as well.
778*7836SJohn.Forte@Sun.COM */
779*7836SJohn.Forte@Sun.COM
780*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
781*7836SJohn.Forte@Sun.COM mdb_printf("\n");
782*7836SJohn.Forte@Sun.COM
783*7836SJohn.Forte@Sun.COM mdb_printf("primary: %s %8Tfile: %s \nbitmap: %s ",
784*7836SJohn.Forte@Sun.COM urdc->primary.intf, urdc->primary.file, urdc->primary.bitmap);
785*7836SJohn.Forte@Sun.COM mdb_printf("netbuf: 0x%p\n", addr + OFFSETOF(rdc_set_t, primary));
786*7836SJohn.Forte@Sun.COM mdb_printf("secondary: %s %8Tfile: %s \nbitmap: %s ",
787*7836SJohn.Forte@Sun.COM urdc->secondary.intf, urdc->secondary.file, urdc->secondary.bitmap);
788*7836SJohn.Forte@Sun.COM mdb_printf("netbuf: 0x%p\n", addr + OFFSETOF(rdc_set_t, secondary));
789*7836SJohn.Forte@Sun.COM
790*7836SJohn.Forte@Sun.COM mdb_printf("sflags: %d %8Tbflags: %d%8T mflags: %d\n",
791*7836SJohn.Forte@Sun.COM urdc->sync_flags, urdc->bmap_flags, urdc->mflags);
792*7836SJohn.Forte@Sun.COM mdb_printf("index: %d %8Tsync_pos: %d%8T vsize: %d\n",
793*7836SJohn.Forte@Sun.COM urdc->index, urdc->sync_pos, urdc->volume_size);
794*7836SJohn.Forte@Sun.COM mdb_printf("setid: %d %8Tbits set: %d %8Tautosync: %d\n",
795*7836SJohn.Forte@Sun.COM urdc->setid, urdc->bits_set, urdc->autosync);
796*7836SJohn.Forte@Sun.COM mdb_printf("maxqfbas: %d %8Tmaxqitems: %d\n",
797*7836SJohn.Forte@Sun.COM urdc->maxqfbas, urdc->maxqitems);
798*7836SJohn.Forte@Sun.COM mdb_printf("netconfig: %p\n", urdc->netconfig);
799*7836SJohn.Forte@Sun.COM mdb_printf("group: %s %8TdirectIO: %s\n",
800*7836SJohn.Forte@Sun.COM urdc->group_name, urdc->direct_file);
801*7836SJohn.Forte@Sun.COM mdb_printf("diskqueue: %s ", urdc->disk_queue);
802*7836SJohn.Forte@Sun.COM if (dqp) {
803*7836SJohn.Forte@Sun.COM mdb_printf("diskqsize: %d\n", QSIZE(dqp));
804*7836SJohn.Forte@Sun.COM } else {
805*7836SJohn.Forte@Sun.COM mdb_printf("\n");
806*7836SJohn.Forte@Sun.COM }
807*7836SJohn.Forte@Sun.COM mdb_printf("rdc_k_info: 0x%p\n", krdc);
808*7836SJohn.Forte@Sun.COM mdb_printf("\n");
809*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
810*7836SJohn.Forte@Sun.COM
811*7836SJohn.Forte@Sun.COM mdb_printf("\n");
812*7836SJohn.Forte@Sun.COM return (DCMD_OK);
813*7836SJohn.Forte@Sun.COM }
814*7836SJohn.Forte@Sun.COM
815*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
816*7836SJohn.Forte@Sun.COM static int
rdc_infodev(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)817*7836SJohn.Forte@Sun.COM rdc_infodev(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
818*7836SJohn.Forte@Sun.COM {
819*7836SJohn.Forte@Sun.COM rdc_info_dev_t *infodev;
820*7836SJohn.Forte@Sun.COM _rdc_info_dev_t *infp;
821*7836SJohn.Forte@Sun.COM
822*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
823*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
824*7836SJohn.Forte@Sun.COM
825*7836SJohn.Forte@Sun.COM infodev = mdb_zalloc(sizeof (*infodev), UM_GC);
826*7836SJohn.Forte@Sun.COM infp = mdb_zalloc(sizeof (*infp), UM_GC);
827*7836SJohn.Forte@Sun.COM
828*7836SJohn.Forte@Sun.COM if (mdb_vread(infodev, sizeof (*infodev), addr) != sizeof (*infodev)) {
829*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_infodev at 0x%p\n", addr);
830*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
831*7836SJohn.Forte@Sun.COM }
832*7836SJohn.Forte@Sun.COM
833*7836SJohn.Forte@Sun.COM infp = &infodev->id_cache_dev;
834*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
835*7836SJohn.Forte@Sun.COM
836*7836SJohn.Forte@Sun.COM mdb_printf("id_next: 0x%p\n", infodev->id_next);
837*7836SJohn.Forte@Sun.COM mdb_printf("id_cache_dev:\n");
838*7836SJohn.Forte@Sun.COM
839*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
840*7836SJohn.Forte@Sun.COM mdb_printf("bi_fd: 0x%p %8Tbi_iodev: 0x%p %8Tbi_krdc 0x%p\n",
841*7836SJohn.Forte@Sun.COM infp->bi_fd, infp->bi_iodev, infp->bi_krdc);
842*7836SJohn.Forte@Sun.COM mdb_printf("bi_rsrv: %d %8Tbi_orsrv: %d %8Tbi_failed: %d %8T\n"
843*7836SJohn.Forte@Sun.COM "bi_ofailed: %d %8Tbi_flag: %d\n", infp->bi_rsrv, infp->bi_orsrv,
844*7836SJohn.Forte@Sun.COM infp->bi_failed, infp->bi_ofailed, infp->bi_flag);
845*7836SJohn.Forte@Sun.COM
846*7836SJohn.Forte@Sun.COM infp = &infodev->id_raw_dev;
847*7836SJohn.Forte@Sun.COM
848*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
849*7836SJohn.Forte@Sun.COM mdb_printf("id_cache_dev:\n");
850*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
851*7836SJohn.Forte@Sun.COM
852*7836SJohn.Forte@Sun.COM mdb_printf("bi_fd: 0x%p %8Tbi_iodev: 0x%p %8Tbi_krdc 0x%p\n",
853*7836SJohn.Forte@Sun.COM infp->bi_fd, infp->bi_iodev, infp->bi_krdc);
854*7836SJohn.Forte@Sun.COM mdb_printf("bi_rsrv: %d %8Tbi_orsrv: %d %8Tbi_failed: %d %8T\n"
855*7836SJohn.Forte@Sun.COM "bi_ofailed: %d %8Tbi_flag: %d\n", infp->bi_rsrv, infp->bi_orsrv,
856*7836SJohn.Forte@Sun.COM infp->bi_failed, infp->bi_ofailed, infp->bi_flag);
857*7836SJohn.Forte@Sun.COM
858*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
859*7836SJohn.Forte@Sun.COM
860*7836SJohn.Forte@Sun.COM mdb_printf("id_sets: %d %8Tid_release: %d %8Tid_flag %d",
861*7836SJohn.Forte@Sun.COM infodev->id_sets, infodev->id_release, infodev->id_flag);
862*7836SJohn.Forte@Sun.COM
863*7836SJohn.Forte@Sun.COM if (infodev->id_flag & RDC_ID_CLOSING) {
864*7836SJohn.Forte@Sun.COM mdb_printf("closing");
865*7836SJohn.Forte@Sun.COM }
866*7836SJohn.Forte@Sun.COM mdb_printf("\n");
867*7836SJohn.Forte@Sun.COM
868*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
869*7836SJohn.Forte@Sun.COM return (DCMD_OK);
870*7836SJohn.Forte@Sun.COM }
871*7836SJohn.Forte@Sun.COM
872*7836SJohn.Forte@Sun.COM /*
873*7836SJohn.Forte@Sun.COM * Display general sv module information.
874*7836SJohn.Forte@Sun.COM */
875*7836SJohn.Forte@Sun.COM
876*7836SJohn.Forte@Sun.COM #define rdc_get_print(kvar, str, fmt, val) \
877*7836SJohn.Forte@Sun.COM if (mdb_readvar(&(val), #kvar) == -1) { \
878*7836SJohn.Forte@Sun.COM mdb_dec_indent(4); \
879*7836SJohn.Forte@Sun.COM mdb_warn("unable to read '" #kvar "'"); \
880*7836SJohn.Forte@Sun.COM return (DCMD_ERR); \
881*7836SJohn.Forte@Sun.COM } \
882*7836SJohn.Forte@Sun.COM mdb_printf("%-20s" fmt "\n", str ":", val)
883*7836SJohn.Forte@Sun.COM
884*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
885*7836SJohn.Forte@Sun.COM static int
rdc(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)886*7836SJohn.Forte@Sun.COM rdc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
887*7836SJohn.Forte@Sun.COM {
888*7836SJohn.Forte@Sun.COM int maj, min, mic, baseline, i;
889*7836SJohn.Forte@Sun.COM
890*7836SJohn.Forte@Sun.COM if (argc != 0)
891*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
892*7836SJohn.Forte@Sun.COM
893*7836SJohn.Forte@Sun.COM if (mdb_readvar(&maj, "sndr_major_rev") == -1) {
894*7836SJohn.Forte@Sun.COM mdb_warn("unable to read 'sndr_major_rev'");
895*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
896*7836SJohn.Forte@Sun.COM }
897*7836SJohn.Forte@Sun.COM
898*7836SJohn.Forte@Sun.COM if (mdb_readvar(&min, "sndr_minor_rev") == -1) {
899*7836SJohn.Forte@Sun.COM mdb_warn("unable to read 'sndr_minor_rev'");
900*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
901*7836SJohn.Forte@Sun.COM }
902*7836SJohn.Forte@Sun.COM
903*7836SJohn.Forte@Sun.COM if (mdb_readvar(&mic, "sndr_micro_rev") == -1) {
904*7836SJohn.Forte@Sun.COM mdb_warn("unable to read 'sndr_micro_rev'");
905*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
906*7836SJohn.Forte@Sun.COM }
907*7836SJohn.Forte@Sun.COM
908*7836SJohn.Forte@Sun.COM if (mdb_readvar(&baseline, "sndr_baseline_rev") == -1) {
909*7836SJohn.Forte@Sun.COM mdb_warn("unable to read 'sndr_baseline_rev'");
910*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
911*7836SJohn.Forte@Sun.COM }
912*7836SJohn.Forte@Sun.COM
913*7836SJohn.Forte@Sun.COM mdb_printf("Remote Mirror module version: kernel %d.%d.%d.%d; "
914*7836SJohn.Forte@Sun.COM "mdb %d.%d.%d.%d\n", maj, min, mic, baseline,
915*7836SJohn.Forte@Sun.COM ISS_VERSION_MAJ, ISS_VERSION_MIN, ISS_VERSION_MIC, ISS_VERSION_NUM);
916*7836SJohn.Forte@Sun.COM mdb_inc_indent(4);
917*7836SJohn.Forte@Sun.COM
918*7836SJohn.Forte@Sun.COM rdc_get_print(rdc_debug, "debug", "%d", i);
919*7836SJohn.Forte@Sun.COM rdc_get_print(rdc_bitmap_mode, "bitmap mode", "%d", i);
920*7836SJohn.Forte@Sun.COM rdc_get_print(rdc_max_sets, "max sndr devices", "%d", i);
921*7836SJohn.Forte@Sun.COM rdc_get_print(rdc_rpc_tmout, "client RPC timeout", "%d", i);
922*7836SJohn.Forte@Sun.COM rdc_get_print(rdc_health_thres, "health threshold", "%d", i);
923*7836SJohn.Forte@Sun.COM rdc_get_print(MAX_RDC_FBAS, "max trans fba", "%d", i);
924*7836SJohn.Forte@Sun.COM
925*7836SJohn.Forte@Sun.COM mdb_dec_indent(4);
926*7836SJohn.Forte@Sun.COM return (DCMD_OK);
927*7836SJohn.Forte@Sun.COM }
928*7836SJohn.Forte@Sun.COM
929*7836SJohn.Forte@Sun.COM static int
rdc_k2u(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)930*7836SJohn.Forte@Sun.COM rdc_k2u(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
931*7836SJohn.Forte@Sun.COM {
932*7836SJohn.Forte@Sun.COM rdc_k_info_t *krdc;
933*7836SJohn.Forte@Sun.COM rdc_u_info_t *rdc_u_info, *urdc;
934*7836SJohn.Forte@Sun.COM int rc;
935*7836SJohn.Forte@Sun.COM
936*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
937*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
938*7836SJohn.Forte@Sun.COM
939*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
940*7836SJohn.Forte@Sun.COM urdc = mdb_zalloc(sizeof (*urdc), UM_GC);
941*7836SJohn.Forte@Sun.COM
942*7836SJohn.Forte@Sun.COM if (mdb_vread(krdc, sizeof (*krdc), addr) != sizeof (*krdc)) {
943*7836SJohn.Forte@Sun.COM mdb_warn("failed to read krdc at %p", addr);
944*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
945*7836SJohn.Forte@Sun.COM }
946*7836SJohn.Forte@Sun.COM
947*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_u_info, "rdc_u_info") == -1) {
948*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_u_info'");
949*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
950*7836SJohn.Forte@Sun.COM }
951*7836SJohn.Forte@Sun.COM
952*7836SJohn.Forte@Sun.COM urdc = &rdc_u_info[krdc->index];
953*7836SJohn.Forte@Sun.COM
954*7836SJohn.Forte@Sun.COM rc = rdc_uinfo((uintptr_t)urdc, DCMD_ADDRSPEC, argc, argv);
955*7836SJohn.Forte@Sun.COM return (rc);
956*7836SJohn.Forte@Sun.COM }
957*7836SJohn.Forte@Sun.COM
958*7836SJohn.Forte@Sun.COM static int
rdc_u2k(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)959*7836SJohn.Forte@Sun.COM rdc_u2k(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
960*7836SJohn.Forte@Sun.COM {
961*7836SJohn.Forte@Sun.COM rdc_u_info_t *urdc;
962*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info, *krdc;
963*7836SJohn.Forte@Sun.COM int rc;
964*7836SJohn.Forte@Sun.COM
965*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
966*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
967*7836SJohn.Forte@Sun.COM
968*7836SJohn.Forte@Sun.COM urdc = mdb_zalloc(sizeof (*urdc), UM_GC);
969*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
970*7836SJohn.Forte@Sun.COM
971*7836SJohn.Forte@Sun.COM if (mdb_vread(urdc, sizeof (*urdc), addr) != sizeof (*urdc)) {
972*7836SJohn.Forte@Sun.COM mdb_warn("failed to read urdc at %p\n", addr);
973*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
974*7836SJohn.Forte@Sun.COM }
975*7836SJohn.Forte@Sun.COM
976*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
977*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
978*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
979*7836SJohn.Forte@Sun.COM }
980*7836SJohn.Forte@Sun.COM
981*7836SJohn.Forte@Sun.COM krdc = &rdc_k_info[urdc->index];
982*7836SJohn.Forte@Sun.COM
983*7836SJohn.Forte@Sun.COM rc = rdc_kinfo((uintptr_t)krdc, DCMD_ADDRSPEC, argc, argv);
984*7836SJohn.Forte@Sun.COM return (rc);
985*7836SJohn.Forte@Sun.COM }
986*7836SJohn.Forte@Sun.COM
987*7836SJohn.Forte@Sun.COM #ifdef DEBUG
988*7836SJohn.Forte@Sun.COM /*
989*7836SJohn.Forte@Sun.COM * This routine is used to set the seq field in the rdc_kinfo->group
990*7836SJohn.Forte@Sun.COM * structure. Used to test that the queue code handles the integer
991*7836SJohn.Forte@Sun.COM * overflow correctly.
992*7836SJohn.Forte@Sun.COM * Takes two arguments index and value.
993*7836SJohn.Forte@Sun.COM * The index is the index into the kinfo structure array and
994*7836SJohn.Forte@Sun.COM * the value is the new value to set into the seq field.
995*7836SJohn.Forte@Sun.COM */
996*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
997*7836SJohn.Forte@Sun.COM static int
rdc_setseq(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)998*7836SJohn.Forte@Sun.COM rdc_setseq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
999*7836SJohn.Forte@Sun.COM {
1000*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info;
1001*7836SJohn.Forte@Sun.COM rdc_group_t *group;
1002*7836SJohn.Forte@Sun.COM int index;
1003*7836SJohn.Forte@Sun.COM uint_t val;
1004*7836SJohn.Forte@Sun.COM uintptr_t pokeaddr;
1005*7836SJohn.Forte@Sun.COM
1006*7836SJohn.Forte@Sun.COM if (argc != 2) {
1007*7836SJohn.Forte@Sun.COM mdb_warn("must have two arguments, index and value\n");
1008*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1009*7836SJohn.Forte@Sun.COM }
1010*7836SJohn.Forte@Sun.COM
1011*7836SJohn.Forte@Sun.COM index = (int)mdb_strtoull(argv[0].a_un.a_str);
1012*7836SJohn.Forte@Sun.COM val = (uint_t)mdb_strtoull(argv[1].a_un.a_str);
1013*7836SJohn.Forte@Sun.COM
1014*7836SJohn.Forte@Sun.COM /*
1015*7836SJohn.Forte@Sun.COM * Find out where in memory the seq field.
1016*7836SJohn.Forte@Sun.COM * The structure offset first.
1017*7836SJohn.Forte@Sun.COM */
1018*7836SJohn.Forte@Sun.COM
1019*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
1020*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
1021*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1022*7836SJohn.Forte@Sun.COM }
1023*7836SJohn.Forte@Sun.COM pokeaddr = (uintptr_t)&rdc_k_info[index].group;
1024*7836SJohn.Forte@Sun.COM if (mdb_vread(&group, sizeof (rdc_group_t *), pokeaddr) !=
1025*7836SJohn.Forte@Sun.COM sizeof (rdc_group_t *)) {
1026*7836SJohn.Forte@Sun.COM mdb_warn("failed to fetch the group structure for set %d\n",
1027*7836SJohn.Forte@Sun.COM index);
1028*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1029*7836SJohn.Forte@Sun.COM }
1030*7836SJohn.Forte@Sun.COM pokeaddr = (uintptr_t)(&group->seq);
1031*7836SJohn.Forte@Sun.COM if (mdb_vwrite(&val, sizeof (val), pokeaddr) != sizeof (val)) {
1032*7836SJohn.Forte@Sun.COM mdb_warn("failed to write seq at %p\n", pokeaddr);
1033*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1034*7836SJohn.Forte@Sun.COM }
1035*7836SJohn.Forte@Sun.COM
1036*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1037*7836SJohn.Forte@Sun.COM }
1038*7836SJohn.Forte@Sun.COM
1039*7836SJohn.Forte@Sun.COM
1040*7836SJohn.Forte@Sun.COM /*
1041*7836SJohn.Forte@Sun.COM * This routine is used to set the seqack field in the rdc_kinfo->group
1042*7836SJohn.Forte@Sun.COM * structure. Used to test that the queue code handles the integer
1043*7836SJohn.Forte@Sun.COM * overflow correctly.
1044*7836SJohn.Forte@Sun.COM * Takes two arguments index and value.
1045*7836SJohn.Forte@Sun.COM * The index is the index into the kinfo structure array and
1046*7836SJohn.Forte@Sun.COM * the value is the new value to set into the seqack field.
1047*7836SJohn.Forte@Sun.COM */
1048*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1049*7836SJohn.Forte@Sun.COM static int
rdc_setseqack(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1050*7836SJohn.Forte@Sun.COM rdc_setseqack(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1051*7836SJohn.Forte@Sun.COM {
1052*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info;
1053*7836SJohn.Forte@Sun.COM rdc_group_t *group;
1054*7836SJohn.Forte@Sun.COM int index;
1055*7836SJohn.Forte@Sun.COM uint_t val;
1056*7836SJohn.Forte@Sun.COM uintptr_t pokeaddr;
1057*7836SJohn.Forte@Sun.COM
1058*7836SJohn.Forte@Sun.COM if (argc != 2) {
1059*7836SJohn.Forte@Sun.COM mdb_warn("must have two arguments, index and value\n");
1060*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1061*7836SJohn.Forte@Sun.COM }
1062*7836SJohn.Forte@Sun.COM
1063*7836SJohn.Forte@Sun.COM index = (int)mdb_strtoull(argv[0].a_un.a_str);
1064*7836SJohn.Forte@Sun.COM val = (uint_t)mdb_strtoull(argv[1].a_un.a_str);
1065*7836SJohn.Forte@Sun.COM
1066*7836SJohn.Forte@Sun.COM /*
1067*7836SJohn.Forte@Sun.COM * Find out where in memory the seqack field.
1068*7836SJohn.Forte@Sun.COM * The structure offset first.
1069*7836SJohn.Forte@Sun.COM */
1070*7836SJohn.Forte@Sun.COM
1071*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
1072*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
1073*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1074*7836SJohn.Forte@Sun.COM }
1075*7836SJohn.Forte@Sun.COM pokeaddr = (uintptr_t)&rdc_k_info[index].group;
1076*7836SJohn.Forte@Sun.COM if (mdb_vread(&group, sizeof (rdc_group_t *), pokeaddr) !=
1077*7836SJohn.Forte@Sun.COM sizeof (rdc_group_t *)) {
1078*7836SJohn.Forte@Sun.COM mdb_warn("failed to fetch the group structure for set %d\n",
1079*7836SJohn.Forte@Sun.COM index);
1080*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1081*7836SJohn.Forte@Sun.COM }
1082*7836SJohn.Forte@Sun.COM pokeaddr = (uintptr_t)(&group->seqack);
1083*7836SJohn.Forte@Sun.COM if (mdb_vwrite(&val, sizeof (val), pokeaddr) != sizeof (val)) {
1084*7836SJohn.Forte@Sun.COM mdb_warn("failed to write seqack at %p\n", pokeaddr);
1085*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1086*7836SJohn.Forte@Sun.COM }
1087*7836SJohn.Forte@Sun.COM
1088*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1089*7836SJohn.Forte@Sun.COM }
1090*7836SJohn.Forte@Sun.COM
1091*7836SJohn.Forte@Sun.COM /*
1092*7836SJohn.Forte@Sun.COM * random define printing stuff, just does the define, and print the result
1093*7836SJohn.Forte@Sun.COM */
1094*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1095*7836SJohn.Forte@Sun.COM static int
fba_to_log_num(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1096*7836SJohn.Forte@Sun.COM fba_to_log_num(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1097*7836SJohn.Forte@Sun.COM {
1098*7836SJohn.Forte@Sun.COM int num;
1099*7836SJohn.Forte@Sun.COM if (argc < 1) {
1100*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1101*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1102*7836SJohn.Forte@Sun.COM }
1103*7836SJohn.Forte@Sun.COM num = (int)mdb_strtoull(argv[0].a_un.a_str);
1104*7836SJohn.Forte@Sun.COM num = FBA_TO_LOG_NUM(num);
1105*7836SJohn.Forte@Sun.COM mdb_printf("LOG NUM: %d (0x%x)", num, num);
1106*7836SJohn.Forte@Sun.COM
1107*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1108*7836SJohn.Forte@Sun.COM }
1109*7836SJohn.Forte@Sun.COM
1110*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1111*7836SJohn.Forte@Sun.COM static int
log_to_fba_num(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1112*7836SJohn.Forte@Sun.COM log_to_fba_num(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1113*7836SJohn.Forte@Sun.COM {
1114*7836SJohn.Forte@Sun.COM int num;
1115*7836SJohn.Forte@Sun.COM if (argc < 1) {
1116*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1117*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1118*7836SJohn.Forte@Sun.COM }
1119*7836SJohn.Forte@Sun.COM num = (int)mdb_strtoull(argv[0].a_un.a_str);
1120*7836SJohn.Forte@Sun.COM num = LOG_TO_FBA_NUM(num);
1121*7836SJohn.Forte@Sun.COM mdb_printf("LOG NUM: %d (0x%x)", num, num);
1122*7836SJohn.Forte@Sun.COM
1123*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1124*7836SJohn.Forte@Sun.COM }
1125*7836SJohn.Forte@Sun.COM
1126*7836SJohn.Forte@Sun.COM static int
bmap_bit_isset(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1127*7836SJohn.Forte@Sun.COM bmap_bit_isset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1128*7836SJohn.Forte@Sun.COM {
1129*7836SJohn.Forte@Sun.COM int st;
1130*7836SJohn.Forte@Sun.COM int i, num;
1131*7836SJohn.Forte@Sun.COM rdc_k_info_t *krdc;
1132*7836SJohn.Forte@Sun.COM unsigned char *bmap;
1133*7836SJohn.Forte@Sun.COM unsigned char *bmaddr;
1134*7836SJohn.Forte@Sun.COM int bmsize;
1135*7836SJohn.Forte@Sun.COM
1136*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
1137*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
1138*7836SJohn.Forte@Sun.COM
1139*7836SJohn.Forte@Sun.COM if (argc < 1) {
1140*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1141*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1142*7836SJohn.Forte@Sun.COM }
1143*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
1144*7836SJohn.Forte@Sun.COM
1145*7836SJohn.Forte@Sun.COM if (mdb_vread(krdc, sizeof (*krdc), addr) != sizeof (*krdc)) {
1146*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_k_info at %p", addr);
1147*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1148*7836SJohn.Forte@Sun.COM }
1149*7836SJohn.Forte@Sun.COM
1150*7836SJohn.Forte@Sun.COM bmaddr = krdc->dcio_bitmap;
1151*7836SJohn.Forte@Sun.COM bmsize = krdc->bitmap_size;
1152*7836SJohn.Forte@Sun.COM bmap = mdb_zalloc(bmsize, UM_GC);
1153*7836SJohn.Forte@Sun.COM if (mdb_vread(bmap, bmsize, (uintptr_t)bmaddr) != bmsize) {
1154*7836SJohn.Forte@Sun.COM mdb_warn("failed to read bitmap");
1155*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1156*7836SJohn.Forte@Sun.COM }
1157*7836SJohn.Forte@Sun.COM
1158*7836SJohn.Forte@Sun.COM num = (int)mdb_strtoull(argv[0].a_un.a_str);
1159*7836SJohn.Forte@Sun.COM st = FBA_TO_LOG_NUM(num);
1160*7836SJohn.Forte@Sun.COM i = BMAP_BIT_ISSET(bmap, st);
1161*7836SJohn.Forte@Sun.COM mdb_printf(" BIT (%d) for %x %s set (%02x)", st, num, i?"IS":"IS NOT",
1162*7836SJohn.Forte@Sun.COM bmap[IND_BYTE(st)] & 0xff);
1163*7836SJohn.Forte@Sun.COM
1164*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1165*7836SJohn.Forte@Sun.COM }
1166*7836SJohn.Forte@Sun.COM
1167*7836SJohn.Forte@Sun.COM static int
bmap_bitref_isset(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1168*7836SJohn.Forte@Sun.COM bmap_bitref_isset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1169*7836SJohn.Forte@Sun.COM {
1170*7836SJohn.Forte@Sun.COM int num, st, i;
1171*7836SJohn.Forte@Sun.COM rdc_k_info_t *krdc;
1172*7836SJohn.Forte@Sun.COM unsigned char *brefbyte;
1173*7836SJohn.Forte@Sun.COM unsigned int *brefint;
1174*7836SJohn.Forte@Sun.COM void *bradder;
1175*7836SJohn.Forte@Sun.COM int brsize;
1176*7836SJohn.Forte@Sun.COM size_t refcntsize = sizeof (unsigned char);
1177*7836SJohn.Forte@Sun.COM struct bm_ref_ops *refops;
1178*7836SJohn.Forte@Sun.COM
1179*7836SJohn.Forte@Sun.COM if (!(flags & DCMD_ADDRSPEC))
1180*7836SJohn.Forte@Sun.COM return (DCMD_USAGE);
1181*7836SJohn.Forte@Sun.COM
1182*7836SJohn.Forte@Sun.COM if (argc < 1) {
1183*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1184*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1185*7836SJohn.Forte@Sun.COM }
1186*7836SJohn.Forte@Sun.COM
1187*7836SJohn.Forte@Sun.COM krdc = mdb_zalloc(sizeof (*krdc), UM_GC);
1188*7836SJohn.Forte@Sun.COM
1189*7836SJohn.Forte@Sun.COM if (mdb_vread(krdc, sizeof (*krdc), addr) != sizeof (*krdc)) {
1190*7836SJohn.Forte@Sun.COM mdb_warn("failed to read rdc_k_info at %p", addr);
1191*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1192*7836SJohn.Forte@Sun.COM }
1193*7836SJohn.Forte@Sun.COM
1194*7836SJohn.Forte@Sun.COM bradder = krdc->bitmap_ref;
1195*7836SJohn.Forte@Sun.COM refops = mdb_zalloc(sizeof (*refops), UM_GC);
1196*7836SJohn.Forte@Sun.COM if (mdb_vread(refops, sizeof (*refops), (uintptr_t)krdc->bm_refs) !=
1197*7836SJohn.Forte@Sun.COM sizeof (*refops)) {
1198*7836SJohn.Forte@Sun.COM mdb_warn("failed to read bm_refops at %p", krdc->bm_refs);
1199*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1200*7836SJohn.Forte@Sun.COM }
1201*7836SJohn.Forte@Sun.COM refcntsize = refops->bmap_ref_size;
1202*7836SJohn.Forte@Sun.COM brsize = krdc->bitmap_size * BITS_IN_BYTE * refcntsize;
1203*7836SJohn.Forte@Sun.COM if (refcntsize == sizeof (unsigned char)) {
1204*7836SJohn.Forte@Sun.COM brefbyte = mdb_zalloc(brsize, UM_GC);
1205*7836SJohn.Forte@Sun.COM if (mdb_vread(brefbyte, brsize, (uintptr_t)bradder) != brsize) {
1206*7836SJohn.Forte@Sun.COM mdb_warn("failed to read bitmap");
1207*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1208*7836SJohn.Forte@Sun.COM }
1209*7836SJohn.Forte@Sun.COM } else {
1210*7836SJohn.Forte@Sun.COM brefint = mdb_zalloc(brsize, UM_GC);
1211*7836SJohn.Forte@Sun.COM if (mdb_vread(brefint, brsize, (uintptr_t)bradder) != brsize) {
1212*7836SJohn.Forte@Sun.COM mdb_warn("failed to read bitmap");
1213*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1214*7836SJohn.Forte@Sun.COM }
1215*7836SJohn.Forte@Sun.COM }
1216*7836SJohn.Forte@Sun.COM
1217*7836SJohn.Forte@Sun.COM num = (int)mdb_strtoull(argv[0].a_un.a_str);
1218*7836SJohn.Forte@Sun.COM st = FBA_TO_LOG_NUM(num);
1219*7836SJohn.Forte@Sun.COM if (refcntsize == sizeof (unsigned char))
1220*7836SJohn.Forte@Sun.COM i = brefbyte[st];
1221*7836SJohn.Forte@Sun.COM else
1222*7836SJohn.Forte@Sun.COM i = brefint[st];
1223*7836SJohn.Forte@Sun.COM
1224*7836SJohn.Forte@Sun.COM mdb_printf("BITREF (%d) for %x %s set (%02x)", st, num, i?"IS":"IS NOT",
1225*7836SJohn.Forte@Sun.COM i);
1226*7836SJohn.Forte@Sun.COM
1227*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1228*7836SJohn.Forte@Sun.COM }
1229*7836SJohn.Forte@Sun.COM
1230*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1231*7836SJohn.Forte@Sun.COM static int
ind_byte(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1232*7836SJohn.Forte@Sun.COM ind_byte(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1233*7836SJohn.Forte@Sun.COM {
1234*7836SJohn.Forte@Sun.COM int num;
1235*7836SJohn.Forte@Sun.COM
1236*7836SJohn.Forte@Sun.COM if (argc < 1) {
1237*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1238*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1239*7836SJohn.Forte@Sun.COM }
1240*7836SJohn.Forte@Sun.COM num = FBA_TO_LOG_NUM((int)mdb_strtoull(argv[0].a_un.a_str));
1241*7836SJohn.Forte@Sun.COM mdb_printf("IND_BYTE: %d", IND_BYTE(num));
1242*7836SJohn.Forte@Sun.COM
1243*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1244*7836SJohn.Forte@Sun.COM }
1245*7836SJohn.Forte@Sun.COM
1246*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1247*7836SJohn.Forte@Sun.COM static int
ind_bit(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1248*7836SJohn.Forte@Sun.COM ind_bit(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1249*7836SJohn.Forte@Sun.COM {
1250*7836SJohn.Forte@Sun.COM int num;
1251*7836SJohn.Forte@Sun.COM
1252*7836SJohn.Forte@Sun.COM if (argc < 1) {
1253*7836SJohn.Forte@Sun.COM mdb_warn("must have an argument\n");
1254*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1255*7836SJohn.Forte@Sun.COM }
1256*7836SJohn.Forte@Sun.COM num = FBA_TO_LOG_NUM((int)mdb_strtoull(argv[0].a_un.a_str));
1257*7836SJohn.Forte@Sun.COM mdb_printf("IND_BIT: %d 0x%x", IND_BIT(num), IND_BIT(num));
1258*7836SJohn.Forte@Sun.COM
1259*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1260*7836SJohn.Forte@Sun.COM }
1261*7836SJohn.Forte@Sun.COM
1262*7836SJohn.Forte@Sun.COM static char *
print_bit(uint_t bitmask)1263*7836SJohn.Forte@Sun.COM print_bit(uint_t bitmask)
1264*7836SJohn.Forte@Sun.COM {
1265*7836SJohn.Forte@Sun.COM int bitval = 1;
1266*7836SJohn.Forte@Sun.COM int i;
1267*7836SJohn.Forte@Sun.COM
1268*7836SJohn.Forte@Sun.COM bitstr[32] = '\0';
1269*7836SJohn.Forte@Sun.COM
1270*7836SJohn.Forte@Sun.COM for (i = 31; i >= 0; i--) {
1271*7836SJohn.Forte@Sun.COM if (bitmask & bitval) {
1272*7836SJohn.Forte@Sun.COM bitstr[i] = '1';
1273*7836SJohn.Forte@Sun.COM } else {
1274*7836SJohn.Forte@Sun.COM bitstr[i] = '0';
1275*7836SJohn.Forte@Sun.COM }
1276*7836SJohn.Forte@Sun.COM bitval *= 2;
1277*7836SJohn.Forte@Sun.COM }
1278*7836SJohn.Forte@Sun.COM return (bitstr);
1279*7836SJohn.Forte@Sun.COM }
1280*7836SJohn.Forte@Sun.COM
1281*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1282*7836SJohn.Forte@Sun.COM static int
rdc_bitmask(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1283*7836SJohn.Forte@Sun.COM rdc_bitmask(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1284*7836SJohn.Forte@Sun.COM {
1285*7836SJohn.Forte@Sun.COM uint_t bitmask = 0;
1286*7836SJohn.Forte@Sun.COM int first, st, en, pos, len;
1287*7836SJohn.Forte@Sun.COM
1288*7836SJohn.Forte@Sun.COM if (argc < 2) {
1289*7836SJohn.Forte@Sun.COM mdb_warn("must have 2 args (pos, len)\n");
1290*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1291*7836SJohn.Forte@Sun.COM }
1292*7836SJohn.Forte@Sun.COM pos = (int)mdb_strtoull(argv[0].a_un.a_str);
1293*7836SJohn.Forte@Sun.COM len = (int)mdb_strtoull(argv[1].a_un.a_str);
1294*7836SJohn.Forte@Sun.COM
1295*7836SJohn.Forte@Sun.COM if (len <= 0) {
1296*7836SJohn.Forte@Sun.COM mdb_printf("non positive len specified");
1297*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1298*7836SJohn.Forte@Sun.COM }
1299*7836SJohn.Forte@Sun.COM
1300*7836SJohn.Forte@Sun.COM if ((len - pos) > 2048) {
1301*7836SJohn.Forte@Sun.COM mdb_printf("len out of range, 32 bit bitmask");
1302*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1303*7836SJohn.Forte@Sun.COM }
1304*7836SJohn.Forte@Sun.COM
1305*7836SJohn.Forte@Sun.COM first = st = FBA_TO_LOG_NUM(pos);
1306*7836SJohn.Forte@Sun.COM en = FBA_TO_LOG_NUM(pos + len - 1);
1307*7836SJohn.Forte@Sun.COM while (st <= en) {
1308*7836SJohn.Forte@Sun.COM BMAP_BIT_SET((uchar_t *)&bitmask, st - first);
1309*7836SJohn.Forte@Sun.COM st++;
1310*7836SJohn.Forte@Sun.COM }
1311*7836SJohn.Forte@Sun.COM
1312*7836SJohn.Forte@Sun.COM mdb_printf("bitmask for POS: %d LEN: %d : 0x%08x (%s)", pos, len,
1313*7836SJohn.Forte@Sun.COM bitmask & 0xffffffff, print_bit(bitmask));
1314*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1315*7836SJohn.Forte@Sun.COM
1316*7836SJohn.Forte@Sun.COM }
1317*7836SJohn.Forte@Sun.COM
1318*7836SJohn.Forte@Sun.COM /*
1319*7836SJohn.Forte@Sun.COM * Dump the bitmap of the krdc structure indicated by the index
1320*7836SJohn.Forte@Sun.COM * argument. Used by the ZatoIchi tests.
1321*7836SJohn.Forte@Sun.COM */
1322*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1323*7836SJohn.Forte@Sun.COM static int
rdc_bmapdump(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1324*7836SJohn.Forte@Sun.COM rdc_bmapdump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1325*7836SJohn.Forte@Sun.COM {
1326*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info;
1327*7836SJohn.Forte@Sun.COM int index;
1328*7836SJohn.Forte@Sun.COM uintptr_t bmapaddr;
1329*7836SJohn.Forte@Sun.COM uintptr_t bmapdata;
1330*7836SJohn.Forte@Sun.COM unsigned char *data;
1331*7836SJohn.Forte@Sun.COM int bmapsize;
1332*7836SJohn.Forte@Sun.COM int i;
1333*7836SJohn.Forte@Sun.COM int st = 0;
1334*7836SJohn.Forte@Sun.COM int en = 0;
1335*7836SJohn.Forte@Sun.COM
1336*7836SJohn.Forte@Sun.COM if (argc < 1) {
1337*7836SJohn.Forte@Sun.COM mdb_warn("must have index argument\n");
1338*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1339*7836SJohn.Forte@Sun.COM }
1340*7836SJohn.Forte@Sun.COM
1341*7836SJohn.Forte@Sun.COM i = argc;
1342*7836SJohn.Forte@Sun.COM if (i == 3) {
1343*7836SJohn.Forte@Sun.COM en = (int)mdb_strtoull(argv[2].a_un.a_str);
1344*7836SJohn.Forte@Sun.COM en = FBA_TO_LOG_NUM(en);
1345*7836SJohn.Forte@Sun.COM i--;
1346*7836SJohn.Forte@Sun.COM }
1347*7836SJohn.Forte@Sun.COM if (i == 2) {
1348*7836SJohn.Forte@Sun.COM st = (int)mdb_strtoull(argv[1].a_un.a_str);
1349*7836SJohn.Forte@Sun.COM st = FBA_TO_LOG_NUM(st);
1350*7836SJohn.Forte@Sun.COM }
1351*7836SJohn.Forte@Sun.COM
1352*7836SJohn.Forte@Sun.COM index = (int)mdb_strtoull(argv[0].a_un.a_str);
1353*7836SJohn.Forte@Sun.COM /*
1354*7836SJohn.Forte@Sun.COM * Find out where in memory the rdc_k_kinfo array starts
1355*7836SJohn.Forte@Sun.COM */
1356*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
1357*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
1358*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1359*7836SJohn.Forte@Sun.COM }
1360*7836SJohn.Forte@Sun.COM bmapaddr = (uintptr_t)(&rdc_k_info[index].bitmap_size);
1361*7836SJohn.Forte@Sun.COM if (mdb_vread(&bmapsize, sizeof (bmapsize), bmapaddr)
1362*7836SJohn.Forte@Sun.COM != sizeof (bmapsize)) {
1363*7836SJohn.Forte@Sun.COM mdb_warn("failed to read dcio_bitmap at %p\n", bmapaddr);
1364*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1365*7836SJohn.Forte@Sun.COM }
1366*7836SJohn.Forte@Sun.COM
1367*7836SJohn.Forte@Sun.COM bmapaddr = (uintptr_t)(&rdc_k_info[index].dcio_bitmap);
1368*7836SJohn.Forte@Sun.COM if (mdb_vread(&bmapdata, sizeof (bmapdata), bmapaddr)
1369*7836SJohn.Forte@Sun.COM != sizeof (bmapdata)) {
1370*7836SJohn.Forte@Sun.COM mdb_warn("failed to read dcio_bitmap at %p\n", bmapaddr);
1371*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1372*7836SJohn.Forte@Sun.COM }
1373*7836SJohn.Forte@Sun.COM data = mdb_zalloc(bmapsize, UM_SLEEP);
1374*7836SJohn.Forte@Sun.COM
1375*7836SJohn.Forte@Sun.COM if (mdb_vread(data, bmapsize, bmapdata) != bmapsize) {
1376*7836SJohn.Forte@Sun.COM mdb_warn("failed to read the bitmap data\n");
1377*7836SJohn.Forte@Sun.COM mdb_free(data, bmapsize);
1378*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1379*7836SJohn.Forte@Sun.COM }
1380*7836SJohn.Forte@Sun.COM mdb_printf("bitmap data address 0x%p bitmap size %d\n"
1381*7836SJohn.Forte@Sun.COM "kinfo 0x%p\n", bmapdata, bmapsize, &rdc_k_info[index]);
1382*7836SJohn.Forte@Sun.COM
1383*7836SJohn.Forte@Sun.COM if ((st < 0) || ((st/8) > bmapsize) || (en < 0)) {
1384*7836SJohn.Forte@Sun.COM mdb_warn("offset is out of range st %d bms %d en %d",
1385*7836SJohn.Forte@Sun.COM st, bmapsize, en);
1386*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1387*7836SJohn.Forte@Sun.COM }
1388*7836SJohn.Forte@Sun.COM if (((en/8) > bmapsize) || (en == 0))
1389*7836SJohn.Forte@Sun.COM en = bmapsize * 8;
1390*7836SJohn.Forte@Sun.COM
1391*7836SJohn.Forte@Sun.COM mdb_printf("bit start pos: %d bit end pos: %d\n\n", st, en);
1392*7836SJohn.Forte@Sun.COM st /= 8;
1393*7836SJohn.Forte@Sun.COM en /= 8;
1394*7836SJohn.Forte@Sun.COM for (i = st; i < en; i++) {
1395*7836SJohn.Forte@Sun.COM mdb_printf("%02x ", data[i] & 0xff);
1396*7836SJohn.Forte@Sun.COM if ((i % 16) == 15) {
1397*7836SJohn.Forte@Sun.COM int s = LOG_TO_FBA_NUM((i-15)*8);
1398*7836SJohn.Forte@Sun.COM int e = LOG_TO_FBA_NUM(((i+1)*8)) - 1;
1399*7836SJohn.Forte@Sun.COM mdb_printf(" fbas: %x - %x\n", s, e);
1400*7836SJohn.Forte@Sun.COM }
1401*7836SJohn.Forte@Sun.COM }
1402*7836SJohn.Forte@Sun.COM mdb_printf("\n");
1403*7836SJohn.Forte@Sun.COM mdb_free(data, bmapsize);
1404*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1405*7836SJohn.Forte@Sun.COM }
1406*7836SJohn.Forte@Sun.COM
1407*7836SJohn.Forte@Sun.COM /*
1408*7836SJohn.Forte@Sun.COM * dump the bitmap reference count
1409*7836SJohn.Forte@Sun.COM */
1410*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1411*7836SJohn.Forte@Sun.COM static int
rdc_brefdump(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1412*7836SJohn.Forte@Sun.COM rdc_brefdump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1413*7836SJohn.Forte@Sun.COM {
1414*7836SJohn.Forte@Sun.COM rdc_k_info_t *rdc_k_info;
1415*7836SJohn.Forte@Sun.COM int index;
1416*7836SJohn.Forte@Sun.COM uintptr_t bmapaddr;
1417*7836SJohn.Forte@Sun.COM uintptr_t bmapdata;
1418*7836SJohn.Forte@Sun.COM unsigned char *data;
1419*7836SJohn.Forte@Sun.COM int bmapsize;
1420*7836SJohn.Forte@Sun.COM int i;
1421*7836SJohn.Forte@Sun.COM int st = 0;
1422*7836SJohn.Forte@Sun.COM int en = 0;
1423*7836SJohn.Forte@Sun.COM
1424*7836SJohn.Forte@Sun.COM if (argc < 1) {
1425*7836SJohn.Forte@Sun.COM mdb_warn("must have index argument\n");
1426*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1427*7836SJohn.Forte@Sun.COM }
1428*7836SJohn.Forte@Sun.COM index = (int)mdb_strtoull(argv[0].a_un.a_str);
1429*7836SJohn.Forte@Sun.COM
1430*7836SJohn.Forte@Sun.COM i = argc;
1431*7836SJohn.Forte@Sun.COM if (i == 3) {
1432*7836SJohn.Forte@Sun.COM en = (int)mdb_strtoull(argv[2].a_un.a_str);
1433*7836SJohn.Forte@Sun.COM en = FBA_TO_LOG_NUM(en);
1434*7836SJohn.Forte@Sun.COM i--;
1435*7836SJohn.Forte@Sun.COM
1436*7836SJohn.Forte@Sun.COM }
1437*7836SJohn.Forte@Sun.COM if (i == 2) {
1438*7836SJohn.Forte@Sun.COM st = (int)mdb_strtoull(argv[1].a_un.a_str);
1439*7836SJohn.Forte@Sun.COM st = FBA_TO_LOG_NUM(st);
1440*7836SJohn.Forte@Sun.COM }
1441*7836SJohn.Forte@Sun.COM
1442*7836SJohn.Forte@Sun.COM /*
1443*7836SJohn.Forte@Sun.COM * Find out where in memory the rdc_k_kinfo array starts
1444*7836SJohn.Forte@Sun.COM */
1445*7836SJohn.Forte@Sun.COM if (mdb_readvar(&rdc_k_info, "rdc_k_info") == -1) {
1446*7836SJohn.Forte@Sun.COM mdb_warn("failed to read 'rdc_k_info'");
1447*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1448*7836SJohn.Forte@Sun.COM }
1449*7836SJohn.Forte@Sun.COM bmapaddr = (uintptr_t)(&rdc_k_info[index].bitmap_size);
1450*7836SJohn.Forte@Sun.COM
1451*7836SJohn.Forte@Sun.COM if (mdb_vread(&bmapsize, sizeof (bmapsize), bmapaddr)
1452*7836SJohn.Forte@Sun.COM != sizeof (bmapsize)) {
1453*7836SJohn.Forte@Sun.COM mdb_warn("failed to read dcio_bitmap at %p\n", bmapaddr);
1454*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1455*7836SJohn.Forte@Sun.COM }
1456*7836SJohn.Forte@Sun.COM
1457*7836SJohn.Forte@Sun.COM bmapsize *= 8;
1458*7836SJohn.Forte@Sun.COM bmapaddr = (uintptr_t)(&rdc_k_info[index].bitmap_ref);
1459*7836SJohn.Forte@Sun.COM
1460*7836SJohn.Forte@Sun.COM if (mdb_vread(&bmapdata, sizeof (bmapdata), bmapaddr)
1461*7836SJohn.Forte@Sun.COM != sizeof (bmapdata)) {
1462*7836SJohn.Forte@Sun.COM mdb_warn("failed to read dcio_bitmap at %p\n", bmapaddr);
1463*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1464*7836SJohn.Forte@Sun.COM }
1465*7836SJohn.Forte@Sun.COM data = mdb_zalloc(bmapsize, UM_SLEEP);
1466*7836SJohn.Forte@Sun.COM
1467*7836SJohn.Forte@Sun.COM if (mdb_vread(data, bmapsize, bmapdata) != bmapsize) {
1468*7836SJohn.Forte@Sun.COM mdb_warn("failed to read the bitmap data\n");
1469*7836SJohn.Forte@Sun.COM mdb_free(data, bmapsize);
1470*7836SJohn.Forte@Sun.COM return (DCMD_ERR);
1471*7836SJohn.Forte@Sun.COM }
1472*7836SJohn.Forte@Sun.COM mdb_printf("bitmap data address 0x%p bitmap size %d\n"
1473*7836SJohn.Forte@Sun.COM "kinfo 0x%p\n", bmapdata, bmapsize, &rdc_k_info[index]);
1474*7836SJohn.Forte@Sun.COM
1475*7836SJohn.Forte@Sun.COM if ((st < 0) || (st > bmapsize) || (en < 0)) {
1476*7836SJohn.Forte@Sun.COM mdb_warn("offset is out of range");
1477*7836SJohn.Forte@Sun.COM }
1478*7836SJohn.Forte@Sun.COM if ((en > bmapsize) || (en == 0))
1479*7836SJohn.Forte@Sun.COM en = bmapsize;
1480*7836SJohn.Forte@Sun.COM
1481*7836SJohn.Forte@Sun.COM mdb_printf("bit start pos: %d bit end pos: %d\n\n", st, en);
1482*7836SJohn.Forte@Sun.COM
1483*7836SJohn.Forte@Sun.COM for (i = st; i < en; i++) {
1484*7836SJohn.Forte@Sun.COM mdb_printf("%02x ", data[i] & 0xff);
1485*7836SJohn.Forte@Sun.COM if ((i % 16) == 15) {
1486*7836SJohn.Forte@Sun.COM int s = LOG_TO_FBA_NUM(i-15);
1487*7836SJohn.Forte@Sun.COM int e = LOG_TO_FBA_NUM(i+1) - 1;
1488*7836SJohn.Forte@Sun.COM mdb_printf(" fbas: 0x%x - 0x%x \n", s, e);
1489*7836SJohn.Forte@Sun.COM }
1490*7836SJohn.Forte@Sun.COM }
1491*7836SJohn.Forte@Sun.COM mdb_printf("\n");
1492*7836SJohn.Forte@Sun.COM mdb_free(data, bmapsize);
1493*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1494*7836SJohn.Forte@Sun.COM }
1495*7836SJohn.Forte@Sun.COM
1496*7836SJohn.Forte@Sun.COM static int
rdc_bmapnref(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1497*7836SJohn.Forte@Sun.COM rdc_bmapnref(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1498*7836SJohn.Forte@Sun.COM {
1499*7836SJohn.Forte@Sun.COM mdb_printf("\nRDC bitmap info\n");
1500*7836SJohn.Forte@Sun.COM rdc_bmapdump(addr, flags, argc, argv);
1501*7836SJohn.Forte@Sun.COM mdb_printf("RDC bitmap reference count info\n");
1502*7836SJohn.Forte@Sun.COM rdc_brefdump(addr, flags, argc, argv);
1503*7836SJohn.Forte@Sun.COM return (DCMD_OK);
1504*7836SJohn.Forte@Sun.COM }
1505*7836SJohn.Forte@Sun.COM
1506*7836SJohn.Forte@Sun.COM #endif
1507*7836SJohn.Forte@Sun.COM /*
1508*7836SJohn.Forte@Sun.COM * MDB module linkage information:
1509*7836SJohn.Forte@Sun.COM */
1510*7836SJohn.Forte@Sun.COM
1511*7836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = {
1512*7836SJohn.Forte@Sun.COM { "rdc", NULL, "display sndr module info", rdc },
1513*7836SJohn.Forte@Sun.COM { "rdc_buf", "?[-v]", "rdc_buf structure", rdc_buf },
1514*7836SJohn.Forte@Sun.COM { "rdc_kinfo", "?[-av]", "rdc_k_info structure", rdc_kinfo },
1515*7836SJohn.Forte@Sun.COM { "rdc_uinfo", "?[-av]", "rdc_u_info structure", rdc_uinfo },
1516*7836SJohn.Forte@Sun.COM { "rdc_group", "?", "rdc group structure", rdc_group },
1517*7836SJohn.Forte@Sun.COM { "rdc_srv", "?", "rdc_srv structure", rdc_srv },
1518*7836SJohn.Forte@Sun.COM { "rdc_if", "?", "rdc_if structure", rdc_if },
1519*7836SJohn.Forte@Sun.COM { "rdc_infodev", "?", "rdc_info_dev structure", rdc_infodev },
1520*7836SJohn.Forte@Sun.COM { "rdc_k2u", "?", "rdc_kinfo to rdc_uinfo", rdc_k2u },
1521*7836SJohn.Forte@Sun.COM { "rdc_u2k", "?", "rdc_uinfo to rdc_kinfo", rdc_u2k },
1522*7836SJohn.Forte@Sun.COM { "rdc_aio", "?", "rdc_aio structure", rdc_aio},
1523*7836SJohn.Forte@Sun.COM { "rdc_iohdr", "?", "rdc_iohdr structure", rdc_iohdr},
1524*7836SJohn.Forte@Sun.COM #ifdef DEBUG
1525*7836SJohn.Forte@Sun.COM { "rdc_setseq", "?", "Write seq field in group", rdc_setseq },
1526*7836SJohn.Forte@Sun.COM { "rdc_setseqack", "?", "Write seqack field in group", rdc_setseqack },
1527*7836SJohn.Forte@Sun.COM { "rdc_dset", "?", "Dump dset info", rdc_dset },
1528*7836SJohn.Forte@Sun.COM { "rdc_bmapdump", "?", "Dump bitmap", rdc_bmapdump },
1529*7836SJohn.Forte@Sun.COM { "rdc_brefdump", "?", "Dump bitmap reference count", rdc_brefdump },
1530*7836SJohn.Forte@Sun.COM { "rdc_bmapnref", "?", "Dump bitmap and ref count", rdc_bmapnref },
1531*7836SJohn.Forte@Sun.COM { "rdc_fba2log", "?", "fba to log num", fba_to_log_num },
1532*7836SJohn.Forte@Sun.COM { "rdc_log2fba", "?", "log to fba num", log_to_fba_num },
1533*7836SJohn.Forte@Sun.COM { "rdc_bitisset", "?", "check bit set", bmap_bit_isset },
1534*7836SJohn.Forte@Sun.COM { "rdc_brefisset", "?", "check bit ref set", bmap_bitref_isset },
1535*7836SJohn.Forte@Sun.COM { "rdc_indbyte", "?", "print indbyte", ind_byte },
1536*7836SJohn.Forte@Sun.COM { "rdc_indbit", "?", "print indbit", ind_bit },
1537*7836SJohn.Forte@Sun.COM { "rdc_bitmask", "?", "print bitmask for pos->len", rdc_bitmask },
1538*7836SJohn.Forte@Sun.COM #endif
1539*7836SJohn.Forte@Sun.COM { NULL }
1540*7836SJohn.Forte@Sun.COM };
1541*7836SJohn.Forte@Sun.COM
1542*7836SJohn.Forte@Sun.COM
1543*7836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = {
1544*7836SJohn.Forte@Sun.COM { "rdc_kinfo", "walk the rdc_k_info array",
1545*7836SJohn.Forte@Sun.COM rdc_k_info_winit, rdc_k_info_wstep, rdc_k_info_wfini },
1546*7836SJohn.Forte@Sun.COM { "rdc_uinfo", "walk the rdc_u_info array",
1547*7836SJohn.Forte@Sun.COM rdc_u_info_winit, rdc_u_info_wstep, rdc_u_info_wfini },
1548*7836SJohn.Forte@Sun.COM { "rdc_if", "walk rdc_if chain",
1549*7836SJohn.Forte@Sun.COM rdc_if_winit, rdc_if_wstep, rdc_if_wfini },
1550*7836SJohn.Forte@Sun.COM { NULL }
1551*7836SJohn.Forte@Sun.COM };
1552*7836SJohn.Forte@Sun.COM
1553*7836SJohn.Forte@Sun.COM
1554*7836SJohn.Forte@Sun.COM static const mdb_modinfo_t modinfo = {
1555*7836SJohn.Forte@Sun.COM MDB_API_VERSION, dcmds, walkers
1556*7836SJohn.Forte@Sun.COM };
1557*7836SJohn.Forte@Sun.COM
1558*7836SJohn.Forte@Sun.COM
1559*7836SJohn.Forte@Sun.COM const mdb_modinfo_t *
_mdb_init(void)1560*7836SJohn.Forte@Sun.COM _mdb_init(void)
1561*7836SJohn.Forte@Sun.COM {
1562*7836SJohn.Forte@Sun.COM return (&modinfo);
1563*7836SJohn.Forte@Sun.COM }
1564