xref: /illumos-gate/usr/src/lib/fm/libdiskstatus/common/ds_impl.h (revision b9538c2103fde34bfe8a8c2b3e878ecd1586d182)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef	_DS_IMPL_H
28 #define	_DS_IMPL_H
29 
30 #include <dlfcn.h>
31 #include <libnvpair.h>
32 #include <sys/types.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 struct disk_status;
39 
40 typedef struct ds_transport {
41 	void		*(*dt_open)(struct disk_status *);
42 	void		(*dt_close)(void *);
43 	int		(*dt_scan)(void *);
44 } ds_transport_t;
45 
46 struct disk_status {
47 	char			*ds_path;	/* path to device */
48 	int			ds_fd;		/* device file descriptor */
49 	ds_transport_t		*ds_transport;	/* associated transport */
50 	void			*ds_data;	/* transport-specific data */
51 	int			ds_faults;	/* mask of current faults */
52 	nvlist_t		*ds_overtemp;	/* overtemp */
53 	nvlist_t		*ds_predfail;	/* predict fail */
54 	nvlist_t		*ds_testfail;	/* self test fail */
55 	nvlist_t		*ds_ssmwearout;	/* SSM wearout fail */
56 	int			ds_error;	/* last error */
57 	nvlist_t		*ds_state;	/* protocol state */
58 };
59 
60 #define	DS_FAULT_OVERTEMP	0x1
61 #define	DS_FAULT_PREDFAIL	0x2
62 #define	DS_FAULT_TESTFAIL	0x4
63 #define	DS_FAULT_SSMWEAROUT	0x8
64 
65 extern void dprintf(const char *, ...);
66 extern void ddump(const char *, const void *, size_t);
67 extern boolean_t ds_debug;
68 
69 extern int ds_set_errno(struct disk_status *, int);
70 
71 #ifdef	__cplusplus
72 }
73 #endif
74 
75 #endif	/* _DS_IMPL_H */
76