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 /*
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #ifndef _FMD_API_H
27 #define _FMD_API_H
28
29 #include <sys/types.h>
30 #include <libnvpair.h>
31 #include <stdarg.h>
32 #include <door.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /*
39 * Fault Management Daemon Client Interfaces
40 *
41 * Note: The contents of this file are private to the implementation of the
42 * Solaris system and FMD subsystem and are subject to change at any time
43 * without notice. Applications and drivers using these interfaces will fail
74 #define FMD_TYPE_BOOL 0 /* int */
75 #define FMD_TYPE_INT32 1 /* int32_t */
76 #define FMD_TYPE_UINT32 2 /* uint32_t */
77 #define FMD_TYPE_INT64 3 /* int64_t */
78 #define FMD_TYPE_UINT64 4 /* uint64_t */
79 #define FMD_TYPE_STRING 5 /* const char* */
80 #define FMD_TYPE_TIME 6 /* uint64_t */
81 #define FMD_TYPE_SIZE 7 /* uint64_t */
82
83 typedef struct fmd_prop {
84 const char *fmdp_name; /* property name */
85 uint_t fmdp_type; /* property type (see above) */
86 const char *fmdp_defv; /* default value */
87 } fmd_prop_t;
88
89 typedef struct fmd_stat {
90 char fmds_name[32]; /* statistic name */
91 uint_t fmds_type; /* statistic type (see above) */
92 char fmds_desc[64]; /* statistic description */
93 union {
94 int bool; /* FMD_TYPE_BOOL */
95 int32_t i32; /* FMD_TYPE_INT32 */
96 uint32_t ui32; /* FMD_TYPE_UINT32 */
97 int64_t i64; /* FMD_TYPE_INT64 */
98 uint64_t ui64; /* FMD_TYPE_UINT64, TIME, SIZE */
99 char *str; /* FMD_TYPE_STRING */
100 } fmds_value;
101 } fmd_stat_t;
102
103 typedef struct fmd_hdl_ops {
104 void (*fmdo_recv)(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
105 void (*fmdo_timeout)(fmd_hdl_t *, id_t, void *);
106 void (*fmdo_close)(fmd_hdl_t *, fmd_case_t *);
107 void (*fmdo_stats)(fmd_hdl_t *);
108 void (*fmdo_gc)(fmd_hdl_t *);
109 int (*fmdo_send)(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *, nvlist_t *);
110 void (*fmdo_topo)(fmd_hdl_t *, struct topo_hdl *);
111 } fmd_hdl_ops_t;
112
113 #define FMD_SEND_SUCCESS 0 /* fmdo_send queued event */
114 #define FMD_SEND_FAILED 1 /* fmdo_send unrecoverable error */
120 const fmd_hdl_ops_t *fmdi_ops; /* ops vector for client */
121 const fmd_prop_t *fmdi_props; /* array of configuration props */
122 } fmd_hdl_info_t;
123
124 extern void _fmd_init(fmd_hdl_t *);
125 extern void _fmd_fini(fmd_hdl_t *);
126
127 extern int fmd_hdl_register(fmd_hdl_t *, int, const fmd_hdl_info_t *);
128 extern void fmd_hdl_unregister(fmd_hdl_t *);
129
130 extern void fmd_hdl_subscribe(fmd_hdl_t *, const char *);
131 extern void fmd_hdl_unsubscribe(fmd_hdl_t *, const char *);
132
133 extern void fmd_hdl_setspecific(fmd_hdl_t *, void *);
134 extern void *fmd_hdl_getspecific(fmd_hdl_t *);
135
136 extern void fmd_hdl_opendict(fmd_hdl_t *, const char *);
137 extern struct topo_hdl *fmd_hdl_topo_hold(fmd_hdl_t *, int);
138 extern void fmd_hdl_topo_rele(fmd_hdl_t *, struct topo_hdl *);
139
140 #define FMD_NOSLEEP 0x0 /* do not sleep or retry on failure */
141 #define FMD_SLEEP 0x1 /* sleep or retry if alloc fails */
142
143 extern void *fmd_hdl_alloc(fmd_hdl_t *, size_t, int);
144 extern void *fmd_hdl_zalloc(fmd_hdl_t *, size_t, int);
145 extern void fmd_hdl_free(fmd_hdl_t *, void *, size_t);
146
147 extern char *fmd_hdl_strdup(fmd_hdl_t *, const char *, int);
148 extern void fmd_hdl_strfree(fmd_hdl_t *, char *);
149
150 extern void fmd_hdl_vabort(fmd_hdl_t *, const char *, va_list) __NORETURN;
151 extern void fmd_hdl_abort(fmd_hdl_t *, const char *, ...) __NORETURN;
152
153 extern void fmd_hdl_verror(fmd_hdl_t *, const char *, va_list);
154 extern void fmd_hdl_error(fmd_hdl_t *, const char *, ...);
155
156 extern void fmd_hdl_vdebug(fmd_hdl_t *, const char *, va_list);
157 extern void fmd_hdl_debug(fmd_hdl_t *, const char *, ...);
158
159 extern int32_t fmd_prop_get_int32(fmd_hdl_t *, const char *);
|
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 /*
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 #ifndef _FMD_API_H
28 #define _FMD_API_H
29
30 #include <sys/types.h>
31 #include <libnvpair.h>
32 #include <stdarg.h>
33 #include <door.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * Fault Management Daemon Client Interfaces
41 *
42 * Note: The contents of this file are private to the implementation of the
43 * Solaris system and FMD subsystem and are subject to change at any time
44 * without notice. Applications and drivers using these interfaces will fail
75 #define FMD_TYPE_BOOL 0 /* int */
76 #define FMD_TYPE_INT32 1 /* int32_t */
77 #define FMD_TYPE_UINT32 2 /* uint32_t */
78 #define FMD_TYPE_INT64 3 /* int64_t */
79 #define FMD_TYPE_UINT64 4 /* uint64_t */
80 #define FMD_TYPE_STRING 5 /* const char* */
81 #define FMD_TYPE_TIME 6 /* uint64_t */
82 #define FMD_TYPE_SIZE 7 /* uint64_t */
83
84 typedef struct fmd_prop {
85 const char *fmdp_name; /* property name */
86 uint_t fmdp_type; /* property type (see above) */
87 const char *fmdp_defv; /* default value */
88 } fmd_prop_t;
89
90 typedef struct fmd_stat {
91 char fmds_name[32]; /* statistic name */
92 uint_t fmds_type; /* statistic type (see above) */
93 char fmds_desc[64]; /* statistic description */
94 union {
95 int b; /* FMD_TYPE_BOOL */
96 int32_t i32; /* FMD_TYPE_INT32 */
97 uint32_t ui32; /* FMD_TYPE_UINT32 */
98 int64_t i64; /* FMD_TYPE_INT64 */
99 uint64_t ui64; /* FMD_TYPE_UINT64, TIME, SIZE */
100 char *str; /* FMD_TYPE_STRING */
101 } fmds_value;
102 } fmd_stat_t;
103
104 typedef struct fmd_hdl_ops {
105 void (*fmdo_recv)(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
106 void (*fmdo_timeout)(fmd_hdl_t *, id_t, void *);
107 void (*fmdo_close)(fmd_hdl_t *, fmd_case_t *);
108 void (*fmdo_stats)(fmd_hdl_t *);
109 void (*fmdo_gc)(fmd_hdl_t *);
110 int (*fmdo_send)(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *, nvlist_t *);
111 void (*fmdo_topo)(fmd_hdl_t *, struct topo_hdl *);
112 } fmd_hdl_ops_t;
113
114 #define FMD_SEND_SUCCESS 0 /* fmdo_send queued event */
115 #define FMD_SEND_FAILED 1 /* fmdo_send unrecoverable error */
121 const fmd_hdl_ops_t *fmdi_ops; /* ops vector for client */
122 const fmd_prop_t *fmdi_props; /* array of configuration props */
123 } fmd_hdl_info_t;
124
125 extern void _fmd_init(fmd_hdl_t *);
126 extern void _fmd_fini(fmd_hdl_t *);
127
128 extern int fmd_hdl_register(fmd_hdl_t *, int, const fmd_hdl_info_t *);
129 extern void fmd_hdl_unregister(fmd_hdl_t *);
130
131 extern void fmd_hdl_subscribe(fmd_hdl_t *, const char *);
132 extern void fmd_hdl_unsubscribe(fmd_hdl_t *, const char *);
133
134 extern void fmd_hdl_setspecific(fmd_hdl_t *, void *);
135 extern void *fmd_hdl_getspecific(fmd_hdl_t *);
136
137 extern void fmd_hdl_opendict(fmd_hdl_t *, const char *);
138 extern struct topo_hdl *fmd_hdl_topo_hold(fmd_hdl_t *, int);
139 extern void fmd_hdl_topo_rele(fmd_hdl_t *, struct topo_hdl *);
140
141 typedef struct fmd_hdl_topo_node_info {
142 const char *device;
143 nvlist_t *fru;
144 nvlist_t *resource;
145 } fmd_hdl_topo_node_info_t;
146
147 extern fmd_hdl_topo_node_info_t *fmd_hdl_topo_node_get_by_devid(
148 fmd_hdl_t *hdl, char *device);
149
150 #define FMD_NOSLEEP 0x0 /* do not sleep or retry on failure */
151 #define FMD_SLEEP 0x1 /* sleep or retry if alloc fails */
152
153 extern void *fmd_hdl_alloc(fmd_hdl_t *, size_t, int);
154 extern void *fmd_hdl_zalloc(fmd_hdl_t *, size_t, int);
155 extern void fmd_hdl_free(fmd_hdl_t *, void *, size_t);
156
157 extern char *fmd_hdl_strdup(fmd_hdl_t *, const char *, int);
158 extern void fmd_hdl_strfree(fmd_hdl_t *, char *);
159
160 extern void fmd_hdl_vabort(fmd_hdl_t *, const char *, va_list) __NORETURN;
161 extern void fmd_hdl_abort(fmd_hdl_t *, const char *, ...) __NORETURN;
162
163 extern void fmd_hdl_verror(fmd_hdl_t *, const char *, va_list);
164 extern void fmd_hdl_error(fmd_hdl_t *, const char *, ...);
165
166 extern void fmd_hdl_vdebug(fmd_hdl_t *, const char *, va_list);
167 extern void fmd_hdl_debug(fmd_hdl_t *, const char *, ...);
168
169 extern int32_t fmd_prop_get_int32(fmd_hdl_t *, const char *);
|