xref: /illumos-gate/usr/src/cmd/mdb/common/modules/nfs/common.h (revision 42b53e0fbc5c05289c3d334bb864b784fafe5ce4)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 /*
12  * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
13  */
14 
15 #ifndef _COMMON_H
16 #define	_COMMON_H
17 
18 #include <sys/zone.h>
19 #include <sys/mutex.h>
20 #include <sys/rwlock.h>
21 #include <rpc/svc.h>
22 #include <nfs/nfs.h>
23 
24 extern int zoned_zsd_find_by_key(uintptr_t, zone_key_t, uintptr_t *);
25 extern int zoned_get_nfs_globals(uintptr_t, uintptr_t *);
26 extern int zoned_get_zsd(uintptr_t, char *, uintptr_t *);
27 
28 extern const char *common_mutex(kmutex_t *);
29 extern const char *common_rwlock(krwlock_t *);
30 extern const char *common_netbuf_str(struct netbuf *);
31 
32 /*
33  * Generic hash table walker
34  *
35  * Generic hash table is an array of head structures starting at address
36  * array_addr. The number of the head structures in the array is array_len.
37  * Size of the head structure is head_size. There is a pointer in the head
38  * structure called first_name with offset first_offset that points to the
39  * linked list of member structures. The member structure type name is stored
40  * in member_type_name.  Size of the member structure is member_size. The
41  * member structure have a pointer to the next member structure at offset
42  * next_offset.
43  *
44  * A pointer to the hash_table_walk_arg_t should be passed as walk_arg to the
45  * hash_table_walk_init().
46  */
47 
48 typedef struct hash_table_walk_arg {
49 	uintptr_t array_addr;
50 	int array_len;
51 	size_t head_size;
52 	const char *first_name;
53 	size_t first_offset;
54 	const char *member_type_name;
55 	size_t member_size;
56 	size_t next_offset;
57 } hash_table_walk_arg_t;
58 
59 extern int hash_table_walk_init(mdb_walk_state_t *);
60 extern int hash_table_walk_step(mdb_walk_state_t *);
61 extern void hash_table_walk_fini(mdb_walk_state_t *);
62 
63 #endif	/* _COMMON_H */
64