xref: /onnv-gate/usr/src/cmd/mdb/common/modules/crypto/sched_impl.c (revision 12304:bcfa0838b31e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54072Skrishna  * Common Development and Distribution License (the "License").
64072Skrishna  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
214072Skrishna 
220Sstevel@tonic-gate /*
23*12304SValerie.Fenwick@Oracle.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <stdio.h>
270Sstevel@tonic-gate #include <sys/mdb_modapi.h>
280Sstevel@tonic-gate #include <sys/modctl.h>
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/crypto/api.h>
310Sstevel@tonic-gate #include <sys/crypto/common.h>
320Sstevel@tonic-gate #include <sys/crypto/api.h>
330Sstevel@tonic-gate #include <sys/crypto/sched_impl.h>
340Sstevel@tonic-gate #include "crypto_cmds.h"
350Sstevel@tonic-gate 
360Sstevel@tonic-gate static void
prt_an_state(int state)370Sstevel@tonic-gate prt_an_state(int state)
380Sstevel@tonic-gate {
390Sstevel@tonic-gate 	switch (state) {
400Sstevel@tonic-gate 		case REQ_ALLOCATED:
410Sstevel@tonic-gate 			mdb_printf("REQ_ALLOCATED  ");
420Sstevel@tonic-gate 			break;
430Sstevel@tonic-gate 		case REQ_WAITING:
440Sstevel@tonic-gate 			mdb_printf("REQ_WAITING    ");
450Sstevel@tonic-gate 			break;
460Sstevel@tonic-gate 		case REQ_INPROGRESS:
470Sstevel@tonic-gate 			mdb_printf("REQ_INPROGRESS ");
480Sstevel@tonic-gate 			break;
490Sstevel@tonic-gate 		case REQ_DONE:
500Sstevel@tonic-gate 			mdb_printf("REQ_DONE       ");
510Sstevel@tonic-gate 			break;
520Sstevel@tonic-gate 		case REQ_CANCELED:
530Sstevel@tonic-gate 			mdb_printf("REQ_CANCELED   ");
540Sstevel@tonic-gate 			break;
550Sstevel@tonic-gate 		default:
560Sstevel@tonic-gate 			mdb_printf("? %d ??        ", state);
570Sstevel@tonic-gate 			break;
580Sstevel@tonic-gate 	}
590Sstevel@tonic-gate }
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 
620Sstevel@tonic-gate static const mdb_bitmask_t call_flags[] = {
630Sstevel@tonic-gate 	{ "CRYPTO_ALWAYS_QUEUE", CRYPTO_ALWAYS_QUEUE, CRYPTO_ALWAYS_QUEUE },
640Sstevel@tonic-gate 	{ "CRYPTO_NOTIFY_OPDONE", CRYPTO_NOTIFY_OPDONE, CRYPTO_NOTIFY_OPDONE },
650Sstevel@tonic-gate 	{ "CRYPTO_SKIP_REQID", CRYPTO_SKIP_REQID, CRYPTO_SKIP_REQID },
660Sstevel@tonic-gate 	{ NULL, 0, 0 }
670Sstevel@tonic-gate };
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /*ARGSUSED*/
700Sstevel@tonic-gate static int
kcf_areq_node_simple(kcf_areq_node_t * areqn)710Sstevel@tonic-gate kcf_areq_node_simple(kcf_areq_node_t *areqn)
720Sstevel@tonic-gate {
730Sstevel@tonic-gate 	mdb_printf("\nan_type: ");
740Sstevel@tonic-gate 	if (areqn->an_type != CRYPTO_ASYNCH)
750Sstevel@tonic-gate 		mdb_printf("%-8d    ", areqn->an_type);
760Sstevel@tonic-gate 	else
770Sstevel@tonic-gate 		mdb_printf("CRYPTO_ASYNCH");
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	mdb_printf("\nan_state: ");
800Sstevel@tonic-gate 	prt_an_state(areqn->an_state);
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	mdb_printf("\nan_context: %-16p\t", areqn->an_context);
830Sstevel@tonic-gate 	mdb_printf("an_is_my_turn: %s\t     ", areqn->an_is_my_turn == B_FALSE ?
84*12304SValerie.Fenwick@Oracle.COM 	    "B_FALSE" : "B_TRUE");
850Sstevel@tonic-gate 
860Sstevel@tonic-gate 	mdb_printf("\ncr_reqid: %lx\n", areqn->an_reqarg.cr_reqid);
870Sstevel@tonic-gate 	return (DCMD_OK);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate /*
900Sstevel@tonic-gate  * Verbose print of kcf_areq_node_t
910Sstevel@tonic-gate  */
920Sstevel@tonic-gate static int
v_kcf_areq_node(kcf_areq_node_t * areqn)930Sstevel@tonic-gate v_kcf_areq_node(kcf_areq_node_t *areqn)
940Sstevel@tonic-gate {
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	/* contents only -- the address is printed elsewhere */
970Sstevel@tonic-gate 	/* First column */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	mdb_printf("\n%16s:  ", "an_type");
1000Sstevel@tonic-gate 	if (areqn->an_type != CRYPTO_ASYNCH)
1010Sstevel@tonic-gate 		mdb_printf("%-8d    ", areqn->an_type);
1020Sstevel@tonic-gate 	else
1030Sstevel@tonic-gate 		mdb_printf("CRYPTO_ASYNCH");
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate 	/* Second column */
1060Sstevel@tonic-gate 	mdb_printf("\t\t%16s:  %p\n", "an_lock", areqn->an_lock);
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate 	/* First column */
1090Sstevel@tonic-gate 	mdb_printf("%16s:  ", "an_state");
1100Sstevel@tonic-gate 	prt_an_state(areqn->an_state);
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate 	/* Second column */
1130Sstevel@tonic-gate 	mdb_printf("%14s:  next 4 items\n", "an_reqarg");
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 	/* First column again */
1160Sstevel@tonic-gate 	mdb_printf("%16s: '%16b'", "cr_flag", areqn->an_reqarg.cr_flag,
117*12304SValerie.Fenwick@Oracle.COM 	    call_flags);
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate 	/* Second column */
1200Sstevel@tonic-gate 	mdb_printf("\t%16s:  %p\n", "cr_callback_func",
121*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_reqarg.cr_callback_func);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 	/* First column again */
1240Sstevel@tonic-gate 	mdb_printf("%16s:  %-16p", "cr_callback_arg",
125*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_reqarg.cr_callback_arg);
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	/* Second column */
1280Sstevel@tonic-gate 	mdb_printf("\t%16s:  %lx\n", "cr_reqid",
129*12304SValerie.Fenwick@Oracle.COM 	    (ulong_t)areqn->an_reqarg.cr_reqid);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 	/* First column again */
1320Sstevel@tonic-gate 	mdb_printf("%16s:  %d", "an_params.rp_opgrp",
133*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_params.rp_opgrp);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate 	/* Second column */
1360Sstevel@tonic-gate 	mdb_printf("\t%16s:  %d\n", "an_params.rp_optype",
137*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_params.rp_optype);
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate 	/* First column again */
1400Sstevel@tonic-gate 	mdb_printf("%16s:  %-16p", "an_context",
141*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_context);
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 	/* Second column */
1440Sstevel@tonic-gate 	mdb_printf("\t%16s:  %p\n", "an_ctxchain_next",
145*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_ctxchain_next);
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate 	/* First column again */
1480Sstevel@tonic-gate 	mdb_printf("%16s:  %s", "an_is_my_turn",
1490Sstevel@tonic-gate 	    areqn->an_is_my_turn == B_FALSE ? "B_FALSE" : "B_TRUE");
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 	/* Second column */
1520Sstevel@tonic-gate 	mdb_printf("\t\t%16s:  %s\n", "an_isdual",
1530Sstevel@tonic-gate 	    areqn->an_isdual == B_FALSE ? "B_FALSE" : "B_TRUE");
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate 	/* First column again */
1560Sstevel@tonic-gate 	mdb_printf("%16s:  %p", "an_next",
157*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_next);
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 	/* Second column */
1600Sstevel@tonic-gate 	mdb_printf("\t\t%16s:  %p\n", "an_prev", areqn->an_prev);
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate 	/* First column again */
1630Sstevel@tonic-gate 	mdb_printf("%16s:  %p", "an_provider",
164*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_provider);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate 	/* Second column */
1670Sstevel@tonic-gate 	mdb_printf("\t\t%16s:  %p\n", "an_idnext", areqn->an_idnext);
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate 	/* First column again */
1700Sstevel@tonic-gate 	mdb_printf("%16s:  %p", "an_idprev",
171*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_idprev);
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate 	/* Second column */
1740Sstevel@tonic-gate 	mdb_printf("\t\t%16s:  %hx\n", "an_done", areqn->an_done);
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate 	/* First column again */
1770Sstevel@tonic-gate 	mdb_printf("%16s:  %d\n", "an_refcnt",
178*12304SValerie.Fenwick@Oracle.COM 	    areqn->an_refcnt);
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 	return (DCMD_OK);
1810Sstevel@tonic-gate }
1820Sstevel@tonic-gate /*ARGSUSED*/
1830Sstevel@tonic-gate int
kcf_areq_node(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1840Sstevel@tonic-gate kcf_areq_node(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1850Sstevel@tonic-gate {
1860Sstevel@tonic-gate 	kcf_areq_node_t areqn;
1870Sstevel@tonic-gate 	uint_t opt_v = FALSE;
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v,
1910Sstevel@tonic-gate 	    NULL) != argc)
1920Sstevel@tonic-gate 			return (DCMD_USAGE);
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate 	/*
1950Sstevel@tonic-gate 	 * read even if we're looping, because the cbdata design does not
1960Sstevel@tonic-gate 	 * apply to mdb_pwalk_dcmd
1970Sstevel@tonic-gate 	 */
1980Sstevel@tonic-gate 	if (mdb_vread(&areqn, sizeof (kcf_areq_node_t), addr) == -1) {
1990Sstevel@tonic-gate 		mdb_warn("cannot read %p", addr);
2000Sstevel@tonic-gate 		return (DCMD_ERR);
2010Sstevel@tonic-gate 	}
2020Sstevel@tonic-gate 	if (opt_v)	/* verbose */
2030Sstevel@tonic-gate 		return (v_kcf_areq_node(&areqn));
2040Sstevel@tonic-gate 	else
2050Sstevel@tonic-gate 		return (kcf_areq_node_simple(&areqn));
2060Sstevel@tonic-gate }
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate /*ARGSUSED*/
2090Sstevel@tonic-gate int
kcf_global_swq(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2100Sstevel@tonic-gate kcf_global_swq(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2110Sstevel@tonic-gate {
2120Sstevel@tonic-gate 	kcf_global_swq_t swq;
2130Sstevel@tonic-gate 	kcf_global_swq_t *ptr;
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate 	if (!flags && DCMD_ADDRSPEC) {
2160Sstevel@tonic-gate 		if (mdb_readsym(&ptr, sizeof (uintptr_t), "gswq")
2170Sstevel@tonic-gate 		    == -1) {
2180Sstevel@tonic-gate 			mdb_warn("cannot read gswq");
2190Sstevel@tonic-gate 			return (DCMD_ERR);
2200Sstevel@tonic-gate 		}
2210Sstevel@tonic-gate 	}
2220Sstevel@tonic-gate 	else
2230Sstevel@tonic-gate 		ptr = (kcf_global_swq_t *)addr;
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 	if (mdb_vread(&swq, sizeof (kcf_global_swq_t), (uintptr_t)ptr) == -1) {
2260Sstevel@tonic-gate 		mdb_warn("cannot read %p", ptr);
2270Sstevel@tonic-gate 		return (DCMD_ERR);
2280Sstevel@tonic-gate 	}
2290Sstevel@tonic-gate 	mdb_printf("gs_lock (mutex):\t%p\n", swq.gs_lock);
2300Sstevel@tonic-gate 	mdb_printf("gs_cv:\t%hx\n", swq.gs_cv._opaque);
2310Sstevel@tonic-gate 	mdb_printf("gs_njobs:\t%u\n", swq.gs_njobs);
2320Sstevel@tonic-gate 	mdb_printf("gs_maxjobs:\t%u\n", swq.gs_maxjobs);
2330Sstevel@tonic-gate 	mdb_printf("gs_first:\t%p\n", swq.gs_first);
2340Sstevel@tonic-gate 	mdb_printf("gs_last:\t%p\n", swq.gs_last);
2350Sstevel@tonic-gate 	return (mdb_pwalk_dcmd("an_next", "kcf_areq_node", argc,
2360Sstevel@tonic-gate 	    argv, (uintptr_t)swq.gs_first));
2370Sstevel@tonic-gate }
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate static int
areq_walk_init_common(mdb_walk_state_t * wsp,boolean_t use_first)2400Sstevel@tonic-gate areq_walk_init_common(mdb_walk_state_t *wsp, boolean_t use_first)
2410Sstevel@tonic-gate {
2420Sstevel@tonic-gate 	kcf_global_swq_t gswq_copy;
2430Sstevel@tonic-gate 	uintptr_t gswq_ptr;
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate 	if (mdb_readsym(&gswq_ptr, sizeof (gswq_ptr), "gswq") == -1) {
246*12304SValerie.Fenwick@Oracle.COM 		mdb_warn("failed to read 'gswq'");
247*12304SValerie.Fenwick@Oracle.COM 		return (WALK_ERR);
2480Sstevel@tonic-gate 	}
2490Sstevel@tonic-gate 	if (mdb_vread(&gswq_copy, sizeof (gswq_copy), gswq_ptr) == -1) {
2500Sstevel@tonic-gate 		mdb_warn("cannot read %p", gswq_ptr);
2510Sstevel@tonic-gate 		return (WALK_ERR);
2520Sstevel@tonic-gate 	}
2530Sstevel@tonic-gate 	if ((wsp->walk_addr = (use_first ? (uintptr_t)gswq_copy.gs_first :
2540Sstevel@tonic-gate 	    (uintptr_t)gswq_copy.gs_last)) == NULL) {
2550Sstevel@tonic-gate 		mdb_printf("Global swq is empty\n");
2560Sstevel@tonic-gate 		return (WALK_DONE);
2570Sstevel@tonic-gate 	}
2580Sstevel@tonic-gate 	wsp->walk_data = mdb_alloc(sizeof (kcf_areq_node_t), UM_SLEEP);
2590Sstevel@tonic-gate 	return (WALK_NEXT);
2600Sstevel@tonic-gate }
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate int
areq_first_walk_init(mdb_walk_state_t * wsp)2630Sstevel@tonic-gate areq_first_walk_init(mdb_walk_state_t *wsp)
2640Sstevel@tonic-gate {
2650Sstevel@tonic-gate 	return (areq_walk_init_common(wsp, B_TRUE));
2660Sstevel@tonic-gate }
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate int
areq_last_walk_init(mdb_walk_state_t * wsp)2690Sstevel@tonic-gate areq_last_walk_init(mdb_walk_state_t *wsp)
2700Sstevel@tonic-gate {
2710Sstevel@tonic-gate 	return (areq_walk_init_common(wsp, B_FALSE));
2720Sstevel@tonic-gate }
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate typedef enum idwalk_type {
2750Sstevel@tonic-gate 	IDNEXT,		/* an_idnext */
2760Sstevel@tonic-gate 	IDPREV,		/* an_idprev */
2770Sstevel@tonic-gate 	CTXCHAIN	/* an_ctxchain_next */
2780Sstevel@tonic-gate } idwalk_type_t;
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate static int
an_id_walk_init(mdb_walk_state_t * wsp,idwalk_type_t type)2810Sstevel@tonic-gate an_id_walk_init(mdb_walk_state_t *wsp, idwalk_type_t type)
2820Sstevel@tonic-gate {
2830Sstevel@tonic-gate 	kcf_areq_node_t *adn;
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate 	if (wsp->walk_addr == NULL) {
2860Sstevel@tonic-gate 		mdb_warn("must give kcf_areq_node address\n");
2870Sstevel@tonic-gate 		return (WALK_ERR);
2880Sstevel@tonic-gate 	}
2890Sstevel@tonic-gate 	adn = wsp->walk_data = mdb_alloc(sizeof (kcf_areq_node_t), UM_SLEEP);
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate 	if (mdb_vread(adn, sizeof (kcf_areq_node_t), wsp->walk_addr) == -1) {
2920Sstevel@tonic-gate 		mdb_warn("cannot read %p", wsp->walk_addr);
2930Sstevel@tonic-gate 		return (WALK_ERR);
2940Sstevel@tonic-gate 	}
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 	switch (type) {
2970Sstevel@tonic-gate 		case IDNEXT:
2980Sstevel@tonic-gate 			wsp->walk_addr = (uintptr_t)adn->an_idnext;
2990Sstevel@tonic-gate 			break;
3000Sstevel@tonic-gate 		case IDPREV:
3010Sstevel@tonic-gate 			wsp->walk_addr = (uintptr_t)adn->an_idprev;
3020Sstevel@tonic-gate 			break;
3030Sstevel@tonic-gate 		case CTXCHAIN:
3040Sstevel@tonic-gate 			wsp->walk_addr = (uintptr_t)adn->an_ctxchain_next;
3050Sstevel@tonic-gate 			break;
3060Sstevel@tonic-gate 		default:
3070Sstevel@tonic-gate 			mdb_warn("Bad structure member in walk_init\n");
3080Sstevel@tonic-gate 			return (WALK_ERR);
3090Sstevel@tonic-gate 	}
3100Sstevel@tonic-gate 	return (WALK_NEXT);
3110Sstevel@tonic-gate }
3120Sstevel@tonic-gate int
an_idnext_walk_init(mdb_walk_state_t * wsp)3130Sstevel@tonic-gate an_idnext_walk_init(mdb_walk_state_t *wsp)
3140Sstevel@tonic-gate {
3150Sstevel@tonic-gate 	return (an_id_walk_init(wsp, IDNEXT));
3160Sstevel@tonic-gate }
3170Sstevel@tonic-gate int
an_idprev_walk_init(mdb_walk_state_t * wsp)3180Sstevel@tonic-gate an_idprev_walk_init(mdb_walk_state_t *wsp)
3190Sstevel@tonic-gate {
3200Sstevel@tonic-gate 	return (an_id_walk_init(wsp, IDPREV));
3210Sstevel@tonic-gate }
3220Sstevel@tonic-gate int
an_ctxchain_walk_init(mdb_walk_state_t * wsp)3230Sstevel@tonic-gate an_ctxchain_walk_init(mdb_walk_state_t *wsp)
3240Sstevel@tonic-gate {
3250Sstevel@tonic-gate 	return (an_id_walk_init(wsp, CTXCHAIN));
3260Sstevel@tonic-gate }
3270Sstevel@tonic-gate /*
3280Sstevel@tonic-gate  * At each step, read a kcf_areq_node_t into our private storage, then invoke
3290Sstevel@tonic-gate  * the callback function.  We terminate when we reach a NULL type pointer.
3300Sstevel@tonic-gate  */
3310Sstevel@tonic-gate static int
an_id_walk_step(mdb_walk_state_t * wsp,idwalk_type_t type)3320Sstevel@tonic-gate an_id_walk_step(mdb_walk_state_t *wsp, idwalk_type_t type)
3330Sstevel@tonic-gate {
3340Sstevel@tonic-gate 	int status;
3350Sstevel@tonic-gate 	kcf_areq_node_t *ptr;
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate 	if (wsp->walk_addr == NULL)	/* then we're done */
3380Sstevel@tonic-gate 		return (WALK_DONE);
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate 	ptr = wsp->walk_data;
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate 	if (mdb_vread(wsp->walk_data, sizeof (kcf_areq_node_t),
3430Sstevel@tonic-gate 	    wsp->walk_addr) == -1) {
3440Sstevel@tonic-gate 		mdb_warn("cannot read %p", wsp->walk_addr);
3450Sstevel@tonic-gate 		return (WALK_ERR);
3460Sstevel@tonic-gate 	}
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
3490Sstevel@tonic-gate 	    wsp->walk_cbdata);
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate 	switch (type) {
3520Sstevel@tonic-gate 		case IDNEXT:
3530Sstevel@tonic-gate 			if ((wsp->walk_addr =
3540Sstevel@tonic-gate 			    (uintptr_t)ptr->an_idnext) == NULL)
3550Sstevel@tonic-gate 				return (WALK_DONE);
3560Sstevel@tonic-gate 			break;
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate 		case IDPREV:
3590Sstevel@tonic-gate 			if ((wsp->walk_addr =
3600Sstevel@tonic-gate 			    (uintptr_t)ptr->an_idprev) == NULL)
3610Sstevel@tonic-gate 				return (WALK_DONE);
3620Sstevel@tonic-gate 			break;
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 		case CTXCHAIN:
3650Sstevel@tonic-gate 			if ((wsp->walk_addr =
3660Sstevel@tonic-gate 			    (uintptr_t)ptr->an_ctxchain_next) == NULL)
3670Sstevel@tonic-gate 				return (WALK_DONE);
3680Sstevel@tonic-gate 			break;
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate 		default:
3710Sstevel@tonic-gate 			mdb_warn("Bad structure member in walk_step\n");
3720Sstevel@tonic-gate 			return (WALK_ERR);
3730Sstevel@tonic-gate 	}
3740Sstevel@tonic-gate 	return (status);
3750Sstevel@tonic-gate }
3760Sstevel@tonic-gate int
an_idnext_walk_step(mdb_walk_state_t * wsp)3770Sstevel@tonic-gate an_idnext_walk_step(mdb_walk_state_t *wsp)
3780Sstevel@tonic-gate {
3790Sstevel@tonic-gate 	return (an_id_walk_step(wsp, IDNEXT));
3800Sstevel@tonic-gate }
3810Sstevel@tonic-gate int
an_idprev_walk_step(mdb_walk_state_t * wsp)3820Sstevel@tonic-gate an_idprev_walk_step(mdb_walk_state_t *wsp)
3830Sstevel@tonic-gate {
3840Sstevel@tonic-gate 	return (an_id_walk_step(wsp, IDPREV));
3850Sstevel@tonic-gate }
3860Sstevel@tonic-gate int
an_ctxchain_walk_step(mdb_walk_state_t * wsp)3870Sstevel@tonic-gate an_ctxchain_walk_step(mdb_walk_state_t *wsp)
3880Sstevel@tonic-gate {
3890Sstevel@tonic-gate 	return (an_id_walk_step(wsp, CTXCHAIN));
3900Sstevel@tonic-gate }
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * The walker's fini function is invoked at the end of each walk.  Since we
3940Sstevel@tonic-gate  * dynamically allocated a kcf_areq_node_t in areq_walk_init,
3950Sstevel@tonic-gate  * we must free it now.
3960Sstevel@tonic-gate  */
3970Sstevel@tonic-gate void
areq_walk_fini(mdb_walk_state_t * wsp)3980Sstevel@tonic-gate areq_walk_fini(mdb_walk_state_t *wsp)
3990Sstevel@tonic-gate {
4000Sstevel@tonic-gate #ifdef	DEBUG
4010Sstevel@tonic-gate 	mdb_printf("...end of kcf_areq_node walk\n");
4020Sstevel@tonic-gate #endif
4030Sstevel@tonic-gate 	mdb_free(wsp->walk_data, sizeof (kcf_areq_node_t));
4040Sstevel@tonic-gate }
4050Sstevel@tonic-gate 
4060Sstevel@tonic-gate /*
4070Sstevel@tonic-gate  * At each step, read a kcf_areq_node_t into our private storage, then invoke
4080Sstevel@tonic-gate  * the callback function.  We terminate when we reach a NULL an_next pointer
4090Sstevel@tonic-gate  * or a NULL an_prev pointer. use_next flag indicates which one to check.
4100Sstevel@tonic-gate  */
4110Sstevel@tonic-gate static int
an_walk_step_common(mdb_walk_state_t * wsp,boolean_t use_next)4120Sstevel@tonic-gate an_walk_step_common(mdb_walk_state_t *wsp, boolean_t use_next)
4130Sstevel@tonic-gate {
4140Sstevel@tonic-gate 	int status;
4150Sstevel@tonic-gate 	kcf_areq_node_t *ptr;
4160Sstevel@tonic-gate 
4170Sstevel@tonic-gate 	ptr = (kcf_areq_node_t *)wsp->walk_data;
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate 	if (mdb_vread(wsp->walk_data, sizeof (kcf_areq_node_t),
4200Sstevel@tonic-gate 	    wsp->walk_addr) == -1) {
4210Sstevel@tonic-gate 		mdb_warn("failed to read kcf_areq_node at %p", wsp->walk_addr);
4220Sstevel@tonic-gate 		return (WALK_DONE);
4230Sstevel@tonic-gate 	}
4240Sstevel@tonic-gate 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
4250Sstevel@tonic-gate 	    wsp->walk_cbdata);
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate 	if ((wsp->walk_addr = (use_next ? (uintptr_t)ptr->an_next :
4280Sstevel@tonic-gate 	    (uintptr_t)ptr->an_prev)) == NULL)
4290Sstevel@tonic-gate 		return (WALK_DONE);
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate 	return (status);
4320Sstevel@tonic-gate }
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate int
an_next_walk_step(mdb_walk_state_t * wsp)4350Sstevel@tonic-gate an_next_walk_step(mdb_walk_state_t *wsp)
4360Sstevel@tonic-gate {
4370Sstevel@tonic-gate 	return (an_walk_step_common(wsp, B_TRUE));
4380Sstevel@tonic-gate }
4390Sstevel@tonic-gate 
4400Sstevel@tonic-gate int
an_prev_walk_step(mdb_walk_state_t * wsp)4410Sstevel@tonic-gate an_prev_walk_step(mdb_walk_state_t *wsp)
4420Sstevel@tonic-gate {
4430Sstevel@tonic-gate 	return (an_walk_step_common(wsp, B_FALSE));
4440Sstevel@tonic-gate }
4450Sstevel@tonic-gate 
4460Sstevel@tonic-gate /*
4470Sstevel@tonic-gate  * Walker data for reqid_table walking
4480Sstevel@tonic-gate  */
4490Sstevel@tonic-gate typedef	struct reqid_data {
4500Sstevel@tonic-gate 	kcf_reqid_table_t rd_table;
4510Sstevel@tonic-gate 	kcf_reqid_table_t *rd_tbl_ptrs[REQID_TABLES];
4520Sstevel@tonic-gate 	int		rd_cur_index;
4530Sstevel@tonic-gate } reqid_data_t;
4540Sstevel@tonic-gate 
4550Sstevel@tonic-gate typedef struct reqid_cb_data {
4560Sstevel@tonic-gate 	crypto_req_id_t cb_reqid;
4570Sstevel@tonic-gate 	int verbose;
4580Sstevel@tonic-gate 	int found;
4590Sstevel@tonic-gate } reqid_cb_data_t;
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate extern int crypto_pr_reqid(uintptr_t, reqid_data_t *, reqid_cb_data_t *);
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate 
4640Sstevel@tonic-gate int
reqid_table_walk_init(mdb_walk_state_t * wsp)4650Sstevel@tonic-gate reqid_table_walk_init(mdb_walk_state_t *wsp)
4660Sstevel@tonic-gate {
4670Sstevel@tonic-gate 	reqid_data_t *wdata;
4680Sstevel@tonic-gate 	reqid_cb_data_t *cbdata;
4690Sstevel@tonic-gate 
4700Sstevel@tonic-gate 	wsp->walk_callback = (mdb_walk_cb_t)crypto_pr_reqid;
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate 	wsp->walk_data = mdb_alloc(sizeof (reqid_data_t), UM_SLEEP);
4730Sstevel@tonic-gate 
4740Sstevel@tonic-gate 	/* see if the walker was called from the command line or mdb_pwalk */
4750Sstevel@tonic-gate 	if (wsp->walk_cbdata == NULL) {		/* command line */
476*12304SValerie.Fenwick@Oracle.COM 		if ((wsp->walk_cbdata = mdb_zalloc(sizeof (reqid_cb_data_t),
477*12304SValerie.Fenwick@Oracle.COM 		    UM_SLEEP)) == NULL) {
478*12304SValerie.Fenwick@Oracle.COM 			mdb_warn("couldn't get cb memory for "
479*12304SValerie.Fenwick@Oracle.COM 			    "reqid_table_walker");
480*12304SValerie.Fenwick@Oracle.COM 			return (WALK_ERR);
481*12304SValerie.Fenwick@Oracle.COM 		}
482*12304SValerie.Fenwick@Oracle.COM 		/* initialize for a simple walk, as opposed to a reqid search */
483*12304SValerie.Fenwick@Oracle.COM 		cbdata = wsp->walk_cbdata;
484*12304SValerie.Fenwick@Oracle.COM 		cbdata->verbose = TRUE;
485*12304SValerie.Fenwick@Oracle.COM 		cbdata->cb_reqid = 0;
4860Sstevel@tonic-gate 	}
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate 	wdata = (reqid_data_t *)wsp->walk_data;
4890Sstevel@tonic-gate 
4900Sstevel@tonic-gate 	if (mdb_readsym(wdata->rd_tbl_ptrs, sizeof (wdata->rd_tbl_ptrs),
491*12304SValerie.Fenwick@Oracle.COM 	    "kcf_reqid_table") == -1) {
4920Sstevel@tonic-gate 		mdb_warn("failed to read 'kcf_reqid_table'");
4930Sstevel@tonic-gate 		return (WALK_ERR);
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate 	}
4960Sstevel@tonic-gate 	wdata->rd_cur_index = 0;
4970Sstevel@tonic-gate 	wsp->walk_addr = (uintptr_t)wdata->rd_tbl_ptrs[wdata->rd_cur_index];
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate 	return (WALK_NEXT);
5010Sstevel@tonic-gate }
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate /*
5040Sstevel@tonic-gate  * At each step, read a kcf_reqid_table_t into our private storage, then invoke
5050Sstevel@tonic-gate  * the callback function.  We terminate when we reach a
5060Sstevel@tonic-gate  */
5070Sstevel@tonic-gate int
reqid_table_walk_step(mdb_walk_state_t * wsp)5080Sstevel@tonic-gate reqid_table_walk_step(mdb_walk_state_t *wsp)
5090Sstevel@tonic-gate {
5100Sstevel@tonic-gate 	int status;
5110Sstevel@tonic-gate 	reqid_data_t *wdata;
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate 	wdata = wsp->walk_data;
5150Sstevel@tonic-gate 	wsp->walk_addr = (uintptr_t)wdata->rd_tbl_ptrs[wdata->rd_cur_index];
5160Sstevel@tonic-gate 
5170Sstevel@tonic-gate #ifdef DEBUG
5180Sstevel@tonic-gate 	mdb_printf(
5190Sstevel@tonic-gate 	    "DEBUG: kcf_reqid_table at %p, sizeof kcf_reqid_table_t = %d\n",
520*12304SValerie.Fenwick@Oracle.COM 	    wsp->walk_addr, sizeof (kcf_reqid_table_t));
5210Sstevel@tonic-gate #endif
5220Sstevel@tonic-gate 
5230Sstevel@tonic-gate 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
5240Sstevel@tonic-gate 	    wsp->walk_cbdata);
5250Sstevel@tonic-gate 
5260Sstevel@tonic-gate 	/* get ready for next call */
5270Sstevel@tonic-gate 	wdata->rd_cur_index++;
5280Sstevel@tonic-gate 	if (wdata->rd_cur_index >= REQID_TABLES)
5290Sstevel@tonic-gate 		return (WALK_DONE);
5300Sstevel@tonic-gate 	return (status);
5310Sstevel@tonic-gate }
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate /*
5340Sstevel@tonic-gate  * The walker's fini function is invoked at the end of each walk.  Since we
5350Sstevel@tonic-gate  * dynamically allocated a reqid_data_t in areq_walk_init,
5360Sstevel@tonic-gate  * we must free it now.
5370Sstevel@tonic-gate  */
5380Sstevel@tonic-gate void
reqid_table_walk_fini(mdb_walk_state_t * wsp)5390Sstevel@tonic-gate reqid_table_walk_fini(mdb_walk_state_t *wsp)
5400Sstevel@tonic-gate {
5410Sstevel@tonic-gate #ifdef DEBUG
5420Sstevel@tonic-gate 	mdb_printf("...end of kcf_reqid walk\n");
5430Sstevel@tonic-gate #endif
5440Sstevel@tonic-gate 	mdb_free(wsp->walk_data, sizeof (reqid_data_t));
5450Sstevel@tonic-gate }
5460Sstevel@tonic-gate 
5470Sstevel@tonic-gate /*
5480Sstevel@tonic-gate  * If there's an argument beyond -v, then we're looking for a specific
5490Sstevel@tonic-gate  * reqid, otherwise, print any non-null kcf_areq things we run across.
5500Sstevel@tonic-gate  */
5510Sstevel@tonic-gate 
5520Sstevel@tonic-gate int
crypto_pr_reqid(uintptr_t addr,reqid_data_t * data,reqid_cb_data_t * cbdata)5530Sstevel@tonic-gate crypto_pr_reqid(uintptr_t addr, reqid_data_t *data, reqid_cb_data_t *cbdata)
5540Sstevel@tonic-gate {
5550Sstevel@tonic-gate 	kcf_areq_node_t node;
5560Sstevel@tonic-gate 	int i;
5570Sstevel@tonic-gate 	int needhdr = TRUE;
5580Sstevel@tonic-gate 
5590Sstevel@tonic-gate 	if (addr == NULL) {
5600Sstevel@tonic-gate 		mdb_printf("kcf_reqid_table[%d] = NULL\n", data->rd_cur_index);
5610Sstevel@tonic-gate 		return (WALK_NEXT);
5620Sstevel@tonic-gate 	}
5630Sstevel@tonic-gate 
5640Sstevel@tonic-gate 	if (mdb_vread(&(data->rd_table), sizeof (kcf_reqid_table_t),
5650Sstevel@tonic-gate 	    addr) == -1) {
5660Sstevel@tonic-gate 		mdb_warn("failed to read kcf_reqid_table at %p",
5670Sstevel@tonic-gate 		    addr);
5680Sstevel@tonic-gate 		return (WALK_ERR);
5690Sstevel@tonic-gate 	}
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate 	/* Loop over all rt_idhash's */
5720Sstevel@tonic-gate 	for (i = 0; i < REQID_BUCKETS; i++) {
5730Sstevel@tonic-gate 	    uint_t number_in_chain = 0;
5740Sstevel@tonic-gate 	    uintptr_t node_addr;
5750Sstevel@tonic-gate 
5760Sstevel@tonic-gate 	    /* follow the an_idnext chains for each bucket */
5770Sstevel@tonic-gate 	    do {
5780Sstevel@tonic-gate 		/* read kcf_areq_node */
5790Sstevel@tonic-gate 		if (number_in_chain == 0)
5800Sstevel@tonic-gate 		    node_addr = (uintptr_t)data->rd_table.rt_idhash[i];
5810Sstevel@tonic-gate 		else
5820Sstevel@tonic-gate 		    /*LINTED*/
5830Sstevel@tonic-gate 		    node_addr = (uintptr_t)node.an_idnext;
5840Sstevel@tonic-gate #ifdef DEBUG
5850Sstevel@tonic-gate 		mdb_printf("DEBUG: node_addr = %p\n", node_addr);
5860Sstevel@tonic-gate #endif
5870Sstevel@tonic-gate 
5880Sstevel@tonic-gate 		if (node_addr == NULL)
5890Sstevel@tonic-gate 			break;  /* skip */
5900Sstevel@tonic-gate 
5910Sstevel@tonic-gate 		if (mdb_vread(&node, sizeof (kcf_areq_node_t), node_addr)
5920Sstevel@tonic-gate 		    == -1) {
5930Sstevel@tonic-gate 			if (cbdata->verbose == TRUE)
5940Sstevel@tonic-gate 			    mdb_printf(
5950Sstevel@tonic-gate 				"cannot read rt_idhash %d an_idnext %d\n",
5960Sstevel@tonic-gate 				i, number_in_chain);
5970Sstevel@tonic-gate 			break;
5980Sstevel@tonic-gate 		}
5990Sstevel@tonic-gate 		/* see if we want to print it */
6000Sstevel@tonic-gate 		if ((cbdata->cb_reqid == 0) ||
6010Sstevel@tonic-gate 		    (node.an_reqarg.cr_reqid == cbdata->cb_reqid)) {
6020Sstevel@tonic-gate 			cbdata->found = TRUE;  /* printed if false || reqid */
6030Sstevel@tonic-gate 			/* is this the first rd_idhash found for this table? */
6040Sstevel@tonic-gate 			if (needhdr == TRUE) {
6050Sstevel@tonic-gate 			    /* print both indices in bold */
6060Sstevel@tonic-gate 			    mdb_printf("%<b>kcf_reqid_table[%lu] at %p:%</b>\n",
6070Sstevel@tonic-gate 				data->rd_cur_index, addr);
6080Sstevel@tonic-gate 			    mdb_printf("\trt_lock:  %p\trt_curid: %llx\n",
6090Sstevel@tonic-gate 				data->rd_table.rt_lock,
6100Sstevel@tonic-gate 				data->rd_table.rt_curid);
6110Sstevel@tonic-gate 			    needhdr = FALSE;
6120Sstevel@tonic-gate 			}
6130Sstevel@tonic-gate 			/* print kcf_areq_node */
6140Sstevel@tonic-gate 			if (number_in_chain < 1)
6150Sstevel@tonic-gate 			    mdb_printf(
6160Sstevel@tonic-gate 				"    %<b>rt_idhash[%lu%]%</b> = %<b>%p:%</b>\n",
6170Sstevel@tonic-gate 				i, node_addr);
6180Sstevel@tonic-gate 			else
6190Sstevel@tonic-gate 			    mdb_printf(
6200Sstevel@tonic-gate 				"    rt_idhash[%lu%]"
6210Sstevel@tonic-gate 					" an_idnext %d  = %<b>%p:%</b>\n",
6220Sstevel@tonic-gate 					i, number_in_chain, node_addr);
6230Sstevel@tonic-gate 			mdb_inc_indent(8);
6240Sstevel@tonic-gate 
6250Sstevel@tonic-gate 			/* if we're looking for one and only one reqid */
6260Sstevel@tonic-gate 			/* do it REALLY verbose */
6270Sstevel@tonic-gate 			if ((node.an_reqarg.cr_reqid == cbdata->cb_reqid) &&
6280Sstevel@tonic-gate 			    (cbdata->cb_reqid != 0))
6290Sstevel@tonic-gate 				v_kcf_areq_node(&node);
6300Sstevel@tonic-gate 			else if (cbdata->verbose == TRUE)
6310Sstevel@tonic-gate 			/*
6320Sstevel@tonic-gate 			 * verbose for this walker means non-verbose for
6330Sstevel@tonic-gate 			 * the kcf_areq_node details
6340Sstevel@tonic-gate 			 */
6350Sstevel@tonic-gate 			    kcf_areq_node_simple(&node);
6360Sstevel@tonic-gate 			mdb_dec_indent(8);
6370Sstevel@tonic-gate 		}
6380Sstevel@tonic-gate 		/* if we only wanted one reqid, quit now */
6390Sstevel@tonic-gate 		if (node.an_reqarg.cr_reqid == cbdata->cb_reqid) {
6400Sstevel@tonic-gate 			return (WALK_DONE);
6410Sstevel@tonic-gate 		}
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 		number_in_chain++;
6440Sstevel@tonic-gate 
6450Sstevel@tonic-gate 	    } while (node.an_idnext != NULL); /* follow chain in same bucket */
6460Sstevel@tonic-gate 
6470Sstevel@tonic-gate 	}  /* for each REQID_BUCKETS */
6480Sstevel@tonic-gate 
6490Sstevel@tonic-gate 	if ((needhdr == TRUE) && (cbdata->cb_reqid == 0)) {
6500Sstevel@tonic-gate 	    mdb_printf("%kcf_reqid_table[%lu]: %p\n",
6510Sstevel@tonic-gate 		data->rd_cur_index, addr);
6520Sstevel@tonic-gate 	}
6530Sstevel@tonic-gate 	return (WALK_NEXT);
6540Sstevel@tonic-gate }
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate /*ARGSUSED*/
6570Sstevel@tonic-gate int
crypto_find_reqid(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)6580Sstevel@tonic-gate crypto_find_reqid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
6590Sstevel@tonic-gate {
6600Sstevel@tonic-gate 	const mdb_arg_t *argp = NULL;
6610Sstevel@tonic-gate 	reqid_cb_data_t cbdata;
6620Sstevel@tonic-gate 	int i, status;
6630Sstevel@tonic-gate 
6640Sstevel@tonic-gate 	cbdata.cb_reqid = 0L;
6650Sstevel@tonic-gate 	cbdata.verbose = FALSE;
6660Sstevel@tonic-gate 	cbdata.found = FALSE;
6670Sstevel@tonic-gate 
6680Sstevel@tonic-gate 	if (flags & DCMD_ADDRSPEC) {
6690Sstevel@tonic-gate 		mdb_printf("use addr ::kcf_reqid_table\n");
6700Sstevel@tonic-gate 		return (DCMD_USAGE);
6710Sstevel@tonic-gate 	}
6720Sstevel@tonic-gate 	if ((i = mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE,
6730Sstevel@tonic-gate 	    &cbdata.verbose, NULL)) != argc) {
6740Sstevel@tonic-gate 		if (argc - i > 1)
6750Sstevel@tonic-gate 			return (DCMD_USAGE);
6760Sstevel@tonic-gate 	}
6770Sstevel@tonic-gate 
6780Sstevel@tonic-gate 	if (argc > i)
679*12304SValerie.Fenwick@Oracle.COM 		argp = &argv[i];
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate 	if ((argp != NULL)) {
682*12304SValerie.Fenwick@Oracle.COM 		if (argp->a_type == MDB_TYPE_IMMEDIATE)
683*12304SValerie.Fenwick@Oracle.COM 			cbdata.cb_reqid = argp->a_un.a_val;
684*12304SValerie.Fenwick@Oracle.COM 		else
685*12304SValerie.Fenwick@Oracle.COM 			cbdata.cb_reqid = (crypto_req_id_t)
686*12304SValerie.Fenwick@Oracle.COM 			    mdb_strtoull(argp->a_un.a_str);
6870Sstevel@tonic-gate 	}
6880Sstevel@tonic-gate 	status = mdb_pwalk("kcf_reqid_table", (mdb_walk_cb_t)crypto_pr_reqid,
6890Sstevel@tonic-gate 	    &cbdata, addr);
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate 	if ((cbdata.cb_reqid != 0L) && (cbdata.found == FALSE))
6920Sstevel@tonic-gate 		mdb_printf("ID 0x%lx not found\n", cbdata.cb_reqid);
6930Sstevel@tonic-gate #ifdef DEBUG
6940Sstevel@tonic-gate 	else
6950Sstevel@tonic-gate 		mdb_printf("DEBUG: cbdata.db_reqid = %lx, cbdata.found = %d\n",
6960Sstevel@tonic-gate 		    cbdata.cb_reqid, cbdata.found);
6970Sstevel@tonic-gate #endif
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate 	return (status);
7000Sstevel@tonic-gate }
7010Sstevel@tonic-gate 
7020Sstevel@tonic-gate int
kcf_reqid_table_dcmd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)7030Sstevel@tonic-gate kcf_reqid_table_dcmd(uintptr_t addr, uint_t flags, int argc,
7040Sstevel@tonic-gate     const mdb_arg_t *argv)
7050Sstevel@tonic-gate {
7060Sstevel@tonic-gate 	reqid_data_t wdata;
7070Sstevel@tonic-gate 	reqid_cb_data_t cbdata;
7080Sstevel@tonic-gate 
7090Sstevel@tonic-gate 	if (!(flags & DCMD_ADDRSPEC))
7100Sstevel@tonic-gate 		return (DCMD_USAGE);
7110Sstevel@tonic-gate 
7120Sstevel@tonic-gate 	memset(&wdata, 0, sizeof (wdata));
7130Sstevel@tonic-gate 	memset(&cbdata, 0, sizeof (cbdata));
7140Sstevel@tonic-gate 
7150Sstevel@tonic-gate 	if ((mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE,
7160Sstevel@tonic-gate 	    &cbdata.verbose, NULL)) != argc) {
7170Sstevel@tonic-gate 			return (DCMD_USAGE);
7180Sstevel@tonic-gate 	}
7190Sstevel@tonic-gate 	crypto_pr_reqid(addr, &wdata, &cbdata);
7200Sstevel@tonic-gate 	return (DCMD_OK);
7210Sstevel@tonic-gate }
722